use of org.apache.nifi.registry.db.entity.FlowEntity in project nifi-registry by apache.
the class TestDatabaseMetadataService method testUpdateFlow.
@Test
public void testUpdateFlow() {
final FlowEntity flow = metadataService.getFlowById("1");
assertNotNull(flow);
final Date originalModified = flow.getModified();
flow.setName(flow.getName() + " UPDATED");
flow.setDescription(flow.getDescription() + " UPDATED");
metadataService.updateFlow(flow);
final FlowEntity updatedFlow = metadataService.getFlowById("1");
assertNotNull(flow);
assertEquals(flow.getName(), updatedFlow.getName());
assertEquals(flow.getDescription(), updatedFlow.getDescription());
assertEquals(flow.getModified().getTime(), updatedFlow.getModified().getTime());
assertTrue(updatedFlow.getModified().getTime() > originalModified.getTime());
}
use of org.apache.nifi.registry.db.entity.FlowEntity in project nifi-registry by apache.
the class TestDatabaseMetadataService method testCreateFlow.
@Test
public void testCreateFlow() {
final String bucketId = "1";
final FlowEntity flow = new FlowEntity();
flow.setId(UUID.randomUUID().toString());
flow.setBucketId(bucketId);
flow.setName("Test Flow 1");
flow.setDescription("Description for Test Flow 1");
flow.setCreated(new Date());
flow.setModified(new Date());
flow.setType(BucketItemEntityType.FLOW);
metadataService.createFlow(flow);
final FlowEntity createdFlow = metadataService.getFlowById(flow.getId());
assertNotNull(flow);
assertEquals(flow.getId(), createdFlow.getId());
assertEquals(flow.getBucketId(), createdFlow.getBucketId());
assertEquals(flow.getName(), createdFlow.getName());
assertEquals(flow.getDescription(), createdFlow.getDescription());
assertEquals(flow.getCreated(), createdFlow.getCreated());
assertEquals(flow.getModified(), createdFlow.getModified());
assertEquals(flow.getType(), createdFlow.getType());
}
use of org.apache.nifi.registry.db.entity.FlowEntity in project nifi-registry by apache.
the class TestDatabaseMetadataService method testGetFlowsByBucket.
@Test
public void testGetFlowsByBucket() {
final BucketEntity bucketEntity = metadataService.getBucketById("1");
final List<FlowEntity> flows = metadataService.getFlowsByBucket(bucketEntity.getId());
assertEquals(2, flows.size());
final FlowEntity flowEntity = flows.stream().filter(f -> f.getId().equals("1")).findFirst().orElse(null);
assertNotNull(flowEntity);
assertEquals(3, flowEntity.getSnapshotCount());
}
use of org.apache.nifi.registry.db.entity.FlowEntity in project nifi-registry by apache.
the class TestDatabaseMetadataService method testGetFlowByIdWithSnapshotCount.
@Test
public void testGetFlowByIdWithSnapshotCount() {
final FlowEntity flowEntity = metadataService.getFlowByIdWithSnapshotCounts("1");
assertNotNull(flowEntity);
assertEquals(3, flowEntity.getSnapshotCount());
}
use of org.apache.nifi.registry.db.entity.FlowEntity in project nifi-registry by apache.
the class TestDatabaseMetadataService method testGetItemsWithCounts.
@Test
public void testGetItemsWithCounts() {
final List<BucketItemEntity> items = metadataService.getBucketItems(new HashSet<>(Arrays.asList("1", "2")));
assertNotNull(items);
// 3 items across all buckets
assertEquals(3, items.size());
final BucketItemEntity item1 = items.stream().filter(i -> i.getId().equals("1")).findFirst().orElse(null);
assertNotNull(item1);
assertEquals(BucketItemEntityType.FLOW, item1.getType());
final FlowEntity flowEntity = (FlowEntity) item1;
assertEquals(3, flowEntity.getSnapshotCount());
items.stream().forEach(i -> assertNotNull(i.getBucketName()));
}
Aggregations