use of org.mule.runtime.api.meta.model.stereotype.StereotypeModel in project mule by mulesoft.
the class DefaultExtensionModelFactoryTestCase method validatorStereotype.
@Test
public void validatorStereotype() {
ExtensionModel extensionModel = createExtension(HeisenbergExtension.class);
OperationModel operation = extensionModel.getOperationModel("validateMoney").get();
StereotypeModel stereotypeModel = operation.getStereotype();
assertThat(stereotypeModel.isAssignableTo(PROCESSOR), is(true));
assertThat(stereotypeModel.isAssignableTo(VALIDATOR), is(true));
assertThat(stereotypeModel.getType(), is(VALIDATOR_DEFINITION.getName()));
assertThat(stereotypeModel.getNamespace(), is(HEISENBERG.toUpperCase()));
assertThat(stereotypeModel.getParent().get(), is(VALIDATOR));
}
use of org.mule.runtime.api.meta.model.stereotype.StereotypeModel in project mule by mulesoft.
the class DefaultExtensionModelFactoryTestCase method objectStoreParameters.
@Test
public void objectStoreParameters() {
ExtensionModel extensionModel = createExtension(HeisenbergExtension.class);
OperationModel operationModel = extensionModel.getOperationModel("storeMoney").get();
ParameterModel parameter = operationModel.getAllParameterModels().stream().filter(p -> "objectStore".equals(p.getName())).findFirst().get();
StereotypeModel stereotype = parameter.getAllowedStereotypes().stream().filter(s -> s.getType().equals(OBJECT_STORE.getType())).findFirst().get();
assertThat(stereotype.getNamespace(), equalTo(OBJECT_STORE.getNamespace()));
Optional<ImportedTypeModel> typeImport = extensionModel.getImportedTypes().stream().filter(i -> getTypeId(i.getImportedType()).map(id -> ObjectStore.class.getName().equals(id)).orElse(false)).findFirst();
assertThat(typeImport.isPresent(), is(true));
}
use of org.mule.runtime.api.meta.model.stereotype.StereotypeModel in project mule by mulesoft.
the class DefaultExtensionModelFactoryTestCase method defaultStereotype.
@Test
public void defaultStereotype() {
ExtensionModel extensionModel = createExtension(VeganExtension.class);
OperationModel operation = extensionModel.getConfigurationModel(APPLE).get().getOperationModel("eatApple").get();
StereotypeModel stereotypeModel = operation.getStereotype();
assertThat(stereotypeModel.isAssignableTo(PROCESSOR), is(true));
assertThat(stereotypeModel.getType(), is(PROCESSOR_DEFINITION.getName()));
assertThat(stereotypeModel.getNamespace(), is("MULE"));
assertThat(stereotypeModel.getParent().isPresent(), is(false));
}
use of org.mule.runtime.api.meta.model.stereotype.StereotypeModel in project mule by mulesoft.
the class ParameterAllowedStereotypesDeclarionEnricher method getStereotypes.
private List<StereotypeModel> getStereotypes(AnnotatedElement element) {
ConfigReferences references = element.getAnnotation(ConfigReferences.class);
if (references != null) {
return stream(references.value()).map(ref -> newStereotype(ref.name(), ref.namespace()).withParent(CONFIG).build()).collect(toList());
}
ConfigReference ref = element.getAnnotation(ConfigReference.class);
if (ref != null) {
return singletonList(newStereotype(ref.name(), ref.namespace()).withParent(CONFIG).build());
}
if (element.getAnnotation(FlowReference.class) != null) {
return singletonList(FLOW);
}
if (element.getAnnotation(ObjectStoreReference.class) != null) {
return singletonList(OBJECT_STORE);
}
return emptyList();
}
use of org.mule.runtime.api.meta.model.stereotype.StereotypeModel in project mule by mulesoft.
the class StereotypesDeclarationEnricherTestCase method assertStereotype.
private void assertStereotype(StereotypeModel stereotypeModel, String ns, String name, StereotypeModel parent) {
StereotypeModel expected = newStereotype(name, ns).withParent(parent).build();
assertThat(stereotypeModel.getNamespace(), is(expected.getNamespace()));
assertThat(stereotypeModel.getType(), is(expected.getType()));
if (stereotypeModel.getParent().isPresent()) {
assertThat(expected.getParent().isPresent(), is(true));
assertStereotype(stereotypeModel.getParent().get(), parent.getNamespace(), parent.getType(), parent.getParent().orElse(null));
} else {
assertThat(expected.getParent().isPresent(), is(false));
}
}
Aggregations