use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.
the class PostgreSQLTypeInstancesCommentTests method deleteTypeInstanceComment5.
@Test
public void deleteTypeInstanceComment5() throws CouldntDeleteException, CouldntSaveDataException, CouldntLoadDataException {
final List<IComment> comments = instanceContainer.getComments(typeInstance);
final IComment lastComment = comments.size() == 0 ? null : Iterables.getLast(comments);
final String commentString = " TEST DELETE TypeInstance COMMENT ";
final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
final int commentId = getProvider().appendTypeInstanceComment(typeInstance.getModule().getConfiguration().getId(), typeInstance.getId(), commentString, user.getUserId());
final IComment newComment = new CComment(commentId, user, lastComment, commentString);
final ArrayList<IComment> storedComments = getProvider().loadCommentById(commentId);
assertNotNull(storedComments);
assertEquals(comments.size() + 1, storedComments.size());
assertEquals(newComment, storedComments.get(storedComments.size() - 1));
getProvider().deleteTypeInstanceComment(typeInstance.getModule().getConfiguration().getId(), typeInstance.getId(), commentId, newComment.getUser().getUserId());
final ArrayList<IComment> commentsAfterDelete = getProvider().loadCommentById(commentId);
assertNotNull(commentsAfterDelete);
assertTrue(commentsAfterDelete.isEmpty());
}
use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.
the class CCodeNodeTest method testMiscFunctions.
@Test
public void testMiscFunctions() throws MaybeNullException, CouldntSaveDataException, CouldntLoadDataException {
final MockSqlProvider provider = new MockSqlProvider();
final CUserManager userManager = CUserManager.get(provider);
final IUser currentUser = userManager.addUser("TEST USER 1");
userManager.setCurrentActiveUser(currentUser);
final CModule internalModule = new CModule(1, "", "", new Date(), new Date(), CommonTestObjects.MD5, CommonTestObjects.SHA1, 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, provider);
final CFunction parentFunction = new CFunction(internalModule, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, provider);
final CCodeNode node = new CCodeNode(1, 0, 0, 0, 0, Color.BLACK, Color.BLACK, false, true, Lists.<IComment>newArrayList(new CComment(null, CommonTestObjects.TEST_USER_1, null, "foobar")), parentFunction, new LinkedHashSet<CTag>(), provider);
final MockInstruction i1 = new MockInstruction(new CAddress(0x123), "nop", new ArrayList<COperandTree>(), null);
final MockInstruction i2 = new MockInstruction(new CAddress(0x124), "nop", new ArrayList<COperandTree>(), null);
final MockInstruction i3 = new MockInstruction(new CAddress(0x125), "nop", new ArrayList<COperandTree>(), null);
final MockInstruction i4 = new MockInstruction(new CAddress(0x126), "nop", new ArrayList<COperandTree>(), m_globalComment);
final MockInstruction i5 = new MockInstruction(new CAddress(0x127), "nop", new ArrayList<COperandTree>(), null);
node.addInstruction(i1, Lists.<IComment>newArrayList(new CComment(null, currentUser, null, "Foo\nBar")));
node.addInstruction(i2, Lists.<IComment>newArrayList(new CComment(null, currentUser, null, "\n")));
node.addInstruction(i3, null);
node.addInstruction(i4, null);
final INaviCodeNodeListener listener = new CNaviCodeNodeListenerAdapter();
node.addListener(listener);
node.addInstruction(i5, null);
assertNotNull(node.cloneNode());
assertFalse(CCodeNodeHelpers.containsAddress(node, new CAddress(0xFFFFFFFEL)));
assertEquals(null, node.getComments().getGlobalCodeNodeComment());
assertEquals(new CAddress(0x123L), node.getAddress());
assertEquals(0, CCodeNodeHelpers.getInstruction(node, new CAddress(0x123L)));
assertEquals(-1, CCodeNodeHelpers.getInstruction(node, new CAddress(0x129L)));
assertEquals(i1, Iterables.getFirst(node.getInstructions(), null));
assertEquals(5, Iterables.size(node.getInstructions()));
assertEquals(5, node.instructionCount());
assertNotNull(node.getParentFunction());
node.removeInstruction(i5);
assertEquals(4, node.instructionCount());
try {
node.removeInstruction(null);
fail();
} catch (final NullPointerException e) {
}
try {
node.removeInstruction(i5);
fail();
} catch (final IllegalArgumentException e) {
}
final List<IComment> comments = node.getComments().appendGlobalCodeNodeComment("barfoos");
assertEquals(comments, node.getComments().getGlobalCodeNodeComment());
try {
node.getComments().appendGlobalCodeNodeComment(null);
fail();
} catch (final Exception e) {
}
node.setInstructionColor(i4, 0, Color.YELLOW);
try {
node.setInstructionColor(null, 0, null);
fail();
} catch (final Exception e) {
}
try {
node.setInstructionColor(i5, 0, null);
fail();
} catch (final Exception e) {
}
node.setBorderColor(Color.GRAY);
assertEquals(Color.GRAY, node.getBorderColor());
final List<IComment> comments2 = node.getComments().appendLocalCodeNodeComment("barfoos2");
assertEquals(comments2, node.getComments().getLocalCodeNodeComment());
final List<IComment> appendedComments = node.getComments().appendLocalInstructionComment(i4, "foo");
assertEquals(appendedComments, node.getComments().getLocalInstructionComment(i4));
try {
node.getComments().appendLocalInstructionComment(i5, " INSTRUCTION i5 COMMENT ");
fail();
} catch (final IllegalArgumentException e) {
}
node.getComments().appendLocalCodeNodeComment("foo");
node.toString();
node.removeListener(listener);
node.close();
}
use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.
the class CUserManagerTest method editUserWrongArgumentsTest3.
@Test(expected = IllegalStateException.class)
public void editUserWrongArgumentsTest3() throws CouldntSaveDataException {
final CUserManager manager = CUserManager.get(m_sql);
final IUser user = new CUser(2123, "TEST USER 12412");
manager.editUserName(user, "FOOBAR");
}
use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.
the class CUserManagerTest method getCurrentActiveUserTest.
@Test
public void getCurrentActiveUserTest() throws CouldntSaveDataException {
final CUserManager manager = CUserManager.get(m_sql);
final IUser activeUser = manager.addUser(" ACTIVE USER ");
manager.setCurrentActiveUser(activeUser);
assertEquals(activeUser, manager.getCurrentActiveUser());
}
use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.
the class CUserManagerTest method deleteUserCorrectArgumentTest.
@Test
public void deleteUserCorrectArgumentTest() throws CouldntSaveDataException, CouldntDeleteException {
final CUserManager manager = CUserManager.get(m_sql);
final IUser user = manager.addUser("ONE");
manager.deleteUser(user);
}
Aggregations