Search in sources :

Example 1 with ImmutableOutputModel

use of org.mule.runtime.extension.api.model.ImmutableOutputModel in project mule by mulesoft.

the class MetadataComponentModelValidatorTestCase method operationReturnsObjectType.

@Test
public void operationReturnsObjectType() {
    exception.expect(IllegalModelDefinitionException.class);
    when(operationModel.getOutput()).thenReturn(new ImmutableOutputModel(EMPTY, toMetadataType(Object.class), false, emptySet()));
    validate(extensionModel, validator);
}
Also used : ImmutableOutputModel(org.mule.runtime.extension.api.model.ImmutableOutputModel) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 2 with ImmutableOutputModel

use of org.mule.runtime.extension.api.model.ImmutableOutputModel in project mule by mulesoft.

the class MetadataComponentModelValidatorTestCase method sourceReturnsArrayTypeOfDictionaryWithObjectValue.

@Test
public void sourceReturnsArrayTypeOfDictionaryWithObjectValue() {
    arrayType = typeBuilder.arrayType().of(dictionaryType).build();
    exception.expect(IllegalModelDefinitionException.class);
    when(sourceModel.getOutput()).thenReturn(new ImmutableOutputModel("", arrayType, false, emptySet()));
    validate(extensionModel, validator);
}
Also used : ImmutableOutputModel(org.mule.runtime.extension.api.model.ImmutableOutputModel) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 3 with ImmutableOutputModel

use of org.mule.runtime.extension.api.model.ImmutableOutputModel in project mule by mulesoft.

the class MetadataComponentModelValidatorTestCase method before.

@Before
public void before() {
    when(extensionModel.getOperationModels()).thenReturn(asList(operationModel));
    when(extensionModel.getSourceModels()).thenReturn(asList(sourceModel));
    ExtensionTypeDescriptorModelProperty descriptorModelProperty = mock(ExtensionTypeDescriptorModelProperty.class);
    when(extensionModel.getModelProperty(ExtensionTypeDescriptorModelProperty.class)).thenReturn(of(descriptorModelProperty));
    Type extensionType = mock(Type.class);
    when(descriptorModelProperty.getType()).thenReturn(extensionType);
    when(extensionType.getDeclaringClass()).thenReturn(of(this.getClass()));
    when(operationModel.getOutput()).thenReturn(new ImmutableOutputModel(EMPTY, toMetadataType(String.class), false, emptySet()));
    when(operationModel.getOutputAttributes()).thenReturn(new ImmutableOutputModel(StringUtils.EMPTY, create(JAVA).voidType().build(), false, emptySet()));
    when(operationModel.getName()).thenReturn("operation");
    mockMetadataResolverFactory(operationModel, null);
    when(sourceModel.getOutput()).thenReturn(new ImmutableOutputModel(EMPTY, toMetadataType(String.class), false, emptySet()));
    when(sourceModel.getOutputAttributes()).thenReturn(new ImmutableOutputModel(StringUtils.EMPTY, create(JAVA).voidType().build(), false, emptySet()));
    when(sourceModel.getName()).thenReturn("source");
    when(sourceModel.getSuccessCallback()).thenReturn(of(sourceCallbackModel));
    when(sourceModel.getErrorCallback()).thenReturn(of(sourceCallbackModel));
    mockMetadataResolverFactory(sourceModel, null);
    MetadataKeyIdModelProperty keyIdModelProperty = new MetadataKeyIdModelProperty(loader.load(InvalidMetadataKeyIdPojo.class), EMPTY);
    when(sourceModel.getModelProperty(MetadataKeyIdModelProperty.class)).thenReturn(of(keyIdModelProperty));
    when(operationModel.getModelProperty(MetadataKeyIdModelProperty.class)).thenReturn(empty());
    when(sourceModel.getModelProperty(ExtensionOperationDescriptorModelProperty.class)).thenReturn(empty());
    when(operationModel.getModelProperty(ExtensionOperationDescriptorModelProperty.class)).thenReturn(empty());
    visitableMock(operationModel, sourceModel);
    dictionaryType = typeBuilder.objectType().openWith(toMetadataType(Object.class)).build();
}
Also used : ImmutableOutputModel(org.mule.runtime.extension.api.model.ImmutableOutputModel) Type(org.mule.runtime.module.extension.api.loader.java.type.Type) ArrayType(org.mule.metadata.api.model.ArrayType) ObjectType(org.mule.metadata.api.model.ObjectType) MetadataType(org.mule.metadata.api.model.MetadataType) ExtensionsTestUtils.toMetadataType(org.mule.test.module.extension.internal.util.ExtensionsTestUtils.toMetadataType) MetadataKeyIdModelProperty(org.mule.runtime.extension.api.property.MetadataKeyIdModelProperty) ExtensionTypeDescriptorModelProperty(org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionTypeDescriptorModelProperty) Before(org.junit.Before)

