@Test
public void testDeleteBucketWithFlows() {

    final BucketEntity bucketToDelete = new BucketEntity();
    bucketToDelete.setId("b1");
    bucketToDelete.setName("My Bucket");
    bucketToDelete.setDescription("This is my bucket");
    bucketToDelete.setCreated(new Date());
    final FlowEntity flowToDelete = new FlowEntity();
    flowToDelete.setId("flow1");
    flowToDelete.setName("Flow 1");
    flowToDelete.setDescription("This is flow 1");
    flowToDelete.setCreated(new Date());
    final List<FlowEntity> flows = new ArrayList<>();
    flows.add(flowToDelete);
    when(metadataService.getBucketById(bucketToDelete.getId())).thenReturn(bucketToDelete);
    when(metadataService.getFlowsByBucket(bucketToDelete.getId())).thenReturn(flows);
    final Bucket deletedBucket = registryService.deleteBucket(bucketToDelete.getId());
    assertNotNull(deletedBucket);
    assertEquals(bucketToDelete.getId(), deletedBucket.getIdentifier());
    verify(flowPersistenceProvider, times(1))
            .deleteAllFlowContent(eq(bucketToDelete.getId()), eq(flowToDelete.getId()));
}