use of org.apache.nifi.registry.db.entity.FlowEntity 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);
}
Aggregations