You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by bb...@apache.org on 2017/09/21 13:50:39 UTC

[5/7] nifi-registry git commit: NIFIREG-18 Initial plumbling for H2 database - Setup Flyway with initial migration to define tables - Setup entity classes with repositories - Setup unit testing for repositories - Removed existing MetadataProvider concept

http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d478c20e/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/repository/TestBucketRepository.java
----------------------------------------------------------------------
diff --git a/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/repository/TestBucketRepository.java b/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/repository/TestBucketRepository.java
new file mode 100644
index 0000000..6a0a3ed
--- /dev/null
+++ b/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/repository/TestBucketRepository.java
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.registry.db.repository;
+
+import org.apache.nifi.registry.db.entity.BucketEntity;
+import org.apache.nifi.registry.db.entity.BucketItemEntity;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+import java.util.UUID;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+public class TestBucketRepository extends RepositoryBaseTest {
+
+    @Autowired
+    private BucketRepository bucketRepository;
+
+    @Test
+    public void testCreate() {
+        final BucketEntity bucket = new BucketEntity();
+        bucket.setId(UUID.randomUUID().toString());
+        bucket.setName("Some new bucket");
+        bucket.setDescription("This is some new bucket");
+        bucket.setCreated(new Date());
+
+        final BucketEntity createdBucket = bucketRepository.save(bucket);
+        assertNotNull(createdBucket);
+        assertEquals(bucket.getId(), createdBucket.getId());
+        assertEquals(bucket.getName(), createdBucket.getName());
+        assertEquals(bucket.getDescription(), createdBucket.getDescription());
+        assertEquals(bucket.getCreated(), createdBucket.getCreated());
+    }
+
+    @Test
+    public void testUpdate() {
+        final String id = "1";
+
+        final BucketEntity existingBucket = bucketRepository.findOne(id);
+        assertNotNull(existingBucket);
+
+        final String updatedDescription = existingBucket.getDescription() + " UPDATED";
+        existingBucket.setDescription(updatedDescription);
+
+        bucketRepository.save(existingBucket);
+
+        final BucketEntity updatedBucket = bucketRepository.findOne(id);
+        assertNotNull(updatedBucket);
+        assertEquals(updatedDescription, updatedBucket.getDescription());
+
+        // create date should not have changed
+        assertEquals(existingBucket.getCreated(), updatedBucket.getCreated());
+    }
+
+    @Test
+    public void testDelete() {
+        final String id = "6";
+
+        final BucketEntity existingBucket = bucketRepository.findOne(id);
+        assertNotNull(existingBucket);
+
+        bucketRepository.delete(existingBucket);
+
+        final BucketEntity updatedBucket = bucketRepository.findOne(id);
+        assertNull(updatedBucket);
+    }
+
+    @Test
+    public void testOneToManyWithBucketItems() {
+        final String id = "1";
+
+        final BucketEntity existingBucket = bucketRepository.findOne(id);
+        assertNotNull(existingBucket);
+
+        final Set<BucketItemEntity> items = existingBucket.getItems();
+        assertNotNull(items);
+        assertEquals(2, items.size());
+    }
+
+    @Test
+    public void testFindByNameCaseInsensitive() {
+        final String bucketName = "bUcKEt 1";
+
+        final List<BucketEntity> buckets = bucketRepository.findByNameIgnoreCase(bucketName);
+        assertNotNull(buckets);
+        assertEquals(1, buckets.size());
+
+        final BucketEntity bucket = buckets.get(0);
+        assertEquals(bucketName.toLowerCase(), bucket.getName().toLowerCase());
+    }
+
+    @Test
+    public void testFindAllWithPaging() {
+        final Sort sort = new Sort(Sort.Direction.ASC, "id");
+
+        int pageIndex = 0;
+        int pageSize = 2;
+
+        // query for first page
+        Pageable pageable = new PageRequest(pageIndex, pageSize, sort);
+
+        Page<BucketEntity> page = bucketRepository.findAll(pageable);
+        assertNotNull(page);
+        assertEquals(6, page.getTotalElements());
+        assertEquals(3, page.getTotalPages());
+
+        Iterable<BucketEntity> buckets = page.getContent();
+        assertNotNull(buckets);
+
+        List<String> ids = getIds(buckets);
+        assertEquals(2, ids.size());
+        assertEquals("1", ids.get(0));
+        assertEquals("2", ids.get(1));
+
+        // query for second page
+        pageIndex++;
+        pageable = new PageRequest(pageIndex, pageSize, sort);
+        buckets = bucketRepository.findAll(pageable);
+        assertNotNull(buckets);
+
+        ids = getIds(buckets);
+        assertEquals(2, ids.size());
+        assertEquals("3", ids.get(0));
+        assertEquals("4", ids.get(1));
+
+        // query for third page
+        pageIndex++;
+        pageable = new PageRequest(pageIndex, pageSize, sort);
+        buckets = bucketRepository.findAll(pageable);
+        assertNotNull(buckets);
+
+        ids = getIds(buckets);
+        assertEquals(2, ids.size());
+        assertEquals("5", ids.get(0));
+        assertEquals("6", ids.get(1));
+
+        // query for fourth page
+        pageIndex++;
+        pageable = new PageRequest(pageIndex, pageSize, sort);
+        buckets = bucketRepository.findAll(pageable);
+        assertNotNull(buckets);
+
+        ids = getIds(buckets);
+        assertEquals(0, ids.size());
+    }
+
+    private List<String> getIds(final Iterable<BucketEntity> buckets) {
+        List<String> ids = new ArrayList<>();
+        buckets.forEach(b -> ids.add(b.getId()));
+        return ids;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d478c20e/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/repository/TestFlowRepository.java
----------------------------------------------------------------------
diff --git a/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/repository/TestFlowRepository.java b/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/repository/TestFlowRepository.java
new file mode 100644
index 0000000..b176f1e
--- /dev/null
+++ b/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/repository/TestFlowRepository.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.registry.db.repository;
+
+import org.apache.nifi.registry.db.entity.BucketEntity;
+import org.apache.nifi.registry.db.entity.BucketItemEntityType;
+import org.apache.nifi.registry.db.entity.FlowEntity;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+public class TestFlowRepository extends RepositoryBaseTest {
+
+    @Autowired
+    private BucketRepository bucketRepository;
+
+    @Autowired
+    private FlowRepository flowRepository;
+
+
+    @Test
+    public void testCreateFlow() {
+        final String bucketId = "1";
+
+        final BucketEntity existingBucket = bucketRepository.findOne(bucketId);
+        assertNotNull(existingBucket);
+        assertNotNull(existingBucket.getItems());
+        assertEquals(2, existingBucket.getItems().size());
+
+        // created, and modified should get set automatically
+        final FlowEntity flow = new FlowEntity();
+        flow.setId(UUID.randomUUID().toString());
+        flow.setName("Flow 4");
+        flow.setDescription("This is flow 4");
+        flow.setBucket(existingBucket);
+        flow.setCreated(new Date());
+        flow.setModified(new Date());
+
+        final FlowEntity createdFlow = flowRepository.save(flow);
+        assertEquals(flow.getId(), createdFlow.getId());
+        assertEquals(flow.getName(), createdFlow.getName());
+        assertEquals(flow.getDescription(), createdFlow.getDescription());
+        assertEquals(flow.getCreated(), createdFlow.getCreated());
+        assertEquals(flow.getModified(), createdFlow.getModified());
+        assertEquals(BucketItemEntityType.FLOW, flow.getType());
+    }
+
+    @Test
+    public void testUpdateFlow() {
+        final String flowId = "1";
+
+        final FlowEntity flow = flowRepository.findOne(flowId);
+        assertNotNull(flow);
+        assertEquals(flowId, flow.getId());
+
+        flow.setName(flow.getName() + " UPDATED");
+        flow.setDescription(flow.getDescription() + " UPDATED");
+
+        flowRepository.save(flow);
+
+        final FlowEntity updatedFlow = flowRepository.findOne(flowId);
+        assertEquals(flow.getName(), updatedFlow.getName());
+        assertEquals(flow.getDescription(), updatedFlow.getDescription());
+        assertEquals(flow.getCreated(), updatedFlow.getCreated());
+        assertEquals(flow.getModified(), updatedFlow.getModified());
+        assertEquals(BucketItemEntityType.FLOW, updatedFlow.getType());
+    }
+
+    @Test
+    public void testDeleteFlow() {
+        final String flowId = "1";
+
+        final FlowEntity flow = flowRepository.findOne(flowId);
+        assertNotNull(flow);
+
+        flowRepository.delete(flow);
+
+        final FlowEntity deletedFlow = flowRepository.findOne(flowId);
+        assertNull(deletedFlow);
+    }
+
+    @Test
+    public void testOneToManyWithFlowSnapshots() {
+        final String flowId = "1";
+
+        final FlowEntity flow = flowRepository.findOne(flowId);
+        assertNotNull(flow);
+        assertNotNull(flow.getSnapshots());
+        assertEquals(3, flow.getSnapshots().size());
+    }
+
+    @Test
+    public void testFindFlowByNameCaseInsensitive() {
+        final String flowName = "fLoW 1";
+
+        final List<FlowEntity> flows = flowRepository.findByNameIgnoreCase(flowName);
+        assertNotNull(flows);
+        assertEquals(1, flows.size());
+
+        final FlowEntity flow = flows.get(0);
+        assertEquals(flowName.toLowerCase(), flow.getName().toLowerCase());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d478c20e/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/repository/TestFlowSnapshotRepository.java
----------------------------------------------------------------------
diff --git a/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/repository/TestFlowSnapshotRepository.java b/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/repository/TestFlowSnapshotRepository.java
new file mode 100644
index 0000000..2b30272
--- /dev/null
+++ b/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/repository/TestFlowSnapshotRepository.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.registry.db.repository;
+
+import org.apache.nifi.registry.db.entity.BucketEntity;
+import org.apache.nifi.registry.db.entity.FlowEntity;
+import org.apache.nifi.registry.db.entity.FlowSnapshotEntity;
+import org.apache.nifi.registry.db.entity.FlowSnapshotEntityKey;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Date;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+public class TestFlowSnapshotRepository extends RepositoryBaseTest {
+
+    @Autowired
+    private BucketRepository bucketRepository;
+
+    @Autowired
+    private FlowRepository flowRepository;
+
+    @Autowired
+    private FlowSnapshotRepository flowSnapshotRepository;
+
+
+    @Test
+    public void testCreateFlowSnapshot() {
+        final FlowSnapshotEntityKey key = new FlowSnapshotEntityKey();
+        key.setFlowId("2");
+        key.setVersion(1);
+
+        final FlowSnapshotEntity flowSnapshot = new FlowSnapshotEntity();
+        flowSnapshot.setId(key);
+        flowSnapshot.setComments("This is snapshot 1 for flow 2");
+        flowSnapshot.setCreated(new Date());
+
+        flowSnapshotRepository.save(flowSnapshot);
+
+        final FlowSnapshotEntity createdFlowSnapshot = flowSnapshotRepository.findOne(key);
+        assertNotNull(createdFlowSnapshot);
+    }
+
+    @Test
+    public void testFindById() {
+        final FlowSnapshotEntityKey key = new FlowSnapshotEntityKey();
+        key.setFlowId("1");
+        key.setVersion(1);
+
+        final FlowSnapshotEntity flowSnapshot = flowSnapshotRepository.findOne(key);
+        assertNotNull(flowSnapshot);
+        assertEquals(key, flowSnapshot.getId());
+        assertNotNull(flowSnapshot.getFlow());
+    }
+
+    @Test
+    public void testDeleteFlowSnapshot() {
+        final FlowSnapshotEntityKey key = new FlowSnapshotEntityKey();
+        key.setFlowId("1");
+        key.setVersion(1);
+
+        final FlowSnapshotEntity flowSnapshot = flowSnapshotRepository.findOne(key);
+        assertNotNull(flowSnapshot);
+
+        flowSnapshotRepository.delete(flowSnapshot);
+
+        final FlowSnapshotEntity deletedFlowSnapshot = flowSnapshotRepository.findOne(key);
+        assertNull(deletedFlowSnapshot);
+    }
+
+    @Test
+    public void testDeleteBucketCascadesToSnapshots() {
+        final FlowSnapshotEntityKey key = new FlowSnapshotEntityKey();
+        key.setFlowId("1");
+        key.setVersion(1);
+
+        final FlowSnapshotEntity flowSnapshot = flowSnapshotRepository.findOne(key);
+        assertNotNull(flowSnapshot);
+
+        final FlowEntity flow = flowSnapshot.getFlow();
+        assertNotNull(flow);
+
+        final BucketEntity bucket = flow.getBucket();
+        assertNotNull(bucket);
+
+        bucketRepository.delete(bucket);
+
+        assertNull(flowRepository.findOne(flow.getId()));
+        assertNull(flowSnapshotRepository.findOne(key));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d478c20e/nifi-registry-framework/src/test/java/org/apache/nifi/registry/flow/TestStandardFlowSnapshotContext.java
----------------------------------------------------------------------
diff --git a/nifi-registry-framework/src/test/java/org/apache/nifi/registry/flow/TestStandardFlowSnapshotContext.java b/nifi-registry-framework/src/test/java/org/apache/nifi/registry/flow/TestStandardFlowSnapshotContext.java
deleted file mode 100644
index e0c7f16..0000000
--- a/nifi-registry-framework/src/test/java/org/apache/nifi/registry/flow/TestStandardFlowSnapshotContext.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.nifi.registry.flow;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class TestStandardFlowSnapshotContext {
-
-    @Test
-    public void testBuilder() {
-        final String bucketId = "1234-1234-1234-1234";
-        final String bucketName = "Some Bucket";
-        final String flowId = "2345-2345-2345-2345";
-        final String flowName = "Some Flow";
-        final int version = 2;
-        final String comments = "Some Comments";
-        final long timestamp = System.currentTimeMillis();
-
-        final FlowSnapshotContext context = new StandardFlowSnapshotContext.Builder()
-                .bucketId(bucketId)
-                .bucketName(bucketName)
-                .flowId(flowId)
-                .flowName(flowName)
-                .version(version)
-                .comments(comments)
-                .snapshotTimestamp(timestamp)
-                .build();
-
-        Assert.assertEquals(bucketId, context.getBucketId());
-        Assert.assertEquals(bucketName, context.getBucketName());
-        Assert.assertEquals(flowId, context.getFlowId());
-        Assert.assertEquals(flowName, context.getFlowName());
-        Assert.assertEquals(version, context.getVersion());
-        Assert.assertEquals(comments, context.getComments());
-        Assert.assertEquals(timestamp, context.getSnapshotTimestamp());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d478c20e/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/MockMetadataProvider.java
----------------------------------------------------------------------
diff --git a/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/MockMetadataProvider.java b/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/MockMetadataProvider.java
deleted file mode 100644
index 176a9a5..0000000
--- a/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/MockMetadataProvider.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.nifi.registry.provider;
-
-import org.apache.nifi.registry.metadata.BucketMetadata;
-import org.apache.nifi.registry.metadata.FlowMetadata;
-import org.apache.nifi.registry.metadata.FlowSnapshotMetadata;
-import org.apache.nifi.registry.metadata.MetadataProvider;
-
-import java.util.Map;
-import java.util.Set;
-
-public class MockMetadataProvider implements MetadataProvider {
-
-    private Map<String,String> properties;
-
-    @Override
-    public void onConfigured(ProviderConfigurationContext configurationContext) throws ProviderCreationException {
-        this.properties = configurationContext.getProperties();
-    }
-
-    public Map<String,String> getProperties() {
-        return properties;
-    }
-
-    @Override
-    public BucketMetadata createBucket(BucketMetadata bucket) {
-        return null;
-    }
-
-    @Override
-    public BucketMetadata getBucketById(String bucketIdentifier) {
-        return null;
-    }
-
-    @Override
-    public BucketMetadata getBucketByName(String name) {
-        return null;
-    }
-
-    @Override
-    public BucketMetadata updateBucket(BucketMetadata bucket) {
-        return null;
-    }
-
-    @Override
-    public void deleteBucket(String bucketIdentifier) {
-
-    }
-
-    @Override
-    public Set<BucketMetadata> getBuckets() {
-        return null;
-    }
-
-    @Override
-    public FlowMetadata createFlow(String bucketIdentifier, FlowMetadata flow) {
-        return null;
-    }
-
-    @Override
-    public FlowMetadata getFlowById(String flowIdentifier) {
-        return null;
-    }
-
-    @Override
-    public FlowMetadata getFlowByName(String name) {
-        return null;
-    }
-
-    @Override
-    public FlowMetadata updateFlow(FlowMetadata versionedFlow) {
-        return null;
-    }
-
-    @Override
-    public void deleteFlow(String flowIdentifier) {
-
-    }
-
-    @Override
-    public Set<FlowMetadata> getFlows() {
-        return null;
-    }
-
-    @Override
-    public Set<FlowMetadata> getFlows(String bucketId) {
-        return null;
-    }
-
-    @Override
-    public FlowSnapshotMetadata createFlowSnapshot(FlowSnapshotMetadata flowSnapshot) {
-        return null;
-    }
-
-    @Override
-    public FlowSnapshotMetadata getFlowSnapshot(String flowIdentifier, Integer version) {
-        return null;
-    }
-
-    @Override
-    public void deleteFlowSnapshot(String flowIdentifier, Integer version) {
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d478c20e/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/TestStandardProviderFactory.java
----------------------------------------------------------------------
diff --git a/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/TestStandardProviderFactory.java b/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/TestStandardProviderFactory.java
index 2bec5ba..f5ad445 100644
--- a/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/TestStandardProviderFactory.java
+++ b/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/TestStandardProviderFactory.java
@@ -17,13 +17,11 @@
 package org.apache.nifi.registry.provider;
 
 import org.apache.nifi.registry.flow.FlowPersistenceProvider;
-import org.apache.nifi.registry.metadata.MetadataProvider;
 import org.apache.nifi.registry.properties.NiFiRegistryProperties;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
 
 public class TestStandardProviderFactory {
 
@@ -35,15 +33,6 @@ public class TestStandardProviderFactory {
         final ProviderFactory providerFactory = new StandardProviderFactory(props);
         providerFactory.initialize();
 
-        final MetadataProvider metadataProvider = providerFactory.getMetadataProvider();
-        assertNotNull(metadataProvider);
-        assertTrue(metadataProvider instanceof MockMetadataProvider);
-
-        final MockMetadataProvider mockMetadataProvider = (MockMetadataProvider) metadataProvider;
-        assertNotNull(mockMetadataProvider.getProperties());
-        assertEquals("metadata foo", mockMetadataProvider.getProperties().get("Metadata Property 1"));
-        assertEquals("metadata bar", mockMetadataProvider.getProperties().get("Metadata Property 2"));
-
         final FlowPersistenceProvider flowPersistenceProvider = providerFactory.getFlowPersistenceProvider();
         assertNotNull(flowPersistenceProvider);
 
@@ -54,15 +43,6 @@ public class TestStandardProviderFactory {
     }
 
     @Test(expected = ProviderFactoryException.class)
-    public void testGetMetadataProviderBeforeInitializingShouldThrowException() {
-        final NiFiRegistryProperties props = new NiFiRegistryProperties();
-        props.setProperty(NiFiRegistryProperties.PROVIDERS_CONFIGURATION_FILE, "src/test/resources/provider/providers-good.xml");
-
-        final ProviderFactory providerFactory = new StandardProviderFactory(props);
-        providerFactory.getMetadataProvider();
-    }
-
-    @Test(expected = ProviderFactoryException.class)
     public void testGetFlowProviderBeforeInitializingShouldThrowException() {
         final NiFiRegistryProperties props = new NiFiRegistryProperties();
         props.setProperty(NiFiRegistryProperties.PROVIDERS_CONFIGURATION_FILE, "src/test/resources/provider/providers-good.xml");
@@ -81,17 +61,6 @@ public class TestStandardProviderFactory {
     }
 
     @Test(expected = ProviderFactoryException.class)
-    public void testMetadataProviderClassNotFound() {
-        final NiFiRegistryProperties props = new NiFiRegistryProperties();
-        props.setProperty(NiFiRegistryProperties.PROVIDERS_CONFIGURATION_FILE, "src/test/resources/provider/providers-class-not-found.xml");
-
-        final ProviderFactory providerFactory = new StandardProviderFactory(props);
-        providerFactory.initialize();
-
-        providerFactory.getMetadataProvider();
-    }
-
-    @Test(expected = ProviderFactoryException.class)
     public void testFlowProviderClassNotFound() {
         final NiFiRegistryProperties props = new NiFiRegistryProperties();
         props.setProperty(NiFiRegistryProperties.PROVIDERS_CONFIGURATION_FILE, "src/test/resources/provider/providers-class-not-found.xml");

http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d478c20e/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestFileSystemFlowPersistenceProvider.java
----------------------------------------------------------------------
diff --git a/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestFileSystemFlowPersistenceProvider.java b/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestFileSystemFlowPersistenceProvider.java
new file mode 100644
index 0000000..e51aa7f
--- /dev/null
+++ b/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestFileSystemFlowPersistenceProvider.java
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.registry.provider.flow;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.nifi.registry.flow.FlowPersistenceProvider;
+import org.apache.nifi.registry.flow.FlowSnapshotContext;
+import org.apache.nifi.registry.provider.ProviderConfigurationContext;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.mockito.Mockito.when;
+
+public class TestFileSystemFlowPersistenceProvider {
+
+    static final String FLOW_STORAGE_DIR = "target/flow_storage";
+
+    static final ProviderConfigurationContext CONFIGURATION_CONTEXT = new ProviderConfigurationContext() {
+        @Override
+        public Map<String, String> getProperties() {
+            final Map<String,String> props = new HashMap<>();
+            props.put(FileSystemFlowPersistenceProvider.FLOW_STORAGE_DIR_PROP, FLOW_STORAGE_DIR);
+            return props;
+        }
+    };
+
+    private File flowStorageDir;
+    private FileSystemFlowPersistenceProvider fileSystemFlowProvider;
+
+    @Before
+    public void setup() throws IOException {
+        flowStorageDir = new File(FLOW_STORAGE_DIR);
+        if (flowStorageDir.exists()) {
+            org.apache.commons.io.FileUtils.cleanDirectory(flowStorageDir);
+            flowStorageDir.delete();
+        }
+
+        Assert.assertFalse(flowStorageDir.exists());
+
+        fileSystemFlowProvider = new FileSystemFlowPersistenceProvider();
+        fileSystemFlowProvider.onConfigured(CONFIGURATION_CONTEXT);
+        Assert.assertTrue(flowStorageDir.exists());
+    }
+
+    @Test
+    public void testSaveSuccessfully() throws IOException {
+        createAndSaveSnapshot(fileSystemFlowProvider,"bucket1", "flow1", 1, "flow1v1");
+        verifySnapshot(flowStorageDir, "bucket1", "flow1", 1, "flow1v1");
+
+        createAndSaveSnapshot(fileSystemFlowProvider,"bucket1", "flow1", 2, "flow1v2");
+        verifySnapshot(flowStorageDir, "bucket1", "flow1", 2, "flow1v2");
+
+        createAndSaveSnapshot(fileSystemFlowProvider,"bucket1", "flow2", 1, "flow2v1");
+        verifySnapshot(flowStorageDir, "bucket1", "flow2", 1, "flow2v1");
+
+        createAndSaveSnapshot(fileSystemFlowProvider,"bucket2", "flow3", 1, "flow3v1");
+        verifySnapshot(flowStorageDir, "bucket2", "flow3", 1, "flow3v1");
+    }
+
+    @Test
+    public void testSaveWithExistingVersion() throws IOException {
+        final FlowSnapshotContext context = Mockito.mock(FlowSnapshotContext.class);
+        when(context.getBucketId()).thenReturn("bucket1");
+        when(context.getFlowId()).thenReturn("flow1");
+        when(context.getVersion()).thenReturn(1);
+
+        final byte[] content = "flow1v1".getBytes(StandardCharsets.UTF_8);
+        fileSystemFlowProvider.saveSnapshot(context, content);
+
+        // save new content for an existing version
+        final byte[] content2 = "XXX".getBytes(StandardCharsets.UTF_8);
+        try {
+            fileSystemFlowProvider.saveSnapshot(context, content2);
+            Assert.fail("Should have thrown exception");
+        } catch (Exception e) {
+
+        }
+
+        // verify the new content wasn't written
+        final File flowSnapshotFile = new File(flowStorageDir, "bucket1/flow1/1/1" + FileSystemFlowPersistenceProvider.SNAPSHOT_EXTENSION);
+        try (InputStream in = new FileInputStream(flowSnapshotFile)) {
+            Assert.assertEquals("flow1v1", IOUtils.toString(in, StandardCharsets.UTF_8));
+        }
+    }
+
+    @Test
+    public void testSaveAndGet() throws IOException {
+        createAndSaveSnapshot(fileSystemFlowProvider,"bucket1", "flow1", 1, "flow1v1");
+        createAndSaveSnapshot(fileSystemFlowProvider,"bucket1", "flow1", 2, "flow1v2");
+
+        final byte[] flow1v1 = fileSystemFlowProvider.getSnapshot("bucket1", "flow1", 1);
+        Assert.assertEquals("flow1v1", new String(flow1v1, StandardCharsets.UTF_8));
+
+        final byte[] flow1v2 = fileSystemFlowProvider.getSnapshot("bucket1", "flow1", 2);
+        Assert.assertEquals("flow1v2", new String(flow1v2, StandardCharsets.UTF_8));
+    }
+
+    @Test
+    public void testGetWhenDoesNotExist() {
+        final byte[] flow1v1 = fileSystemFlowProvider.getSnapshot("bucket1", "flow1", 1);
+        Assert.assertNull(flow1v1);
+    }
+
+    @Test
+    public void testDeleteSnapshots() throws IOException {
+        final String bucketId = "bucket1";
+        final String flowId = "flow1";
+
+        createAndSaveSnapshot(fileSystemFlowProvider, bucketId, flowId, 1, "flow1v1");
+        createAndSaveSnapshot(fileSystemFlowProvider, bucketId, flowId, 2, "flow1v2");
+
+        Assert.assertNotNull(fileSystemFlowProvider.getSnapshot(bucketId, flowId, 1));
+        Assert.assertNotNull(fileSystemFlowProvider.getSnapshot(bucketId, flowId, 2));
+
+        fileSystemFlowProvider.deleteSnapshots(bucketId, flowId);
+
+        Assert.assertNull(fileSystemFlowProvider.getSnapshot(bucketId, flowId, 1));
+        Assert.assertNull(fileSystemFlowProvider.getSnapshot(bucketId, flowId, 2));
+
+        // delete a flow that doesn't exist
+        fileSystemFlowProvider.deleteSnapshots(bucketId, "some-other-flow");
+
+        // delete a bucket that doesn't exist
+        fileSystemFlowProvider.deleteSnapshots("some-other-bucket", flowId);
+    }
+
+    @Test
+    public void testDeleteSnapshot() throws IOException {
+        final String bucketId = "bucket1";
+        final String flowId = "flow1";
+
+        createAndSaveSnapshot(fileSystemFlowProvider, bucketId, flowId, 1, "flow1v1");
+        createAndSaveSnapshot(fileSystemFlowProvider, bucketId, flowId, 2, "flow1v2");
+
+        Assert.assertNotNull(fileSystemFlowProvider.getSnapshot(bucketId, flowId, 1));
+        Assert.assertNotNull(fileSystemFlowProvider.getSnapshot(bucketId, flowId, 2));
+
+        fileSystemFlowProvider.deleteSnapshot(bucketId, flowId, 1);
+
+        Assert.assertNull(fileSystemFlowProvider.getSnapshot(bucketId, flowId, 1));
+        Assert.assertNotNull(fileSystemFlowProvider.getSnapshot(bucketId, flowId, 2));
+
+        fileSystemFlowProvider.deleteSnapshot(bucketId, flowId, 2);
+
+        Assert.assertNull(fileSystemFlowProvider.getSnapshot(bucketId, flowId, 1));
+        Assert.assertNull(fileSystemFlowProvider.getSnapshot(bucketId, flowId, 2));
+
+        // delete a version that doesn't exist
+        fileSystemFlowProvider.deleteSnapshot(bucketId, flowId, 3);
+
+        // delete a flow that doesn't exist
+        fileSystemFlowProvider.deleteSnapshot(bucketId, "some-other-flow", 1);
+
+        // delete a bucket that doesn't exist
+        fileSystemFlowProvider.deleteSnapshot("some-other-bucket", flowId, 1);
+    }
+
+    private void createAndSaveSnapshot(final FlowPersistenceProvider flowPersistenceProvider, final String bucketId, final String flowId, final int version,
+                                       final String contentString) throws IOException {
+        final FlowSnapshotContext context = Mockito.mock(FlowSnapshotContext.class);
+        when(context.getBucketId()).thenReturn(bucketId);
+        when(context.getFlowId()).thenReturn(flowId);
+        when(context.getVersion()).thenReturn(version);
+
+        final byte[] content = contentString.getBytes(StandardCharsets.UTF_8);
+        flowPersistenceProvider.saveSnapshot(context, content);
+    }
+
+    private void verifySnapshot(final File flowStorageDir, final String bucketId, final String flowId, final int version,
+                                final String contentString) throws IOException {
+        // verify the correct snapshot file was created
+        final File flowSnapshotFile = new File(flowStorageDir,
+                bucketId + "/" + flowId + "/" + version + "/" + version + FileSystemFlowPersistenceProvider.SNAPSHOT_EXTENSION);
+        Assert.assertTrue(flowSnapshotFile.exists());
+
+        try (InputStream in = new FileInputStream(flowSnapshotFile)) {
+            Assert.assertEquals(contentString, IOUtils.toString(in, StandardCharsets.UTF_8));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d478c20e/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestStandardFlowSnapshotContext.java
----------------------------------------------------------------------
diff --git a/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestStandardFlowSnapshotContext.java b/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestStandardFlowSnapshotContext.java
new file mode 100644
index 0000000..3e0a106
--- /dev/null
+++ b/nifi-registry-framework/src/test/java/org/apache/nifi/registry/provider/flow/TestStandardFlowSnapshotContext.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.registry.provider.flow;
+
+import org.apache.nifi.registry.flow.FlowSnapshotContext;
+import org.apache.nifi.registry.provider.flow.StandardFlowSnapshotContext;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestStandardFlowSnapshotContext {
+
+    @Test
+    public void testBuilder() {
+        final String bucketId = "1234-1234-1234-1234";
+        final String bucketName = "Some Bucket";
+        final String flowId = "2345-2345-2345-2345";
+        final String flowName = "Some Flow";
+        final int version = 2;
+        final String comments = "Some Comments";
+        final long timestamp = System.currentTimeMillis();
+
+        final FlowSnapshotContext context = new StandardFlowSnapshotContext.Builder()
+                .bucketId(bucketId)
+                .bucketName(bucketName)
+                .flowId(flowId)
+                .flowName(flowName)
+                .version(version)
+                .comments(comments)
+                .snapshotTimestamp(timestamp)
+                .build();
+
+        Assert.assertEquals(bucketId, context.getBucketId());
+        Assert.assertEquals(bucketName, context.getBucketName());
+        Assert.assertEquals(flowId, context.getFlowId());
+        Assert.assertEquals(flowName, context.getFlowName());
+        Assert.assertEquals(version, context.getVersion());
+        Assert.assertEquals(comments, context.getComments());
+        Assert.assertEquals(timestamp, context.getSnapshotTimestamp());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/d478c20e/nifi-registry-framework/src/test/java/org/apache/nifi/registry/service/TestDataModelMapper.java
----------------------------------------------------------------------
diff --git a/nifi-registry-framework/src/test/java/org/apache/nifi/registry/service/TestDataModelMapper.java b/nifi-registry-framework/src/test/java/org/apache/nifi/registry/service/TestDataModelMapper.java
deleted file mode 100644
index 1a6f3c9..0000000
--- a/nifi-registry-framework/src/test/java/org/apache/nifi/registry/service/TestDataModelMapper.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.nifi.registry.service;
-
-import org.apache.nifi.registry.bucket.Bucket;
-import org.apache.nifi.registry.flow.VersionedFlow;
-import org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata;
-import org.apache.nifi.registry.metadata.BucketMetadata;
-import org.apache.nifi.registry.metadata.FlowMetadata;
-import org.apache.nifi.registry.metadata.FlowSnapshotMetadata;
-import org.apache.nifi.registry.metadata.StandardBucketMetadata;
-import org.apache.nifi.registry.metadata.StandardFlowMetadata;
-import org.apache.nifi.registry.metadata.StandardFlowSnapshotMetadata;
-import org.junit.Test;
-
-import java.util.LinkedHashSet;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-public class TestDataModelMapper {
-
-    @Test
-    public void testMapBucketToBucketMetadata() {
-        // create a bucket
-        final Bucket bucket = new Bucket();
-        bucket.setIdentifier("bucket1");
-        bucket.setName("Bucket 1");
-        bucket.setDescription("This is bucket 1.");
-        bucket.setCreatedTimestamp(System.currentTimeMillis());
-
-        // create a flow
-        final VersionedFlow versionedFlow = new VersionedFlow();
-        versionedFlow.setIdentifier("flow1");
-        versionedFlow.setName("Flow 1");
-        versionedFlow.setDescription("This is flow 1");
-        versionedFlow.setBucketIdentifier(bucket.getIdentifier());
-        versionedFlow.setCreatedTimestamp(System.currentTimeMillis());
-        versionedFlow.setModifiedTimestamp(System.currentTimeMillis());
-
-        // create a snapshot for the flow
-        final VersionedFlowSnapshotMetadata versionedFlowSnapshotMetadata = new VersionedFlowSnapshotMetadata();
-        versionedFlowSnapshotMetadata.setBucketIdentifier(bucket.getIdentifier());
-        versionedFlowSnapshotMetadata.setFlowIdentifier(versionedFlow.getIdentifier());
-        versionedFlowSnapshotMetadata.setFlowName(versionedFlow.getName());
-        versionedFlowSnapshotMetadata.setVersion(1);
-        versionedFlowSnapshotMetadata.setTimestamp(System.currentTimeMillis());
-        versionedFlowSnapshotMetadata.setComments("This is snapshot 1 of flow 1");
-
-        // add the snapshot to the flow
-        final SortedSet<VersionedFlowSnapshotMetadata> versionedFlowSnapshotMetadataSet = new TreeSet<>();
-        versionedFlowSnapshotMetadataSet.add(versionedFlowSnapshotMetadata);
-        versionedFlow.setSnapshotMetadata(versionedFlowSnapshotMetadataSet);
-
-        // add the flow to the bucket
-        final Set<VersionedFlow> versionedFlows = new LinkedHashSet<>();
-        versionedFlows.add(versionedFlow);
-        bucket.setVersionedFlows(versionedFlows);
-
-        // test the mapping from bucket to bucket metadata
-
-        final BucketMetadata bucketMetadata = DataModelMapper.map(bucket);
-        assertEquals(bucket.getIdentifier(), bucketMetadata.getIdentifier());
-        assertEquals(bucket.getName(), bucketMetadata.getName());
-        assertEquals(bucket.getDescription(), bucketMetadata.getDescription());
-        assertEquals(bucket.getCreatedTimestamp(), bucketMetadata.getCreatedTimestamp());
-
-        assertNotNull(bucketMetadata.getFlowMetadata());
-        assertEquals(1, bucketMetadata.getFlowMetadata().size());
-
-        final FlowMetadata flowMetadata = bucketMetadata.getFlowMetadata().iterator().next();
-        assertNotNull(flowMetadata);
-        assertEquals(versionedFlow.getIdentifier(), flowMetadata.getIdentifier());
-        assertEquals(versionedFlow.getName(), flowMetadata.getName());
-        assertEquals(versionedFlow.getDescription(), flowMetadata.getDescription());
-        assertEquals(versionedFlow.getBucketIdentifier(), flowMetadata.getBucketIdentifier());
-        assertEquals(versionedFlow.getCreatedTimestamp(), flowMetadata.getCreatedTimestamp());
-        assertEquals(versionedFlow.getModifiedTimestamp(), flowMetadata.getModifiedTimestamp());
-
-        assertNotNull(flowMetadata.getSnapshotMetadata());
-        assertEquals(1, flowMetadata.getSnapshotMetadata().size());
-
-        final FlowSnapshotMetadata flowSnapshotMetadata = flowMetadata.getSnapshotMetadata().iterator().next();
-        assertNotNull(flowSnapshotMetadata);
-        assertEquals(versionedFlowSnapshotMetadata.getFlowIdentifier(), flowSnapshotMetadata.getFlowIdentifier());
-        assertEquals(versionedFlowSnapshotMetadata.getFlowName(), flowSnapshotMetadata.getFlowName());
-        assertEquals(versionedFlowSnapshotMetadata.getBucketIdentifier(), flowSnapshotMetadata.getBucketIdentifier());
-        assertEquals(versionedFlowSnapshotMetadata.getVersion(), flowSnapshotMetadata.getVersion());
-        assertEquals(versionedFlowSnapshotMetadata.getComments(), flowSnapshotMetadata.getComments());
-        assertEquals(versionedFlowSnapshotMetadata.getTimestamp(), flowSnapshotMetadata.getCreatedTimestamp());
-    }
-
-    @Test
-    public void testMapBucketMetadataToBucket() {
-        // create snapshot metadata
-        final FlowSnapshotMetadata snapshotMetadata = new StandardFlowSnapshotMetadata.Builder()
-                .flowIdentifier("flow1")
-                .flowName("Flow 1")
-                .bucketIdentifier("bucket1")
-                .version(1)
-                .comments("This is snapshot 1 of flow 1.")
-                .created(System.currentTimeMillis())
-                .build();
-
-        // create flow metadata
-        final FlowMetadata flowMetadata = new StandardFlowMetadata.Builder()
-                .identifier("flow1")
-                .name("Flow 1")
-                .bucketIdentifier("bucket1")
-                .description("This flow 1.")
-                .created(System.currentTimeMillis())
-                .modified(System.currentTimeMillis())
-                .addSnapshot(snapshotMetadata)
-                .build();
-
-        // create bucket metadata
-        final BucketMetadata bucketMetadata = new StandardBucketMetadata.Builder()
-                .identifier("bucket1")
-                .name("Bucket 1")
-                .description("This is bucket 1.")
-                .created(System.currentTimeMillis())
-                .addFlow(flowMetadata)
-                .build();
-
-        // test the mapping from bucket metadata to bucket
-
-        final Bucket bucket = DataModelMapper.map(bucketMetadata);
-        assertEquals(bucketMetadata.getIdentifier(), bucket.getIdentifier());
-        assertEquals(bucketMetadata.getName(), bucket.getName());
-        assertEquals(bucketMetadata.getDescription(), bucket.getDescription());
-        assertEquals(bucketMetadata.getCreatedTimestamp(), bucket.getCreatedTimestamp());
-
-        assertNotNull(bucket.getVersionedFlows());
-        assertEquals(1, bucket.getVersionedFlows().size());
-
-        final VersionedFlow versionedFlow = bucket.getVersionedFlows().iterator().next();
-        assertNotNull(versionedFlow);
-        assertEquals(flowMetadata.getIdentifier(), versionedFlow.getIdentifier());
-        assertEquals(flowMetadata.getName(), versionedFlow.getName());
-        assertEquals(flowMetadata.getBucketIdentifier(), versionedFlow.getBucketIdentifier());
-        assertEquals(flowMetadata.getDescription(), versionedFlow.getDescription());
-        assertEquals(flowMetadata.getCreatedTimestamp(), versionedFlow.getCreatedTimestamp());
-        assertEquals(flowMetadata.getModifiedTimestamp(), versionedFlow.getModifiedTimestamp());
-
-        assertNotNull(versionedFlow.getSnapshotMetadata());
-        assertEquals(1, versionedFlow.getSnapshotMetadata().size());
-
-        final VersionedFlowSnapshotMetadata versionedFlowSnapshotMetadata = versionedFlow.getSnapshotMetadata().first();
-        assertEquals(snapshotMetadata.getFlowIdentifier(), versionedFlowSnapshotMetadata.getFlowIdentifier());
-        assertEquals(snapshotMetadata.getFlowName(), versionedFlowSnapshotMetadata.getFlowName());
-        assertEquals(snapshotMetadata.getBucketIdentifier(), versionedFlowSnapshotMetadata.getBucketIdentifier());
-        assertEquals(snapshotMetadata.getVersion(), versionedFlowSnapshotMetadata.getVersion());
-        assertEquals(snapshotMetadata.getComments(), versionedFlowSnapshotMetadata.getComments());
-        assertEquals(snapshotMetadata.getCreatedTimestamp(), versionedFlowSnapshotMetadata.getTimestamp());
-    }
-
-}