@Test
public void testCreateFlowValid() {

    final BucketEntity existingBucket = new BucketEntity();
    existingBucket.setId("b1");
    existingBucket.setName("My Bucket");
    existingBucket.setDescription("This is my bucket");
    existingBucket.setCreated(new Date());
    when(metadataService.getBucketById(existingBucket.getId())).thenReturn(existingBucket);
    final VersionedFlow versionedFlow = new VersionedFlow();
    versionedFlow.setIdentifier("f1");
    versionedFlow.setName("My Flow");
    versionedFlow.setBucketIdentifier("b1");
    doAnswer(createFlowAnswer()).when(metadataService).createFlow(any(FlowEntity.class));
    final VersionedFlow createdFlow = registryService.createFlow(versionedFlow.getBucketIdentifier(), versionedFlow);
    assertNotNull(createdFlow);
    assertNotNull(createdFlow.getIdentifier());
    assertTrue(createdFlow.getCreatedTimestamp() > 0);
    assertTrue(createdFlow.getModifiedTimestamp() > 0);
    assertEquals(versionedFlow.getIdentifier(), createdFlow.getIdentifier());
    assertEquals(versionedFlow.getName(), createdFlow.getName());
    assertEquals(versionedFlow.getBucketIdentifier(), createdFlow.getBucketIdentifier());
    assertEquals(versionedFlow.getDescription(), createdFlow.getDescription());
}