Search in sources :

Example 21 with FlowEntity

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());
}
Also used : Date(java.util.Date) FlowEntity(org.apache.nifi.registry.db.entity.FlowEntity) Test(org.junit.Test)

Example 22 with FlowEntity

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());
}
Also used : Date(java.util.Date) FlowEntity(org.apache.nifi.registry.db.entity.FlowEntity) Test(org.junit.Test)

Example 23 with FlowEntity

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());
}
Also used : BucketEntity(org.apache.nifi.registry.db.entity.BucketEntity) FlowEntity(org.apache.nifi.registry.db.entity.FlowEntity) Test(org.junit.Test)

Example 24 with FlowEntity

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());
}
Also used : FlowEntity(org.apache.nifi.registry.db.entity.FlowEntity) Test(org.junit.Test)

Example 25 with FlowEntity

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()));
}
Also used : BucketItemEntity(org.apache.nifi.registry.db.entity.BucketItemEntity) FlowEntity(org.apache.nifi.registry.db.entity.FlowEntity) Test(org.junit.Test)

Aggregations

FlowEntity (org.apache.nifi.registry.db.entity.FlowEntity)46 BucketEntity (org.apache.nifi.registry.db.entity.BucketEntity)30 Test (org.junit.Test)27 Date (java.util.Date)20 FlowSnapshotEntity (org.apache.nifi.registry.db.entity.FlowSnapshotEntity)16 ResourceNotFoundException (org.apache.nifi.registry.exception.ResourceNotFoundException)12 VersionedFlow (org.apache.nifi.registry.flow.VersionedFlow)10 VersionedFlowSnapshotMetadata (org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata)9 VersionedFlowSnapshot (org.apache.nifi.registry.flow.VersionedFlowSnapshot)7 ArrayList (java.util.ArrayList)5 Bucket (org.apache.nifi.registry.bucket.Bucket)5 BucketItemEntity (org.apache.nifi.registry.db.entity.BucketItemEntity)5 InputStream (java.io.InputStream)3 TreeSet (java.util.TreeSet)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 FlowSnapshotContext (org.apache.nifi.registry.flow.FlowSnapshotContext)2 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)2 StandardFlowSnapshotContext (org.apache.nifi.registry.provider.flow.StandardFlowSnapshotContext)2 Nullable (org.springframework.lang.Nullable)2