ArtifactModelConverter extends AbstractModelConverter<ArtifactModel> { @Override public <G> G convert(Type targetType, Object sourceValue) { if (targetType == Extension.class) { return (G) convertToExtension((ArtifactModel) sourceValue); } else { throw new ConversionException(String.format("Unsupported target type [%s]", targetType)); } }  @Override G convert(Type targetType, Object sourceValue); static final ParameterizedType ROLE; }
@Test void testConvertWithClassifier() throws SecurityException { this.artifactModel.setClassifier("classifier"); Extension extension = this.converter.convert(Extension.class, artifactModel); assertEquals("groupid:artifactid:classifier", extension.getId().getId()); assertEquals("jar", extension.getType()); }
@Test void testConvertPom() throws SecurityException { this.artifactModel.setType("pom"); Extension extension = this.converter.convert(Extension.class, artifactModel); assertNull(extension.getType()); }
@Test void testConvertWithType() throws SecurityException { this.artifactModel.setType("type"); Extension extension = this.converter.convert(Extension.class, artifactModel); assertEquals("groupid:artifactid", extension.getId().getId()); assertEquals("type", extension.getType()); }
@Test void testConvertWithClassifierAndType() throws SecurityException { this.artifactModel.setClassifier("classifier"); this.artifactModel.setType("type"); Extension extension = this.converter.convert(Extension.class, artifactModel); assertEquals("groupid:artifactid:classifier", extension.getId().getId()); assertEquals("type", extension.getType()); }