Search in sources :

Example 26 with CommentNotification

use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification in project binnavi by google.

the class PostgreSQLNotificationParserTest method testFunctionCommentParsingDeleteComment.

@Test
public void testFunctionCommentParsingDeleteComment() {
    new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
    MockPGNotification notification = new MockPGNotification("comment_changes", "bn_functions UPDATE 1 4608 null");
    final CommentNotification result = PostgreSQLCommentNotificationParser.processFunctionCommentNotification(notification, provider);
    assertNotNull(result);
    final FunctionCommentNotificationContainer container = (FunctionCommentNotificationContainer) result;
    final INaviFunction function = container.getFunction();
    assertEquals(new CAddress(4608), function.getAddress());
    assertEquals(CommentOperation.DELETE, container.getOperation());
    assertNull(container.getCommentId());
}
Also used : FunctionCommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionCommentNotificationContainer) CommentNotification(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 27 with CommentNotification

use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification in project binnavi by google.

the class PostgreSQLNotificationParserTest method testLocalEdgeCommentParsingAppend.

@Test
public void testLocalEdgeCommentParsingAppend() {
    new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
    MockPGNotification notification = new MockPGNotification("comment_changes", "bn_edges UPDATE 4444 3333");
    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.APPEND, container.getOperation());
    assertEquals(new Integer(3333), 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 28 with CommentNotification

use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification in project binnavi by google.

the class PostgreSQLNotificationParserTest method testFunctionNodeCommentParsingDeleteComment.

@Test
public void testFunctionNodeCommentParsingDeleteComment() {
    new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
    MockPGNotification notification = new MockPGNotification("comment_changes", "bn_function_nodes UPDATE 1 6666 4608 null");
    final CommentNotification result = PostgreSQLCommentNotificationParser.processFunctionNodeCommentNotification(notification, provider);
    assertNotNull(result);
    final FunctionNodeCommentNotificationContainer container = (FunctionNodeCommentNotificationContainer) result;
    final INaviFunctionNode functionNode = container.getNode();
    assertEquals(new CAddress(4608), functionNode.getAddress());
    assertEquals(CommentOperation.DELETE, container.getOperation());
    assertNull(container.getCommentId());
}
Also used : CommentNotification(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) INaviFunctionNode(com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode) FunctionNodeCommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNodeCommentNotificationContainer) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 29 with CommentNotification

use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification in project binnavi by google.

the class PostgreSQLNotificationParserTest method testGlobalEdgeCommentParsingAppendFirstComment.

@Test
public void testGlobalEdgeCommentParsingAppendFirstComment() {
    new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
    MockPGNotification notification = new MockPGNotification("comment_changes", "bn_global_edge_comments INSERT 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 30 with CommentNotification

use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification in project binnavi by google.

the class PostgreSQLNotificationParserTest method testFunctionCommentParsingAppendComment.

@Test
public void testFunctionCommentParsingAppendComment() {
    new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
    MockPGNotification notification = new MockPGNotification("comment_changes", "bn_functions UPDATE 1 4608 3333");
    final CommentNotification result = PostgreSQLCommentNotificationParser.processFunctionCommentNotification(notification, provider);
    assertNotNull(result);
    final FunctionCommentNotificationContainer container = (FunctionCommentNotificationContainer) result;
    final INaviFunction function = container.getFunction();
    assertEquals(new CAddress(4608), function.getAddress());
    assertEquals(CommentOperation.APPEND, container.getOperation());
    assertEquals(new Integer(3333), container.getCommentId());
}
Also used : FunctionCommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionCommentNotificationContainer) CommentNotification(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Aggregations

CommentNotification (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification)30 Test (org.junit.Test)28 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)26 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)17 CodeNodeCommentNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.CodeNodeCommentNotificationContainer)7 EdgeCommentNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.EdgeCommentNotificationContainer)7 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)6 INaviEdge (com.google.security.zynamics.binnavi.disassembly.INaviEdge)6 InstructionCommentNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.InstructionCommentNotificationContainer)5 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)4 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)4 FunctionCommentNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionCommentNotificationContainer)3 FunctionNodeCommentNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNodeCommentNotificationContainer)3 GroupNodeCommentNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.GroupNodeCommentNotificationContainer)3 TextNodeCommentNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.TextNodeCommentNotificationContainer)3 TypeInstanceCommentNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.TypeInstanceCommentNotificationContainer)3 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)3 CommentOperation (com.google.security.zynamics.binnavi.disassembly.CommentManager.CommentOperation)2 INaviGroupNode (com.google.security.zynamics.binnavi.disassembly.INaviGroupNode)2 INaviTextNode (com.google.security.zynamics.binnavi.disassembly.INaviTextNode)2