Search in sources :

Example 21 with INaviTextNode

use of com.google.security.zynamics.binnavi.disassembly.INaviTextNode in project binnavi by google.

the class TextNodeTest method setUp.

@Before
public void setUp() throws IllegalArgumentException {
    final INaviTextNode internalNode = CTextNodeFactory.getWithComment("Fark");
    final TagManager tagManager = new TagManager(new MockTagManager(TagType.NODE_TAG));
    final TagManager viewTagManager = new TagManager(new MockTagManager(TagType.VIEW_TAG));
    final Database database = new Database(new MockDatabase());
    final INaviModule internalModule = new MockModule();
    final Module module = new Module(database, internalModule, tagManager, viewTagManager);
    final INaviView internalView = new MockView();
    final View view = new View(module, internalView, tagManager, viewTagManager);
    m_node = new TextNode(view, internalNode, tagManager);
}
Also used : MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) INaviTextNode(com.google.security.zynamics.binnavi.disassembly.INaviTextNode) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) INaviTextNode(com.google.security.zynamics.binnavi.disassembly.INaviTextNode) MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) Before(org.junit.Before)

Example 22 with INaviTextNode

use of com.google.security.zynamics.binnavi.disassembly.INaviTextNode in project binnavi by google.

the class PostgreSQLTextNodeCommentTests method appendTextNodeComment3.

@Test(expected = NullPointerException.class)
public void appendTextNodeComment3() throws CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException {
    final INaviTextNode textNode = setupTextNode();
    getProvider().appendTextNodeComment(textNode, "", null);
}
Also used : INaviTextNode(com.google.security.zynamics.binnavi.disassembly.INaviTextNode) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 23 with INaviTextNode

use of com.google.security.zynamics.binnavi.disassembly.INaviTextNode in project binnavi by google.

the class PostgreSQLTextNodeCommentTests method appendTextNodeComment4.

@Test
public void appendTextNodeComment4() throws CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException {
    final INaviTextNode textNode = setupTextNode();
    final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
    final String firstCommentString = " APPEND GROUP NODE COMMENT WITHOUT PARENT ID ";
    final Integer firstCommentId = getProvider().appendTextNodeComment(textNode, firstCommentString, user.getUserId());
    final IComment firstComment = new CComment(firstCommentId, user, null, firstCommentString);
    final String secondCommentString = " APPEND GROUP NODE COMMENT WITH PARENT ID ";
    final Integer secondCommentId = getProvider().appendTextNodeComment(textNode, secondCommentString, user.getUserId());
    final IComment secondComment = new CComment(secondCommentId, user, firstComment, secondCommentString);
    final ArrayList<IComment> commentsFromDatabase = getProvider().loadCommentById(secondCommentId);
    assertNotNull(commentsFromDatabase);
    assertEquals(2, commentsFromDatabase.size());
    assertTrue(commentsFromDatabase.contains(firstComment));
    assertTrue(commentsFromDatabase.contains(secondComment));
    globalView.close();
    globalView.load();
    INaviTextNode savedTextNode;
    for (final INaviViewNode node : globalView.getGraph().getNodes()) {
        if (node instanceof INaviTextNode) {
            savedTextNode = (INaviTextNode) node;
            assertNotNull(savedTextNode.getComments());
            assertEquals(2, (savedTextNode.getComments().size()));
            assertTrue(savedTextNode.getComments().contains(firstComment));
            assertTrue(savedTextNode.getComments().contains(secondComment));
        }
    }
}
Also used : CComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment) IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) INaviTextNode(com.google.security.zynamics.binnavi.disassembly.INaviTextNode) IUser(com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) UniqueTestUserGenerator(com.google.security.zynamics.binnavi.Database.PostgreSQL.UniqueTestUserGenerator) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 24 with INaviTextNode

use of com.google.security.zynamics.binnavi.disassembly.INaviTextNode in project binnavi by google.

the class PostgreSQLTextNodeCommentTests method deleteTextNodeComment6.

/**
   * 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 deleteTextNodeComment6() 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, 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));
}
Also used : CComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment) IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) INaviTextNode(com.google.security.zynamics.binnavi.disassembly.INaviTextNode) IUser(com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser) UniqueTestUserGenerator(com.google.security.zynamics.binnavi.Database.PostgreSQL.UniqueTestUserGenerator) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 25 with INaviTextNode

use of com.google.security.zynamics.binnavi.disassembly.INaviTextNode in project binnavi by google.

the class PostgreSQLTextNodeCommentTests method editTextNodeComment2.

@Test(expected = NullPointerException.class)
public void editTextNodeComment2() throws CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException {
    final INaviTextNode textNode = setupTextNode();
    getProvider().editTextNodeComment(textNode, null, 1, "");
}
Also used : INaviTextNode(com.google.security.zynamics.binnavi.disassembly.INaviTextNode) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Aggregations

INaviTextNode (com.google.security.zynamics.binnavi.disassembly.INaviTextNode)28 Test (org.junit.Test)20 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)15 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)13 CComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment)9 UniqueTestUserGenerator (com.google.security.zynamics.binnavi.Database.PostgreSQL.UniqueTestUserGenerator)8 IUser (com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser)8 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)7 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)5 TextNodeCommentNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.TextNodeCommentNotificationContainer)3 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)3 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)3 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)3 ArrayList (java.util.ArrayList)3 CommentNotification (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification)2 INaviFunctionNode (com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode)2 INaviGroupNode (com.google.security.zynamics.binnavi.disassembly.INaviGroupNode)2 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)2 PreparedStatement (java.sql.PreparedStatement)2 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)1