Search in sources :

Example 1 with MetadataKey

use of org.mule.runtime.api.metadata.MetadataKey in project mule by mulesoft.

the class InvokeKeysResolver method buildServiceKey.

private MetadataKey buildServiceKey(ForwardingSoapClient connection, WebServiceDefinition ws) {
    String serviceId = ws.getServiceId();
    SoapMetadataResolver resolver = connection.getSoapClient(serviceId).getMetadataResolver();
    MetadataKeyBuilder key = newKey(serviceId).withDisplayName(ws.getFriendlyName());
    List<String> excludedOperations = ws.getExcludedOperations();
    resolver.getAvailableOperations().stream().filter(ope -> !excludedOperations.contains(ope)).forEach(ope -> key.withChild(newKey(ope).withDisplayName(NameUtils.titleize(ope))));
    return key.build();
}
Also used : MultilevelMetadataKeyBuilder.newKey(org.mule.runtime.module.extension.api.metadata.MultilevelMetadataKeyBuilder.newKey) ImmutableSet(com.google.common.collect.ImmutableSet) NameUtils(org.mule.runtime.extension.api.util.NameUtils) Set(java.util.Set) WebServiceDefinition(org.mule.runtime.extension.api.soap.WebServiceDefinition) MetadataKeyBuilder(org.mule.runtime.api.metadata.MetadataKeyBuilder) MetadataKey(org.mule.runtime.api.metadata.MetadataKey) List(java.util.List) ConnectionException(org.mule.runtime.api.connection.ConnectionException) MetadataContext(org.mule.runtime.api.metadata.MetadataContext) ForwardingSoapClient(org.mule.runtime.module.extension.soap.internal.runtime.connection.ForwardingSoapClient) MetadataResolvingException(org.mule.runtime.api.metadata.MetadataResolvingException) TypeKeysResolver(org.mule.runtime.api.metadata.resolving.TypeKeysResolver) SoapMetadataResolver(org.mule.runtime.soap.api.client.metadata.SoapMetadataResolver) MetadataKeyBuilder(org.mule.runtime.api.metadata.MetadataKeyBuilder) SoapMetadataResolver(org.mule.runtime.soap.api.client.metadata.SoapMetadataResolver)

Example 2 with MetadataKey

use of org.mule.runtime.api.metadata.MetadataKey in project mule by mulesoft.

the class MetadataNegativeTestCase method failWithDynamicConfigurationWhenRetrievingMetadata.

@Test
public void failWithDynamicConfigurationWhenRetrievingMetadata() throws IOException {
    location = builder().globalName(RESOLVER_WITH_DYNAMIC_CONFIG).addProcessorsPart().addIndexPart(0).build();
    MetadataKey key = newKey(AMERICA, CONTINENT).withChild(newKey(USA, COUNTRY).withChild(newKey(SAN_FRANCISCO, CITY))).build();
    MetadataResult<ComponentMetadataDescriptor<OperationModel>> result = getComponentDynamicMetadata(key);
    assertFailureResult(result, 1);
    assertMetadataFailure(result.getFailures().get(0), CONFIGURATION_CANNOT_BE_DYNAMIC, INVALID_CONFIGURATION, MetadataResolvingException.class.getName(), COMPONENT);
}
Also used : MetadataResolvingException(org.mule.runtime.api.metadata.MetadataResolvingException) MetadataKey(org.mule.runtime.api.metadata.MetadataKey) ComponentMetadataDescriptor(org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor) Test(org.junit.Test)

Example 3 with MetadataKey

use of org.mule.runtime.api.metadata.MetadataKey in project mule by mulesoft.

the class MetadataNegativeTestCase method failToGetMetadataWithMissingMetadataKeyLevels.

