Search in sources :

Example 11 with ComponentMetadataDescriptor

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

the class MetadataOperationTestCase method pagedOperationMetadataTestCase.

@Test
public void pagedOperationMetadataTestCase() throws Exception {
    location = Location.builder().globalName(PAGED_OPERATION_METADATA).addProcessorsPart().addIndexPart(0).build();
    ComponentMetadataDescriptor metadataDescriptor = getSuccessComponentDynamicMetadata(NULL_METADATA_KEY);
    final ComponentModel typedModel = metadataDescriptor.getModel();
    assertExpectedType(getParameter(typedModel, "animal"), Animal.class);
}
Also used : ComponentModel(org.mule.runtime.api.meta.model.ComponentModel) ComponentMetadataDescriptor(org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor) Test(org.junit.Test)

Example 12 with ComponentMetadataDescriptor

use of org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor 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);
}
Also used : ExtensionsTestUtils.toMetadataType(org.mule.test.module.extension.internal.util.ExtensionsTestUtils.toMetadataType) MetadataType(org.mule.metadata.api.model.MetadataType) MetadataKey(org.mule.runtime.api.metadata.MetadataKey) ComponentMetadataDescriptor(org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor) Test(org.junit.Test)

Example 13 with ComponentMetadataDescriptor

use of org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor 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());
}
Also used : ArrayType(org.mule.metadata.api.model.ArrayType) ExtensionsTestUtils.toMetadataType(org.mule.test.module.extension.internal.util.ExtensionsTestUtils.toMetadataType) MetadataType(org.mule.metadata.api.model.MetadataType) MetadataKey(org.mule.runtime.api.metadata.MetadataKey) ComponentMetadataDescriptor(org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor) Test(org.junit.Test)

Example 14 with ComponentMetadataDescriptor

use of org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor 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();
}
Also used : Arrays(java.util.Arrays) DSL_RESOLUTION(org.mule.test.module.extension.metadata.MetadataExtensionFunctionalTestCase.ResolutionType.DSL_RESOLUTION) PERSON(org.mule.test.metadata.extension.MetadataConnection.PERSON) Assert.assertThat(org.junit.Assert.assertThat) MetadataKey(org.mule.runtime.api.metadata.MetadataKey) ExtensionsTestUtils(org.mule.test.module.extension.internal.util.ExtensionsTestUtils) Is.is(org.hamcrest.core.Is.is) ComponentMetadataDescriptor(org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor) ClassTypeLoader(org.mule.metadata.api.ClassTypeLoader) MetadataService(org.mule.runtime.api.metadata.MetadataService) Parameterized(org.junit.runners.Parameterized) NullMetadataKey(org.mule.runtime.extension.api.metadata.NullMetadataKey) ConnectableComponentModel(org.mule.runtime.api.meta.model.ConnectableComponentModel) Collection(java.util.Collection) Set(java.util.Set) SAN_FRANCISCO(org.mule.test.metadata.extension.resolver.TestMultiLevelKeyResolver.SAN_FRANCISCO) Message.of(org.mule.runtime.api.message.Message.of) Collectors.joining(java.util.stream.Collectors.joining) USA(org.mule.test.metadata.extension.resolver.TestMultiLevelKeyResolver.USA) METADATA_SERVICE_KEY(org.mule.runtime.api.metadata.MetadataService.METADATA_SERVICE_KEY) MetadataComponent(org.mule.runtime.api.metadata.resolving.MetadataComponent) TestMetadataResolverUtils.getMetadata(org.mule.test.metadata.extension.resolver.TestMetadataResolverUtils.getMetadata) Type(java.lang.reflect.Type) EXPLICIT_RESOLUTION(org.mule.test.module.extension.metadata.MetadataExtensionFunctionalTestCase.ResolutionType.EXPLICIT_RESOLUTION) OutputModel(org.mule.runtime.api.meta.model.OutputModel) MetadataType(org.mule.metadata.api.model.MetadataType) Matchers.containsString(org.hamcrest.Matchers.containsString) MetadataResult(org.mule.runtime.api.metadata.resolving.MetadataResult) AbstractExtensionFunctionalTestCase(org.mule.test.module.extension.AbstractExtensionFunctionalTestCase) AMERICA(org.mule.test.metadata.extension.resolver.TestMultiLevelKeyResolver.AMERICA) ComponentModel(org.mule.runtime.api.meta.model.ComponentModel) ExtensionsTypeLoaderFactory(org.mule.runtime.extension.api.declaration.type.ExtensionsTypeLoaderFactory) JAVA(org.mule.metadata.api.model.MetadataFormat.JAVA) Preconditions.checkArgument(org.mule.runtime.api.util.Preconditions.checkArgument) MultilevelMetadataKeyBuilder(org.mule.runtime.module.extension.api.metadata.MultilevelMetadataKeyBuilder) Location(org.mule.runtime.api.component.location.Location) BaseTypeBuilder(org.mule.metadata.api.builder.BaseTypeBuilder) Inject(javax.inject.Inject) RunnerDelegateTo(org.mule.test.runner.RunnerDelegateTo) BiConsumer(java.util.function.BiConsumer) Matchers.hasSize(org.hamcrest.Matchers.hasSize) MetadataKeyBuilder.newKey(org.mule.runtime.api.metadata.MetadataKeyBuilder.newKey) Named(javax.inject.Named) Before(org.junit.Before) Typed(org.mule.runtime.api.meta.Typed) FailureCode(org.mule.runtime.api.metadata.resolving.FailureCode) Matchers.empty(org.hamcrest.Matchers.empty) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) StringUtils.isBlank(org.apache.commons.lang3.StringUtils.isBlank) CAR(org.mule.test.metadata.extension.MetadataConnection.CAR) MetadataKeysContainer(org.mule.runtime.api.metadata.MetadataKeysContainer) MetadataFailure(org.mule.runtime.api.metadata.resolving.MetadataFailure) Matchers.containsString(org.hamcrest.Matchers.containsString) ComponentMetadataDescriptor(org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor)

