Search in sources :

Example 6 with BucketClient

use of org.apache.nifi.registry.client.BucketClient 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)

Aggregations

BucketClient (org.apache.nifi.registry.client.BucketClient)6 Bucket (org.apache.nifi.registry.bucket.Bucket)4 FlowClient (org.apache.nifi.registry.client.FlowClient)3 NiFiRegistryException (org.apache.nifi.registry.client.NiFiRegistryException)3 VersionedFlow (org.apache.nifi.registry.flow.VersionedFlow)3 Test (org.junit.Test)3 FlowSnapshotClient (org.apache.nifi.registry.client.FlowSnapshotClient)2 VersionedFlowSnapshot (org.apache.nifi.registry.flow.VersionedFlowSnapshot)2 VersionedFlowSnapshotMetadata (org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata)2 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 BucketItem (org.apache.nifi.registry.bucket.BucketItem)1 ItemsClient (org.apache.nifi.registry.client.ItemsClient)1 NiFiRegistryClient (org.apache.nifi.registry.client.NiFiRegistryClient)1 JerseyNiFiRegistryClient (org.apache.nifi.registry.client.impl.JerseyNiFiRegistryClient)1 VersionedFlowDifference (org.apache.nifi.registry.diff.VersionedFlowDifference)1 Fields (org.apache.nifi.registry.field.Fields)1 OkResult (org.apache.nifi.toolkit.cli.impl.result.OkResult)1