TemplateGeneratorInitializer { public TemplateGenerator getTemplateGenerator(final String className) { return externalInitializer.loadExternalClass(className, stubResourcePathProvider.getTemplatesPathAsString(), TemplateGenerator.class); }  TemplateGenerator getTemplateGenerator(final String className);  }
@Test public void testGetTemplateGeneratorShouldReturnWithTemplateGenerator() { given(stubResourcePathProvider.getTemplatesPathAsString()).willReturn(CLASS); given(externalInitializer.loadExternalClass(CLASS, CLASS, TemplateGenerator.class)).willReturn(templateGenerator); TemplateGenerator actual = underTest.getTemplateGenerator(CLASS); Assert.assertEquals(actual, templateGenerator); }
@Test(expectedExceptions = DescriptorValidationFailedException.class) public void testGetTemplateGeneratorShouldThrowExceptionWhenExternalClassCanNotLoad() { given(stubResourcePathProvider.getTemplatesPathAsString()).willReturn(CLASS); given(externalInitializer.loadExternalClass(CLASS, CLASS, TemplateGenerator.class)).willThrow( new DescriptorValidationFailedException(CLASS)); underTest.getTemplateGenerator(CLASS); }