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());
}
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();
}
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);
}
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);
}
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));
}
Aggregations