Search in sources :

Example 31 with VersionedFlow

use of org.apache.nifi.registry.flow.VersionedFlow in project nifi-registry by apache.

the class FlowsIT method testDeleteBucket.

@Test
public void testDeleteBucket() throws Exception {
    // Given: a flow exists on the server
    final String bucketId = "3";
    final VersionedFlow flow = new VersionedFlow();
    flow.setBucketIdentifier(bucketId);
    flow.setName("Test Flow");
    flow.setDescription("This is a flow created by an integration test.");
    final VersionedFlow createdFlow = client.target(createURL("buckets/{bucketId}/flows")).resolveTemplate("bucketId", bucketId).request().post(Entity.entity(flow, MediaType.APPLICATION_JSON), VersionedFlow.class);
    // When: the flow is deleted
    final VersionedFlow deletedFlow = client.target(createURL("buckets/{bucketId}/flows/{flowId}")).resolveTemplate("bucketId", bucketId).resolveTemplate("flowId", createdFlow.getIdentifier()).request().delete(VersionedFlow.class);
    // Then: the body of the server response matches the flow that was deleted
    // and: the flow is no longer accessible (resource not found)
    // self URI will not be present in deletedBucket
    createdFlow.setLink(null);
    assertFlowsEqual(createdFlow, deletedFlow, true);
    final Response response = client.target(createURL("buckets/{bucketId}/flows/{flowId}")).resolveTemplate("bucketId", bucketId).resolveTemplate("flowId", createdFlow.getIdentifier()).request().get();
    assertEquals(404, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) VersionedFlow(org.apache.nifi.registry.flow.VersionedFlow) Test(org.junit.Test)

Example 32 with VersionedFlow

use of org.apache.nifi.registry.flow.VersionedFlow in project nifi-registry by apache.

the class SecureNiFiRegistryClientIT method testCrudOperations.

@Test
public void testCrudOperations() throws IOException, NiFiRegistryException {
    final Bucket bucket = new Bucket();
    bucket.setName("Bucket 1");
    bucket.setDescription("This is bucket 1");
    final BucketClient bucketClient = client.getBucketClient();
    final Bucket createdBucket = bucketClient.create(bucket);
    Assert.assertNotNull(createdBucket);
    Assert.assertNotNull(createdBucket.getIdentifier());
    final List<Bucket> buckets = bucketClient.getAll();
    Assert.assertEquals(1, buckets.size());
    final VersionedFlow flow = new VersionedFlow();
    flow.setBucketIdentifier(createdBucket.getIdentifier());
    flow.setName("Flow 1");
    final FlowClient flowClient = client.getFlowClient();
    final VersionedFlow createdFlow = flowClient.create(flow);
    Assert.assertNotNull(createdFlow);
    Assert.assertNotNull(createdFlow.getIdentifier());
    final VersionedFlowSnapshotMetadata snapshotMetadata = new VersionedFlowSnapshotMetadata();
    snapshotMetadata.setBucketIdentifier(createdFlow.getBucketIdentifier());
    snapshotMetadata.setFlowIdentifier(createdFlow.getIdentifier());
    snapshotMetadata.setVersion(1);
    snapshotMetadata.setComments("This is snapshot #1");
    final VersionedProcessGroup rootProcessGroup = new VersionedProcessGroup();
    rootProcessGroup.setIdentifier("root-pg");
    rootProcessGroup.setName("Root Process Group");
    final VersionedFlowSnapshot snapshot = new VersionedFlowSnapshot();
    snapshot.setSnapshotMetadata(snapshotMetadata);
    snapshot.setFlowContents(rootProcessGroup);
    final FlowSnapshotClient snapshotClient = client.getFlowSnapshotClient();
    final VersionedFlowSnapshot createdSnapshot = snapshotClient.create(snapshot);
    Assert.assertNotNull(createdSnapshot);
    Assert.assertEquals("CN=user1, OU=nifi", createdSnapshot.getSnapshotMetadata().getAuthor());
}
Also used : BucketClient(org.apache.nifi.registry.client.BucketClient) Bucket(org.apache.nifi.registry.bucket.Bucket) VersionedFlow(org.apache.nifi.registry.flow.VersionedFlow) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) VersionedFlowSnapshot(org.apache.nifi.registry.flow.VersionedFlowSnapshot) FlowClient(org.apache.nifi.registry.client.FlowClient) FlowSnapshotClient(org.apache.nifi.registry.client.FlowSnapshotClient) VersionedFlowSnapshotMetadata(org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 33 with VersionedFlow

use of org.apache.nifi.registry.flow.VersionedFlow in project nifi-registry by apache.

the class UnsecuredNiFiRegistryClientIT method createFlow.

private static VersionedFlow createFlow(FlowClient client, Bucket bucket, int num) throws IOException, NiFiRegistryException {
    final VersionedFlow versionedFlow = new VersionedFlow();
    versionedFlow.setName(bucket.getName() + " Flow #" + num);
    versionedFlow.setDescription("This is " + bucket.getName() + " flow #" + num);
    versionedFlow.setBucketIdentifier(bucket.getIdentifier());
    return client.create(versionedFlow);
}
Also used : VersionedFlow(org.apache.nifi.registry.flow.VersionedFlow)

Example 34 with VersionedFlow

use of org.apache.nifi.registry.flow.VersionedFlow in project nifi-registry by apache.

the class TestRestAPI method createFlows.

private static List<VersionedFlow> createFlows(Client client, Bucket bucket, int numFlows) {
    final List<VersionedFlow> createdFlows = new ArrayList<>();
    for (int i = 0; i < numFlows; i++) {
        final VersionedFlow createdFlow = createFlow(client, bucket, i);
        System.out.println("Created flow # " + i + " with id " + createdFlow.getIdentifier());
        createdFlows.add(createdFlow);
    }
    return createdFlows;
}
Also used : VersionedFlow(org.apache.nifi.registry.flow.VersionedFlow) ArrayList(java.util.ArrayList)

Example 35 with VersionedFlow

use of org.apache.nifi.registry.flow.VersionedFlow in project nifi-registry by apache.

the class TestRestAPI method createFlow.

private static VersionedFlow createFlow(Client client, Bucket bucket, int num) {
    final VersionedFlow versionedFlow = new VersionedFlow();
    versionedFlow.setName(bucket.getName() + " Flow #" + num);
    versionedFlow.setDescription("This is " + bucket.getName() + " flow #" + num);
    final VersionedFlow createdFlow = client.target(REGISTRY_API_BUCKETS_URL).path("/{bucketId}/flows").resolveTemplate("bucketId", bucket.getIdentifier()).request().post(Entity.entity(versionedFlow, MediaType.APPLICATION_JSON), VersionedFlow.class);
    return createdFlow;
}
Also used : VersionedFlow(org.apache.nifi.registry.flow.VersionedFlow)

Aggregations

VersionedFlow (org.apache.nifi.registry.flow.VersionedFlow)46 Test (org.junit.Test)19 Bucket (org.apache.nifi.registry.bucket.Bucket)12 BucketEntity (org.apache.nifi.registry.db.entity.BucketEntity)11 FlowEntity (org.apache.nifi.registry.db.entity.FlowEntity)11 VersionedFlowSnapshot (org.apache.nifi.registry.flow.VersionedFlowSnapshot)11 VersionedFlowSnapshotMetadata (org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata)10 Date (java.util.Date)9 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)8 ApiOperation (io.swagger.annotations.ApiOperation)7 ApiResponses (io.swagger.annotations.ApiResponses)7 Consumes (javax.ws.rs.Consumes)7 Produces (javax.ws.rs.Produces)7 ArrayList (java.util.ArrayList)6 Path (javax.ws.rs.Path)6 IOException (java.io.IOException)5 FlowClient (org.apache.nifi.registry.client.FlowClient)5 NiFiRegistryException (org.apache.nifi.registry.client.NiFiRegistryException)5 TreeSet (java.util.TreeSet)3 Response (javax.ws.rs.core.Response)3