use of org.apache.nifi.registry.db.entity.BucketEntity in project nifi-registry by apache.
the class TestRegistryService method createBucketEntity.
private BucketEntity createBucketEntity(final String bucketId) {
final BucketEntity existingBucket = new BucketEntity();
existingBucket.setId(bucketId);
existingBucket.setName("My Bucket");
existingBucket.setDescription("This is my bucket");
existingBucket.setCreated(new Date());
return existingBucket;
}
use of org.apache.nifi.registry.db.entity.BucketEntity in project nifi-registry by apache.
the class TestRegistryService method testUpdateBucketPartial.
@Test
public void testUpdateBucketPartial() {
final BucketEntity bucketToUpdate = new BucketEntity();
bucketToUpdate.setId("b1");
bucketToUpdate.setName("My Bucket");
bucketToUpdate.setDescription("This is my bucket");
bucketToUpdate.setCreated(new Date());
when(metadataService.getBucketById(bucketToUpdate.getId())).thenReturn(bucketToUpdate);
doAnswer(updateBucketAnswer()).when(metadataService).updateBucket(any(BucketEntity.class));
final Bucket updatedBucket = new Bucket();
updatedBucket.setIdentifier(bucketToUpdate.getId());
updatedBucket.setName("Updated Name");
updatedBucket.setDescription(null);
// name should be updated but description should not be changed
final Bucket result = registryService.updateBucket(updatedBucket);
assertNotNull(result);
assertEquals(updatedBucket.getName(), result.getName());
assertEquals(bucketToUpdate.getDescription(), result.getDescription());
}
use of org.apache.nifi.registry.db.entity.BucketEntity in project nifi-registry by apache.
the class TestRegistryService method testGetSnapshotDoesNotExistInPersistenceProvider.
@Test(expected = IllegalStateException.class)
public void testGetSnapshotDoesNotExistInPersistenceProvider() {
final BucketEntity existingBucket = createBucketEntity("b1");
final FlowEntity existingFlow = createFlowEntity(existingBucket.getId());
final FlowSnapshotEntity existingSnapshot = createFlowSnapshotEntity(existingFlow.getId());
existingFlow.setSnapshotCount(10);
when(metadataService.getBucketById(existingBucket.getId())).thenReturn(existingBucket);
when(metadataService.getFlowByIdWithSnapshotCounts(existingFlow.getId())).thenReturn(existingFlow);
when(metadataService.getFlowSnapshot(existingFlow.getId(), existingSnapshot.getVersion())).thenReturn(existingSnapshot);
when(flowPersistenceProvider.getFlowContent(existingBucket.getId(), existingSnapshot.getFlowId(), existingSnapshot.getVersion())).thenReturn(null);
registryService.getFlowSnapshot(existingBucket.getId(), existingSnapshot.getFlowId(), existingSnapshot.getVersion());
}
use of org.apache.nifi.registry.db.entity.BucketEntity in project nifi-registry by apache.
the class TestRegistryService method testCreateBucketWithSameName.
@Test(expected = IllegalStateException.class)
public void testCreateBucketWithSameName() {
final Bucket bucket = new Bucket();
bucket.setName("My Bucket");
bucket.setDescription("This is my bucket.");
final BucketEntity existingBucket = new BucketEntity();
existingBucket.setId("b1");
existingBucket.setName("My Bucket");
existingBucket.setCreated(new Date());
when(metadataService.getBucketsByName(bucket.getName())).thenReturn(Collections.singletonList(existingBucket));
// should throw exception since a bucket with the same name exists
registryService.createBucket(bucket);
}
use of org.apache.nifi.registry.db.entity.BucketEntity in project nifi-registry by apache.
the class TestRegistryService method testCreateFirstSnapshotWithBadVersion.
@Test(expected = IllegalStateException.class)
public void testCreateFirstSnapshotWithBadVersion() {
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());
when(metadataService.getFlowById(existingFlow.getId())).thenReturn(existingFlow);
// set the first version to something other than 1
snapshot.getSnapshotMetadata().setVersion(100);
registryService.createFlowSnapshot(snapshot);
}
Aggregations