### Question:
EventFactory { public static Event flowVersionCreated(final VersionedFlowSnapshot versionedFlowSnapshot) { final String versionComments = versionedFlowSnapshot.getSnapshotMetadata().getComments() == null ? "" : versionedFlowSnapshot.getSnapshotMetadata().getComments(); return new StandardEvent.Builder() .eventType(EventType.CREATE_FLOW_VERSION) .addField(EventFieldName.BUCKET_ID, versionedFlowSnapshot.getSnapshotMetadata().getBucketIdentifier()) .addField(EventFieldName.FLOW_ID, versionedFlowSnapshot.getSnapshotMetadata().getFlowIdentifier()) .addField(EventFieldName.VERSION, String.valueOf(versionedFlowSnapshot.getSnapshotMetadata().getVersion())) .addField(EventFieldName.USER, versionedFlowSnapshot.getSnapshotMetadata().getAuthor()) .addField(EventFieldName.COMMENT, versionComments) .build(); }  static Event bucketCreated(final Bucket bucket); static Event bucketUpdated(final Bucket bucket); static Event bucketDeleted(final Bucket bucket); static Event flowCreated(final VersionedFlow versionedFlow); static Event flowUpdated(final VersionedFlow versionedFlow); static Event flowDeleted(final VersionedFlow versionedFlow); static Event flowVersionCreated(final VersionedFlowSnapshot versionedFlowSnapshot); static Event extensionBundleCreated(final Bundle bundle); static Event extensionBundleDeleted(final Bundle bundle); static Event extensionBundleVersionCreated(final BundleVersion bundleVersion); static Event extensionBundleVersionDeleted(final BundleVersion bundleVersion); static Event userCreated(final User user); static Event userUpdated(final User user); static Event userDeleted(final User user); static Event userGroupCreated(final UserGroup userGroup); static Event userGroupUpdated(final UserGroup userGroup); static Event userGroupDeleted(final UserGroup userGroup);  }### Answer:
@Test public void testFlowVersionedCreated() { final Event event = EventFactory.flowVersionCreated(versionedFlowSnapshot); event.validate(); assertEquals(EventType.CREATE_FLOW_VERSION, event.getEventType()); assertEquals(5, event.getFields().size()); assertEquals(bucket.getIdentifier(), event.getField(EventFieldName.BUCKET_ID).getValue()); assertEquals(versionedFlow.getIdentifier(), event.getField(EventFieldName.FLOW_ID).getValue()); assertEquals(String.valueOf(versionedFlowSnapshot.getSnapshotMetadata().getVersion()), event.getField(EventFieldName.VERSION).getValue()); assertEquals(versionedFlowSnapshot.getSnapshotMetadata().getAuthor(), event.getField(EventFieldName.USER).getValue()); assertEquals(versionedFlowSnapshot.getSnapshotMetadata().getComments(), event.getField(EventFieldName.COMMENT).getValue()); }
@Test public void testFlowVersionedCreatedWhenCommentsMissing() { versionedFlowSnapshot.getSnapshotMetadata().setComments(null); final Event event = EventFactory.flowVersionCreated(versionedFlowSnapshot); event.validate(); assertEquals("", event.getField(EventFieldName.COMMENT).getValue()); }