Search in sources :

Example 31 with INaviGroupNode

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

the class PostgreSQLNotificationProviderTest method testDeleteGroupNodeComment.

@Test
public void testDeleteGroupNodeComment() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException, CPartialLoadException, InterruptedException, CouldntDeleteException {
    final CView databaseOneGroupNodeView = databaseOneModuleTwo.getContent().getViewContainer().createView(" GROUP NODE TESTING VIEW ", "");
    CViewInserter.insertView(databaseOneView, databaseOneGroupNodeView);
    final INaviGroupNode databaseOneGroupNode = databaseOneGroupNodeView.getContent().createGroupNode(databaseOneGroupNodeView.getGraph().getNodes());
    databaseOneGroupNodeView.save();
    databaseTwoModuleTwo.close();
    databaseTwoModuleTwo.load();
    databaseTwoView.load();
    final INaviView databaseTwoGroupNodeView = Iterables.getLast(databaseTwoModuleTwo.getContent().getViewContainer().getUserViews());
    INaviGroupNode databaseTwoGroupNode = null;
    assertEquals(databaseOneGroupNodeView.getName(), databaseTwoGroupNodeView.getName());
    databaseTwoGroupNodeView.load();
    for (final INaviViewNode node : databaseTwoGroupNodeView.getContent().getGraph().getNodes()) {
        if (node instanceof INaviGroupNode) {
            databaseTwoGroupNode = (INaviGroupNode) node;
        }
    }
    assertNotNull(databaseTwoGroupNode);
    assertEquals(databaseTwoGroupNode.getId(), databaseOneGroupNode.getId());
    final List<IComment> comments = databaseOneGroupNode.appendComment(" TEST NOTIFICATION PROVIDER TESTS (GROUP NODE COMMENT) ");
    synchronized (lock) {
        lock.await(1000, TimeUnit.MILLISECONDS);
    }
    final List<IComment> oneAfter = databaseOneGroupNode.getComments();
    final List<IComment> twoAfter = databaseTwoGroupNode.getComments();
    assertNotNull(oneAfter);
    assertNotNull(twoAfter);
    assertEquals(1, oneAfter.size());
    assertEquals(1, twoAfter.size());
    assertEquals(oneAfter, twoAfter);
    final int oneTwoSize = oneAfter.size();
    final int twoTwoSize = twoAfter.size();
    databaseOneGroupNode.deleteComment(Iterables.getLast(comments));
    // database one to two over the PostgreSQL back end.
    synchronized (lock) {
        lock.await(1000, TimeUnit.MILLISECONDS);
    }
    final List<IComment> oneThree = databaseOneGroupNode.getComments();
    final List<IComment> twoThree = databaseTwoGroupNode.getComments();
    assertEquals(oneTwoSize - 1, oneThree.size());
    assertEquals(twoTwoSize - 1, twoThree.size());
    assertEquals(oneThree, twoThree);
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) INaviGroupNode(com.google.security.zynamics.binnavi.disassembly.INaviGroupNode) Test(org.junit.Test)

Example 32 with INaviGroupNode

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

the class PostgreSQLNotificationProviderTest method testAppendGroupNodeCommentSync.

@Test
public void testAppendGroupNodeCommentSync() throws CouldntSaveDataException, CouldntLoadDataException, CPartialLoadException, LoadCancelledException, InterruptedException {
    final CView databaseOneGroupNodeView = databaseOneModuleTwo.getContent().getViewContainer().createView(" GROUP NODE TESTING VIEW ", "");
    CViewInserter.insertView(databaseOneView, databaseOneGroupNodeView);
    final INaviGroupNode databaseOneGroupNode = databaseOneGroupNodeView.getContent().createGroupNode(databaseOneGroupNodeView.getGraph().getNodes());
    databaseOneGroupNodeView.save();
    databaseTwoModuleTwo.close();
    databaseTwoModuleTwo.load();
    databaseTwoView.load();
    final INaviView databaseTwoGroupNodeView = Iterables.getLast(databaseTwoModuleTwo.getContent().getViewContainer().getUserViews());
    INaviGroupNode databaseTwoGroupNode = null;
    assertEquals(databaseOneGroupNodeView.getName(), databaseTwoGroupNodeView.getName());
    databaseTwoGroupNodeView.load();
    for (final INaviViewNode node : databaseTwoGroupNodeView.getContent().getGraph().getNodes()) {
        if (node instanceof INaviGroupNode) {
            databaseTwoGroupNode = (INaviGroupNode) node;
        }
    }
    assertNotNull(databaseTwoGroupNode);
    assertEquals(databaseTwoGroupNode.getId(), databaseOneGroupNode.getId());
    databaseOneGroupNode.appendComment(" TEST NOTIFICATION PROVIDER TESTS (GROUP NODE COMMENT) ");
    synchronized (lock) {
        lock.await(1000, TimeUnit.MILLISECONDS);
    }
    final List<IComment> oneAfter = databaseOneGroupNode.getComments();
    final List<IComment> twoAfter = databaseTwoGroupNode.getComments();
    assertNotNull(oneAfter);
    assertNotNull(twoAfter);
    assertEquals(1, oneAfter.size());
    assertEquals(1, twoAfter.size());
    assertEquals(oneAfter, twoAfter);
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) INaviGroupNode(com.google.security.zynamics.binnavi.disassembly.INaviGroupNode) Test(org.junit.Test)

