use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.
the class PostgreSQLGroupNodeCommentTests method editGroupNodeComment6.
@Test(expected = CouldntSaveDataException.class)
public void editGroupNodeComment6() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException {
final INaviGroupNode groupNode = setupGroupNode();
final List<IComment> comments = groupNode.getComments() == null ? new ArrayList<IComment>() : groupNode.getComments();
final IComment lastComment = comments.size() == 0 ? null : Iterables.getLast(comments);
final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
final String commentText = " CODE NODE COMMENT TEST BEFORE EDIT ";
final Integer commentId = getProvider().appendGroupNodeComment(groupNode, commentText, user.getUserId());
final IComment newComment = new CComment(commentId, user, lastComment, commentText);
final ArrayList<IComment> newComments = getProvider().loadCommentById(commentId);
assertNotNull(newComments);
assertEquals(comments.size() + 1, newComments.size());
assertEquals(newComment, Iterables.getLast(newComments));
final IUser wrongUser = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
getProvider().editGroupNodeComment(groupNode, commentId, wrongUser.getUserId(), " FAIL ");
}
use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.
the class PostgreSQLGroupNodeCommentTests method appendInstructionCommentInGroupNode.
@Test
public void appendInstructionCommentInGroupNode() throws CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException {
final INaviModule module = getProvider().loadModules().get(0);
module.load();
final INaviFunction function = module.getContent().getFunctionContainer().getFunction("sub_1004565");
final INaviView view = module.getContent().getViewContainer().getView(function);
view.load();
assertEquals(42, view.getNodeCount());
final INaviViewNode node1 = view.getContent().getBasicBlocks().get(1);
final INaviViewNode node2 = view.getContent().getBasicBlocks().get(2);
view.getContent().createGroupNode(Lists.newArrayList(node1, node2));
final ZyGraph graph = CGraphBuilder.buildGraph(view);
final INaviView nonNativeView = graph.saveAs(new CModuleContainer(getDatabase(), module), " TEST INSTRUCTION COMMENTS IN GROUP NODE ", " TESTING GROUP NODE COMMENTS ");
final INaviInstruction instruction = view.getContent().getBasicBlocks().get(0).getLastInstruction();
final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
final String firstCommentString = "TEST INSTRUCTION COMMENT PROPAGATION";
final int firstCommentId = getProvider().appendGlobalInstructionComment(instruction, firstCommentString, user.getUserId());
final IComment firstComment = new CComment(firstCommentId, user, null, firstCommentString);
final ArrayList<IComment> commentsFromDatabase = getProvider().loadCommentById(firstCommentId);
assertNotNull(commentsFromDatabase);
assertEquals(1, commentsFromDatabase.size());
assertTrue(commentsFromDatabase.contains(firstComment));
final INaviInstruction instruction2 = nonNativeView.getBasicBlocks().get(0).getLastInstruction();
assertEquals(1, instruction2.getGlobalComment().size());
}
use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.
the class CUserManagerTest method editUserWrongArgumentsTest2.
@Test(expected = NullPointerException.class)
public void editUserWrongArgumentsTest2() throws CouldntSaveDataException {
final CUserManager manager = CUserManager.get(m_sql);
final IUser user = manager.addUser("TEST USER 12412");
manager.editUserName(user, null);
}
use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.
the class CUserManagerTest method setCurrentActiveUserCorrectArgumentsTest.
@Test
public void setCurrentActiveUserCorrectArgumentsTest() throws CouldntSaveDataException {
final CUserManager manager = CUserManager.get(m_sql);
final IUser user = manager.addUser(" TEST SET CURRENT ACTIVE USER ");
manager.setCurrentActiveUser(user);
}
use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.
the class CUserManagerTest method editUserCorrectArgumentsTest.
@Test
public void editUserCorrectArgumentsTest() throws CouldntSaveDataException {
final CUserManager manager = CUserManager.get(m_sql);
final IUser user1 = manager.addUser("TWO");
final IUser user2 = manager.editUserName(user1, "TWO AFTER EDIT");
assertEquals("TWO", user1.getUserName());
assertEquals("TWO AFTER EDIT", user2.getUserName());
assertTrue(user1.getUserId() == user2.getUserId());
}
Aggregations