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