Search in sources :

Example 21 with CommentNotification

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

the class PostgreSQLNotificationParserTest method testCommentTableNotificationParser1.

@Test
public void testCommentTableNotificationParser1() {
    CommentManager.get(provider).initializeGlobalInstructionComment(instruction, Lists.newArrayList(comment1, comment2, comment3));
    final String COMMENTS_TABLE_NOTIFICATION_1 = "bn_comments UPDATE 3333 2222 " + CommonTestObjects.TEST_USER_3.getUserId() + " AAA";
    final CommentNotification result = PostgreSQLCommentNotificationParser.processCommentNotification(new MockPGNotification("comment_changes", COMMENTS_TABLE_NOTIFICATION_1), provider);
    assertNotNull(result);
    final CommentNotificationContainer container = (CommentNotificationContainer) result;
    final IComment comment = container.getCurrentComment();
    assertEquals(comment3, comment);
    final IComment testComment = new CComment(3333, CommonTestObjects.TEST_USER_3, comment2, "AAA");
    assertEquals(testComment, container.getNewComment());
}
Also used : CComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment) IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) CommentNotification(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification) GroupNodeCommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.GroupNodeCommentNotificationContainer) FunctionNodeCommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNodeCommentNotificationContainer) InstructionCommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.InstructionCommentNotificationContainer) TypeInstanceCommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.TypeInstanceCommentNotificationContainer) TextNodeCommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.TextNodeCommentNotificationContainer) CodeNodeCommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.CodeNodeCommentNotificationContainer) CommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.CommentNotificationContainer) FunctionCommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionCommentNotificationContainer) EdgeCommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.EdgeCommentNotificationContainer) Test(org.junit.Test)

Example 22 with CommentNotification

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

the class PostgreSQLNotificationParserTest method testGlobalInstructionCommentParsingAppend.

@Test
public void testGlobalInstructionCommentParsingAppend() {
    new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
    MockPGNotification notification = new MockPGNotification("comment_changes", "bn_instructions UPDATE 1 4608 3333");
    final CommentNotification result = PostgreSQLCommentNotificationParser.processInstructionGlobalCommentNotification(notification, provider);
    assertNotNull(result);
    final InstructionCommentNotificationContainer container = (InstructionCommentNotificationContainer) result;
    final INaviInstruction instruction = container.getInstruction();
    assertEquals(new CAddress(4608), instruction.getAddress());
    assertEquals(CommentOperation.APPEND, container.getOperation());
    assertEquals(new Integer(3333), container.getCommentId());
    assertEquals(CommentScope.GLOBAL, container.getScope());
}
Also used : CommentNotification(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) InstructionCommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.InstructionCommentNotificationContainer) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 23 with CommentNotification

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

the class PostgreSQLNotificationParserTest method testFunctionNodeCommentParsingAppendCommentUnknownModule.

@Test
public void testFunctionNodeCommentParsingAppendCommentUnknownModule() {
    new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
    MockPGNotification notification = new MockPGNotification("comment_changes", "bn_function_nodes UPDATE 2 6666 4608 3333");
    final CommentNotification result = PostgreSQLCommentNotificationParser.processFunctionNodeCommentNotification(notification, provider);
    assertNull(result);
}
Also used : CommentNotification(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) Test(org.junit.Test)

Example 24 with CommentNotification

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

the class PostgreSQLNotificationParserTest method testGlobalEdgeCommentParsingDeleteLastComment.

@Test
public void testGlobalEdgeCommentParsingDeleteLastComment() {
    new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
    MockPGNotification notification = new MockPGNotification("comment_changes", "bn_global_edge_comments DELETE 1 1 4608 4614");
    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.DELETE, container.getOperation());
    assertNull(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 25 with CommentNotification

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

the class PostgreSQLNotificationParserTest method testFunctionNodeCommentParsingAppendComment.

@Test
public void testFunctionNodeCommentParsingAppendComment() {
    new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
    MockPGNotification notification = new MockPGNotification("comment_changes", "bn_function_nodes UPDATE 1 6666 4608 3333");
    final CommentNotification result = PostgreSQLCommentNotificationParser.processFunctionNodeCommentNotification(notification, provider);
    assertNotNull(result);
    final FunctionNodeCommentNotificationContainer container = (FunctionNodeCommentNotificationContainer) result;
    final INaviFunction function = container.getNode().getFunction();
    assertEquals(new CAddress(4608), function.getAddress());
    assertEquals(CommentOperation.APPEND, container.getOperation());
    assertEquals(new Integer(3333), container.getCommentId());
}
Also used : 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) FunctionNodeCommentNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.FunctionNodeCommentNotificationContainer) 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