@Test
public void failToGetMetadataWithMissingMetadataKeyLevels() throws Exception {
    assumeThat(resolutionType, is(ResolutionType.EXPLICIT_RESOLUTION));
    location = builder().globalName(INCOMPLETE_MULTILEVEL_KEY_RESOLVER).addProcessorsPart().addIndexPart(0).build();
    final MetadataKey metadataKey = newKey(AMERICA, CONTINENT).withChild(newKey(USA, COUNTRY)).build();
    final MetadataResult<ComponentMetadataDescriptor<OperationModel>> result = getComponentDynamicMetadata(metadataKey);
    assertMetadataFailure(result.getFailures().get(0), "Missing levels: [city]", INVALID_METADATA_KEY, "", COMPONENT);
}
Also used : MetadataKey(org.mule.runtime.api.metadata.MetadataKey) ComponentMetadataDescriptor(org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor) Test(org.junit.Test)

Example 4 with MetadataKey

use of org.mule.runtime.api.metadata.MetadataKey in project mule by mulesoft.

the class MetadataOperationTestCase method shouldInheritOperationResolvers.

@Test
public void shouldInheritOperationResolvers() throws Exception {
    location = Location.builder().globalName(SHOULD_INHERIT_OPERATION_PARENT_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(3));
    assertThat(metadataKeys, hasItems(metadataKeyWithId(PERSON), metadataKeyWithId(CAR), metadataKeyWithId(HOUSE)));
    final ComponentMetadataDescriptor<OperationModel> metadataDescriptor = getSuccessComponentDynamicMetadata(PERSON_METADATA_KEY);
    final OperationModel typedModel = metadataDescriptor.getModel();
    assertExpectedOutput(typedModel, personType, void.class);
    assertExpectedType(getParameter(typedModel, "type"), String.class);
// TODO MULE-14190: Revamp MetadataScope annotation
// assertExpectedType(getParameter(typedModel, "content"), personType, true);
}
Also used : MetadataKeysContainer(org.mule.runtime.api.metadata.MetadataKeysContainer) MetadataKey(org.mule.runtime.api.metadata.MetadataKey) NullMetadataKey(org.mule.runtime.extension.api.metadata.NullMetadataKey) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) Test(org.junit.Test)

Example 5 with MetadataKey

use of org.mule.runtime.api.metadata.MetadataKey in project mule by mulesoft.

the class MetadataOperationTestCase method injectComposedMetadataKeyIdInstanceInMetadataResolver.

@Test
public void injectComposedMetadataKeyIdInstanceInMetadataResolver() throws Exception {
    location = Location.builder().globalName(SIMPLE_MULTILEVEL_KEY_RESOLVER).addProcessorsPart().addIndexPart(0).build();
    MetadataKey key = LOCATION_MULTILEVEL_KEY;
    final MetadataResult<ComponentMetadataDescriptor<OperationModel>> metadataResult = metadataService.getOperationMetadata(location, key);
    assertSuccessResult(metadataResult);
    assertResolvedKey(metadataResult, LOCATION_MULTILEVEL_KEY);
}
Also used : MetadataKey(org.mule.runtime.api.metadata.MetadataKey) NullMetadataKey(org.mule.runtime.extension.api.metadata.NullMetadataKey) ComponentMetadataDescriptor(org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor) Test(org.junit.Test)

Aggregations

MetadataKey (org.mule.runtime.api.metadata.MetadataKey)19 Test (org.junit.Test)13 ComponentMetadataDescriptor (org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor)9 NullMetadataKey (org.mule.runtime.extension.api.metadata.NullMetadataKey)7 MetadataType (org.mule.metadata.api.model.MetadataType)5 MetadataKeysContainer (org.mule.runtime.api.metadata.MetadataKeysContainer)4 MetadataResolvingException (org.mule.runtime.api.metadata.MetadataResolvingException)3 ExtensionsTestUtils.toMetadataType (org.mule.test.module.extension.internal.util.ExtensionsTestUtils.toMetadataType)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 Set (java.util.Set)2 ArrayType (org.mule.metadata.api.model.ArrayType)2 OperationModel (org.mule.runtime.api.meta.model.operation.OperationModel)2 TypeKeysResolver (org.mule.runtime.api.metadata.resolving.TypeKeysResolver)2 Type (java.lang.reflect.Type)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 List (java.util.List)1 BiConsumer (java.util.function.BiConsumer)1 Collectors.joining (java.util.stream.Collectors.joining)1 Inject (javax.inject.Inject)1