Search in sources :

Example 11 with INaviEdge

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

the class PostgreSQLNotificationParserTest method testGlobalEdgeCommentParsingAppendNewComment.

@Test
public void testGlobalEdgeCommentParsingAppendNewComment() {
    new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
    MockPGNotification notification = new MockPGNotification("comment_changes", "bn_global_edge_comments UPDATE 1 1 4608 4614 3333");
    final Collection<CommentNotification> result = PostgreSQLCommentNotificationParser.processEdgeGlobalCommentNotification(notification, provider);
    assertEquals(1, result.size());
    final EdgeCommentNotificationContainer container = (EdgeCommentNotificationContainer) Iterables.getFirst(result, null);
    final INaviEdge edge = container.getEdge();
    assertEquals(1111, edge.getId());
    assertEquals(CommentOperation.APPEND, container.getOperation());
    assertEquals(new Integer(3333), container.getCommentId());
    assertEquals(CommentScope.GLOBAL, container.getScope());
}
Also used : EdgeCommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.EdgeCommentNotificationContainer) CommentNotification(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge) Test(org.junit.Test)

Example 12 with INaviEdge

use of com.google.security.zynamics.binnavi.disassembly.INaviEdge 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 13 with INaviEdge

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

the class PostgreSQLNotificationParserTest method testLocalEdgeCommentParsingDelete.

@Test
public void testLocalEdgeCommentParsingDelete() {
    new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
    MockPGNotification notification = new MockPGNotification("comment_changes", "bn_edges UPDATE 4444 null");
    final CommentNotification result = PostgreSQLCommentNotificationParser.processEdgeLocalCommentNotification(notification, provider);
    assertNotNull(result);
    final EdgeCommentNotificationContainer container = (EdgeCommentNotificationContainer) result;
    final INaviEdge edge = container.getEdge();
    assertEquals(4444, edge.getId());
    assertEquals(CommentOperation.DELETE, container.getOperation());
    assertNull(container.getCommentId());
    assertEquals(CommentScope.LOCAL, container.getScope());
}
Also used : EdgeCommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.EdgeCommentNotificationContainer) CommentNotification(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge) Test(org.junit.Test)

Example 14 with INaviEdge

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

the class PostgreSQLViewLoader method loadView.

/**
   * Loads the graph of a view from the database.
   * 
   * @param provider The SQL provider that provides the connection.
   * @param view The view to load.
   * @param list A list of all modules that are part of the database.
   * @param nodeTagManager Node tag manager of the database.
   * 
   * @return The graph of the view.
   * 
   * @throws CouldntLoadDataException Thrown if the graph of view could not be loaded.
   * @throws CPartialLoadException Thrown if the graph could not be loaded because not all required
   *         modules are loaded.
   */
public static MutableDirectedGraph<INaviViewNode, INaviEdge> loadView(final AbstractSQLProvider provider, final INaviView view, final List<INaviModule> list, final CTagManager nodeTagManager) throws CouldntLoadDataException, CPartialLoadException {
    checkArguments(provider, view, list, nodeTagManager);
    try {
        final List<INaviViewNode> nodes = PostgreSQLNodeLoader.loadNodes(provider, view, list, nodeTagManager);
        NodeCache.get(provider).addNodes(nodes);
        final List<INaviEdge> edges = PostgreSQLEdgeLoader.loadEdges(provider, view, nodes);
        EdgeCache.get(provider).addEdges(edges);
        return new MutableDirectedGraph<INaviViewNode, INaviEdge>(nodes, edges);
    } catch (final SQLException exception) {
        throw new CouldntLoadDataException(exception);
    }
}
Also used : SQLException(java.sql.SQLException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge) MutableDirectedGraph(com.google.security.zynamics.zylib.types.graphs.MutableDirectedGraph)

Example 15 with INaviEdge

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

the class PostgreSQLNotificationProviderTest method testAppendLocalEdgeCommentSync.

@Test
public void testAppendLocalEdgeCommentSync() throws CouldntSaveDataException, CouldntLoadDataException, InterruptedException {
    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);
    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);
}
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)

Aggregations

INaviEdge (com.google.security.zynamics.binnavi.disassembly.INaviEdge)47 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)21 Test (org.junit.Test)17 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)9 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)9 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)8 EdgeCommentNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.EdgeCommentNotificationContainer)7 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)7 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)7 CNaviViewEdge (com.google.security.zynamics.binnavi.disassembly.CNaviViewEdge)7 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)7 CBend (com.google.security.zynamics.zylib.gui.zygraph.edges.CBend)7 CommentNotification (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification)6 MockInstruction (com.google.security.zynamics.binnavi.disassembly.MockInstruction)6 SQLException (java.sql.SQLException)6 ArrayList (java.util.ArrayList)6 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)5 MockFunction (com.google.security.zynamics.binnavi.disassembly.MockFunction)5 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)5 FilledList (com.google.security.zynamics.zylib.types.lists.FilledList)5