use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.ViewNotificationContainer in project binnavi by google.
the class PostgreSQLViewNotificationParserTest method testViewInform4.
@Test
public void testViewInform4() throws CouldntLoadDataException {
final ViewNotificationContainer container = new ViewNotificationContainer(view.getConfiguration().getId(), Optional.fromNullable(view), Optional.<Integer>absent(), Optional.<INaviModule>absent(), 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.containers.ViewNotificationContainer in project binnavi by google.
the class PostgreSQLViewNotificationParserTest method testViewInform3.
@Test
public void testViewInform3() throws CouldntLoadDataException {
final boolean starState2 = true;
view.getConfiguration().setStaredInternal(starState2);
assertEquals(starState2, view.getConfiguration().isStared());
final ViewNotificationContainer container = new ViewNotificationContainer(view.getConfiguration().getId(), Optional.fromNullable(view), Optional.<Integer>absent(), Optional.<INaviModule>absent(), Optional.<INaviProject>absent(), "UPDATE");
final PostgreSQLViewNotificationParser parser = new PostgreSQLViewNotificationParser();
parser.inform(Lists.<ViewNotificationContainer>newArrayList(container), provider);
assertEquals(false, view.getConfiguration().isStared());
}
use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.ViewNotificationContainer in project binnavi by google.
the class PostgreSQLViewNotificationParser method parseProjectViewNotification.
/**
* Parser for the bn_project_views notification. The function uses the
* projectViewNotificationPattern to parse the incoming {@link PGNotification} into a
* {@link ViewNotificationContainer}
*
* @param notification The {@link PGNotification} to parse.
* @param provider The {@link SQLProvider} to access the database.
*/
private ViewNotificationContainer parseProjectViewNotification(final PGNotification notification, final SQLProvider provider) {
final Matcher matcher = projectViewNotificationPattern.matcher(notification.getParameter());
if (!matcher.find()) {
throw new IllegalStateException("IE02744: compiled pattern: " + projectViewNotificationPattern.toString() + " did not match notification: " + notification.getParameter());
}
final Integer viewId = Integer.parseInt(matcher.group(3));
final Optional<INaviView> view = Optional.fromNullable(ViewManager.get(provider).getView(viewId));
final Optional<Integer> projectId = Optional.fromNullable(Integer.parseInt(matcher.group(4)));
final Optional<INaviProject> project = Optional.fromNullable(provider.findProject(projectId.get()));
final String databaseOperation = matcher.group(2);
return new ViewNotificationContainer(viewId, view, projectId, Optional.<INaviModule>absent(), project, databaseOperation);
}
use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.ViewNotificationContainer in project binnavi by google.
the class PostgreSQLViewNotificationParserTest method testViewInform2.
@Test
public void testViewInform2() throws CouldntLoadDataException {
final String name2 = "TEST NAME STATE CHANGE";
view.getConfiguration().setNameInternal(name2);
assertEquals(name2, view.getConfiguration().getName());
final ViewNotificationContainer container = new ViewNotificationContainer(view.getConfiguration().getId(), Optional.fromNullable(view), Optional.<Integer>absent(), Optional.<INaviModule>absent(), Optional.<INaviProject>absent(), "UPDATE");
final PostgreSQLViewNotificationParser parser = new PostgreSQLViewNotificationParser();
parser.inform(Lists.<ViewNotificationContainer>newArrayList(container), provider);
assertEquals("DB PROJECT VIEW NAME", view.getConfiguration().getName());
}
use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.ViewNotificationContainer in project binnavi by google.
the class PostgreSQLViewNotificationParserTest method testModuleViewInform0.
@Test
public void testModuleViewInform0() throws CouldntLoadDataException {
final INaviModule module = new MockModule(provider);
final int currentUserViewSize = module.getContent().getViewContainer().getUserViews().size();
final ViewNotificationContainer container = new ViewNotificationContainer(view.getConfiguration().getId(), Optional.fromNullable(view), Optional.of(module.getConfiguration().getId()), Optional.of(module), Optional.<INaviProject>absent(), "INSERT");
final PostgreSQLViewNotificationParser parser = new PostgreSQLViewNotificationParser();
parser.inform(Lists.<ViewNotificationContainer>newArrayList(container), provider);
assertEquals(currentUserViewSize + 1, module.getContent().getViewContainer().getUserViews().size());
}
Aggregations