Search in sources :

Example 1 with INaviTextNode

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

the class PostgreSQLTextNodeCommentTests method editTextNodeComment5.

@Test
public void editTextNodeComment5() throws CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException {
    final INaviTextNode textNode = setupTextNode();
    final List<IComment> comments = textNode.getComments() == null ? new ArrayList<IComment>() : textNode.getComments();
    final IComment lastComment = comments.size() == 0 ? null : Iterables.getLast(comments);
    final IUser user = new UniqueTestUserGenerator(getProvider()).nextActiveUser();
    final String commentText = " TEXT NODE COMMENT TEST BEFORE EDIT ";
    final Integer commentId = getProvider().appendTextNodeComment(textNode, commentText, user.getUserId());
    final IComment newComment = new CComment(commentId, user, lastComment, commentText);
    final ArrayList<IComment> newComments = getProvider().loadCommentById(commentId);
    assertNotNull(newComments);
    assertEquals(comments.size() + 1, newComments.size());
    assertEquals(newComment, Iterables.getLast(newComments));
    final String commentAfterEdit = " TEXT NODE COMMENT TEST AFTER EDIT ";
    getProvider().editTextNodeComment(textNode, commentId, user.getUserId(), commentAfterEdit);
    final ArrayList<IComment> commentsAfterEdit = PostgreSQLCommentFunctions.loadCommentByCommentId(getProvider(), commentId);
    assertEquals(commentAfterEdit, Iterables.getLast(commentsAfterEdit).getComment());
    assertEquals(commentsAfterEdit.size(), newComments.size());
}
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 2 with INaviTextNode

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

the class PostgreSQLTextNodeCommentTests method setupTextNode.

private INaviTextNode setupTextNode() throws CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException {
    final INaviModule module = getProvider().loadModules().get(1);
    module.load();
    final INaviFunction function = module.getContent().getFunctionContainer().getFunction("SetCommState");
    final INaviView view = module.getContent().getViewContainer().getView(function);
    view.load();
    final INaviCodeNode codeNode = view.getContent().getBasicBlocks().get(5);
    final INaviTextNode textNode = view.getContent().createTextNode(null);
    view.getContent().createEdge(codeNode, textNode, EdgeType.TEXTNODE_EDGE);
    final ZyGraph graph = CGraphBuilder.buildGraph(view);
    globalView = graph.saveAs(new CModuleContainer(getDatabase(), module), " TEST TEXT NODE COMMENTS ", " TESTING TEXT NODE COMMENTS ");
    INaviTextNode savedTextNode = null;
    for (final INaviViewNode node : globalView.getGraph().getNodes()) {
        if (node instanceof INaviTextNode) {
            savedTextNode = (INaviTextNode) node;
        }
    }
    return savedTextNode;
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) INaviTextNode(com.google.security.zynamics.binnavi.disassembly.INaviTextNode) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) CModuleContainer(com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction)

Example 3 with INaviTextNode

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

the class PostgreSQLTextNodeCommentTests method deleteTextNodeComment2.

@Test(expected = NullPointerException.class)
public void deleteTextNodeComment2() throws CouldntDeleteException, CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException {
    final INaviTextNode textNode = setupTextNode();
    getProvider().deleteTextNodeComment(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)

Example 4 with INaviTextNode

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

the class PostgreSQLTextNodeCommentTests method deleteTextNodeComment3.

@Test(expected = NullPointerException.class)
public void deleteTextNodeComment3() throws CouldntDeleteException, CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException {
    final INaviTextNode textNode = setupTextNode();
    getProvider().deleteTextNodeComment(textNode, 1, 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 5 with INaviTextNode

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

the class PostgreSQLTextNodeCommentTests method editTextNodeComment3.

@Test(expected = NullPointerException.class)
public void editTextNodeComment3() throws CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException, CouldntSaveDataException {
    final INaviTextNode textNode = setupTextNode();
    getProvider().editTextNodeComment(textNode, 1, null, "");
}
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