Search in sources :

Example 96 with MetadataType

use of org.mule.metadata.api.model.MetadataType in project mule by mulesoft.

the class MetadataOperationTestCase method pagedOperationResultMetadataTestCase.

@Test
public void pagedOperationResultMetadataTestCase() throws Exception {
    location = Location.builder().globalName(PAGED_OPERATION_METADATA_RESULT).addProcessorsPart().addIndexPart(0).build();
    ComponentMetadataDescriptor<OperationModel> metadataDescriptor = getSuccessComponentDynamicMetadata(PERSON_METADATA_KEY);
    MetadataType param = metadataDescriptor.getModel().getOutput().getType();
    assertThat(param, is(instanceOf(ArrayType.class)));
    assertThat(getId(param).get(), is(Iterator.class.getName()));
    assertMessageType(((ArrayType) param).getType(), personType, TYPE_LOADER.load(Animal.class));
}
Also used : Animal(org.mule.test.metadata.extension.model.animals.Animal) MetadataType(org.mule.metadata.api.model.MetadataType) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) Test(org.junit.Test)

Example 97 with MetadataType

use of org.mule.metadata.api.model.MetadataType 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 98 with MetadataType

use of org.mule.metadata.api.model.MetadataType in project mule by mulesoft.

the class MetadataOperationTestCase method pagedOperationResultWithAttributeResolverMetadataTestCase.

@Test
public void pagedOperationResultWithAttributeResolverMetadataTestCase() throws Exception {
    location = Location.builder().globalName(PAGED_OPERATION_METADATA_RESULT_WITH_ATTRIBUTES).addProcessorsPart().addIndexPart(0).build();
    ComponentMetadataDescriptor<OperationModel> metadataDescriptor = getSuccessComponentDynamicMetadata(PERSON_METADATA_KEY);
    MetadataType param = metadataDescriptor.getModel().getOutput().getType();
    assertThat(param, is(instanceOf(ArrayType.class)));
    assertThat(getId(param).get(), is(Iterator.class.getName()));
    assertMessageType(((ArrayType) param).getType(), personType, personType);
}
Also used : MetadataType(org.mule.metadata.api.model.MetadataType) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) Test(org.junit.Test)

Example 99 with MetadataType

use of org.mule.metadata.api.model.MetadataType 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

MetadataType (org.mule.metadata.api.model.MetadataType)99 ObjectType (org.mule.metadata.api.model.ObjectType)36 ArrayType (org.mule.metadata.api.model.ArrayType)28 Test (org.junit.Test)26 MetadataTypeVisitor (org.mule.metadata.api.visitor.MetadataTypeVisitor)21 Optional (java.util.Optional)20 MessageMetadataType (org.mule.metadata.message.api.MessageMetadataType)18 String.format (java.lang.String.format)17 List (java.util.List)17 ObjectFieldType (org.mule.metadata.api.model.ObjectFieldType)17 StringType (org.mule.metadata.api.model.StringType)15 Map (java.util.Map)14 Collectors.toList (java.util.stream.Collectors.toList)14 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)14 ParameterModel (org.mule.runtime.api.meta.model.parameter.ParameterModel)14 Reference (org.mule.runtime.api.util.Reference)14 DslElementSyntax (org.mule.runtime.extension.api.dsl.syntax.DslElementSyntax)14 ParameterGroupModel (org.mule.runtime.api.meta.model.parameter.ParameterGroupModel)13 Set (java.util.Set)11 ParameterizedModel (org.mule.runtime.api.meta.model.parameter.ParameterizedModel)11