use of com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment in project binnavi by google.
the class PostgreSQLGlobalEdgeCommentTests method editGlobalEdgeComment5.
@Test
public void editGlobalEdgeComment5() throws CouldntSaveDataException, CouldntLoadDataException {
final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
final List<IComment> storedComments = edge.getGlobalComment() == null ? new ArrayList<IComment>() : edge.getGlobalComment();
final IComment lastComment = storedComments.isEmpty() ? null : Iterables.getLast(storedComments);
final String beforeEditCommentString = " EDIT GLOBAL EDGE COMMENT BEFORE EDIT ";
final int editedCommentId = getProvider().appendGlobalEdgeComment(edge, beforeEditCommentString, user.getUserId());
final IComment commentBeforeEdit = new CComment(editedCommentId, user, lastComment, beforeEditCommentString);
final ArrayList<IComment> commentsFromDatabase = getProvider().loadCommentById(editedCommentId);
assertNotNull(commentsFromDatabase);
assertTrue(commentsFromDatabase.contains(commentBeforeEdit));
assertEquals(storedComments.size() + 1, commentsFromDatabase.size());
final String afterEditCommentString = " EDIT GLOBAL EDGE COMMENT AFTER EDIT ";
getProvider().editGlobalEdgeComment(edge, editedCommentId, user.getUserId(), afterEditCommentString);
final IComment commentAfterEdit = new CComment(editedCommentId, user, lastComment, afterEditCommentString);
final ArrayList<IComment> commentsAfterEdit = getProvider().loadCommentById(editedCommentId);
assertNotNull(commentsAfterEdit);
assertTrue(commentsAfterEdit.contains(commentAfterEdit));
}
use of com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment in project binnavi by google.
the class PostgreSQLGlobalEdgeCommentTests method deleteGlobalEdgeComment5.
/**
* This test checks if the delete of a comment in a series of comments works if the comment is the
* last comment.
*
* <pre>
* Comment 1: Comment 1:
* Comment 2: -> Comment 2:
* Comment 3:
* </pre>
*/
@Test
public void deleteGlobalEdgeComment5() throws CouldntLoadDataException, CouldntSaveDataException, CouldntDeleteException {
final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
final List<IComment> storedComments = edge.getGlobalComment() == null ? new ArrayList<IComment>() : edge.getGlobalComment();
final IComment lastComment = storedComments.isEmpty() ? null : Iterables.getLast(storedComments);
final String comment1String = " Comment 1: ";
final int comment1Id = getProvider().appendGlobalEdgeComment(edge, comment1String, user.getUserId());
final IComment comment1 = new CComment(comment1Id, user, lastComment, comment1String);
final String comment2String = " Comment 2: ";
final int comment2Id = getProvider().appendGlobalEdgeComment(edge, comment2String, user.getUserId());
final IComment comment2 = new CComment(comment2Id, user, comment1, comment2String);
final String comment3String = " Comment 3: ";
final int comment3Id = getProvider().appendGlobalEdgeComment(edge, 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().deleteGlobalEdgeComment(edge, comment3Id, user.getUserId());
final ArrayList<IComment> commentsAfterDelete1 = getProvider().loadCommentById(comment3Id);
assertNotNull(commentsAfterDelete1);
assertTrue(commentsAfterDelete1.isEmpty());
final ArrayList<IComment> commentsAfterDelete2 = getProvider().loadCommentById(comment2Id);
assertNotNull(commentsAfterDelete2);
assertEquals(storedComments.size() + 2, commentsAfterDelete2.size());
assertTrue(commentsAfterDelete2.contains(comment2));
assertTrue(commentsAfterDelete2.contains(comment1));
assertEquals(comment2, Iterables.getLast(commentsAfterDelete2));
assertEquals(comment1, commentsAfterDelete2.get(commentsAfterDelete2.size() - 2));
}
use of com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment in project binnavi by google.
the class PostgreSQLGlobalEdgeCommentTests method editGlobalEdgeComment6.
@Test(expected = CouldntSaveDataException.class)
public void editGlobalEdgeComment6() throws CouldntLoadDataException, CouldntSaveDataException {
final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
final List<IComment> storedComments = edge.getGlobalComment() == null ? new ArrayList<IComment>() : edge.getGlobalComment();
final IComment lastComment = storedComments.isEmpty() ? null : Iterables.getLast(storedComments);
final String beforeEditCommentString = " EDIT GLOBAL EDGE COMMENT BEFORE EDIT ";
final int editedCommentId = getProvider().appendGlobalEdgeComment(edge, beforeEditCommentString, user.getUserId());
final IComment commentBeforeEdit = new CComment(editedCommentId, user, lastComment, beforeEditCommentString);
final ArrayList<IComment> commentsFromDatabase = getProvider().loadCommentById(editedCommentId);
assertNotNull(commentsFromDatabase);
assertTrue(commentsFromDatabase.contains(commentBeforeEdit));
assertEquals(storedComments.size() + 1, commentsFromDatabase.size());
final IUser wrongUser = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
getProvider().editGlobalEdgeComment(edge, editedCommentId, wrongUser.getUserId(), " FAIL ");
}
use of com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment in project binnavi by google.
the class PostgreSQLGlobalEdgeCommentTests method deleteGlobalEdgeComment4.
/**
* This test checks if the deletion of a single global edge comment works consistently.
*/
@Test
public void deleteGlobalEdgeComment4() throws CouldntSaveDataException, CouldntLoadDataException, CouldntDeleteException {
final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
final List<IComment> comments = edge.getGlobalComment() == null ? new ArrayList<IComment>() : edge.getGlobalComment();
final IComment lastComment = comments.isEmpty() ? null : Iterables.getLast(comments);
final String commentText = " COMMENT TO BE DELETED ";
final Integer commentId = getProvider().appendGlobalEdgeComment(edge, commentText, user.getUserId());
final IComment commentToBeDelete = new CComment(commentId, user, lastComment, commentText);
final ArrayList<IComment> commentsFromDatabase = getProvider().loadCommentById(commentId);
assertNotNull(commentsFromDatabase);
assertEquals(comments.size() + 1, commentsFromDatabase.size());
assertTrue(commentsFromDatabase.contains(commentToBeDelete));
getProvider().deleteGlobalEdgeComment(edge, commentId, user.getUserId());
final ArrayList<IComment> commentsAfterDelete = getProvider().loadCommentById(commentId);
assertNotNull(commentsAfterDelete);
assertTrue(commentsAfterDelete.isEmpty());
}
use of com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment in project binnavi by google.
the class PostgreSQLGroupNodeCommentTests method deleteGroupNodeComment4.
@Test
public void deleteGroupNodeComment4() throws CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException, CouldntDeleteException {
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 String commentString = " TEST DELETE GROUP NODE COMMENT ";
final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
final int commentId = getProvider().appendGroupNodeComment(groupNode, 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, Iterables.getLast(storedComments));
getProvider().deleteGroupNodeComment(groupNode, commentId, user.getUserId());
final ArrayList<IComment> commentsAfterDelete = getProvider().loadCommentById(commentId);
assertNotNull(commentsAfterDelete);
assertTrue(commentsAfterDelete.isEmpty());
}
Aggregations