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());
}
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());
}
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);
}
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;
}
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;
}
Aggregations