@Test
public void testGetFlowsByBucketExists() {

    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 FlowEntity flowEntity1 = new FlowEntity();
    flowEntity1.setId("flow1");
    flowEntity1.setName("My Flow");
    flowEntity1.setDescription("This is my flow.");
    flowEntity1.setCreated(new Date());
    flowEntity1.setModified(new Date());
    flowEntity1.setBucketId(existingBucket.getId());
    final FlowEntity flowEntity2 = new FlowEntity();
    flowEntity2.setId("flow2");
    flowEntity2.setName("My Flow 2");
    flowEntity2.setDescription("This is my flow 2.");
    flowEntity2.setCreated(new Date());
    flowEntity2.setModified(new Date());
    flowEntity2.setBucketId(existingBucket.getId());
    final List<FlowEntity> flows = new ArrayList<>();
    flows.add(flowEntity1);
    flows.add(flowEntity2);
    when(metadataService.getFlowsByBucket(eq(existingBucket.getId()))).thenReturn(flows);
    final List<VersionedFlow> allFlows = registryService.getFlows(existingBucket.getId());
    assertNotNull(allFlows);
    assertEquals(2, allFlows.size());
}