@Override @SuppressWarnings("unchecked") public Class<? extends Annotator> getCustomAnnotator() { if (isNotBlank(customAnnotator)) { try { return (Class<? extends Annotator>) Class.forName(customAnnotator); } catch (ClassNotFoundException e) { throw new IllegalArgumentException(e); } } else { return NoopAnnotator.class; } }
/** * Sets the 'customAnnotator' property of this class * * @param customAnnotator * A custom annotator to use to annotate the generated types */ @SuppressWarnings("unchecked") public void setCustomAnnotator(String customAnnotator) { if (isNotBlank(customAnnotator)) { try { this.customAnnotator = (Class<? extends Annotator>) Class.forName(customAnnotator); } catch (ClassNotFoundException e) { throw new IllegalArgumentException(e); } } else { this.customAnnotator = NoopAnnotator.class; } }
@Test public void generationConfigIsReturned() { GenerationConfig mockGenerationConfig = mock(GenerationConfig.class); RuleFactory ruleFactory = new RuleFactory(mockGenerationConfig, new NoopAnnotator(), new SchemaStore()); assertThat(ruleFactory.getGenerationConfig(), is(sameInstance(mockGenerationConfig))); }
@Test public void schemaStoreIsReturned() { SchemaStore mockSchemaStore = mock(SchemaStore.class); RuleFactory ruleFactory = new RuleFactory(new DefaultGenerationConfig(), new NoopAnnotator(), mockSchemaStore); assertThat(ruleFactory.getSchemaStore(), is(sameInstance(mockSchemaStore))); }