use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.
the class MockInstruction method appendGlobalComment.
@Override
public List<IComment> appendGlobalComment(final String commentText) {
final int id = m_globalComment.size() + 1;
final IComment parent = m_globalComment.size() == 0 ? null : m_globalComment.get(m_globalComment.size() - 1);
final IUser user = CUserManager.get(m_provider).getCurrentActiveUser();
final IComment comment = new CComment(id, user, parent, commentText);
m_globalComment.add(comment);
return m_globalComment;
}
use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.
the class GroupNodeTest method testSetText.
@Test
public void testSetText() throws CouldntSaveDataException, com.google.security.zynamics.binnavi.API.disassembly.CouldntSaveDataException, CouldntLoadDataException {
final Database database = new Database(new MockDatabase());
final SQLProvider provider = new MockSqlProvider();
final MockModule mockModule = new MockModule();
final TagManager nodeTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.NODE_TAG));
final TagManager viewTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.VIEW_TAG));
final Module module = new Module(database, mockModule, nodeTagManager, viewTagManager);
final MockView mockView = new MockView();
final View view = new View(module, mockView, nodeTagManager, viewTagManager);
final INaviGroupNode internalGroupNode = new CGroupNode(0, 0, 0, 0, 0, Color.RED, false, false, new HashSet<CTag>(), new ArrayList<IComment>(), false, provider);
final GroupNode node = new GroupNode(view, internalGroupNode, viewTagManager);
final MockGroupNodeListener listener = new MockGroupNodeListener();
final CUserManager userManager = CUserManager.get(provider);
final IUser user = userManager.addUser(" TEST APPEND GROUP NODE COMMENT ");
userManager.setCurrentActiveUser(user);
node.addListener(listener);
final List<IComment> comments = node.appendComment("Hannes");
assertEquals("appendedComment;", listener.events);
assertEquals(comments, node.getComment());
node.removeListener(listener);
}
use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.
the class MockSqlProvider method appendComment.
private int appendComment(final Commentable commentable, final Integer userId, final String commentText) {
Preconditions.checkNotNull(commentable, "Error: commentable argument can not be null");
Preconditions.checkNotNull(userId, "Error: userId argument can not be null");
Preconditions.checkNotNull(commentText, "Error: commentText argument can not be null");
final IUser currentUser = getCurrentUser(userId);
final int commentId = getRandom();
final ArrayList<IComment> currentComments = comments.containsKey(commentable) ? comments.get(commentable) : new ArrayList<IComment>();
currentComments.add(new CComment(commentId, currentUser, null, commentText));
comments.put(commentable, currentComments);
return commentId;
}
use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.
the class UniqueTestUserGenerator method nextActiveUser.
public IUser nextActiveUser() throws CouldntSaveDataException {
final CUserManager userManager = CUserManager.get(provider);
final IUser user = userManager.addUser(new BigInteger(130, random).toString(32));
userManager.setCurrentActiveUser(user);
return user;
}
use of com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser in project binnavi by google.
the class PostgreSQLFunctionNodeCommentTests method deleteFunctionNodeComment7.
/**
* This test checks if the delete of a comment in a series of comments works if the comment is the
* first comment.
*
* <pre>
* Comment 1:
* Comment 2: -> Comment 2:
* Comment 3: Comment 3:
* </pre>
*/
@Test
public void deleteFunctionNodeComment7() throws CouldntLoadDataException, CouldntSaveDataException, CouldntDeleteException {
final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
final List<IComment> storedComments = functionNode.getLocalFunctionComment() == null ? new ArrayList<IComment>() : functionNode.getLocalFunctionComment();
final IComment lastComment = storedComments.isEmpty() ? null : Iterables.getLast(storedComments);
final String comment1String = " Comment 1: ";
final int comment1Id = getProvider().appendFunctionNodeComment(functionNode, comment1String, user.getUserId());
final IComment comment1 = new CComment(comment1Id, user, lastComment, comment1String);
final String comment2String = " Comment 2: ";
final int comment2Id = getProvider().appendFunctionNodeComment(functionNode, comment2String, user.getUserId());
final IComment comment2 = new CComment(comment2Id, user, comment1, comment2String);
final String comment3String = " Comment 3: ";
final int comment3Id = getProvider().appendFunctionNodeComment(functionNode, comment3String, user.getUserId());
final IComment comment3 = new CComment(comment3Id, user, comment2, comment3String);
final ArrayList<IComment> commentsBeforeDelete = getProvider().loadCommentById(comment3Id);
assertNotNull(commentsBeforeDelete);
assertEquals(storedComments.size() + 3, commentsBeforeDelete.size());
assertTrue(commentsBeforeDelete.contains(comment1));
assertTrue(commentsBeforeDelete.contains(comment2));
assertTrue(commentsBeforeDelete.contains(comment3));
assertEquals(comment3, Iterables.getLast(commentsBeforeDelete));
assertEquals(comment2, commentsBeforeDelete.get(commentsBeforeDelete.size() - 2));
assertEquals(comment1, commentsBeforeDelete.get(commentsBeforeDelete.size() - 3));
getProvider().deleteFunctionNodeComment(functionNode, comment1Id, user.getUserId());
final ArrayList<IComment> commentsAfterDelete1 = getProvider().loadCommentById(comment1Id);
assertNotNull(commentsAfterDelete1);
assertTrue(commentsAfterDelete1.isEmpty());
final ArrayList<IComment> commentsAfterDelete2 = getProvider().loadCommentById(comment3Id);
final IComment comment2AfterDelete = new CComment(comment2Id, user, lastComment, comment2String);
final IComment comment3AfterDelete = new CComment(comment3Id, user, comment2AfterDelete, comment3String);
assertNotNull(commentsAfterDelete2);
assertEquals(storedComments.size() + 2, commentsAfterDelete2.size());
assertTrue(commentsAfterDelete2.contains(comment3AfterDelete));
assertTrue(commentsAfterDelete2.contains(comment2AfterDelete));
assertEquals(comment3AfterDelete, Iterables.getLast(commentsAfterDelete2));
assertEquals(comment2AfterDelete, commentsAfterDelete2.get(commentsAfterDelete2.size() - 2));
}
Aggregations