Search in sources :

Example 11 with PostgreSQLViewNotificationParser

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);
}
Also used : PostgreSQLViewNotificationParser(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLViewNotificationParser) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) ViewNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.ViewNotificationContainer) Test(org.junit.Test)

Example 12 with PostgreSQLViewNotificationParser

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());
    }
}
Also used : PostgreSQLViewNotificationParser(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLViewNotificationParser) ViewNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.ViewNotificationContainer)

Example 13 with PostgreSQLViewNotificationParser

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());
}
Also used : MockProject(com.google.security.zynamics.binnavi.disassembly.MockProject) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) PostgreSQLViewNotificationParser(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLViewNotificationParser) ViewNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.ViewNotificationContainer) Test(org.junit.Test)

Example 14 with PostgreSQLViewNotificationParser

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());
}
Also used : MockProject(com.google.security.zynamics.binnavi.disassembly.MockProject) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) PostgreSQLViewNotificationParser(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLViewNotificationParser) ViewNotificationContainer(com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.ViewNotificationContainer) Test(org.junit.Test)

Aggregations

ViewNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.ViewNotificationContainer)14 PostgreSQLViewNotificationParser (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLViewNotificationParser)14 Test (org.junit.Test)13 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)4 INaviProject (com.google.security.zynamics.binnavi.disassembly.INaviProject)4 MockProject (com.google.security.zynamics.binnavi.disassembly.MockProject)4 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)4