Search in sources :

Example 21 with FlowSnapshotEntity

use of org.apache.nifi.registry.db.entity.FlowSnapshotEntity in project nifi-registry by apache.

the class TestRegistryService method testGetFlowSnapshotsWhenNoSnapshots.

@Test
public void testGetFlowSnapshotsWhenNoSnapshots() {
    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);
    // return a flow with the existing snapshot when getFlowById is called
    final FlowEntity existingFlow = new FlowEntity();
    existingFlow.setId("flow1");
    existingFlow.setName("My Flow");
    existingFlow.setDescription("This is my flow.");
    existingFlow.setCreated(new Date());
    existingFlow.setModified(new Date());
    existingFlow.setBucketId(existingBucket.getId());
    final Set<FlowSnapshotEntity> snapshots = new HashSet<>();
    when(metadataService.getFlowById(existingFlow.getId())).thenReturn(existingFlow);
    final SortedSet<VersionedFlowSnapshotMetadata> retrievedSnapshots = registryService.getFlowSnapshots(existingBucket.getId(), existingFlow.getId());
    assertNotNull(retrievedSnapshots);
    assertEquals(0, retrievedSnapshots.size());
}
Also used : BucketEntity(org.apache.nifi.registry.db.entity.BucketEntity) FlowSnapshotEntity(org.apache.nifi.registry.db.entity.FlowSnapshotEntity) Date(java.util.Date) FlowEntity(org.apache.nifi.registry.db.entity.FlowEntity) HashSet(java.util.HashSet) VersionedFlowSnapshotMetadata(org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata) Test(org.junit.Test)

Example 22 with FlowSnapshotEntity

use of org.apache.nifi.registry.db.entity.FlowSnapshotEntity in project nifi-registry by apache.

the class TestRegistryService method testCreateSnapshotVersionNotNextVersion.

@Test(expected = IllegalStateException.class)
public void testCreateSnapshotVersionNotNextVersion() {
    final VersionedFlowSnapshot snapshot = createSnapshot();
    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);
    // return a flow with the existing snapshot when getFlowById is called
    final FlowEntity existingFlow = new FlowEntity();
    existingFlow.setId("flow1");
    existingFlow.setName("My Flow");
    existingFlow.setDescription("This is my flow.");
    existingFlow.setCreated(new Date());
    existingFlow.setModified(new Date());
    existingFlow.setBucketId(existingBucket.getId());
    // make a snapshot that has the same version as the one being created
    final FlowSnapshotEntity existingSnapshot = new FlowSnapshotEntity();
    existingSnapshot.setFlowId(snapshot.getSnapshotMetadata().getFlowIdentifier());
    existingSnapshot.setVersion(snapshot.getSnapshotMetadata().getVersion());
    existingSnapshot.setComments("This is an existing snapshot");
    existingSnapshot.setCreated(new Date());
    existingSnapshot.setCreatedBy("test-user");
    when(metadataService.getFlowById(existingFlow.getId())).thenReturn(existingFlow);
    // set the version to something that is not the next one-up version
    snapshot.getSnapshotMetadata().setVersion(100);
    registryService.createFlowSnapshot(snapshot);
}
Also used : BucketEntity(org.apache.nifi.registry.db.entity.BucketEntity) FlowSnapshotEntity(org.apache.nifi.registry.db.entity.FlowSnapshotEntity) VersionedFlowSnapshot(org.apache.nifi.registry.flow.VersionedFlowSnapshot) Date(java.util.Date) FlowEntity(org.apache.nifi.registry.db.entity.FlowEntity) Test(org.junit.Test)

Example 23 with FlowSnapshotEntity

use of org.apache.nifi.registry.db.entity.FlowSnapshotEntity in project nifi-registry by apache.

the class TestRegistryService method createFlowSnapshotEntity.

private FlowSnapshotEntity createFlowSnapshotEntity(final String flowId) {
    final FlowSnapshotEntity existingSnapshot = new FlowSnapshotEntity();
    existingSnapshot.setVersion(1);
    existingSnapshot.setFlowId(flowId);
    existingSnapshot.setComments("This is an existing snapshot");
    existingSnapshot.setCreated(new Date());
    existingSnapshot.setCreatedBy("test-user");
    return existingSnapshot;
}
Also used : FlowSnapshotEntity(org.apache.nifi.registry.db.entity.FlowSnapshotEntity) Date(java.util.Date)

Aggregations

FlowSnapshotEntity (org.apache.nifi.registry.db.entity.FlowSnapshotEntity)23 Test (org.junit.Test)15 BucketEntity (org.apache.nifi.registry.db.entity.BucketEntity)14 FlowEntity (org.apache.nifi.registry.db.entity.FlowEntity)14 Date (java.util.Date)10 VersionedFlowSnapshotMetadata (org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata)8 ResourceNotFoundException (org.apache.nifi.registry.exception.ResourceNotFoundException)6 VersionedFlowSnapshot (org.apache.nifi.registry.flow.VersionedFlowSnapshot)4 Bucket (org.apache.nifi.registry.bucket.Bucket)3 VersionedFlow (org.apache.nifi.registry.flow.VersionedFlow)3 InputStream (java.io.InputStream)2 TreeSet (java.util.TreeSet)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 FlowSnapshotContext (org.apache.nifi.registry.flow.FlowSnapshotContext)1 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)1 StandardFlowSnapshotContext (org.apache.nifi.registry.provider.flow.StandardFlowSnapshotContext)1 Nullable (org.springframework.lang.Nullable)1