Example 15 with ComponentMetadataDescriptor

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

the class MetadataNoRefDynamicConfigurationTestCase method resolveMetadataWithNoRefDynamicConfig.

@Test
public void resolveMetadataWithNoRefDynamicConfig() throws Exception {
    location = builder().globalName(RESOLVER_WITH_IMPLICIT_DYNAMIC_CONFIG).addProcessorsPart().addIndexPart(0).build();
    MetadataKey key = newKey(AMERICA).withChild(newKey(USA).withChild(newKey(SAN_FRANCISCO))).build();
    final MetadataResult<ComponentMetadataDescriptor<OperationModel>> metadataResult = getComponentDynamicMetadata(key);
    assertFailureResult(metadataResult, 1);
    assertMetadataFailure(metadataResult.getFailures().get(0), "Configuration used for Metadata fetch 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)

Aggregations

ComponentMetadataDescriptor (org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor)19 Test (org.junit.Test)17 MetadataType (org.mule.metadata.api.model.MetadataType)10 MetadataKey (org.mule.runtime.api.metadata.MetadataKey)9 ComponentModel (org.mule.runtime.api.meta.model.ComponentModel)4 OperationModel (org.mule.runtime.api.meta.model.operation.OperationModel)3 NullMetadataKey (org.mule.runtime.extension.api.metadata.NullMetadataKey)3 ExtensionsTestUtils.toMetadataType (org.mule.test.module.extension.internal.util.ExtensionsTestUtils.toMetadataType)3 ArrayType (org.mule.metadata.api.model.ArrayType)2 MetadataResolvingException (org.mule.runtime.api.metadata.MetadataResolvingException)2 Type (java.lang.reflect.Type)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Set (java.util.Set)1 BiConsumer (java.util.function.BiConsumer)1 Collectors.joining (java.util.stream.Collectors.joining)1 Inject (javax.inject.Inject)1 Named (javax.inject.Named)1 StringUtils.isBlank (org.apache.commons.lang3.StringUtils.isBlank)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1