Search in sources :

Example 1 with ComponentMetadataDescriptor

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

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

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

the class MetadataOperationTestCase method operationReceivesListOfObjects.

@Test
public void operationReceivesListOfObjects() throws Exception {
    location = Location.builder().globalName("objectListAsInput").addProcessorsPart().addIndexPart(0).build();
    MetadataResult<ComponentMetadataDescriptor<OperationModel>> operationMetadata = metadataService.getOperationMetadata(location);
    MetadataType objects = getParameter(operationMetadata.get().getModel(), "objects").getType();
    assertThat(objects, is(instanceOf(ArrayType.class)));
    assertThat(((ArrayType) objects).getType(), is(personType));
}
Also used : MetadataType(org.mule.metadata.api.model.MetadataType) ComponentMetadataDescriptor(org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor) Test(org.junit.Test)

Example 4 with ComponentMetadataDescriptor

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

the class MetadataOperationTestCase method getResolvedTypeFromList.

private MetadataType getResolvedTypeFromList() {
    final MetadataResult<ComponentMetadataDescriptor<OperationModel>> result = metadataService.getOperationMetadata(location);
    assertSuccessResult(result);
    ComponentMetadataDescriptor<OperationModel> descriptor = result.get();
    MetadataType param = descriptor.getModel().getOutput().getType();
    assertThat(param, is(instanceOf(ArrayType.class)));
    assertThat(getId(param).get(), is(List.class.getName()));
    return param;
}
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)

Example 5 with ComponentMetadataDescriptor

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

the class MetadataOperationTestCase method operationWhichReturnsListOfMessages.

@Test
public void operationWhichReturnsListOfMessages() throws Exception {
    location = Location.builder().globalName("listOfMessages").addProcessorsPart().addIndexPart(0).build();
    final MetadataResult<ComponentMetadataDescriptor<OperationModel>> result = metadataService.getOperationMetadata(location);
    assertSuccessResult(result);
    ComponentMetadataDescriptor<OperationModel> descriptor = result.get();
    MetadataType param = descriptor.getModel().getOutput().getType();
    assertThat(param, is(instanceOf(ArrayType.class)));
    assertMessageType(((ArrayType) param).getType(), TYPE_LOADER.load(String.class), TYPE_LOADER.load(StringAttributes.class));
}
Also used : MetadataType(org.mule.metadata.api.model.MetadataType) StringAttributes(org.mule.tck.message.StringAttributes) ComponentMetadataDescriptor(org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) 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