C2NiFiRegistryClient { public Optional<String> resolveNiFiRegistryBucketId() throws NiFiRegistryException, IOException { if (registryBucketId != null) { logger.debug("Using configured bucketId '{}'", registryBucketId); return Optional.of(registryBucketId); } Optional<String> bucketIdForName = getBucketIdByName(); if (bucketIdForName.isPresent()) { logger.debug("Resolved bucketId={} for bucketName={}", bucketIdForName.get(), registryBucketName); } else { logger.debug("Could not determine bucketId. Bucket named '{}' not found.", registryBucketName); } return bucketIdForName; } @Autowired  C2NiFiRegistryClient(
            final NifiRegistryProperties nifiRegistryProperties,
            final ServerProperties serverProperties);   C2NiFiRegistryClient(
            final NifiRegistryProperties nifiRegistryProperties,
            final ServerProperties serverProperties,
            final NiFiRegistryClient client); String getNiFiRegistryUrl(); Optional<String> getNiFiRegistryBucketId(); Optional<String> getNiFiRegistryBucketName(); Optional<String> resolveNiFiRegistryBucketId(); NiFiRegistryClient getClient();  }
@Test public void testResolveBucketIdWhenIdIsSet() throws Exception { C2NiFiRegistryClient client = createC2NiFiRegistryClient(BUCKET_ID, null); assertEquals(BUCKET_ID, client.resolveNiFiRegistryBucketId().get()); }
@Test public void testResolveBucketIdWhenNameIsSet() throws Exception { C2NiFiRegistryClient client = createC2NiFiRegistryClient(null, matchingBucket.getName()); when(bucketClient.getAll()).thenReturn(Arrays.asList(noNameBucket, nonMatchingBucket, matchingBucket)); assertEquals(BUCKET_ID, client.resolveNiFiRegistryBucketId().get()); }
@Test public void testResolveBucketIdWhenNameIsSetButNotFound() throws Exception { C2NiFiRegistryClient client = createC2NiFiRegistryClient(null, matchingBucket.getName()); when(bucketClient.getAll()).thenReturn(Arrays.asList(noNameBucket, nonMatchingBucket)); assertFalse(client.resolveNiFiRegistryBucketId().isPresent()); }