use of org.mule.runtime.dsl.api.component.TypeDefinition in project mule by mulesoft.
the class ObjectTypeVisitorTestCase method typeIsInstanceOfCheckedClassFromAttribute.
@Test
public void typeIsInstanceOfCheckedClassFromAttribute() throws ClassNotFoundException {
ComponentModel componentModel = new SpringComponentModel();
componentModel.setParameter("type", "org.mule.runtime.core.internal.processor.ReferenceProcessor");
ObjectTypeVisitor visitor = new ObjectTypeVisitor(componentModel);
TypeDefinition typeDefinition = fromConfigurationAttribute("type").checkingThatIsClassOrInheritsFrom(ReferenceProcessor.class);
typeDefinition.visit(visitor);
assertTrue(ReferenceProcessor.class.isAssignableFrom(visitor.getType()));
}
use of org.mule.runtime.dsl.api.component.TypeDefinition in project mule by mulesoft.
the class ObjectTypeVisitorTestCase method typeIsInstanceOfClassInheritedFromCheckedClassFromAttribute.
@Test
public void typeIsInstanceOfClassInheritedFromCheckedClassFromAttribute() throws ClassNotFoundException {
ComponentModel componentModel = new SpringComponentModel();
componentModel.setParameter("type", "org.mule.runtime.core.internal.processor.ReferenceProcessor");
ObjectTypeVisitor visitor = new ObjectTypeVisitor(componentModel);
// Check that ReferenceProcessor inherits from AbstractProcessor
TypeDefinition typeDefinition = fromConfigurationAttribute("type").checkingThatIsClassOrInheritsFrom(AbstractProcessor.class);
typeDefinition.visit(visitor);
assertTrue(AbstractProcessor.class.isAssignableFrom(visitor.getType()));
}
use of org.mule.runtime.dsl.api.component.TypeDefinition in project mule by mulesoft.
the class ObjectTypeVisitorTestCase method typeIsInstanceOfGivenClassFromAttribute.
@Test
public void typeIsInstanceOfGivenClassFromAttribute() throws ClassNotFoundException {
ComponentModel componentModel = new SpringComponentModel();
componentModel.setParameter("type", "org.mule.runtime.core.internal.processor.ReferenceProcessor");
ObjectTypeVisitor visitor = new ObjectTypeVisitor(componentModel);
TypeDefinition typeDefinition = fromConfigurationAttribute("type");
typeDefinition.visit(visitor);
assertTrue(ReferenceProcessor.class.isAssignableFrom(visitor.getType()));
}
use of org.mule.runtime.dsl.api.component.TypeDefinition 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);
}
use of org.mule.runtime.dsl.api.component.TypeDefinition 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()));
}
Aggregations