Search in sources :

Example 16 with IComment

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment in project binnavi by google.

the class PostgreSQLNotificationProviderTest method testAppendFunctionNodeCommentSync.

@Test
public void testAppendFunctionNodeCommentSync() throws CouldntLoadDataException, CPartialLoadException, LoadCancelledException, CouldntSaveDataException, InterruptedException {
    databaseOneCallGraph = databaseOneModuleTwo.getContent().getViewContainer().getNativeCallgraphView();
    databaseOneCallGraph.load();
    final INaviFunctionNode databaseOneFunctionNode = (INaviFunctionNode) databaseOneCallGraph.getGraph().getNodes().get(1);
    databaseTwoCallGraph = databaseTwoModuleTwo.getContent().getViewContainer().getNativeCallgraphView();
    databaseTwoCallGraph.load();
    final INaviFunctionNode databaseTwoFunctionNode = (INaviFunctionNode) databaseTwoCallGraph.getGraph().getNodes().get(1);
    final List<IComment> oneBefore = databaseOneFunctionNode.getLocalFunctionComment() == null ? new ArrayList<IComment>() : databaseOneFunctionNode.getLocalFunctionComment();
    final List<IComment> twoBefore = databaseTwoFunctionNode.getLocalFunctionComment() == null ? new ArrayList<IComment>() : databaseTwoFunctionNode.getLocalFunctionComment();
    assertEquals(oneBefore, twoBefore);
    databaseOneFunctionNode.appendLocalFunctionComment(" TEST NOTIFICATION PROVIDER TESTS (LOCAL FUNCTION NODE COMMENT) ");
    // database one to two over the PostgreSQL back end.
    synchronized (lock) {
        lock.await(1000, TimeUnit.MILLISECONDS);
    }
    final List<IComment> oneAfter = databaseOneFunctionNode.getLocalFunctionComment();
    final List<IComment> twoAfter = databaseTwoFunctionNode.getLocalFunctionComment();
    assertNotNull(oneAfter);
    assertNotNull(twoAfter);
    assertEquals(oneBefore.size() + 1, oneAfter.size());
    assertEquals(twoBefore.size() + 1, twoAfter.size());
    assertEquals(oneAfter, twoAfter);
}
Also used : IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) INaviFunctionNode(com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode) Test(org.junit.Test)

Example 17 with IComment

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment in project binnavi by google.

the class PostgreSQLNotificationProviderTest method testAppendGlobalInstructionCommentSync.

@Test
public void testAppendGlobalInstructionCommentSync() throws CouldntSaveDataException, CouldntLoadDataException, InterruptedException {
    final INaviCodeNode databaseOnecodeNode = databaseOneView.getContent().getBasicBlocks().get(3);
    final INaviCodeNode databaseTwocodeNode = databaseTwoView.getContent().getBasicBlocks().get(3);
    final List<IComment> oneBefore = Iterables.getFirst(databaseOnecodeNode.getInstructions(), null).getGlobalComment() == null ? new ArrayList<IComment>() : Iterables.getFirst(databaseOnecodeNode.getInstructions(), null).getGlobalComment();
    final List<IComment> twoBefore = Iterables.getFirst(databaseTwocodeNode.getInstructions(), null).getGlobalComment() == null ? new ArrayList<IComment>() : Iterables.getFirst(databaseTwocodeNode.getInstructions(), null).getGlobalComment();
    assertEquals(oneBefore, twoBefore);
    Iterables.getFirst(databaseOnecodeNode.getInstructions(), null).appendGlobalComment(" TEST NOTIFICATION PROVIDER TESTS (GLOBAL INSTRUCTION COMMENT)");
    // database one to two over the PostgreSQL back end.
    synchronized (lock) {
        lock.await(1000, TimeUnit.MILLISECONDS);
    }
    final List<IComment> oneAfter = Iterables.getFirst(databaseOnecodeNode.getInstructions(), null).getGlobalComment();
    final List<IComment> twoAfter = Iterables.getFirst(databaseTwocodeNode.getInstructions(), null).getGlobalComment();
    assertNotNull(oneAfter);
    assertNotNull(twoAfter);
    assertEquals(oneBefore.size() + 1, oneAfter.size());
    assertEquals(twoBefore.size() + 1, twoAfter.size());
    assertEquals(oneAfter, twoAfter);
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) Test(org.junit.Test)