Example 4 with ImmutableOutputModel

use of org.mule.runtime.extension.api.model.ImmutableOutputModel in project mule by mulesoft.

the class MetadataComponentModelValidatorTestCase method operationReturnsDictionaryTypeWithObjectTypeValue.

@Test
public void operationReturnsDictionaryTypeWithObjectTypeValue() {
    exception.expect(IllegalModelDefinitionException.class);
    when(operationModel.getOutput()).thenReturn(new ImmutableOutputModel("", dictionaryType, false, emptySet()));
    validate(extensionModel, validator);
}
Also used : ImmutableOutputModel(org.mule.runtime.extension.api.model.ImmutableOutputModel) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 5 with ImmutableOutputModel

use of org.mule.runtime.extension.api.model.ImmutableOutputModel in project mule by mulesoft.

the class MetadataComponentModelValidatorTestCase method sourceReturnsObjectTypeWithDefinedOutputResolver.

@Test
public void sourceReturnsObjectTypeWithDefinedOutputResolver() {
    when(sourceModel.getOutput()).thenReturn(new ImmutableOutputModel(EMPTY, toMetadataType(Object.class), false, emptySet()));
    mockMetadataResolverFactory(sourceModel, new DefaultMetadataResolverFactory(NULL_RESOLVER_SUPPLIER, emptyMap(), SIMPLE_OUTPUT_RESOLVER, NULL_RESOLVER_SUPPLIER));
    validate(extensionModel, validator);
}
Also used : ImmutableOutputModel(org.mule.runtime.extension.api.model.ImmutableOutputModel) DefaultMetadataResolverFactory(org.mule.runtime.core.internal.metadata.DefaultMetadataResolverFactory) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Aggregations

ImmutableOutputModel (org.mule.runtime.extension.api.model.ImmutableOutputModel)17 Test (org.junit.Test)12 SmallTest (org.mule.tck.size.SmallTest)12 DefaultMetadataResolverFactory (org.mule.runtime.core.internal.metadata.DefaultMetadataResolverFactory)5 Before (org.junit.Before)4 MetadataKeyIdModelProperty (org.mule.runtime.extension.api.property.MetadataKeyIdModelProperty)3 MetadataType (org.mule.metadata.api.model.MetadataType)2 NullMetadataResolver (org.mule.runtime.extension.api.metadata.NullMetadataResolver)2 ExecutionContext (org.mule.runtime.extension.api.runtime.operation.ExecutionContext)2 TestNoConfigMetadataResolver (org.mule.test.metadata.extension.resolver.TestNoConfigMetadataResolver)2 ExtensionsTestUtils.toMetadataType (org.mule.test.module.extension.internal.util.ExtensionsTestUtils.toMetadataType)2 Map (java.util.Map)1 Matchers.anyMap (org.mockito.Matchers.anyMap)1 Matchers.anyObject (org.mockito.Matchers.anyObject)1 Matchers.anyString (org.mockito.Matchers.anyString)1 ArrayType (org.mule.metadata.api.model.ArrayType)1 ObjectType (org.mule.metadata.api.model.ObjectType)1 NotificationDispatcher (org.mule.runtime.api.notification.NotificationDispatcher)1 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)1 NoRetryPolicyTemplate (org.mule.runtime.core.api.retry.policy.NoRetryPolicyTemplate)1