Search in sources :

Example 1 with JavaXmlDeclarationEnricher

use of org.mule.runtime.module.extension.internal.loader.enricher.JavaXmlDeclarationEnricher in project mule by mulesoft.

the class DefaultExtensionSchemaGeneratorTestCase method data.

@Parameterized.Parameters(name = "{1}")
public static Collection<Object[]> data() {
    final ClassLoader classLoader = DefaultExtensionSchemaGeneratorTestCase.class.getClassLoader();
    final ServiceRegistry serviceRegistry = mock(ServiceRegistry.class);
    when(serviceRegistry.lookupProviders(DeclarationEnricher.class, classLoader)).thenReturn(asList(new JavaXmlDeclarationEnricher()));
    final List<SchemaGeneratorTestUnit> extensions;
    extensions = asList(newTestUnit(javaLoader, MapConnector.class, "map.xsd"), newTestUnit(javaLoader, ListConnector.class, "list.xsd"), newTestUnit(javaLoader, TestConnector.class, "basic.xsd"), newTestUnit(javaLoader, StringListConnector.class, "string-list.xsd"), newTestUnit(javaLoader, GlobalPojoConnector.class, "global-pojo.xsd"), newTestUnit(javaLoader, GlobalInnerPojoConnector.class, "global-inner-pojo.xsd"), newTestUnit(javaLoader, VeganExtension.class, "vegan.xsd"), newTestUnit(javaLoader, PetStoreConnector.class, "petstore.xsd"), newTestUnit(javaLoader, MetadataExtension.class, "metadata.xsd"), newTestUnit(javaLoader, HeisenbergExtension.class, "heisenberg.xsd"), newTestUnit(javaLoader, SubstitutionGroupExtension.class, "substitutiongroup.xsd"), newTestUnit(javaLoader, TransactionalExtension.class, "tx-ext.xsd"), newTestUnit(javaLoader, SubTypesMappingConnector.class, "subtypes.xsd"), newTestUnit(javaLoader, MarvelExtension.class, "marvel.xsd"), newTestUnit(soapLoader, FootballSoapExtension.class, "soap.xsd"), newTestUnit(soapLoader, RickAndMortyExtension.class, "ram.xsd"), newTestUnit(javaLoader, TypedValueExtension.class, "typed-value.xsd"), newTestUnit(javaLoader, TestOAuthExtension.class, "test-oauth.xsd"), newTestUnit(javaLoader, WeaveFunctionExtension.class, "test-fn.xsd"), newTestUnit(javaLoader, ValuesExtension.class, "values.xsd"), newTestUnit(javaLoader, ReconnectionExtension.class, "reconnection-extension.xsd"));
    BiFunction<Class<?>, ExtensionModelLoader, ExtensionModel> createExtensionModel = (extension, loader) -> {
        ExtensionModel model = loadExtension(extension, loader);
        if (extensionModels.put(model.getName(), model) != null) {
            throw new IllegalArgumentException(format("Extension names must be unique. Name [%s] for extension [%s] was already used", model.getName(), extension.getName()));
        }
        return model;
    };
    return extensions.stream().map(e -> new Object[] { createExtensionModel.apply(e.getExtensionClass(), e.getLoader()), e.getFileName() }).collect(toList());
}
Also used : IOUtils.getResourceAsUrl(org.mule.runtime.core.api.util.IOUtils.getResourceAsUrl) TestOAuthExtension(org.mule.test.oauth.TestOAuthExtension) FootballSoapExtension(org.mule.test.soap.extension.FootballSoapExtension) BiFunction(java.util.function.BiFunction) MapConnector(org.mule.runtime.module.extension.internal.runtime.connectivity.basic.MapConnector) MetadataExtension(org.mule.test.metadata.extension.MetadataExtension) SmallTest(org.mule.tck.size.SmallTest) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) DslResolvingContext(org.mule.runtime.api.dsl.DslResolvingContext) ServiceRegistry(org.mule.runtime.core.api.registry.ServiceRegistry) DeclarationEnricher(org.mule.runtime.extension.api.loader.DeclarationEnricher) Parameterized(org.junit.runners.Parameterized) DefaultJavaExtensionModelLoader(org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader) Collection(java.util.Collection) Set(java.util.Set) String.format(java.lang.String.format) List(java.util.List) ExtensionSchemaGenerator(org.mule.runtime.extension.api.dsl.syntax.resources.spi.ExtensionSchemaGenerator) ListConnector(org.mule.runtime.module.extension.internal.runtime.connectivity.basic.ListConnector) Optional(java.util.Optional) IOUtils.getResourceAsString(org.mule.runtime.core.api.util.IOUtils.getResourceAsString) DslResolvingContext.getDefault(org.mule.runtime.api.dsl.DslResolvingContext.getDefault) FileUtils.stringToFile(org.mule.runtime.core.api.util.FileUtils.stringToFile) MarvelExtension(org.mule.test.marvel.MarvelExtension) Mockito.mock(org.mockito.Mockito.mock) MuleManifest.getProductVersion(org.mule.runtime.core.api.config.MuleManifest.getProductVersion) RickAndMortyExtension(org.mule.test.ram.RickAndMortyExtension) StringListConnector(org.mule.runtime.module.extension.internal.runtime.connectivity.basic.StringListConnector) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) TypeCatalog(org.mule.runtime.api.meta.type.TypeCatalog) WeaveFunctionExtension(org.mule.test.function.extension.WeaveFunctionExtension) SoapExtensionModelLoader(org.mule.runtime.module.extension.soap.api.loader.SoapExtensionModelLoader) GlobalInnerPojoConnector(org.mule.runtime.module.extension.internal.runtime.connectivity.basic.GlobalInnerPojoConnector) AbstractMuleTestCase(org.mule.tck.junit4.AbstractMuleTestCase) GlobalPojoConnector(org.mule.runtime.module.extension.internal.runtime.connectivity.basic.GlobalPojoConnector) TestConnector(org.mule.runtime.module.extension.internal.runtime.connectivity.basic.TestConnector) ExtensionModelLoader(org.mule.runtime.extension.api.loader.ExtensionModelLoader) HeisenbergExtension(org.mule.test.heisenberg.extension.HeisenbergExtension) LinkedHashSet(java.util.LinkedHashSet) TransactionalExtension(org.mule.test.transactional.TransactionalExtension) TypedValueExtension(org.mule.test.typed.value.extension.extension.TypedValueExtension) Before(org.junit.Before) DefaultExtensionSchemaGenerator(org.mule.runtime.module.extension.internal.capability.xml.schema.DefaultExtensionSchemaGenerator) ValuesExtension(org.mule.test.values.extension.ValuesExtension) ImmutableSet.copyOf(com.google.common.collect.ImmutableSet.copyOf) Optional.ofNullable(java.util.Optional.ofNullable) PetStoreConnector(org.mule.test.petstore.extension.PetStoreConnector) SubstitutionGroupExtension(org.mule.test.substitutiongroup.extension.SubstitutionGroupExtension) IOException(java.io.IOException) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) VERSION(org.mule.runtime.module.extension.api.loader.AbstractJavaExtensionModelLoader.VERSION) VeganExtension(org.mule.test.vegan.extension.VeganExtension) File(java.io.File) ExtensionsTestUtils.compareXML(org.mule.test.module.extension.internal.util.ExtensionsTestUtils.compareXML) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) Collectors.toList(java.util.stream.Collectors.toList) ReconnectionExtension(org.mule.extension.test.extension.reconnection.ReconnectionExtension) SchemaGeneratorTestUnit.newTestUnit(org.mule.runtime.module.extension.internal.capability.xml.DefaultExtensionSchemaGeneratorTestCase.SchemaGeneratorTestUnit.newTestUnit) TYPE_PROPERTY_NAME(org.mule.runtime.module.extension.api.loader.AbstractJavaExtensionModelLoader.TYPE_PROPERTY_NAME) SubTypesMappingConnector(org.mule.test.subtypes.extension.SubTypesMappingConnector) JavaXmlDeclarationEnricher(org.mule.runtime.module.extension.internal.loader.enricher.JavaXmlDeclarationEnricher) JavaXmlDeclarationEnricher(org.mule.runtime.module.extension.internal.loader.enricher.JavaXmlDeclarationEnricher) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) DefaultJavaExtensionModelLoader(org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader) SoapExtensionModelLoader(org.mule.runtime.module.extension.soap.api.loader.SoapExtensionModelLoader) ExtensionModelLoader(org.mule.runtime.extension.api.loader.ExtensionModelLoader) ServiceRegistry(org.mule.runtime.core.api.registry.ServiceRegistry)

