Search in sources :

Example 1 with SimplePojo

use of org.mule.tests.parsers.api.SimplePojo in project mule by mulesoft.

the class TestParsersComponentBuildingDefinitionProvider method getComponentBuildingDefinitions.

@Override
public List<ComponentBuildingDefinition> getComponentBuildingDefinitions() {
    List<ComponentBuildingDefinition> definitions = new ArrayList<>();
    ComponentBuildingDefinition.Builder baseBuilder = new ComponentBuildingDefinition.Builder().withNamespace(TestParsersNamespaceInfoProvider.PARSERS_TEST_NAMESPACE);
    ComponentBuildingDefinition.Builder baseParameterCollectionParserBuilder = baseBuilder.withTypeDefinition(fromType(ParsersTestObject.class)).asNamed().withSetterParameterDefinition("simpleTypeWithConverter", fromChildConfiguration(String.class).build()).withSetterParameterDefinition("simpleTypeList", fromChildConfiguration(List.class).withWrapperIdentifier("simple-type-child-list").build()).withSetterParameterDefinition("simpleTypeListWithConverter", fromChildConfiguration(List.class).withWrapperIdentifier("simple-type-child-list-with-converter").build()).withSetterParameterDefinition("simpleTypeSet", fromChildConfiguration(Set.class).withWrapperIdentifier("simple-type-child-set").build()).withSetterParameterDefinition("simpleTypeMap", fromChildMapConfiguration(String.class, Integer.class).withWrapperIdentifier("simple-type-map").build()).withSetterParameterDefinition("simpleListTypeMap", fromChildMapConfiguration(String.class, String.class).withWrapperIdentifier("simple-list-type-map").build()).withSetterParameterDefinition("complexTypeMap", fromChildMapConfiguration(Long.class, ParsersTestObject.class).withWrapperIdentifier("complex-type-map").build()).withSetterParameterDefinition("simpleParameters", fromMultipleDefinitions(newBuilder().withAttributeDefinition(fromSimpleParameter("firstname").build()).withKey("firstname").build(), newBuilder().withAttributeDefinition(fromSimpleParameter("lastname").build()).withKey("lastname").build(), newBuilder().withAttributeDefinition(fromSimpleParameter("age").build()).withKey("age").build(), newBuilder().withAttributeDefinition(fromChildConfiguration(ParsersTestObject.class).withWrapperIdentifier("first-child").build()).withKey("first-child").build(), newBuilder().withAttributeDefinition(fromChildConfiguration(ParsersTestObject.class).withWrapperIdentifier("second-child").build()).withKey("second-child").build(), newBuilder().withAttributeDefinition(fromChildConfiguration(List.class).withWrapperIdentifier("other-children").build()).withKey("other-children").build(), newBuilder().withAttributeDefinition(fromChildConfiguration(List.class).withWrapperIdentifier("other-children-custom-collection-type").build()).withKey("other-children-custom-collection-type").build(), newBuilder().withAttributeDefinition(fromChildConfiguration(List.class).withWrapperIdentifier("other-simple-type-child-list").build()).withKey("other-simple-type-child-list-custom-key").build()).build());
    definitions.add(baseParameterCollectionParserBuilder.withIdentifier("parameter-collection-parser").build());
    definitions.add(baseParameterCollectionParserBuilder.withIdentifier("elementTypeA").build());
    definitions.add(baseParameterCollectionParserBuilder.withIdentifier("anotherElementTypeA").build());
    definitions.add(baseBuilder.withIdentifier("simple-type-child-list").withTypeDefinition(fromType(List.class)).build());
    definitions.add(baseBuilder.withIdentifier("simple-type-child-list-with-converter").withTypeDefinition(fromType(List.class)).build());
    definitions.add(baseBuilder.withIdentifier("other-children-custom-collection-type").withTypeDefinition(fromType(LinkedList.class)).build());
    definitions.add(baseBuilder.withIdentifier("other-children").withTypeDefinition(fromType(List.class)).build());
    definitions.add(baseBuilder.withIdentifier("simple-type-child-set").withTypeDefinition(fromType(TreeSet.class)).build());
    definitions.add(baseBuilder.withIdentifier("other-simple-type-child-list").withTypeDefinition(fromType(List.class)).build());
    definitions.add(baseBuilder.withIdentifier("simple-type-child").withTypeDefinition(fromType(String.class)).build());
    definitions.add(baseBuilder.withIdentifier("simple-type-child-with-converter").withTypeDefinition(fromType(String.class)).withTypeConverter(input -> input + "-with-converter").build());
    definitions.add(baseBuilder.withIdentifier("simple-type-map").withTypeDefinition(fromType(TreeMap.class)).build());
    definitions.add(baseBuilder.withIdentifier("simple-type-entry").withTypeDefinition(fromMapEntryType(String.class, Integer.class)).withKeyTypeConverter(input -> input + "-with-converter").withTypeConverter(input -> valueOf((String) input) + 1).build());
    definitions.add(baseBuilder.withIdentifier("simple-list-type-map").withTypeDefinition(fromType(Map.class)).build());
    definitions.add(baseBuilder.withIdentifier("simple-list-entry").withTypeDefinition(fromMapEntryType(String.class, List.class)).build());
    definitions.add(baseBuilder.withIdentifier("complex-type-map").withTypeDefinition(fromType(Map.class)).build());
    definitions.add(baseBuilder.withIdentifier("complex-type-entry").withTypeDefinition(fromMapEntryType(Long.class, ParsersTestObject.class)).build());
    definitions.add(baseBuilder.withIdentifier("global-element-with-object-factory").withTypeDefinition(fromType(LifecycleSensingMessageProcessor.class)).withObjectFactoryType(LifecycleSensingObjectFactory.class).build());
    definitions.add(baseBuilder.withIdentifier("inner-element-with-object-factory").withTypeDefinition(fromType(LifecycleSensingMessageProcessor.class)).withObjectFactoryType(LifecycleSensingObjectFactory.class).build());
    definitions.add(baseBuilder.withIdentifier("element-with-attribute-and-child").withTypeDefinition(fromType(ParameterAndChildElement.class)).withSetterParameterDefinition("simplePojo", fromSimpleParameter("myPojo", input -> new SimplePojo((String) input)).withDefaultValue("jose").build()).withSetterParameterDefinition("simplePojo", fromChildConfiguration(SimplePojo.class).build()).build());
    definitions.add(baseBuilder.withIdentifier("my-pojo").withTypeDefinition(fromType(SimplePojo.class)).withSetterParameterDefinition("someParameter", fromSimpleParameter("someParameter").build()).build());
    definitions.add(baseBuilder.withIdentifier("text-pojo").withTypeDefinition(fromType(SimplePojo.class)).withSetterParameterDefinition("someParameter", fromChildConfiguration(String.class).withIdentifier("text").build()).build());
    definitions.add(baseBuilder.withIdentifier("text").withTypeDefinition(fromType(String.class)).build());
    definitions.add(baseBuilder.withIdentifier("same-child-type-container").withTypeDefinition(fromType(PojoWithSameTypeChildren.class)).withSetterParameterDefinition("elementTypeA", fromChildConfiguration(ParsersTestObject.class).withIdentifier("elementTypeA").build()).withSetterParameterDefinition("anotherElementTypeA", fromChildConfiguration(ParsersTestObject.class).withIdentifier("anotherElementTypeA").build()).build());
    definitions.add(baseBuilder.withIdentifier("simple-type").withTypeConverter(o -> new SimplePojo((String) o)).withTypeDefinition(fromType(String.class)).build());
    definitions.add(baseBuilder.withIdentifier("component-created-with-object-factory").withObjectFactoryType(TestObjectFactory.class).withTypeDefinition(fromType(TestObject.class)).build());
    definitions.add(baseBuilder.withIdentifier("composite-processor-chain-router").withTypeDefinition(fromType(CompositeProcessorChainRouter.class)).withSetterParameterDefinition("processorChains", fromChildCollectionConfiguration(Object.class).build()).build());
    definitions.add(baseBuilder.withIdentifier("chain").withTypeDefinition(fromType(Component.class)).withObjectFactoryType(MessageProcessorChainObjectFactory.class).withSetterParameterDefinition("messageProcessors", fromChildCollectionConfiguration(Object.class).build()).build());
    definitions.add(baseBuilder.withIdentifier("processor-chain-router").withTypeDefinition(fromType(ProcessorChainRouter.class)).withSetterParameterDefinition("processors", fromChildCollectionConfiguration(Object.class).build()).build());
    return definitions;
}
Also used : LifecycleSensingMessageProcessor(org.mule.tests.parsers.api.LifecycleSensingMessageProcessor) KeyAttributeDefinitionPair.newBuilder(org.mule.runtime.dsl.api.component.KeyAttributeDefinitionPair.newBuilder) CompositeProcessorChainRouter(org.mule.runtime.core.privileged.processor.CompositeProcessorChainRouter) Builder.fromChildConfiguration(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromChildConfiguration) Builder.fromChildMapConfiguration(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromChildMapConfiguration) MessageProcessorChainObjectFactory(org.mule.runtime.core.privileged.processor.objectfactory.MessageProcessorChainObjectFactory) TreeSet(java.util.TreeSet) Builder.fromSimpleParameter(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromSimpleParameter) ComponentBuildingDefinitionProvider(org.mule.runtime.dsl.api.component.ComponentBuildingDefinitionProvider) ArrayList(java.util.ArrayList) TypeDefinition.fromMapEntryType(org.mule.runtime.dsl.api.component.TypeDefinition.fromMapEntryType) SimplePojo(org.mule.tests.parsers.api.SimplePojo) Component(org.mule.runtime.api.component.Component) Map(java.util.Map) Integer.valueOf(java.lang.Integer.valueOf) ProcessorChainRouter(org.mule.runtime.core.privileged.processor.ProcessorChainRouter) LinkedList(java.util.LinkedList) Builder.fromChildCollectionConfiguration(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromChildCollectionConfiguration) TestObjectFactory(org.mule.tests.parsers.api.TestObjectFactory) TypeDefinition.fromType(org.mule.runtime.dsl.api.component.TypeDefinition.fromType) ParsersTestObject(org.mule.tests.parsers.api.ParsersTestObject) Set(java.util.Set) Builder.fromMultipleDefinitions(org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromMultipleDefinitions) TestObject(org.mule.tests.parsers.api.TestObject) LifecycleSensingObjectFactory(org.mule.tests.parsers.api.LifecycleSensingObjectFactory) ComponentBuildingDefinition(org.mule.runtime.dsl.api.component.ComponentBuildingDefinition) List(java.util.List) TreeMap(java.util.TreeMap) PojoWithSameTypeChildren(org.mule.tests.parsers.api.PojoWithSameTypeChildren) ParameterAndChildElement(org.mule.tests.parsers.api.ParameterAndChildElement) TestObjectFactory(org.mule.tests.parsers.api.TestObjectFactory) TreeSet(java.util.TreeSet) Set(java.util.Set) ArrayList(java.util.ArrayList) ParameterAndChildElement(org.mule.tests.parsers.api.ParameterAndChildElement) ParsersTestObject(org.mule.tests.parsers.api.ParsersTestObject) TestObject(org.mule.tests.parsers.api.TestObject) TreeMap(java.util.TreeMap) PojoWithSameTypeChildren(org.mule.tests.parsers.api.PojoWithSameTypeChildren) SimplePojo(org.mule.tests.parsers.api.SimplePojo) LinkedList(java.util.LinkedList) MessageProcessorChainObjectFactory(org.mule.runtime.core.privileged.processor.objectfactory.MessageProcessorChainObjectFactory) TreeSet(java.util.TreeSet) ParsersTestObject(org.mule.tests.parsers.api.ParsersTestObject) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) ComponentBuildingDefinition(org.mule.runtime.dsl.api.component.ComponentBuildingDefinition) Component(org.mule.runtime.api.component.Component) Map(java.util.Map) TreeMap(java.util.TreeMap)

