Search in sources :

Example 16 with FlowSnapshotEntity

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

the class TestDatabaseMetadataService method testDeleteFlowSnapshot.

@Test
public void testDeleteFlowSnapshot() {
    final FlowSnapshotEntity entity = metadataService.getFlowSnapshot("1", 1);
    assertNotNull(entity);
    metadataService.deleteFlowSnapshot(entity);
    final FlowSnapshotEntity deletedEntity = metadataService.getFlowSnapshot("1", 1);
    assertNull(deletedEntity);
}
Also used : FlowSnapshotEntity(org.apache.nifi.registry.db.entity.FlowSnapshotEntity) Test(org.junit.Test)

Example 17 with FlowSnapshotEntity

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

the class TestDatabaseMetadataService method testGetFlowSnapshot.

// ----------------- FlowSnapshots ---------------------------------
@Test
public void testGetFlowSnapshot() {
    final FlowSnapshotEntity entity = metadataService.getFlowSnapshot("1", 1);
    assertNotNull(entity);
    assertEquals("1", entity.getFlowId());
    assertEquals(1, entity.getVersion().intValue());
}
Also used : FlowSnapshotEntity(org.apache.nifi.registry.db.entity.FlowSnapshotEntity) Test(org.junit.Test)

Example 18 with FlowSnapshotEntity

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

the class DataModelMapper method map.

// --- Map snapshots
public static FlowSnapshotEntity map(final VersionedFlowSnapshotMetadata versionedFlowSnapshot) {
    final FlowSnapshotEntity flowSnapshotEntity = new FlowSnapshotEntity();
    flowSnapshotEntity.setFlowId(versionedFlowSnapshot.getFlowIdentifier());
    flowSnapshotEntity.setVersion(versionedFlowSnapshot.getVersion());
    flowSnapshotEntity.setComments(versionedFlowSnapshot.getComments());
    flowSnapshotEntity.setCreated(new Date(versionedFlowSnapshot.getTimestamp()));
    flowSnapshotEntity.setCreatedBy(versionedFlowSnapshot.getAuthor());
    return flowSnapshotEntity;
}
Also used : FlowSnapshotEntity(org.apache.nifi.registry.db.entity.FlowSnapshotEntity) Date(java.util.Date)

Example 19 with FlowSnapshotEntity

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

the class TestRegistryService method testGetLatestSnapshotMetadataWhenVersionsExist.

@Test
public void testGetLatestSnapshotMetadataWhenVersionsExist() {
    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());
    when(metadataService.getFlowById(existingFlow.getId())).thenReturn(existingFlow);
    final FlowSnapshotEntity existingSnapshot1 = new FlowSnapshotEntity();
    existingSnapshot1.setVersion(1);
    existingSnapshot1.setFlowId(existingFlow.getId());
    existingSnapshot1.setCreatedBy("user1");
    existingSnapshot1.setCreated(new Date());
    existingSnapshot1.setComments("This is snapshot 1");
    when(metadataService.getLatestSnapshot(existingFlow.getId())).thenReturn(existingSnapshot1);
    VersionedFlowSnapshotMetadata latestMetadata = registryService.getLatestFlowSnapshotMetadata(existingBucket.getId(), existingFlow.getId());
    assertNotNull(latestMetadata);
    assertEquals(1, latestMetadata.getVersion());
}
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) VersionedFlowSnapshotMetadata(org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata) Test(org.junit.Test)

Example 20 with FlowSnapshotEntity

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

the class TestRegistryService method testDeleteSnapshotExists.

@Test
public void testDeleteSnapshotExists() {
    final BucketEntity existingBucket = createBucketEntity("b1");
    final FlowEntity existingFlow = createFlowEntity(existingBucket.getId());
    final FlowSnapshotEntity existingSnapshot = createFlowSnapshotEntity(existingFlow.getId());
    when(metadataService.getBucketById(existingBucket.getId())).thenReturn(existingBucket);
    when(metadataService.getFlowById(existingFlow.getId())).thenReturn(existingFlow);
    when(metadataService.getFlowSnapshot(existingSnapshot.getFlowId(), existingSnapshot.getVersion())).thenReturn(existingSnapshot);
    final VersionedFlowSnapshotMetadata deletedSnapshot = registryService.deleteFlowSnapshot(existingBucket.getId(), existingSnapshot.getFlowId(), existingSnapshot.getVersion());
    assertNotNull(deletedSnapshot);
    assertEquals(existingSnapshot.getFlowId(), deletedSnapshot.getFlowIdentifier());
    verify(flowPersistenceProvider, times(1)).deleteFlowContent(existingBucket.getId(), existingSnapshot.getFlowId(), existingSnapshot.getVersion());
    verify(metadataService, times(1)).deleteFlowSnapshot(existingSnapshot);
}
Also used : BucketEntity(org.apache.nifi.registry.db.entity.BucketEntity) FlowSnapshotEntity(org.apache.nifi.registry.db.entity.FlowSnapshotEntity) FlowEntity(org.apache.nifi.registry.db.entity.FlowEntity) VersionedFlowSnapshotMetadata(org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata) Test(org.junit.Test)

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