Search in sources :

Example 1 with ExtensionSchemaGenerator

use of org.mule.runtime.extension.api.dsl.syntax.resources.spi.ExtensionSchemaGenerator in project mule by mulesoft.

the class ExtensionsTestInfrastructureDiscoverer method generateSchemaTestResource.

public void generateSchemaTestResource(ExtensionModel model, File generatedResourcesDirectory) {
    String xsdFileName = model.getXmlDslModel().getXsdFileName();
    try {
        ExtensionSchemaGenerator schemaGenerator = getSchemaGenerator();
        Set<ExtensionModel> models = new HashSet<>(extensionManager.getExtensions());
        models.add(MuleExtensionModelProvider.getExtensionModel());
        String schema = schemaGenerator.generate(model, DslResolvingContext.getDefault(models));
        File xsd = FileUtils.newFile(generatedResourcesDirectory, xsdFileName);
        FileUtils.copyStreamToFile(new ByteArrayInputStream(schema.getBytes()), xsd);
    } catch (IOException e) {
        throw new RuntimeException(format("Error generating test xsd resource [%s]: " + e.getMessage(), xsdFileName, e));
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ExtensionSchemaGenerator(org.mule.runtime.extension.api.dsl.syntax.resources.spi.ExtensionSchemaGenerator) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) IOException(java.io.IOException) File(java.io.File) HashSet(java.util.HashSet)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)1 ExtensionSchemaGenerator (org.mule.runtime.extension.api.dsl.syntax.resources.spi.ExtensionSchemaGenerator)1