Commit 05b8d0d6 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

background dao returned wrong type

parent 1b6cf2e7
......@@ -36,8 +36,8 @@ public class ProjectBackgroundDao extends BaseDao<ProjectBackground> {
public List<ProjectBackground> getProjectBackgroundsByProject(String projectId) {
List<?> list = getSession()
.createQuery(
" from " + this.getClazz().getSimpleName()
+ " overlay inner join overlay.project where overlay.project.projectId = :param_val "
"select background from " + this.getClazz().getSimpleName()
+ " background inner join background.project where background.project.projectId = :param_val "
+ removableAndStatemant())
.setParameter("param_val", projectId).list();
return (List<ProjectBackground>) list;
......
package lcsb.mapviewer.persist.dao.map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.List;
......@@ -121,4 +122,36 @@ public class ProjectBackgroundDaoTest extends PersistTestFunctions {
projectDao.delete(project);
}
@Test
public void testGetBackgroundsByProjectId() throws Exception {
Model model = createModel();
Project project = new Project("test_project_id");
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
project.addModel(model);
projectDao.add(project);
List<ProjectBackground> result = backgroundDao.getProjectBackgroundsByProject(project.getProjectId());
assertEquals(0, result.size());
ProjectBackground background = new ProjectBackground();
background.addProjectBackgroundImageLayer(new ProjectBackgroundImageLayer(model, "tmp"));
background.setName("temporary name");
background.setCreator(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
byte[] data = "test".getBytes();
UploadedFileEntry fileEntry = new UploadedFileEntry();
fileEntry.setFileContent(data);
project.addProjectBackground(background);
backgroundDao.add(background);
result = backgroundDao.getProjectBackgroundsByProject(project.getProjectId());
assertEquals(1, result.size());
assertTrue(result.get(0) instanceof ProjectBackground);
project = projectDao.getById(project.getId());
projectDao.delete(project);
}
}
......@@ -185,13 +185,13 @@ public class ProjectBackgroundService implements IProjectBackgroundService {
}
@Override
public ProjectBackground getProjectBackgroundById(String projectId, Integer overlayId)
public ProjectBackground getProjectBackgroundById(String projectId, Integer backgroundId)
throws ObjectNotFoundException {
ProjectBackground result = getProjectBackgroundById(overlayId);
ProjectBackground result = getProjectBackgroundById(backgroundId);
if (result != null && result.getProject().getProjectId().equals(projectId)) {
return result;
}
throw new ObjectNotFoundException("Overlay with given id does not exist: " + overlayId);
throw new ObjectNotFoundException("Overlay with given id does not exist: " + backgroundId);
}
@Override
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment