use of org.mule.runtime.api.metadata.MetadataCache in project mule by mulesoft.
the class MetadataCacheTestCase method elementsAreStoredInCaches.
@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));
}
use of org.mule.runtime.api.metadata.MetadataCache in project mule by mulesoft.
the class TestResolverWithCache method getInputMetadata.
@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());
}
Aggregations