Search in sources :

Example 1 with SubTypesModel

use of org.mule.runtime.api.meta.model.SubTypesModel in project mule by mulesoft.

the class SubtypesModelValidatorTestCase method invalidAbstractSubtypes.

@Test(expected = IllegalModelDefinitionException.class)
public void invalidAbstractSubtypes() {
    Set<SubTypesModel> subTypes = new LinkedHashSet<>();
    subTypes.add(new SubTypesModel(toMetadataType(BaseAbstractPojo.class), singleton(toMetadataType(AbstractPojo.class))));
    subTypes.add(new SubTypesModel(toMetadataType(BaseCustomInterface.class), singleton(toMetadataType(CustomInterface.class))));
    when(extensionModel.getSubTypes()).thenReturn(subTypes);
    when(extensionModel.getImportedTypes()).thenReturn(emptySet());
    validate(extensionModel, new JavaSubtypesModelValidator());
}
Also used : LinkedHashSet(java.util.LinkedHashSet) SubTypesModel(org.mule.runtime.api.meta.model.SubTypesModel) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 2 with SubTypesModel

use of org.mule.runtime.api.meta.model.SubTypesModel in project mule by mulesoft.

the class NameClashModelValidatorTestCase method topLevelParameterClashOnSubtypeWithDifferentType.

@Test
public void topLevelParameterClashOnSubtypeWithDifferentType() {
    exception.expect(IllegalModelDefinitionException.class);
    ParameterModel offending = getParameter(TOP_LEVEL_SINGULAR_PARAM_NAME, TopLevelTest.class);
    mockParameters(operationModel, offending);
    when(extensionModel.getSubTypes()).thenReturn(ImmutableSet.of(new SubTypesModel(toMetadataType(ChildTest.class), ImmutableSet.of(toMetadataType(TopLevelSubtype.class)))));
    validate();
}
Also used : SubTypesModel(org.mule.runtime.api.meta.model.SubTypesModel) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 3 with SubTypesModel

use of org.mule.runtime.api.meta.model.SubTypesModel in project mule by mulesoft.

the class InputParameterTypesValidatorTestCase method validModelDueSubtypeWithoutGetterNotUsedAsInputParameter.

@Test
public void validModelDueSubtypeWithoutGetterNotUsedAsInputParameter() {
    SubTypesModel subTypesModel = new SubTypesModel(toMetadataType(BaseType.class), ImmutableSet.of(toMetadataType(PojoWithParameterWithoutGetter.class)));
    when(extensionModel.getSubTypes()).thenReturn(ImmutableSet.of(subTypesModel));
    when(extensionModel.getOperationModels()).thenReturn(emptyList());
    validate(extensionModel, validator);
}
Also used : SubTypesModel(org.mule.runtime.api.meta.model.SubTypesModel) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 4 with SubTypesModel

use of org.mule.runtime.api.meta.model.SubTypesModel in project mule by mulesoft.

the class InputParameterTypesValidatorTestCase method validateOperationParameterOfType.

private void validateOperationParameterOfType(MetadataType operationParameterType) {
    when(invalidParameterModel.getType()).thenReturn(operationParameterType);
    when(invalidParameterModel.getName()).thenReturn("pojos");
    when(operationModel.getAllParameterModels()).thenReturn(asList(invalidParameterModel));
    SubTypesModel subTypesModel = new SubTypesModel(toMetadataType(BaseType.class), ImmutableSet.of(toMetadataType(PojoWithParameterWithoutGetter.class), toMetadataType(PojoWithParameterWithGetter.class)));
    when(extensionModel.getSubTypes()).thenReturn(ImmutableSet.of(subTypesModel));
    validate(extensionModel, validator);
}
Also used : SubTypesModel(org.mule.runtime.api.meta.model.SubTypesModel)

Example 5 with SubTypesModel

use of org.mule.runtime.api.meta.model.SubTypesModel in project mule by mulesoft.

the class CoreExtensionModelTestCase method otherModels.