Aggregations

Integer.valueOf (java.lang.Integer.valueOf)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 TreeMap (java.util.TreeMap)1 TreeSet (java.util.TreeSet)1 Component (org.mule.runtime.api.component.Component)1 CompositeProcessorChainRouter (org.mule.runtime.core.privileged.processor.CompositeProcessorChainRouter)1 ProcessorChainRouter (org.mule.runtime.core.privileged.processor.ProcessorChainRouter)1 MessageProcessorChainObjectFactory (org.mule.runtime.core.privileged.processor.objectfactory.MessageProcessorChainObjectFactory)1 Builder.fromChildCollectionConfiguration (org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromChildCollectionConfiguration)1 Builder.fromChildConfiguration (org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromChildConfiguration)1 Builder.fromChildMapConfiguration (org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromChildMapConfiguration)1 Builder.fromMultipleDefinitions (org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromMultipleDefinitions)1 Builder.fromSimpleParameter (org.mule.runtime.dsl.api.component.AttributeDefinition.Builder.fromSimpleParameter)1 ComponentBuildingDefinition (org.mule.runtime.dsl.api.component.ComponentBuildingDefinition)1 ComponentBuildingDefinitionProvider (org.mule.runtime.dsl.api.component.ComponentBuildingDefinitionProvider)1 KeyAttributeDefinitionPair.newBuilder (org.mule.runtime.dsl.api.component.KeyAttributeDefinitionPair.newBuilder)1