Example 33 with INaviGroupNode

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

the class GroupNodeTest method testConstructor.

@Test
public void testConstructor() {
    final Database database = new Database(new MockDatabase());
    final MockModule mockModule = new MockModule();
    final TagManager nodeTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.NODE_TAG));
    final TagManager viewTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.VIEW_TAG));
    final Module module = new Module(database, mockModule, nodeTagManager, viewTagManager);
    final MockView mockView = new MockView();
    final View view = new View(module, mockView, nodeTagManager, viewTagManager);
    final INaviGroupNode internalGroupNode = new CGroupNode(0, 0, 0, 0, 0, Color.RED, false, false, new HashSet<CTag>(), new ArrayList<IComment>(), false, new MockSqlProvider());
    final GroupNode node = new GroupNode(view, internalGroupNode, viewTagManager);
    assertEquals("Group Node [0 elements]", node.toString());
}
Also used : IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CGroupNode(com.google.security.zynamics.binnavi.disassembly.CGroupNode) INaviGroupNode(com.google.security.zynamics.binnavi.disassembly.INaviGroupNode) MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) INaviGroupNode(com.google.security.zynamics.binnavi.disassembly.INaviGroupNode) CGroupNode(com.google.security.zynamics.binnavi.disassembly.CGroupNode) Test(org.junit.Test)

Example 34 with INaviGroupNode

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

the class GroupNodeTest method testSetText.

@Test
public void testSetText() throws CouldntSaveDataException, com.google.security.zynamics.binnavi.API.disassembly.CouldntSaveDataException, CouldntLoadDataException {
    final Database database = new Database(new MockDatabase());
    final SQLProvider provider = new MockSqlProvider();
    final MockModule mockModule = new MockModule();
    final TagManager nodeTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.NODE_TAG));
    final TagManager viewTagManager = new TagManager(new MockTagManager(com.google.security.zynamics.binnavi.Tagging.TagType.VIEW_TAG));
    final Module module = new Module(database, mockModule, nodeTagManager, viewTagManager);
    final MockView mockView = new MockView();
    final View view = new View(module, mockView, nodeTagManager, viewTagManager);
    final INaviGroupNode internalGroupNode = new CGroupNode(0, 0, 0, 0, 0, Color.RED, false, false, new HashSet<CTag>(), new ArrayList<IComment>(), false, provider);
    final GroupNode node = new GroupNode(view, internalGroupNode, viewTagManager);
    final MockGroupNodeListener listener = new MockGroupNodeListener();
    final CUserManager userManager = CUserManager.get(provider);
    final IUser user = userManager.addUser(" TEST APPEND GROUP NODE COMMENT ");
    userManager.setCurrentActiveUser(user);
    node.addListener(listener);
    final List<IComment> comments = node.appendComment("Hannes");
    assertEquals("appendedComment;", listener.events);
    assertEquals(comments, node.getComment());
    node.removeListener(listener);
}
Also used : IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CGroupNode(com.google.security.zynamics.binnavi.disassembly.CGroupNode) INaviGroupNode(com.google.security.zynamics.binnavi.disassembly.INaviGroupNode) MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) SQLProvider(com.google.security.zynamics.binnavi.Database.Interfaces.SQLProvider) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) CUserManager(com.google.security.zynamics.binnavi.Gui.Users.CUserManager) MockTagManager(com.google.security.zynamics.binnavi.Tagging.MockTagManager) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) IUser(com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) INaviGroupNode(com.google.security.zynamics.binnavi.disassembly.INaviGroupNode) CGroupNode(com.google.security.zynamics.binnavi.disassembly.CGroupNode) Test(org.junit.Test)

Example 35 with INaviGroupNode

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

the class PostgreSQLGroupNodeCommentTests method editGroupNodeComment3.

@Test(expected = NullPointerException.class)
public void editGroupNodeComment3() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException, MaybeNullException, CPartialLoadException {
    final INaviGroupNode groupNode = setupGroupNode();
    getProvider().editGroupNodeComment(groupNode, 1, null, "");
}
Also used : INaviGroupNode(com.google.security.zynamics.binnavi.disassembly.INaviGroupNode) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Aggregations

INaviGroupNode (com.google.security.zynamics.binnavi.disassembly.INaviGroupNode)40 Test (org.junit.Test)23 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)16 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)15 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)11 CComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment)9 IUser (com.google.security.zynamics.binnavi.Gui.Users.Interfaces.IUser)9 UniqueTestUserGenerator (com.google.security.zynamics.binnavi.Database.PostgreSQL.UniqueTestUserGenerator)8 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)7 ArrayList (java.util.ArrayList)7 CGroupNode (com.google.security.zynamics.binnavi.disassembly.CGroupNode)6 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)5 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)4 INaviFunctionNode (com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode)4 NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)4 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)3 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)3 GroupNodeCommentNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.GroupNodeCommentNotificationContainer)3 MockTagManager (com.google.security.zynamics.binnavi.Tagging.MockTagManager)3 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)3