Search in sources :

Example 6 with ComponentMetadataDescriptor

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

the class MetadataOperationTestCase method componentWithStaticInputs.

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

Example 7 with ComponentMetadataDescriptor

use of org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor 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)

Example 8 with ComponentMetadataDescriptor

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

the class MetadataOperationTestCase method defaultValueMetadataKey.

@Test
public void defaultValueMetadataKey() throws Exception {
    location = Location.builder().globalName(METADATA_KEY_DEFAULT_VALUE).addProcessorsPart().addIndexPart(0).build();
    final MetadataResult<ComponentMetadataDescriptor<OperationModel>> result = metadataService.getOperationMetadata(location);
    assertSuccessResult(result);
    assertResolvedKey(result, CAR_KEY);
    ComponentMetadataDescriptor<OperationModel> descriptor = result.get();
    MetadataType type = descriptor.getModel().getOutput().getType();
    assertThat(type, is(instanceOf(ObjectType.class)));
    assertThat(((ObjectType) type).getFields(), hasSize(2));
}
Also used : MetadataType(org.mule.metadata.api.model.MetadataType) ComponentMetadataDescriptor(org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) Test(org.junit.Test)

Example 9 with ComponentMetadataDescriptor

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

the class MetadataOperationTestCase method operationReceivesExclusiveOptionalParameterGroup.

@Test
public void operationReceivesExclusiveOptionalParameterGroup() throws Exception {
    location = Location.builder().globalName("inputHasExclusiveOptionalParameterGroup").addProcessorsPart().addIndexPart(0).build();
    MetadataResult<ComponentMetadataDescriptor<OperationModel>> operationMetadata = metadataService.getOperationMetadata(location);
    ParameterGroupModel dessert = getParameterGroup(operationMetadata.get().getModel(), "dessert");
    assertThat(dessert.getName(), is("dessert"));
}
Also used : ParameterGroupModel(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel) ComponentMetadataDescriptor(org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor) Test(org.junit.Test)

Example 10 with ComponentMetadataDescriptor

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

the class MetadataOperationTestCase method operationReceivesNullTypeOfList.

@Test
public void operationReceivesNullTypeOfList() throws Exception {
    location = Location.builder().globalName("nullListAsInput").addProcessorsPart().addIndexPart(0).build();
    MetadataResult<ComponentMetadataDescriptor<OperationModel>> operationMetadata = metadataService.getOperationMetadata(location);
    MetadataType objects = getParameter(operationMetadata.get().getModel(), "objects").getType();
    assertThat(objects, is(instanceOf(NullType.class)));
}
Also used : MetadataType(org.mule.metadata.api.model.MetadataType) 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