use of org.mule.runtime.api.metadata.MetadataKey in project mule by mulesoft.
the class MetadataOperationTestCase method shouldInheritExtensionResolvers.
@Test
@Ignore("MULE-14190: Revamp MetadataScope annotation")
public void shouldInheritExtensionResolvers() throws Exception {
location = Location.builder().globalName(SHOULD_INHERIT_EXTENSION_RESOLVERS).addProcessorsPart().addIndexPart(0).build();
final MetadataResult<MetadataKeysContainer> metadataKeysResult = metadataService.getMetadataKeys(location);
assertSuccessResult(metadataKeysResult);
final Set<MetadataKey> metadataKeys = getKeysFromContainer(metadataKeysResult.get());
assertThat(metadataKeys.size(), is(1));
assertThat(metadataKeys, hasItems(metadataKeyWithId("APPLE")));
final ComponentMetadataDescriptor<OperationModel> metadataDescriptor = getSuccessComponentDynamicMetadataWithKey(newKey("APPLE").build());
final OperationModel typedModel = metadataDescriptor.getModel();
assertExpectedOutput(typedModel, typeLoader.load(Apple.class), void.class);
}
use of org.mule.runtime.api.metadata.MetadataKey in project mule by mulesoft.
the class QueryMetadataTestCase method getNativeQueryOutputMetadata.
@Test
public void getNativeQueryOutputMetadata() throws Exception {
location = builder().globalName(NATIVE_QUERY_FLOW).addProcessorsPart().addIndexPart(0).build();
MetadataKey nativeKey = newKey(NATIVE_QUERY).build();
MetadataResult<ComponentMetadataDescriptor<OperationModel>> entityMetadata = getComponentDynamicMetadata(nativeKey);
assertThat(entityMetadata.isSuccess(), is(true));
MetadataType generatedType = entityMetadata.get().getModel().getOutput().getType();
assertCircleType((ObjectType) generatedType);
}
use of org.mule.runtime.api.metadata.MetadataKey in project mule by mulesoft.
the class QueryMetadataTestCase method getDsqlQueryAutomaticGeneratedOutputMetadata.
@Test
public void getDsqlQueryAutomaticGeneratedOutputMetadata() throws Exception {
location = QUERY_LOCATION;
MetadataKey dsqlKey = newKey(DSQL_QUERY).build();
MetadataResult<ComponentMetadataDescriptor<OperationModel>> entityMetadata = getComponentDynamicMetadata(dsqlKey);
assertThat(entityMetadata.isSuccess(), is(true));
MetadataType generatedType = entityMetadata.get().getModel().getOutput().getType();
assertThat(generatedType, is(instanceOf(ArrayType.class)));
assertCircleType((ObjectType) ((ArrayType) generatedType).getType());
}
use of org.mule.runtime.api.metadata.MetadataKey in project mule by mulesoft.
the class MetadataExtensionFunctionalTestCase method getSuccessComponentDynamicMetadata.
private ComponentMetadataDescriptor<T> getSuccessComponentDynamicMetadata(MetadataKey key, BiConsumer<MetadataResult<ComponentMetadataDescriptor<T>>, MetadataKey> assertKeys) {
MetadataResult<ComponentMetadataDescriptor<T>> componentMetadata = getComponentDynamicMetadata(key);
String msg = componentMetadata.getFailures().stream().map(f -> "Failure: " + f.getMessage()).collect(joining(", "));
assertThat(msg, componentMetadata.isSuccess(), is(true));
assertKeys.accept(componentMetadata, key);
return componentMetadata.get();
}
use of org.mule.runtime.api.metadata.MetadataKey in project mule by mulesoft.
the class MetadataKeysDelegate method getMetadataKeys.
MetadataResult<MetadataKeysContainer> getMetadataKeys(MetadataContext context, Object partialKey, ReflectionCache reflectionCache) {
final TypeKeysResolver keyResolver = resolverFactory.getKeyResolver();
final String componentResolverName = keyResolver.getCategoryName();
final MetadataKeysContainerBuilder keysContainer = MetadataKeysContainerBuilder.getInstance();
if (keyParts.isEmpty()) {
return success(keysContainer.add(componentResolverName, ImmutableSet.of(new NullMetadataKey())).build());
}
try {
final Map<Integer, ParameterModel> partsByOrder = getPartOrderMapping(keyParts);
Set<MetadataKey> metadataKeys;
if (keyResolver instanceof PartialTypeKeysResolver && hasInitialLevel(partialKey, partsByOrder, reflectionCache)) {
metadataKeys = singleton(((PartialTypeKeysResolver) keyResolver).resolveChilds(context, partialKey));
} else {
metadataKeys = keyResolver.getKeys(context);
}
final Set<MetadataKey> enrichedMetadataKeys = metadataKeys.stream().map(metadataKey -> cloneAndEnrichMetadataKey(metadataKey, partsByOrder)).map(MetadataKeyBuilder::build).collect(toSet());
keysContainer.add(componentResolverName, enrichedMetadataKeys);
return success(keysContainer.build());
} catch (Exception e) {
return failure(newFailure(e).onKeys());
}
}
Aggregations