use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLViewNotificationParser in project binnavi by google.
the class PostgreSQLViewNotificationParserTest method testModuleViewInform2.
@Test(expected = IllegalArgumentException.class)
public void testModuleViewInform2() throws CouldntLoadDataException {
final INaviModule module = new MockModule(provider);
final ViewNotificationContainer container = new ViewNotificationContainer(view.getConfiguration().getId(), Optional.fromNullable(view), Optional.of(module.getConfiguration().getId()), Optional.of(module), Optional.<INaviProject>absent(), "DELETE");
final PostgreSQLViewNotificationParser parser = new PostgreSQLViewNotificationParser();
parser.inform(Lists.<ViewNotificationContainer>newArrayList(container), provider);
}
use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLViewNotificationParser in project binnavi by google.
the class PostgreSQLViewNotificationParserTest method testParser.
private void testParser(final String table, final String databaseOperation, final String viewId, final String containerId) {
final String NOTIFICATION = containerId != null ? table + " " + databaseOperation + " " + viewId + " " + containerId : table + " " + databaseOperation + " " + viewId;
notifications.add(new MockPGNotification("view_changes", NOTIFICATION));
final PostgreSQLViewNotificationParser parser = new PostgreSQLViewNotificationParser();
final Collection<ViewNotificationContainer> result = parser.parse(notifications, provider);
assertNotNull(result);
assertTrue(!result.isEmpty());
assertTrue(result.size() == 1);
final ViewNotificationContainer container = Iterables.getFirst(result, null);
assertNotNull(container);
assertEquals(databaseOperation, container.getDatabaseOperation());
assertEquals(viewId, container.getViewId().toString());
if (containerId != null) {
assertEquals(containerId, container.getNotificationObjectId().get().toString());
}
}
use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLViewNotificationParser in project binnavi by google.
the class PostgreSQLViewNotificationParserTest method testProjectViewInform3.
@Test
public void testProjectViewInform3() throws CouldntLoadDataException {
final INaviProject project = new MockProject(provider);
final int currentUserViewSize = project.getContent().getViews().size();
final ViewNotificationContainer container = new ViewNotificationContainer(view.getConfiguration().getId(), Optional.fromNullable(view), Optional.of(project.getConfiguration().getId()), Optional.<INaviModule>absent(), Optional.of(project), "INSERT");
final PostgreSQLViewNotificationParser parser = new PostgreSQLViewNotificationParser();
parser.inform(Lists.<ViewNotificationContainer>newArrayList(container), provider);
assertEquals(currentUserViewSize + 1, project.getContent().getViews().size());
final ViewNotificationContainer container2 = new ViewNotificationContainer(view.getConfiguration().getId(), Optional.fromNullable(view), Optional.of(project.getConfiguration().getId()), Optional.<INaviModule>absent(), Optional.of(project), "DELETE");
parser.inform(Lists.<ViewNotificationContainer>newArrayList(container2), provider);
assertEquals(currentUserViewSize, project.getContent().getViews().size());
}
use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLViewNotificationParser in project binnavi by google.
the class PostgreSQLViewNotificationParserTest method testProjectViewInform0.
@Test
public void testProjectViewInform0() throws CouldntLoadDataException {
final INaviProject project = new MockProject(provider);
final int currentUserViewSize = project.getContent().getViews().size();
final ViewNotificationContainer container = new ViewNotificationContainer(view.getConfiguration().getId(), Optional.fromNullable(view), Optional.of(project.getConfiguration().getId()), Optional.<INaviModule>absent(), Optional.of(project), "INSERT");
final PostgreSQLViewNotificationParser parser = new PostgreSQLViewNotificationParser();
parser.inform(Lists.<ViewNotificationContainer>newArrayList(container), provider);
assertEquals(currentUserViewSize + 1, project.getContent().getViews().size());
}
Aggregations