Search in sources :

Example 16 with ComponentMetadataDescriptor

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

the class MetadataOperationTestCase method operationReceivesPojoWithExclusiveOptionalParameterGroup.

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

Example 17 with ComponentMetadataDescriptor

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

the class MetadataOperationTestCase method metadataKeyDefaultValue.

@Test
public void metadataKeyDefaultValue() throws Exception {
    location = Location.builder().globalName(METADATA_KEY_DEFAULT_VALUE).addProcessorsPart().addIndexPart(0).build();
    MetadataResult<ComponentMetadataDescriptor<OperationModel>> result = metadataService.getOperationMetadata(location);
    assertSuccessResult(result);
    MetadataType type = result.get().getModel().getOutput().getType();
    assertThat(type, is(instanceOf(ObjectType.class)));
    ObjectType objectType = (ObjectType) type;
    assertThat(objectType.getFields(), hasSize(2));
    objectType.getFields().forEach(f -> assertThat(f.getKey().getName().getLocalPart(), isOneOf(TIRES, BRAND)));
    Optional<MetadataKey> metadataKeyOptional = result.get().getMetadataAttributes().getKey();
    assertThat(metadataKeyOptional.isPresent(), is(true));
    assertThat(metadataKeyOptional.get().getId(), is(CAR));
}
Also used : ObjectType(org.mule.metadata.api.model.ObjectType) MetadataType(org.mule.metadata.api.model.MetadataType) ComponentMetadataDescriptor(org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor) MetadataKey(org.mule.runtime.api.metadata.MetadataKey) NullMetadataKey(org.mule.runtime.extension.api.metadata.NullMetadataKey) Test(org.junit.Test)

Example 18 with ComponentMetadataDescriptor

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

the class MetadataOperationTestCase method enumMetadataKey.

@Test
public void enumMetadataKey() throws IOException {
    location = Location.builder().globalName(ENUM_METADATA_KEY).addProcessorsPart().addIndexPart(0).build();
    ComponentMetadataDescriptor metadataDescriptor = getSuccessComponentDynamicMetadata(newKey("MAMMAL").build());
    final ComponentModel typedModel = metadataDescriptor.getModel();
    assertExpectedType(getParameter(typedModel, "content"), TYPE_LOADER.load(Bear.class), true);
}
Also used : ComponentModel(org.mule.runtime.api.meta.model.ComponentModel) Bear(org.mule.test.metadata.extension.model.animals.Bear) ComponentMetadataDescriptor(org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor) Test(org.junit.Test)

Example 19 with ComponentMetadataDescriptor

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

the class QueryMetadataTestCase method getNativeQueryOutputArrayMetadata.

@Test
public void getNativeQueryOutputArrayMetadata() throws Exception {
    location = builder().globalName(NATIVE_QUERY_LIST_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();
    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)

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