use of org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer in project mule by mulesoft.
the class JavaDeclarationDelegateTestCase method heisenbergPointer.
@Test
public void heisenbergPointer() throws Exception {
setLoader(loaderFor(HeisenbergPointer.class));
ExtensionDeclarer declarer = declareExtension();
ExtensionDeclaration extensionDeclaration = declarer.getDeclaration();
assertExtensionProperties(extensionDeclaration, OTHER_HEISENBERG);
assertTestModuleConfiguration(extensionDeclaration);
assertTestModuleOperations(extensionDeclaration);
assertTestModuleConnectionProviders(extensionDeclaration);
assertTestModuleMessageSource(extensionDeclaration);
assertModelProperties(extensionDeclaration);
}
use of org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer in project mule by mulesoft.
the class JavaDeclarationDelegateTestCase method categoryDefaultValueIsDescribedCorrectly.
@Test
public void categoryDefaultValueIsDescribedCorrectly() {
setLoader(loaderFor(PetStoreConnector.class));
ExtensionDeclarer declarer = declareExtension();
final ExtensionDeclaration declaration = declarer.getDeclaration();
assertThat(declaration.getCategory(), is(COMMUNITY));
}
use of org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer in project mule by mulesoft.
the class ImportedTypesDeclarationEnricher method enrich.
@Override
public void enrich(ExtensionLoadingContext extensionLoadingContext) {
ExtensionDeclarer descriptor = extensionLoadingContext.getExtensionDeclarer();
ExtensionDeclaration extensionDeclaration = descriptor.getDeclaration();
final Optional<ExtensionTypeDescriptorModelProperty> extensionType = extensionDeclaration.getModelProperty(ExtensionTypeDescriptorModelProperty.class);
if (!extensionType.isPresent()) {
return;
}
Type type = extensionType.get().getType();
final List<AnnotationValueFetcher<Import>> importTypes = parseRepeatableAnnotation(type, Import.class, c -> ((ImportedTypes) c).value());
if (!importTypes.isEmpty()) {
if (importTypes.stream().map(annotation -> annotation.getClassValue(Import::type)).distinct().collect(toList()).size() != importTypes.size()) {
throw new IllegalModelDefinitionException(format("There should be only one Import declaration for any given type in extension [%s]." + " Multiple imports of the same type are not allowed", extensionDeclaration.getName()));
}
importTypes.forEach(imported -> {
MetadataType importedType = imported.getClassValue(Import::type).asMetadataType();
if (!(importedType instanceof ObjectType)) {
throw new IllegalArgumentException(format("Type '%s' is not complex. Only complex types can be imported from other extensions.", type.getTypeName()));
}
extensionDeclaration.addImportedType(new ImportedTypeModel((ObjectType) importedType));
});
}
}
use of org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer in project mule by mulesoft.
the class JavaConfigurationDeclarationEnricherTestCase method setUp.
@Before
public void setUp() {
ExtensionDeclarer declarer = new DefaultJavaModelLoaderDelegate(HeisenbergExtension.class, getProductVersion()).declare(new DefaultExtensionLoadingContext(getClass().getClassLoader(), getDefault(emptySet())));
new JavaConfigurationDeclarationEnricher().enrich(new DefaultExtensionLoadingContext(declarer, this.getClass().getClassLoader(), getDefault(emptySet())));
declaration = declarer.getDeclaration();
}
use of org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer in project mule by mulesoft.
the class TargetParameterDeclarationEnricherTestCase method setUp.
@Before
public void setUp() {
ExtensionDeclarer declarer = new DefaultJavaModelLoaderDelegate(HeisenbergExtension.class, getProductVersion()).declare(new DefaultExtensionLoadingContext(getClass().getClassLoader(), getDefault(emptySet())));
new TargetParameterDeclarationEnricher().enrich(new DefaultExtensionLoadingContext(declarer, this.getClass().getClassLoader(), getDefault(emptySet())));
declaration = declarer.getDeclaration();
}
Aggregations