use of org.mule.runtime.extension.api.resources.GeneratedResource in project mule by mulesoft.
the class ExtensionsTestLoaderResourcesGenerator method dumpAll.
List<GeneratedResource> dumpAll() {
List<GeneratedResource> allResources = contents.entrySet().stream().map(entry -> new GeneratedResource(entry.getKey(), entry.getValue().toString().getBytes())).collect(toImmutableList());
allResources.forEach(resource -> {
File targetFile = new File(resource.getPath());
try {
stringToFile(targetFile.getAbsolutePath(), new String(resource.getContent()));
} catch (IOException e) {
throw new RuntimeException(e);
}
});
return allResources;
}
use of org.mule.runtime.extension.api.resources.GeneratedResource in project mule by mulesoft.
the class AbstractXmlResourceFactory method generateResource.
@Override
public Optional<GeneratedResource> generateResource(ExtensionModel extensionModel) {
Set<ImportedTypeModel> importedTypes = extensionModel.getImportedTypes();
DslResolvingContext dslContext = importedTypes.isEmpty() ? new NullDslResolvingContext() : new ClasspathBasedDslContext(extensionModel.getModelProperty(ImplementingTypeModelProperty.class).map(mp -> mp.getType().getClassLoader()).orElse(Thread.currentThread().getContextClassLoader()));
return generateResource(extensionModel, dslContext);
}
use of org.mule.runtime.extension.api.resources.GeneratedResource in project mule by mulesoft.
the class ExtensionDescriptionDocumenterTestCase method persistDocumentation.
@Test
public void persistDocumentation() throws Exception {
InputStream in = getClass().getResourceAsStream(expectedProductPath);
assertThat(in, is(notNullValue()));
String expectedXml = IOUtils.toString(in);
TestProcessor processor = new TestProcessor(extensionClass);
doCompile(processor);
ExtensionDocumentationResourceGenerator generator = new ExtensionDocumentationResourceGenerator();
GeneratedResource resource = generator.generateResource(processor.getExtensionModel()).orElseThrow(() -> new RuntimeException("No Documentation Generated"));
compareXML(expectedXml, new String(resource.getContent()));
}
use of org.mule.runtime.extension.api.resources.GeneratedResource in project mule by mulesoft.
the class ExtensionDocumentationResourceGenerator method generateResource.
@Override
public Optional<GeneratedResource> generateResource(ExtensionModel extensionModel) {
final ExtensionDescriptionsSerializer serializer = new ExtensionDescriptionsSerializer();
ExtensionDocumenterWalker walker = new ExtensionDocumenterWalker();
walker.walk(extensionModel);
String documenter = serializer.serialize(getDocumenter(extensionModel, walker.getConfigs(), walker.getConnections(), walker.getOperations(), walker.getSources(), getTypesDocumentation(extensionModel)));
return Optional.of(new GeneratedResource(serializer.getFileName(extensionModel.getName()), documenter.getBytes()));
}
Aggregations