test_class.declarator: REGISTRY_URL = "http://localhost:18080"
test_class.modifier: static final
test_class.original_string: static final String REGISTRY_URL = "http://localhost:18080";
test_class.type: String
test_class.var_name: REGISTRY_URL
test_class.declarator: BUCKET_ID = UUID.randomUUID().toString()
test_class.modifier: static final
test_class.original_string: static final String BUCKET_ID = UUID.randomUUID().toString();
test_class.type: String
test_class.var_name: BUCKET_ID
test_class.declarator: client
test_class.modifier: private
test_class.original_string: private NiFiRegistryClient client;
test_class.type: NiFiRegistryClient
test_class.var_name: client
test_class.declarator: flowClient
test_class.modifier: private
test_class.original_string: private FlowClient flowClient;
test_class.type: FlowClient
test_class.var_name: flowClient
test_class.declarator: clientFactory
test_class.modifier: private
test_class.original_string: private C2NiFiRegistryClient clientFactory;
test_class.type: C2NiFiRegistryClient
test_class.var_name: clientFactory
test_class.declarator: flowMapper
test_class.modifier: private
test_class.original_string: private FlowMapper flowMapper;
test_class.type: FlowMapper
test_class.var_name: flowMapper
test_class.file: efm/efm-c2-protocol/efm-c2-protocol-framework/src/test/java/com/cloudera/cem/efm/service/flow/mapping/TestSimpleFlowMapper.java
test_class.identifier: TestSimpleFlowMapper
test_case.body: @Test
      public void testGetFlowMappingWhenAgentClassDoesNotExist() throws FlowMapperException, IOException, NiFiRegistryException {
          final String agentClass = "Class A";
  
          final VersionedFlow versionedFlow = new VersionedFlow();
          versionedFlow.setName("SOME-OTHER-FLOW");
          versionedFlow.setIdentifier(UUID.randomUUID().toString());
          versionedFlow.setBucketIdentifier(BUCKET_ID);
  
          when(flowClient.getByBucket(BUCKET_ID)).thenReturn(Collections.singletonList(versionedFlow));
  
          final Optional<FlowUri> flowUri = flowMapper.getFlowMapping(agentClass);
          assertNotNull(flowUri);
          assertFalse(flowUri.isPresent());
      }
test_case.class_method_signature: TestSimpleFlowMapper.testGetFlowMappingWhenAgentClassDoesNotExist()
test_case.full_signature: @Test public void testGetFlowMappingWhenAgentClassDoesNotExist()
test_case.identifier: testGetFlowMappingWhenAgentClassDoesNotExist
test_case.invocations: setName setIdentifier toString randomUUID setBucketIdentifier thenReturn when getByBucket singletonList getFlowMapping assertNotNull assertFalse isPresent
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetFlowMappingWhenAgentClassDoesNotExist()
focal_class.declarator: clientFactory
focal_class.modifier: private final
focal_class.original_string: private final C2NiFiRegistryClient clientFactory;
focal_class.type: C2NiFiRegistryClient
focal_class.var_name: clientFactory
focal_class.file: efm/efm-c2-protocol/efm-c2-protocol-framework/src/main/java/com/cloudera/cem/efm/service/flow/mapping/SimpleFlowMapper.java
focal_class.identifier: SimpleFlowMapper
focal_class.interfaces: implements FlowMapper
focal_class.class_method_signature: SimpleFlowMapper.SimpleFlowMapper(final C2NiFiRegistryClient clientFactory)
focal_class.full_signature: @Autowired public  SimpleFlowMapper(final C2NiFiRegistryClient clientFactory)
focal_class.identifier: SimpleFlowMapper
focal_class.modifiers: @Autowired public
focal_class.parameters: (final C2NiFiRegistryClient clientFactory)
focal_class.signature:  SimpleFlowMapper(final C2NiFiRegistryClient clientFactory)
focal_class.class_method_signature: SimpleFlowMapper.getFlowMapping(final String agentClass)
focal_class.full_signature: @Override public Optional<FlowUri> getFlowMapping(final String agentClass)
focal_class.identifier: getFlowMapping
focal_class.modifiers: @Override public
focal_class.parameters: (final String agentClass)
focal_class.return: Optional<FlowUri>
focal_class.signature: Optional<FlowUri> getFlowMapping(final String agentClass)
focal_method.body: @Override
      public Optional<FlowUri> getFlowMapping(final String agentClass) throws FlowMapperException {
          if (StringUtils.isBlank(agentClass)) {
              throw new IllegalArgumentException("Agent class cannot be null or blank");
          }
  
          try {
              final String registryUrl = clientFactory.getNiFiRegistryUrl();
              final Optional<String> bucketIdOptional = clientFactory.resolveNiFiRegistryBucketId();
  
              if (bucketIdOptional.isPresent()) {
                  final String bucketId = bucketIdOptional.get();
                  final NiFiRegistryClient client = clientFactory.getClient();
                  final FlowClient flowClient = client.getFlowClient();
                  final List<VersionedFlow> flows = flowClient.getByBucket(bucketId);
  
                  final Optional<String> flowId = flows.stream()
                          .filter(f -> f.getName().equals(agentClass))
                          .map(f -> f.getIdentifier())
                          .findFirst();
  
                  if (flowId.isPresent()) {
                      final FlowUri flowUri = new FlowUri(registryUrl, bucketId, flowId.get());
                      return Optional.of(flowUri);
                  }
              }
              return Optional.empty();
  
          } catch (final Exception e) {
              throw new FlowMapperException("Unable to get flow mapping for " + agentClass + " due to " + e.getMessage(), e);
          }
      }
focal_method.class_method_signature: SimpleFlowMapper.getFlowMapping(final String agentClass)
focal_method.full_signature: @Override public Optional<FlowUri> getFlowMapping(final String agentClass)
focal_method.identifier: getFlowMapping
focal_method.invocations: isBlank getNiFiRegistryUrl resolveNiFiRegistryBucketId isPresent get getClient getFlowClient getByBucket findFirst map filter stream equals getName getIdentifier isPresent get of empty getMessage
focal_method.modifiers: @Override public
focal_method.parameters: (final String agentClass)
focal_method.return: Optional<FlowUri>
focal_method.signature: Optional<FlowUri> getFlowMapping(final String agentClass)