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);
}
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());
}
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;
}
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());
}
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);
}
Aggregations