@Test
public void otherModels() {
    assertThat(coreExtensionModel.getResources(), empty());
    assertThat(coreExtensionModel.getSubTypes(), hasSize(1));
    SubTypesModel subTypesModel = coreExtensionModel.getSubTypes().iterator().next();
    assertThat(subTypesModel.getBaseType().getAnnotation(TypeIdAnnotation.class).get().getValue(), is(Scheduler.class.getName()));
    assertThat(subTypesModel.getSubTypes(), hasSize(2));
    Iterator<ObjectType> iterator = subTypesModel.getSubTypes().iterator();
    final DefaultObjectType ffSchedulerType = (DefaultObjectType) iterator.next();
    assertThat(ffSchedulerType.getFields(), hasSize(3));
    assertThat(ffSchedulerType.getFieldByName("frequency").get().isRequired(), is(false));
    assertThat(ffSchedulerType.getFieldByName("frequency").get().getValue(), instanceOf(DefaultNumberType.class));
    assertThat(ffSchedulerType.getFieldByName("startDelay").get().isRequired(), is(false));
    assertThat(ffSchedulerType.getFieldByName("startDelay").get().getValue(), instanceOf(DefaultNumberType.class));
    assertThat(ffSchedulerType.getFieldByName("timeUnit").get().isRequired(), is(false));
    assertThat(ffSchedulerType.getFieldByName("timeUnit").get().getValue(), instanceOf(DefaultStringType.class));
    final DefaultObjectType cronSchedulerType = (DefaultObjectType) iterator.next();
    assertThat(cronSchedulerType.getFields(), hasSize(2));
    assertThat(cronSchedulerType.getFieldByName("expression").get().isRequired(), is(true));
    assertThat(cronSchedulerType.getFieldByName("expression").get().getValue(), instanceOf(DefaultStringType.class));
    assertThat(cronSchedulerType.getFieldByName("timeZone").get().isRequired(), is(true));
    assertThat(cronSchedulerType.getFieldByName("timeZone").get().getValue(), instanceOf(DefaultStringType.class));
    assertThat(coreExtensionModel.getExternalLibraryModels(), empty());
    assertThat(coreExtensionModel.getImportedTypes(), empty());
    assertThat(coreExtensionModel.getConfigurationModels(), empty());
    assertThat(coreExtensionModel.getOperationModels(), hasSize(8));
    assertThat(coreExtensionModel.getConstructModels(), hasSize(15));
    assertThat(coreExtensionModel.getConnectionProviders(), empty());
    assertThat(coreExtensionModel.getSourceModels(), hasSize(1));
    assertThat(coreExtensionModel.getErrorModels(), hasItem(newError(TRANSFORMATION).withParent(errorMuleAny).build()));
    assertThat(coreExtensionModel.getTypes(), hasSize(5));
}
Also used : SubTypesModel(org.mule.runtime.api.meta.model.SubTypesModel) ObjectType(org.mule.metadata.api.model.ObjectType) DefaultObjectType(org.mule.metadata.api.model.impl.DefaultObjectType) DefaultNumberType(org.mule.metadata.api.model.impl.DefaultNumberType) DefaultObjectType(org.mule.metadata.api.model.impl.DefaultObjectType) DefaultStringType(org.mule.metadata.api.model.impl.DefaultStringType) TypeIdAnnotation(org.mule.metadata.api.annotation.TypeIdAnnotation) Test(org.junit.Test)

Aggregations

SubTypesModel (org.mule.runtime.api.meta.model.SubTypesModel)9 Test (org.junit.Test)7 SmallTest (org.mule.tck.size.SmallTest)6 ParameterModel (org.mule.runtime.api.meta.model.parameter.ParameterModel)2 LinkedHashSet (java.util.LinkedHashSet)1 TypeIdAnnotation (org.mule.metadata.api.annotation.TypeIdAnnotation)1 ObjectType (org.mule.metadata.api.model.ObjectType)1 DefaultNumberType (org.mule.metadata.api.model.impl.DefaultNumberType)1 DefaultObjectType (org.mule.metadata.api.model.impl.DefaultObjectType)1 DefaultStringType (org.mule.metadata.api.model.impl.DefaultStringType)1 DefaultPortalGunDispatcherProvider (org.mule.test.ram.DefaultPortalGunDispatcherProvider)1 MiniverseDispatcherProvider (org.mule.test.ram.MiniverseDispatcherProvider)1 TestHttpMessageDispatcherProvider (org.mule.test.ram.TestHttpMessageDispatcherProvider)1