Example 2 with JavaXmlDeclarationEnricher

use of org.mule.runtime.module.extension.internal.loader.enricher.JavaXmlDeclarationEnricher in project mule by mulesoft.

the class ExtensionModelJsonGeneratorTestCase method data.

@Parameterized.Parameters(name = "{1}")
public static Collection<Object[]> data() {
    final ClassLoader classLoader = ExtensionModelJsonGeneratorTestCase.class.getClassLoader();
    final ServiceRegistry serviceRegistry = mock(ServiceRegistry.class);
    when(serviceRegistry.lookupProviders(DeclarationEnricher.class, classLoader)).thenReturn(asList(new JavaXmlDeclarationEnricher()));
    List<ExtensionJsonGeneratorTestUnit> extensions;
    extensions = asList(newTestUnit(javaLoader, VeganExtension.class, "vegan.json"), newTestUnit(javaLoader, PetStoreConnector.class, "petstore.json"), newTestUnit(javaLoader, MetadataExtension.class, "metadata.json"), newTestUnit(javaLoader, HeisenbergExtension.class, "heisenberg.json"), newTestUnit(javaLoader, SubstitutionGroupExtension.class, "substitutiongroup.json"), newTestUnit(javaLoader, TransactionalExtension.class, "tx-ext.json"), newTestUnit(javaLoader, SubTypesMappingConnector.class, "subtypes.json"), newTestUnit(javaLoader, MarvelExtension.class, "marvel.json"), newTestUnit(soapLoader, RickAndMortyExtension.class, "ram.json"), newTestUnit(javaLoader, TypedValueExtension.class, "typed-value.json"), newTestUnit(javaLoader, TestOAuthExtension.class, "test-oauth.json"), newTestUnit(javaLoader, WeaveFunctionExtension.class, "test-fn.json"), newTestUnit(javaLoader, ValuesExtension.class, "values.json"), newTestUnit(javaLoader, ReconnectionExtension.class, "reconnection-extension.json"));
    BiFunction<Class<?>, ExtensionModelLoader, ExtensionModel> createExtensionModel = (extension, loader) -> {
        ExtensionModel model = loadExtension(extension, loader);
        if (extensionModels.put(model.getName(), model) != null) {
            throw new IllegalArgumentException(format("Extension names must be unique. Name [%s] for extension [%s] was already used", model.getName(), extension.getName()));
        }
        return model;
    };
    return extensions.stream().map(e -> new Object[] { createExtensionModel.apply(e.getExtensionClass(), e.getLoader()), e.getFileName() }).collect(toList());
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) IOUtils.getResourceAsUrl(org.mule.runtime.core.api.util.IOUtils.getResourceAsUrl) TestOAuthExtension(org.mule.test.oauth.TestOAuthExtension) URISyntaxException(java.net.URISyntaxException) BiFunction(java.util.function.BiFunction) MetadataExtension(org.mule.test.metadata.extension.MetadataExtension) SmallTest(org.mule.tck.size.SmallTest) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) DslResolvingContext(org.mule.runtime.api.dsl.DslResolvingContext) ServiceRegistry(org.mule.runtime.core.api.registry.ServiceRegistry) DeclarationEnricher(org.mule.runtime.extension.api.loader.DeclarationEnricher) Parameterized(org.junit.runners.Parameterized) ExtensionJsonGeneratorTestUnit.newTestUnit(org.mule.runtime.module.extension.internal.resources.ExtensionModelJsonGeneratorTestCase.ExtensionJsonGeneratorTestUnit.newTestUnit) DefaultJavaExtensionModelLoader(org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader) Collection(java.util.Collection) ExtensionModelJsonSerializer(org.mule.runtime.extension.api.persistence.ExtensionModelJsonSerializer) String.format(java.lang.String.format) List(java.util.List) IOUtils.getResourceAsString(org.mule.runtime.core.api.util.IOUtils.getResourceAsString) DslResolvingContext.getDefault(org.mule.runtime.api.dsl.DslResolvingContext.getDefault) FileUtils.stringToFile(org.mule.runtime.core.api.util.FileUtils.stringToFile) MarvelExtension(org.mule.test.marvel.MarvelExtension) Mockito.mock(org.mockito.Mockito.mock) RickAndMortyExtension(org.mule.test.ram.RickAndMortyExtension) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) WeaveFunctionExtension(org.mule.test.function.extension.WeaveFunctionExtension) JSONAssert(org.skyscreamer.jsonassert.JSONAssert) SoapExtensionModelLoader(org.mule.runtime.module.extension.soap.api.loader.SoapExtensionModelLoader) AbstractMuleTestCase(org.mule.tck.junit4.AbstractMuleTestCase) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ExtensionModelLoader(org.mule.runtime.extension.api.loader.ExtensionModelLoader) HeisenbergExtension(org.mule.test.heisenberg.extension.HeisenbergExtension) TransactionalExtension(org.mule.test.transactional.TransactionalExtension) TypedValueExtension(org.mule.test.typed.value.extension.extension.TypedValueExtension) Before(org.junit.Before) ValuesExtension(org.mule.test.values.extension.ValuesExtension) Collections.emptySet(java.util.Collections.emptySet) PetStoreConnector(org.mule.test.petstore.extension.PetStoreConnector) SubstitutionGroupExtension(org.mule.test.substitutiongroup.extension.SubstitutionGroupExtension) IOException(java.io.IOException) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) VERSION(org.mule.runtime.module.extension.api.loader.AbstractJavaExtensionModelLoader.VERSION) VeganExtension(org.mule.test.vegan.extension.VeganExtension) File(java.io.File) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) Collectors.toList(java.util.stream.Collectors.toList) ReconnectionExtension(org.mule.extension.test.extension.reconnection.ReconnectionExtension) TYPE_PROPERTY_NAME(org.mule.runtime.module.extension.api.loader.AbstractJavaExtensionModelLoader.TYPE_PROPERTY_NAME) SubTypesMappingConnector(org.mule.test.subtypes.extension.SubTypesMappingConnector) JavaXmlDeclarationEnricher(org.mule.runtime.module.extension.internal.loader.enricher.JavaXmlDeclarationEnricher) JavaXmlDeclarationEnricher(org.mule.runtime.module.extension.internal.loader.enricher.JavaXmlDeclarationEnricher) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) DefaultJavaExtensionModelLoader(org.mule.runtime.module.extension.api.loader.java.DefaultJavaExtensionModelLoader) SoapExtensionModelLoader(org.mule.runtime.module.extension.soap.api.loader.SoapExtensionModelLoader) ExtensionModelLoader(org.mule.runtime.extension.api.loader.ExtensionModelLoader) ServiceRegistry(org.mule.runtime.core.api.registry.ServiceRegistry)

Aggregations

File (java.io.File)2 IOException (java.io.IOException)2 String.format (java.lang.String.format)2 Arrays.asList (java.util.Arrays.asList)2 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 BiFunction (java.util.function.BiFunction)2 Collectors.toList (java.util.stream.Collectors.toList)2 Before (org.junit.Before)2 Test (org.junit.Test)2 RunWith (org.junit.runner.RunWith)2 Parameterized (org.junit.runners.Parameterized)2 Mockito.mock (org.mockito.Mockito.mock)2 Mockito.when (org.mockito.Mockito.when)2 ReconnectionExtension (org.mule.extension.test.extension.reconnection.ReconnectionExtension)2 DslResolvingContext (org.mule.runtime.api.dsl.DslResolvingContext)2 DslResolvingContext.getDefault (org.mule.runtime.api.dsl.DslResolvingContext.getDefault)2 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)2