test_class.declarator: idCache
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private Cache<EntityIdWithResourceType, Entry<EntityIdWithResourceType>> idCache;
test_class.type: Cache<EntityIdWithResourceType, Entry<EntityIdWithResourceType>>
test_class.var_name: idCache
test_class.declarator: enforcerCache
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private Cache<EntityIdWithResourceType, Entry<Enforcer>> enforcerCache;
test_class.type: Cache<EntityIdWithResourceType, Entry<Enforcer>>
test_class.var_name: enforcerCache
test_class.declarator: retriever
test_class.modifier: private
test_class.original_string: private EnforcerRetriever retriever;
test_class.type: EnforcerRetriever
test_class.var_name: retriever
test_class.file: services/concierge/enforcement/src/test/java/org/eclipse/ditto/services/concierge/enforcement/EnforcerRetrieverTest.java
test_class.identifier: EnforcerRetrieverTest
test_case.body: @Test
      public void verifyLookupRevealsInnermostException() throws ExecutionException, InterruptedException {
          final DittoRuntimeException expectedException =
                  DittoRuntimeException.newBuilder("this should be happening", HttpStatusCode.HTTPVERSION_NOT_SUPPORTED)
                          .build();
          final EntityIdWithResourceType entityId = EntityIdWithResourceType.of("any", DefaultEntityId.of("id"));
          final EntityIdWithResourceType innerEntityId =
                  EntityIdWithResourceType.of("other", DefaultEntityId.of("randomId"));
          when(idCache.get(any(EntityIdWithResourceType.class))).thenReturn(
                  CompletableFuture.completedFuture(Optional.of(Entry.permanent(innerEntityId))));
          when(enforcerCache.get(any(EntityIdWithResourceType.class))).thenReturn(
                  CompletableFuture.completedFuture(Optional.of(Entry.nonexistent())));
          final CompletionStage<Contextual<WithDittoHeaders>> result = retriever.retrieve(entityId, (entityIdEntry, enforcerEntry) -> {
              throw expectedException;
          });
  
          verify(idCache).get(entityId);
          verify(enforcerCache).get(innerEntityId);
          verifyException(result, expectedException);
      }