Example 18 with IComment

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment in project binnavi by google.

the class PostgreSQLNotificationProviderTest method testDeleteLocalInstructionCommentSync.

@Test
public void testDeleteLocalInstructionCommentSync() throws CouldntSaveDataException, CouldntLoadDataException, InterruptedException, CouldntDeleteException {
    final INaviCodeNode databaseOnecodeNode = databaseOneView.getContent().getBasicBlocks().get(3);
    final INaviCodeNode databaseTwocodeNode = databaseTwoView.getContent().getBasicBlocks().get(3);
    final List<IComment> oneBefore = databaseOnecodeNode.getComments().getLocalInstructionComment(databaseOnecodeNode.getLastInstruction()) == null ? new ArrayList<IComment>() : databaseOnecodeNode.getComments().getLocalInstructionComment(databaseOnecodeNode.getLastInstruction());
    final List<IComment> twoBefore = databaseTwocodeNode.getComments().getLocalInstructionComment(databaseTwocodeNode.getLastInstruction()) == null ? new ArrayList<IComment>() : databaseTwocodeNode.getComments().getLocalInstructionComment(databaseTwocodeNode.getLastInstruction());
    assertEquals(oneBefore, twoBefore);
    final List<IComment> comments = databaseOnecodeNode.getComments().appendLocalInstructionComment(databaseOnecodeNode.getLastInstruction(), " TEST NOTIFICATION PROVIDER TESTS (GLOBAL INSTRUCTION COMMENT)");
    // database one to two over the PostgreSQL back end.
    synchronized (lock) {
        lock.await(1000, TimeUnit.MILLISECONDS);
    }
    final List<IComment> oneAfter = databaseOnecodeNode.getComments().getLocalInstructionComment(databaseOnecodeNode.getLastInstruction());
    final List<IComment> twoAfter = databaseTwocodeNode.getComments().getLocalInstructionComment(databaseTwocodeNode.getLastInstruction());
    assertNotNull(oneAfter);
    assertNotNull(twoAfter);
    assertEquals(oneBefore.size() + 1, oneAfter.size());
    assertEquals(twoBefore.size() + 1, twoAfter.size());
    assertEquals(oneAfter, twoAfter);
    final int oneTwoSize = oneAfter.size();
    final int twoTwoSize = twoAfter.size();
    databaseOnecodeNode.getComments().deleteLocalInstructionComment(databaseOnecodeNode.getLastInstruction(), Iterables.getLast(comments));
    // database one to two over the PostgreSQL back end.
    synchronized (lock) {
        lock.await(1000, TimeUnit.MILLISECONDS);
    }
    final List<IComment> oneThree = databaseOnecodeNode.getComments().getLocalInstructionComment(databaseOnecodeNode.getLastInstruction());
    final List<IComment> twoThree = databaseTwocodeNode.getComments().getLocalInstructionComment(databaseTwocodeNode.getLastInstruction());
    assertEquals(oneTwoSize - 1, oneThree.size());
    assertEquals(twoTwoSize - 1, twoThree.size());
    assertEquals(oneThree, twoThree);
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) Test(org.junit.Test)

Example 19 with IComment

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment in project binnavi by google.

the class PostgreSQLNotificationProviderTest method testDeleteLocalEdgeCommentSync.

