Commit 0cd1a515 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

fix on tests

parent 9a15d88e
......@@ -21,6 +21,9 @@ import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelFullIndexed;
import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.user.ObjectPrivilege;
import lcsb.mapviewer.model.user.PrivilegeType;
import lcsb.mapviewer.model.user.User;
import lcsb.mapviewer.services.ServiceTestFunctions;
import lcsb.mapviewer.services.search.comment.FullCommentView;
import lcsb.mapviewer.services.view.AuthenticationToken;
......@@ -57,6 +60,7 @@ public class CommentServiceTest extends ServiceTestFunctions {
}
project.addModel(model);
projectDao.add(project);
projectDao.evict(project);
modelDao.evict(model);
......@@ -189,6 +193,9 @@ public class CommentServiceTest extends ServiceTestFunctions {
@Test
public void testReactionComment() throws Exception {
try {
User admin = userService.getUserByLogin("admin");
userService.setUserPrivilege(admin, new ObjectPrivilege(project, 1, PrivilegeType.VIEW_PROJECT, admin));
Reaction reaction = model.getReactionByReactionId("re3");
Comment comment = commentService.addComment("John Doe", "a@a.pl", "Conteneta 1", model, new Point2D.Double(0, 1), reaction, false, model);
......
......@@ -99,8 +99,6 @@ public class LayoutServiceTest extends ServiceTestFunctions {
createUser();
createUser2();
userService.addUser(user2);
originalSender = layoutService.getEmailSender();
layoutService.setEmailSender(Mockito.mock(EmailSender.class));
}
......@@ -368,30 +366,18 @@ public class LayoutServiceTest extends ServiceTestFunctions {
projectService.addProject(localProject);
String tmpLogin = "Test login3";
User tmpUser = userService.getUserByLogin(tmpLogin);
if (tmpUser != null) {
userService.deleteUser(tmpUser);
userDao.commit();
}
User localUser = new User();
localUser.setLogin(tmpLogin);
userService.addUser(localUser);
userService.setUserPrivilege(user, new BasicPrivilege(1, PrivilegeType.CUSTOM_LAYOUTS, user));
userService.setUserPrivilege(user, new ObjectPrivilege(project, 1, PrivilegeType.VIEW_PROJECT, user));
userService.setUserPrivilege(user, new ObjectPrivilege(localProject, 1, PrivilegeType.VIEW_PROJECT, user));
CreateLayoutParams params = new CreateLayoutParams().name("Test").//
directory("testDir").//
model(localModel).//
colorInputStream(new FileInputStream("testFiles/enricoData/ge001.txt")).//
user(localUser);
user(user);
layoutService.createLayout(params);
AuthenticationToken token = userService.login(localUser.getLogin(), null);
AuthenticationToken token = userService.login(user.getLogin(), "passwd");
Project pr2 = projectService.getProjectByProjectId(localProject.getProjectId(), token);
Model fromDbModel = pr2.getModels().iterator().next().getModel();
......@@ -406,8 +392,6 @@ public class LayoutServiceTest extends ServiceTestFunctions {
assertFalse(f1.exists());
assertFalse(f2.exists());
userService.deleteUser(localUser);
} catch (Exception e) {
e.printStackTrace();
throw e;
......
......@@ -153,9 +153,8 @@ public class ModelServiceTest extends ServiceTestFunctions {
project.addModel(model);
projectDao.update(project);
AuthenticationToken token = userService.login(Configuration.ANONYMOUS_LOGIN, null);
ProjectView row = projectService.getProjectViewByProjectId(project.getProjectId(), token);
AuthenticationToken adminToken = userService.login("admin", "admin");
ProjectView row = projectService.getProjectViewByProjectId(project.getProjectId(), adminToken);
projectService.removeProject(row, null, false, adminToken);
} catch (Exception e) {
......
......@@ -749,10 +749,9 @@ public class ProjectServiceTest extends ServiceTestFunctions {
async(false).//
networkLayoutAsDefault(true).//
projectDir(tmpResultDir).//
addUser("gawi", "gawi").//
addUser("admin", "admin").//
analyzeAnnotations(true));
AuthenticationToken token = userService.login("gawi", "gawi");
Project project = projectService.getProjectByProjectId(projectId, token);
Project project = projectService.getProjectByProjectId(projectId, adminToken);
Model model = modelService.getLastModelByProjectId(name, adminToken);
assertNotNull(model);
......
Supports Markdown
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