Search in sources :

Example 1 with DefaultExtensionSchemaGenerator

use of org.mule.runtime.module.extension.internal.capability.xml.schema.DefaultExtensionSchemaGenerator in project mule by mulesoft.

the class ExtensionResourcesGeneratorAnnotationProcessorTestCase method generateDocumentedSchema.

@Test
public void generateDocumentedSchema() throws Exception {
    ArgumentCaptor<ByteSource> byteSourceCaptor = ArgumentCaptor.forClass(ByteSource.class);
    ByteSource byteSource = mock(ByteSource.class);
    when(byteSource.contentEquals(byteSourceCaptor.capture())).thenReturn(true);
    DefaultJavaExtensionModelLoader loader = new DefaultJavaExtensionModelLoader();
    ExtensionModel model = loader.loadExtensionModel(TestExtensionWithDocumentationAndMultipleConfig.class.getClassLoader(), DslResolvingContext.getDefault(emptySet()), ImmutableMap.<String, Object>builder().put(TYPE_PROPERTY_NAME, TestExtensionWithDocumentationAndMultipleConfig.class.getName()).put(VERSION, "4.0.0").build());
    String generatedSchema = new DefaultExtensionSchemaGenerator().generate(model, DslResolvingContext.getDefault(emptySet()));
    assertThat(generatedSchema, is(notNullValue()));
    assertXpath(generatedSchema, "//xs:attribute[@name='configParameter']/xs:annotation/xs:documentation", "Config parameter");
    assertXpath(generatedSchema, "//xs:attribute[@name='configParameterWithComplexJavadoc']/xs:annotation/xs:documentation", "Config Parameter with an Optional value");
    assertXpath(generatedSchema, "//xs:attribute[@name='value1']/xs:annotation/xs:documentation", GROUP_PARAMETER_1);
    assertXpath(generatedSchema, "//xs:attribute[@name='value2']/xs:annotation/xs:documentation", GROUP_PARAMETER_2);
    assertXpath(generatedSchema, "//xs:element[@name='operation']/xs:annotation/xs:documentation", "Test Operation");
    assertXpath(generatedSchema, "//xs:complexType[@name='OperationType']/xs:complexContent/xs:extension/xs:attribute[@name='value']/xs:annotation/xs:documentation", "test value");
    assertXpath(generatedSchema, "//xs:complexType[@name='OperationType']/xs:complexContent/xs:extension/xs:attribute[@name='value1']/xs:annotation/xs:documentation", GROUP_PARAMETER_1);
    assertXpath(generatedSchema, "//xs:complexType[@name='OperationType']/xs:complexContent/xs:extension/xs:attribute[@name='value2']/xs:annotation/xs:documentation", GROUP_PARAMETER_2);
    assertXpath(generatedSchema, "//xs:element[@name='ignore-operation-should-be-ignored']/xs:annotation/xs:documentation", "");
    assertXpath(generatedSchema, "//xs:element[@name='private-operation-should-be-ignored']/xs:annotation/xs:documentation", "");
    assertXpath(generatedSchema, "//xs:element[@name='operation-with-blank-parameter-description']/xs:annotation/xs:documentation", "Test Operation with blank parameter description");
    assertXpath(generatedSchema, "//xs:complexType[@name='OperationWithBlankParameterDescriptionType']/xs:complexContent/xs:extension/xs:attribute[@name='value']/xs:annotation/xs:documentation", "");
    assertXpath(generatedSchema, "//xs:element[@name='operation-with-javadoc-link-references']/xs:annotation/xs:documentation", "Operation that returns a String value");
    assertXpath(generatedSchema, "//xs:complexType[@name='OperationWithJavadocLinkReferencesType']/xs:complexContent/xs:extension/xs:attribute[@name='value']/xs:annotation/xs:documentation", "this is the String to be returned");
}
Also used : DefaultExtensionSchemaGenerator(org.mule.runtime.module.extension.internal.capability.xml.schema.DefaultExtensionSchemaGenerator) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) ByteSource(com.google.common.io.ByteSource) DefaultJavaExtensionModelLoader(org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader) TestExtensionWithDocumentationAndMultipleConfig(org.mule.runtime.module.extension.internal.capability.xml.extension.multiple.config.TestExtensionWithDocumentationAndMultipleConfig) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Aggregations

ByteSource (com.google.common.io.ByteSource)1 Test (org.junit.Test)1 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)1 DefaultJavaExtensionModelLoader (org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader)1 TestExtensionWithDocumentationAndMultipleConfig (org.mule.runtime.module.extension.internal.capability.xml.extension.multiple.config.TestExtensionWithDocumentationAndMultipleConfig)1 DefaultExtensionSchemaGenerator (org.mule.runtime.module.extension.internal.capability.xml.schema.DefaultExtensionSchemaGenerator)1 SmallTest (org.mule.tck.size.SmallTest)1