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());
}
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);
}
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());
}
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);
}
}
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);
}
Aggregations