@Test
public void testDeleteLocalEdgeCommentSync() throws CouldntDeleteException, InterruptedException, CouldntSaveDataException, CouldntLoadDataException {
    final INaviEdge databaseOneEdge = databaseOneView.getContent().getGraph().getEdges().get(3);
    final INaviEdge databaseTwoEdge = databaseTwoView.getContent().getGraph().getEdges().get(3);
    final List<IComment> oneBefore = databaseOneEdge.getLocalComment() == null ? new ArrayList<IComment>() : databaseOneEdge.getLocalComment();
    final List<IComment> twoBefore = databaseTwoEdge.getLocalComment() == null ? new ArrayList<IComment>() : databaseTwoEdge.getLocalComment();
    assertEquals(oneBefore, twoBefore);
    final List<IComment> comments = databaseOneEdge.appendLocalComment(" TEST NOTIFICATION PROVIDER TESTS (LOCAL CODE NODE COMMENT) ");
    // database one to two over the PostgreSQL back end.
    synchronized (lock) {
        lock.await(1000, TimeUnit.MILLISECONDS);
    }
    final List<IComment> oneAfter = databaseOneEdge.getLocalComment();
    final List<IComment> twoAfter = databaseTwoEdge.getLocalComment();
    assertNotNull(oneAfter);
    assertNotNull(twoAfter);
    assertEquals(oneBefore.size() + 1, oneAfter.size());
    assertEquals(twoBefore.size() + 1, twoAfter.size());
    assertEquals(oneAfter, twoAfter);
    final int oneTwoSize = oneAfter.size();
    final int twoTwoSize = twoAfter.size();
    databaseOneEdge.deleteLocalComment(Iterables.getLast(comments));
    // database one to two over the PostgreSQL back end.
    synchronized (lock) {
        lock.await(1000, TimeUnit.MILLISECONDS);
    }
    final List<IComment> oneThree = databaseOneEdge.getLocalComment();
    final List<IComment> twoThree = databaseTwoEdge.getLocalComment();
    assertEquals(oneTwoSize - 1, oneThree.size());
    assertEquals(twoTwoSize - 1, twoThree.size());
    assertEquals(oneThree, twoThree);
}
Also used : IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge) Test(org.junit.Test)

Example 20 with IComment

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment in project binnavi by google.

the class PostgreSQLNotificationProviderTest method testAppendLocalInstructionCommentSync.

@Test
public void testAppendLocalInstructionCommentSync() throws CouldntSaveDataException, CouldntLoadDataException, InterruptedException {
    final INaviCodeNode databaseOnecodeNode = databaseOneView.getContent().getBasicBlocks().get(3);
    final INaviCodeNode databaseTwocodeNode = databaseTwoView.getContent().getBasicBlocks().get(3);
    final List<IComment> oneBefore = databaseOnecodeNode.getComments().getLocalInstructionComment(databaseOnecodeNode.getLastInstruction()) == null ? new ArrayList<IComment>() : databaseOnecodeNode.getComments().getLocalInstructionComment(databaseOnecodeNode.getLastInstruction());
    final List<IComment> twoBefore = databaseTwocodeNode.getComments().getLocalInstructionComment(databaseTwocodeNode.getLastInstruction()) == null ? new ArrayList<IComment>() : databaseTwocodeNode.getComments().getLocalInstructionComment(databaseTwocodeNode.getLastInstruction());
    assertEquals(oneBefore, twoBefore);
    databaseOnecodeNode.getComments().appendLocalInstructionComment(databaseOnecodeNode.getLastInstruction(), " TEST NOTIFICATION PROVIDER TESTS (GLOBAL INSTRUCTION COMMENT)");
    // database one to two over the PostgreSQL back end.
    synchronized (lock) {
        lock.await(1000, TimeUnit.MILLISECONDS);
    }
    final List<IComment> oneAfter = databaseOnecodeNode.getComments().getLocalInstructionComment(databaseOnecodeNode.getLastInstruction());
    final List<IComment> twoAfter = databaseTwocodeNode.getComments().getLocalInstructionComment(databaseTwocodeNode.getLastInstruction());
    assertNotNull(oneAfter);
    assertNotNull(twoAfter);
    assertEquals(oneBefore.size() + 1, oneAfter.size());
    assertEquals(twoBefore.size() + 1, twoAfter.size());
    assertEquals(oneAfter, twoAfter);
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) Test(org.junit.Test)

Aggregations

IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)167 Test (org.junit.Test)129 CComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment)114 IUser (com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser)97 UniqueTestUserGenerator (com.google.security.zynamics.binnavi.Database.PostgreSQL.UniqueTestUserGenerator)89 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)89 ArrayList (java.util.ArrayList)20 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)18 INaviGroupNode (com.google.security.zynamics.binnavi.disassembly.INaviGroupNode)16 INaviTextNode (com.google.security.zynamics.binnavi.disassembly.INaviTextNode)13 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)12 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)11 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)10 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)10 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)9 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)9 PreparedStatement (java.sql.PreparedStatement)8 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)7 INaviEdge (com.google.security.zynamics.binnavi.disassembly.INaviEdge)7 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)7