use of com.google.security.zynamics.binnavi.disassembly.INaviTextNode in project binnavi by google.
the class PostgreSQLTextNodeCommentTests method deleteTextNodeComment7.
/**
* This test checks if the delete of a comment in a series of comments works if the comment is a
* comment in the middle.
*
* <pre>
* Comment 1: Comment 1:
* Comment 2: ->
* Comment 3: Comment 3:
* </pre>
*
*/
@Test
public void deleteTextNodeComment7() throws CouldntDeleteException, CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException {
final INaviTextNode textNode = setupTextNode();
final List<IComment> storedComments = textNode.getComments() == null ? new ArrayList<IComment>() : textNode.getComments();
final IComment lastComment = storedComments.size() == 0 ? null : Iterables.getLast(storedComments);
final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
final String comment1String = " Comment 1: ";
final int comment1Id = getProvider().appendTextNodeComment(textNode, comment1String, user.getUserId());
final IComment comment1 = new CComment(comment1Id, user, lastComment, comment1String);
final String comment2String = " Comment 2: ";
final int comment2Id = getProvider().appendTextNodeComment(textNode, comment2String, user.getUserId());
final IComment comment2 = new CComment(comment2Id, user, comment1, comment2String);
final String comment3String = " Comment 3: ";
final int comment3Id = getProvider().appendTextNodeComment(textNode, 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().deleteTextNodeComment(textNode, comment2Id, user.getUserId());
final ArrayList<IComment> commentsAfterDelete1 = getProvider().loadCommentById(comment2Id);
assertNotNull(commentsAfterDelete1);
assertTrue(commentsAfterDelete1.isEmpty());
final ArrayList<IComment> commentsAfterDelete2 = getProvider().loadCommentById(comment3Id);
assertNotNull(commentsAfterDelete2);
assertEquals(storedComments.size() + 2, commentsAfterDelete2.size());
final IComment comment3AfterDelete = new CComment(comment3Id, user, comment1, comment3String);
assertTrue(commentsAfterDelete2.contains(comment3AfterDelete));
assertTrue(commentsAfterDelete2.contains(comment1));
assertEquals(comment3AfterDelete, Iterables.getLast(commentsAfterDelete2));
assertEquals(comment1, commentsAfterDelete2.get(commentsAfterDelete2.size() - 2));
}
use of com.google.security.zynamics.binnavi.disassembly.INaviTextNode in project binnavi by google.
the class PostgreSQLTextNodeCommentTests method appendTextNodeComment2.
@Test(expected = NullPointerException.class)
public void appendTextNodeComment2() throws CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException {
final INaviTextNode textNode = setupTextNode();
getProvider().appendTextNodeComment(textNode, null, 1);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviTextNode in project binnavi by google.
the class CUnInliner method removeTextNodes.
/**
* Removes text nodes from the deleted nodes.
*
* @param view The view from which the nodes are deleted.
* @param nodes The nodes whose attached text nodes are removed from.
*/
private static void removeTextNodes(final INaviView view, final ImmutableList<INaviViewNode> nodes) {
final Set<INaviViewNode> toDelete = new HashSet<INaviViewNode>();
for (final INaviViewNode node : nodes) {
for (final INaviViewNode parent : node.getParents()) {
if (parent instanceof INaviTextNode) {
toDelete.add(parent);
}
}
}
view.getContent().deleteNodes(toDelete);
}
Aggregations