use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.GroupNodeCommentNotificationContainer in project binnavi by google.
the class PostgreSQLNotificationParserTest method testGroupNodeCommentParsingDeleteComment.
@Test
public void testGroupNodeCommentParsingDeleteComment() {
new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
MockPGNotification notification = new MockPGNotification("comment_changes", "bn_group_nodes UPDATE 8888 null");
final CommentNotification result = PostgreSQLCommentNotificationParser.processGroupNodeCommentNotification(notification, provider);
assertNotNull(result);
final GroupNodeCommentNotificationContainer container = (GroupNodeCommentNotificationContainer) result;
final INaviGroupNode groupNode = container.getNode();
assertEquals(8888, groupNode.getId());
assertEquals(CommentOperation.DELETE, container.getOperation());
assertNull(container.getCommentId());
}
use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.GroupNodeCommentNotificationContainer in project binnavi by google.
the class PostgreSQLNotificationParserTest method testGroupNodeCommentParsingAppendComment.
@Test
public void testGroupNodeCommentParsingAppendComment() {
new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
MockPGNotification notification = new MockPGNotification("comment_changes", "bn_group_nodes UPDATE 8888 3333");
final CommentNotification result = PostgreSQLCommentNotificationParser.processGroupNodeCommentNotification(notification, provider);
assertNotNull(result);
final GroupNodeCommentNotificationContainer container = (GroupNodeCommentNotificationContainer) result;
final INaviGroupNode groupNode = container.getNode();
assertEquals(8888, groupNode.getId());
assertEquals(CommentOperation.APPEND, container.getOperation());
assertEquals(new Integer(3333), container.getCommentId());
}
use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.GroupNodeCommentNotificationContainer in project binnavi by google.
the class PostgreSQLCommentNotificationParser method processGroupNodeCommentNotification.
/**
* Parses the notifications from the database back end for group node comments by using a regular
* expression. If the regular expression matches the supplied {@link PGNotification} notification,
* it is determined if the group node in the notification is currently loaded, and if a
* {@link CommentNotificationContainer} with the gathered data from the notification is returned.
*
* @param notification The {@link PGNotification} from the PostgreSQL database server.
* @param provider The {@link SQLProvider} which is used to communicate with the database.
*/
static CommentNotification processGroupNodeCommentNotification(final PGNotification notification, final SQLProvider provider) {
final Matcher matcher = GROUP_NODE_PATTERN.matcher(notification.getParameter());
if (!matcher.find()) {
return null;
}
final Integer nodeId = Integer.parseInt(matcher.group(3));
final Integer commentId = matcher.group(4).equals("null") ? null : Integer.parseInt(matcher.group(4));
final INaviGroupNode groupNode = (INaviGroupNode) NodeCache.get(provider).getNodeById(nodeId);
if (groupNode == null) {
return null;
}
final CommentOperation operation = commentId == null ? CommentOperation.DELETE : CommentOperation.APPEND;
return new GroupNodeCommentNotificationContainer(groupNode, operation, commentId);
}
Aggregations