Search in sources :

Example 11 with ObjectTypeVisitor

use of org.mule.runtime.config.internal.dsl.processor.ObjectTypeVisitor in project mule by mulesoft.

the class ObjectTypeVisitorTestCase method testFailsIfTypeIsNotOfCheckedClass.

@Test
public void testFailsIfTypeIsNotOfCheckedClass() throws ClassNotFoundException {
    exception.expect(MuleRuntimeException.class);
    exception.expectMessage("is not the same nor inherits from");
    ComponentModel componentModel = new SpringComponentModel();
    componentModel.setParameter("type", this.getClass().getName());
    ObjectTypeVisitor visitor = new ObjectTypeVisitor(componentModel);
    TypeDefinition typeDefinition = fromConfigurationAttribute("type").checkingThatIsClassOrInheritsFrom(ReferenceProcessor.class);
    typeDefinition.visit(visitor);
}
Also used : SpringComponentModel(org.mule.runtime.config.internal.dsl.model.SpringComponentModel) ComponentModel(org.mule.runtime.config.internal.model.ComponentModel) SpringComponentModel(org.mule.runtime.config.internal.dsl.model.SpringComponentModel) ObjectTypeVisitor(org.mule.runtime.config.internal.dsl.processor.ObjectTypeVisitor) TypeDefinition(org.mule.runtime.dsl.api.component.TypeDefinition) Test(org.junit.Test)

Example 12 with ObjectTypeVisitor

use of org.mule.runtime.config.internal.dsl.processor.ObjectTypeVisitor in project mule by mulesoft.

the class ObjectTypeVisitorTestCase method typeIsInstanceOfGivenClass.

@Test
public void typeIsInstanceOfGivenClass() {
    ObjectTypeVisitor visitor = new ObjectTypeVisitor(new SpringComponentModel());
    TypeDefinition typeDefinition = fromType(String.class);
    typeDefinition.visit(visitor);
    assertTrue(String.class.isAssignableFrom(visitor.getType()));
}
Also used : SpringComponentModel(org.mule.runtime.config.internal.dsl.model.SpringComponentModel) ObjectTypeVisitor(org.mule.runtime.config.internal.dsl.processor.ObjectTypeVisitor) TypeDefinition(org.mule.runtime.dsl.api.component.TypeDefinition) Test(org.junit.Test)

Aggregations

ObjectTypeVisitor (org.mule.runtime.config.internal.dsl.processor.ObjectTypeVisitor)12 SpringComponentModel (org.mule.runtime.config.internal.dsl.model.SpringComponentModel)10 ComponentModel (org.mule.runtime.config.internal.model.ComponentModel)6 Test (org.junit.Test)5 ComponentBuildingDefinition (org.mule.runtime.dsl.api.component.ComponentBuildingDefinition)5 TypeDefinition (org.mule.runtime.dsl.api.component.TypeDefinition)5 Map (java.util.Map)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 ArrayList (java.util.ArrayList)2 Collections.emptyMap (java.util.Collections.emptyMap)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Optional (java.util.Optional)2 Optional.empty (java.util.Optional.empty)2 Optional.of (java.util.Optional.of)2 Set (java.util.Set)2 Consumer (java.util.function.Consumer)2 QName (javax.xml.namespace.QName)2 AbstractComponent (org.mule.runtime.api.component.AbstractComponent)2 Component (org.mule.runtime.api.component.Component)2