@Test(expected = MappingException.class) public void shouldFailWithNoSuchMethod() { directive.setTargetClass(SelfFactory.class); directive.setCreateMethod("wrong"); byCreateMethod.create(directive); fail(); }
@Test public void shouldUseFullyQualifiedStaticCreateMethod() { directive.setTargetClass(String.class); directive.setCreateMethod( "org.dozer.factory.ConstructionStrategiesTest$ExternalFactory.create"); String result = (String) byCreateMethod.create(directive); assertEquals("hello", result); }
@Test public void shouldUseStaticCreateMethod() { directive.setTargetClass(SelfFactory.class); directive.setCreateMethod("create"); SelfFactory result = (SelfFactory) byCreateMethod.create(directive); assertNotNull(result); assertEquals("a", result.getName()); }