test_case.class_method_signature: EnforcerRetrieverTest.verifyLookupRevealsInnermostException()
test_case.full_signature: @Test public void verifyLookupRevealsInnermostException()
test_case.identifier: verifyLookupRevealsInnermostException
test_case.invocations: build newBuilder of of of of thenReturn when get any completedFuture of permanent thenReturn when get any completedFuture of nonexistent retrieve get verify get verify verifyException
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void verifyLookupRevealsInnermostException()
focal_class.declarator: LOGGER = LoggerFactory.getLogger(EnforcerRetriever.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory.getLogger(EnforcerRetriever.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: idCache
focal_class.modifier: private final
focal_class.original_string: private final Cache<EntityIdWithResourceType, Entry<EntityIdWithResourceType>> idCache;
focal_class.type: Cache<EntityIdWithResourceType, Entry<EntityIdWithResourceType>>
focal_class.var_name: idCache
focal_class.declarator: enforcerCacheFunction
focal_class.modifier: private final
focal_class.original_string: private final Function<String, Cache<EntityIdWithResourceType, Entry<Enforcer>>> enforcerCacheFunction;
focal_class.type: Function<String, Cache<EntityIdWithResourceType, Entry<Enforcer>>>
focal_class.var_name: enforcerCacheFunction
focal_class.file: services/concierge/enforcement/src/main/java/org/eclipse/ditto/services/concierge/enforcement/EnforcerRetriever.java
focal_class.identifier: EnforcerRetriever
focal_class.class_method_signature: EnforcerRetriever.EnforcerRetriever(
              final Cache<EntityIdWithResourceType, Entry<EntityIdWithResourceType>> idCache,
              final Cache<EntityIdWithResourceType, Entry<Enforcer>> enforcerCache)
focal_class.full_signature: public  EnforcerRetriever(
              final Cache<EntityIdWithResourceType, Entry<EntityIdWithResourceType>> idCache,
              final Cache<EntityIdWithResourceType, Entry<Enforcer>> enforcerCache)
focal_class.identifier: EnforcerRetriever
focal_class.modifiers: public
focal_class.parameters: (
              final Cache<EntityIdWithResourceType, Entry<EntityIdWithResourceType>> idCache,
              final Cache<EntityIdWithResourceType, Entry<Enforcer>> enforcerCache)
focal_class.signature:  EnforcerRetriever(
              final Cache<EntityIdWithResourceType, Entry<EntityIdWithResourceType>> idCache,
              final Cache<EntityIdWithResourceType, Entry<Enforcer>> enforcerCache)
focal_class.class_method_signature: EnforcerRetriever.EnforcerRetriever(
              final Cache<EntityIdWithResourceType, Entry<EntityIdWithResourceType>> idCache,
              final Function<String, Cache<EntityIdWithResourceType, Entry<Enforcer>>> enforcerCacheFunction)
focal_class.full_signature: private  EnforcerRetriever(
              final Cache<EntityIdWithResourceType, Entry<EntityIdWithResourceType>> idCache,
              final Function<String, Cache<EntityIdWithResourceType, Entry<Enforcer>>> enforcerCacheFunction)
focal_class.identifier: EnforcerRetriever
focal_class.modifiers: private
focal_class.parameters: (
              final Cache<EntityIdWithResourceType, Entry<EntityIdWithResourceType>> idCache,
              final Function<String, Cache<EntityIdWithResourceType, Entry<Enforcer>>> enforcerCacheFunction)
focal_class.signature:  EnforcerRetriever(
              final Cache<EntityIdWithResourceType, Entry<EntityIdWithResourceType>> idCache,
              final Function<String, Cache<EntityIdWithResourceType, Entry<Enforcer>>> enforcerCacheFunction)
focal_class.class_method_signature: EnforcerRetriever.EnforcerRetriever(
              final Cache<EntityIdWithResourceType, Entry<EntityIdWithResourceType>> idCache,
              final Map<String, Cache<EntityIdWithResourceType, Entry<Enforcer>>> enforcerCaches)
focal_class.full_signature: public  EnforcerRetriever(
              final Cache<EntityIdWithResourceType, Entry<EntityIdWithResourceType>> idCache,
              final Map<String, Cache<EntityIdWithResourceType, Entry<Enforcer>>> enforcerCaches)
focal_class.identifier: EnforcerRetriever
focal_class.modifiers: public
focal_class.parameters: (
              final Cache<EntityIdWithResourceType, Entry<EntityIdWithResourceType>> idCache,
              final Map<String, Cache<EntityIdWithResourceType, Entry<Enforcer>>> enforcerCaches)
focal_class.signature:  EnforcerRetriever(
              final Cache<EntityIdWithResourceType, Entry<EntityIdWithResourceType>> idCache,
              final Map<String, Cache<EntityIdWithResourceType, Entry<Enforcer>>> enforcerCaches)
focal_class.class_method_signature: EnforcerRetriever.retrieve(final EntityIdWithResourceType entityKey,
              final BiFunction<Entry<EntityIdWithResourceType>, Entry<Enforcer>, CompletionStage<Contextual<WithDittoHeaders>>> handler)
focal_class.full_signature: public CompletionStage<Contextual<WithDittoHeaders>> retrieve(final EntityIdWithResourceType entityKey,
              final BiFunction<Entry<EntityIdWithResourceType>, Entry<Enforcer>, CompletionStage<Contextual<WithDittoHeaders>>> handler)
focal_class.identifier: retrieve
focal_class.modifiers: public
focal_class.parameters: (final EntityIdWithResourceType entityKey,
              final BiFunction<Entry<EntityIdWithResourceType>, Entry<Enforcer>, CompletionStage<Contextual<WithDittoHeaders>>> handler)
focal_class.return: CompletionStage<Contextual<WithDittoHeaders>>
focal_class.signature: CompletionStage<Contextual<WithDittoHeaders>> retrieve(final EntityIdWithResourceType entityKey,
              final BiFunction<Entry<EntityIdWithResourceType>, Entry<Enforcer>, CompletionStage<Contextual<WithDittoHeaders>>> handler)
focal_class.class_method_signature: EnforcerRetriever.retrieveByEnforcerKey(
              final EntityIdWithResourceType enforcerKey,
              final Function<Entry<Enforcer>, CompletionStage<Contextual<WithDittoHeaders>>> handler)
focal_class.full_signature: public CompletionStage<Contextual<WithDittoHeaders>> retrieveByEnforcerKey(
              final EntityIdWithResourceType enforcerKey,
              final Function<Entry<Enforcer>, CompletionStage<Contextual<WithDittoHeaders>>> handler)
focal_class.identifier: retrieveByEnforcerKey
focal_class.modifiers: public
focal_class.parameters: (
              final EntityIdWithResourceType enforcerKey,
              final Function<Entry<Enforcer>, CompletionStage<Contextual<WithDittoHeaders>>> handler)
focal_class.return: CompletionStage<Contextual<WithDittoHeaders>>
focal_class.signature: CompletionStage<Contextual<WithDittoHeaders>> retrieveByEnforcerKey(
              final EntityIdWithResourceType enforcerKey,
              final Function<Entry<Enforcer>, CompletionStage<Contextual<WithDittoHeaders>>> handler)
focal_method.body: public CompletionStage<Contextual<WithDittoHeaders>> retrieve(final EntityIdWithResourceType entityKey,
              final BiFunction<Entry<EntityIdWithResourceType>, Entry<Enforcer>, CompletionStage<Contextual<WithDittoHeaders>>> handler) {
          return idCache.get(entityKey).thenCompose(enforcerKeyEntryOptional -> {
              if (enforcerKeyEntryOptional.isEmpty()) {
                  // may happen due to namespace blocking
                  LOGGER.info("Did not get id-cache value for entityKey <{}>.", entityKey);
                  return handler.apply(Entry.nonexistent(), Entry.nonexistent());
              } else {
                  final Entry<EntityIdWithResourceType> enforcerKeyEntry = enforcerKeyEntryOptional.get();
                  if (enforcerKeyEntry.exists()) {
                      final EntityIdWithResourceType enforcerKey = enforcerKeyEntry.getValueOrThrow();
                      final String resourceType = enforcerKey.getResourceType();
                      final Cache<EntityIdWithResourceType, Entry<Enforcer>> enforcerCache =
                              enforcerCacheFunction.apply(resourceType);
                      if (enforcerCache == null) {
                          LOGGER.error("No enforcerCache for resource type: <{}>", resourceType);
                          throw GatewayInternalErrorException.newBuilder()
                                  .build();
                      }
                      return retrieveByEnforcerKey(enforcerKey, enforcerEntry ->
                              handler.apply(enforcerKeyEntry, enforcerEntry));
                  } else {
                      return handler.apply(enforcerKeyEntry, Entry.nonexistent());
                  }
              }
          });
      }
focal_method.class_method_signature: EnforcerRetriever.retrieve(final EntityIdWithResourceType entityKey,
              final BiFunction<Entry<EntityIdWithResourceType>, Entry<Enforcer>, CompletionStage<Contextual<WithDittoHeaders>>> handler)
focal_method.full_signature: public CompletionStage<Contextual<WithDittoHeaders>> retrieve(final EntityIdWithResourceType entityKey,
              final BiFunction<Entry<EntityIdWithResourceType>, Entry<Enforcer>, CompletionStage<Contextual<WithDittoHeaders>>> handler)
focal_method.identifier: retrieve
focal_method.invocations: thenCompose get isEmpty info apply nonexistent nonexistent get exists getValueOrThrow getResourceType apply error build newBuilder retrieveByEnforcerKey apply apply nonexistent
focal_method.modifiers: public
focal_method.parameters: (final EntityIdWithResourceType entityKey,
              final BiFunction<Entry<EntityIdWithResourceType>, Entry<Enforcer>, CompletionStage<Contextual<WithDittoHeaders>>> handler)
focal_method.return: CompletionStage<Contextual<WithDittoHeaders>>
focal_method.signature: CompletionStage<Contextual<WithDittoHeaders>> retrieve(final EntityIdWithResourceType entityKey,
              final BiFunction<Entry<EntityIdWithResourceType>, Entry<Enforcer>, CompletionStage<Contextual<WithDittoHeaders>>> handler)