@Override public MetadataType getInputMetadata(MetadataContext context, String key) throws MetadataResolvingException, ConnectionException { MetadataCache cache = context.getCache(); Optional<? extends Serializable> element = cache.get(BRAND); if (!element.isPresent()) { throw new MetadataResolvingException(MISSING_ELEMENT_ERROR_MESSAGE, FailureCode.RESOURCE_UNAVAILABLE); } return buildMetadataType((String) element.get()); }
@Test public void elementsAreStoredInCaches() throws Exception { // using config setLocation(OUTPUT_AND_METADATA_KEY_CACHE_RESOLVER); metadataService.getMetadataKeys(location); getSuccessComponentDynamicMetadata(PERSON_METADATA_KEY); // using alternative-config setLocation(CONTENT_AND_OUTPUT_CACHE_RESOLVER_WITH_ALTERNATIVE_CONFIG); getSuccessComponentDynamicMetadata(); MetadataCache configCache = getMetadataObjectStore().retrieve(OUTPUT_AND_METADATA_KEY_CACHE_ID); assertThat(configCache.get(AGE).get(), is(AGE_VALUE)); assertThat(configCache.get(NAME).get(), is(NAME_VALUE)); assertThat(configCache.get(BRAND).get(), is(BRAND_VALUE)); MetadataCache alternativeConfigCache = getMetadataObjectStore().retrieve(CONTENT_AND_OUTPUT_CACHE_ID); assertThat(alternativeConfigCache.get(BRAND).get(), is(BRAND_VALUE)); }
@Override public MetadataType getInputMetadata(MetadataContext context, String key) throws MetadataResolvingException, ConnectionException { MetadataCache cache = context.getCache(); Optional<? extends Serializable> element = cache.get(BRAND); if (!element.isPresent()) { throw new MetadataResolvingException(MISSING_ELEMENT_ERROR_MESSAGE, FailureCode.RESOURCE_UNAVAILABLE); } return buildMetadataType((String) element.get()); }
@Test public void elementsAreStoredInCaches() throws Exception { // using config location = Location.builder().globalName(OUTPUT_AND_METADATA_KEY_CACHE_RESOLVER).addProcessorsPart().addIndexPart(0).build(); metadataService.getMetadataKeys(location); getSuccessComponentDynamicMetadata(PERSON_METADATA_KEY); // using alternative-config location = Location.builder().globalName(CONTENT_AND_OUTPUT_CACHE_RESOLVER_WITH_ALTERNATIVE_CONFIG).addProcessorsPart() .addIndexPart(0).build(); getSuccessComponentDynamicMetadata(); MetadataCache configCache = getMetadataCaches(metadataManager).get(CONFIG); assertThat(configCache.get(AGE).get(), is(AGE_VALUE)); assertThat(configCache.get(NAME).get(), is(NAME_VALUE)); assertThat(configCache.get(BRAND).get(), is(BRAND_VALUE)); MetadataCache alternativeConfigCache = getMetadataCaches(metadataManager).get(ALTERNATIVE_CONFIG); assertThat(alternativeConfigCache.get(BRAND).get(), is(BRAND_VALUE)); }