Commit a037e8d3 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

test fixed after adding project owner as required option

parent 85b789f1
......@@ -47,6 +47,8 @@ import lcsb.mapviewer.services.interfaces.*;
@RunWith(SpringJUnit4ClassRunner.class)
public abstract class RestTestFunctions {
protected static String ADMIN_BUILT_IN_LOGIN = "admin";
private static Map<String, Model> models = new HashMap<>();
@Rule
public UnitTestFailedWatcher unitTestFailedWatcher = new UnitTestFailedWatcher();
......
......@@ -23,6 +23,7 @@ import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.persist.dao.ProjectDao;
import lcsb.mapviewer.persist.dao.user.UserDao;
import lcsb.mapviewer.services.interfaces.IModelService;
import lcsb.mapviewer.services.interfaces.IProjectService;
......@@ -34,12 +35,16 @@ public class ProjectRestImplTest extends RestTestFunctions {
@Autowired
IModelService modelService;
@Autowired
IProjectService projectService;
@Autowired
ProjectDao projectDao;
@Autowired
UserDao userDao;
@Before
public void before() {
_projectRestImpl.setModelService(modelService);
......@@ -66,6 +71,7 @@ public class ProjectRestImplTest extends RestTestFunctions {
String projectId = "test";
Project project = new Project();
project.setProjectId(projectId);
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
projectDao.add(project);
_projectRestImpl.removeProject(projectId, null);
}
......@@ -105,6 +111,7 @@ public class ProjectRestImplTest extends RestTestFunctions {
String projectId = "Some_id";
String directory1 = _projectRestImpl.computePathForProject(projectId, ".");
Project project = new Project(projectId);
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
projectDao.add(project);
projectDao.delete(project);
String directory2 = _projectRestImpl.computePathForProject(projectId, ".");
......
......@@ -17,6 +17,7 @@ import lcsb.mapviewer.model.map.layout.ColorSchemaType;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.user.User;
import lcsb.mapviewer.persist.dao.ProjectDao;
import lcsb.mapviewer.persist.dao.user.UserDao;
import lcsb.mapviewer.services.interfaces.IProjectService;
public class OverlayRestImplTest extends RestTestFunctions {
......@@ -27,6 +28,9 @@ public class OverlayRestImplTest extends RestTestFunctions {
@Autowired
ProjectDao projectDao;
@Autowired
UserDao userDao;
@Autowired
IProjectService projectService;
......@@ -96,6 +100,7 @@ public class OverlayRestImplTest extends RestTestFunctions {
private Project createProject(String string, String projectId) throws Exception {
Project project = new Project(projectId);
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
Model model = super.getModelForFile(string, false);
project.addModel(model);
projectDao.add(project);
......
......@@ -1103,6 +1103,7 @@ public class ProjectService implements IProjectService {
private Project createProjectFromParams(final CreateProjectParams params) {
Project project = new Project(params.getProjectId());
project.setOwner(userDao.getUserByLogin(params.getUser().getLogin()));
project.setName(params.getProjectName());
if (params.getProjectDir() == null) {
logger.warn("Project directory not set");
......
......@@ -40,6 +40,8 @@ import lcsb.mapviewer.services.search.drug.IDrugService;
@RunWith(SpringJUnit4ClassRunner.class)
public abstract class ServiceTestFunctions {
protected static String ADMIN_BUILT_IN_LOGIN = "admin";
private static Map<String, Model> models = new HashMap<String, Model>();
@Rule
public UnitTestFailedWatcher unitTestFailedWatcher = new UnitTestFailedWatcher();
......
......@@ -35,6 +35,8 @@ public class CommentServiceTest extends ServiceTestFunctions {
projectDao.delete(project);
}
project = new Project();
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
project.setProjectId(projectId);
model = getModelForFile("testFiles/centeredAnchorInModifier.xml", false);
model.setTileSize(128);
......
......@@ -71,6 +71,7 @@ public class LayoutServiceTest extends ServiceTestFunctions {
}
project = new Project();
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
CellDesignerXmlParser parser = new CellDesignerXmlParser();
model = parser.createModel(new ConverterParams().filename("testFiles/sample.xml"));
......@@ -185,6 +186,7 @@ public class LayoutServiceTest extends ServiceTestFunctions {
@Test
public void testAddLayoutToComplexModel() throws Exception {
Project localProject = new Project();
localProject.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
try {
CellDesignerXmlParser parser = new CellDesignerXmlParser();
Model localModel = parser.createModel(new ConverterParams().filename("testFiles/sample.xml"));
......@@ -272,6 +274,7 @@ public class LayoutServiceTest extends ServiceTestFunctions {
@Test
public void testGetLayoutAliasesForInvalidAlias() throws Exception {
Project project = new Project("p_id");
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
try {
Model model = new CellDesignerXmlParser()
.createModel(new ConverterParams().filename("testFiles/coloring/problematicModel2.xml"));
......
......@@ -67,6 +67,7 @@ public class ProjectServiceTest extends ServiceTestFunctions {
Project project = new Project();
project.setProjectId(projectId);
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
projectDao.add(project);
projectDao.evict(project);
......@@ -631,6 +632,7 @@ public class ProjectServiceTest extends ServiceTestFunctions {
Project project = new Project();
project.setProjectId(projectId);
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
projectDao.add(project);
projectService.updateProject(project);
projectService.removeProject(project, null, false);
......
......@@ -49,7 +49,11 @@ public class SearchServiceTest extends ServiceTestFunctions {
protected Model createFullModel() throws Exception {
Model model = getModelForFile("testFiles/searchModel.xml", false);
model.setProject(new Project("unknown project"));
Project project = new Project("unknown project");
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
model.setProject(project);
return model;
}
......
......@@ -58,6 +58,7 @@ public class DrugServiceTest extends ServiceTestFunctions {
long count = searchHistoryDao.getCount();
Model model = new ModelFullIndexed(null);
Project project = new Project();
project.setOwner(userDao.getUserByLogin(ADMIN_BUILT_IN_LOGIN));
project.setProjectId("TesT");
project.addModel(model);
Drug drug = drugService.getByName("Diazoxide", new DbSearchCriteria().project(project).ipAddress("ip"));
......
......@@ -64,6 +64,7 @@ public class CommentControllerIntegrationTest extends ControllerIntegrationTest
@Before
public void setup() {
Project project = createProject(TEST_PROJECT);
project.setOwner(userService.getUserByLogin(BUILT_IN_TEST_ADMIN_LOGIN));
map = project.getModels().iterator().next();
reaction = map.getReactions().iterator().next();
element = map.getElements().iterator().next();
......
......@@ -178,6 +178,7 @@ abstract public class ControllerIntegrationTest {
protected Project createProject(String projectId) {
Project project = new Project(projectId);
project.setOwner(userService.getUserByLogin(BUILT_IN_TEST_ADMIN_LOGIN));
ModelData map = new ModelData();
map.setTileSize(256);
map.setWidth(100);
......
......@@ -79,6 +79,7 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest
userService.grantUserPrivilege(curator, PrivilegeType.READ_PROJECT, project.getProjectId());
Project project2 = new Project("test_project2");
project2.setOwner(userService.getUserByLogin(BUILT_IN_TEST_ADMIN_LOGIN));
projectDao.add(project2);
MockHttpSession session = createSession(CURATOR_LOGIN, CURATOR_PASSWORD);
......@@ -103,6 +104,7 @@ public class ProjectControllerIntegrationTest extends ControllerIntegrationTest
MockHttpSession session = createSession(CURATOR_LOGIN, CURATOR_PASSWORD);
Project project = new Project(TEST_PROJECT);
project.setOwner(userService.getUserByLogin(BUILT_IN_TEST_ADMIN_LOGIN));
projectDao.add(project);
userService.grantUserPrivilege(curator, PrivilegeType.READ_PROJECT, project.getProjectId());
......
......@@ -117,6 +117,7 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest {
@Test
public void grantProjectPrivilege() throws Exception {
Project project = new Project("test_project");
project.setOwner(userService.getUserByLogin(BUILT_IN_TEST_ADMIN_LOGIN));
projectDao.add(project);
MockHttpSession session = createSession(TEST_ADMIN_LOGIN, TEST_ADMIN_PASSWORD);
......@@ -182,6 +183,7 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest {
@Test
public void revokeProjectPrivilege() throws Exception {
Project project = new Project("test_project");
project.setOwner(userService.getUserByLogin(BUILT_IN_TEST_ADMIN_LOGIN));
projectDao.add(project);
MockHttpSession session = createSession(TEST_ADMIN_LOGIN, TEST_ADMIN_PASSWORD);
......
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