@Test void convertToExtension() throws SecurityException, URISyntaxException { Model model = new Model(); model.setGroupId("groupid"); model.setArtifactId("artifactid"); model.setVersion("version"); model.addProperty(Extension.IKEYPREFIX + Extension.FIELD_CATEGORY, "category"); model.addProperty(Extension.IKEYPREFIX + Extension.FIELD_NAMESPACES, "namespace1, namespace2,\r\n\t {root}, \"namespace3\", 'namespace4'"); model.addProperty(Extension.IKEYPREFIX + Extension.FIELD_FEATURES, "feature1/1.0"); Repository repository = new Repository(); repository.setId("repository-id"); repository.setUrl("http: model.addRepository(repository); Dependency dependency = new Dependency(); dependency.setGroupId("dgroupid"); dependency.setArtifactId("dartifactId"); dependency.setVersion("1.0"); dependency.setOptional(false); Exclusion exclusion1 = new Exclusion(); exclusion1.setArtifactId("excludedartifact1"); exclusion1.setGroupId("excludedgroup1"); dependency.addExclusion(exclusion1); Exclusion exclusion2 = new Exclusion(); exclusion2.setArtifactId("excludedartifact2"); exclusion2.setGroupId("*"); dependency.addExclusion(exclusion2); Exclusion exclusion3 = new Exclusion(); exclusion3.setArtifactId("*"); exclusion3.setGroupId("excludedgroup3"); dependency.addExclusion(exclusion3); model.addDependency(dependency); Extension extension = this.converter.convert(Extension.class, model); assertEquals(model.getGroupId() + ':' + model.getArtifactId(), extension.getId().getId()); assertEquals(model.getVersion(), extension.getId().getVersion().getValue()); assertEquals(model.getPackaging(), extension.getType()); assertEquals(ListUtils.union(Arrays.asList(new ExtensionId("feature1", "1.0")), INJECTED_FEATURES), new ArrayList<>(extension.getExtensionFeatures())); assertEquals("category", extension.getCategory()); assertNull(extension.getProperty(Extension.IKEYPREFIX + Extension.FIELD_CATEGORY)); assertEquals(Arrays.asList("namespace1", "namespace2", "{root}", "namespace3", "namespace4"), new ArrayList<>(extension.getAllowedNamespaces())); assertNull(extension.getProperty(Extension.IKEYPREFIX + Extension.FIELD_NAMESPACES)); assertEquals( Arrays.asList(new DefaultExtensionRepositoryDescriptor("repository-id", "maven", new URI("http: extension.getRepositories()); assertEquals(1, extension.getDependencies().size()); ExtensionDependency extensionDependency = extension.getDependencies().iterator().next(); assertEquals("dgroupid:dartifactId", extensionDependency.getId()); assertEquals("1.0", extensionDependency.getVersionConstraint().getValue()); Collection<ExtensionPattern> extensionExclusions = extensionDependency.getExclusions(); Iterator<ExtensionPattern> patternIt = extensionExclusions.iterator(); ExtensionPattern pattern = patternIt.next(); assertEquals("excludedgroup1:excludedartifact1", pattern.getIdPattern().toString()); pattern = patternIt.next(); assertEquals(".*:\\Qexcludedartifact2\\E", pattern.getIdPattern().toString()); pattern = patternIt.next(); assertEquals("\\Qexcludedgroup3\\E:.*", pattern.getIdPattern().toString()); }
private MavenExtension convertToExtension(Model model) { String groupId = MavenUtils.resolveGroupId(model); String artifactId = model.getArtifactId(); String type = MavenUtils.packagingToType(model.getPackaging()); String version = MavenUtils.resolveVersion(model); return convertToExtension(model, groupId, artifactId, null, type, version); }
ModelConverter extends AbstractModelConverter<Model> { private MavenExtension convertToExtension(Model model) { String groupId = MavenUtils.resolveGroupId(model); String artifactId = model.getArtifactId(); String type = MavenUtils.packagingToType(model.getPackaging()); String version = MavenUtils.resolveVersion(model); return convertToExtension(model, groupId, artifactId, null, type, version); } }
ModelConverter extends AbstractModelConverter<Model> { private MavenExtension convertToExtension(Model model) { String groupId = MavenUtils.resolveGroupId(model); String artifactId = model.getArtifactId(); String type = MavenUtils.packagingToType(model.getPackaging()); String version = MavenUtils.resolveVersion(model); return convertToExtension(model, groupId, artifactId, null, type, version); }  }
ModelConverter extends AbstractModelConverter<Model> { private MavenExtension convertToExtension(Model model) { String groupId = MavenUtils.resolveGroupId(model); String artifactId = model.getArtifactId(); String type = MavenUtils.packagingToType(model.getPackaging()); String version = MavenUtils.resolveVersion(model); return convertToExtension(model, groupId, artifactId, null, type, version); }  @Override G convert(Type targetType, Object sourceValue); }
ModelConverter extends AbstractModelConverter<Model> { private MavenExtension convertToExtension(Model model) { String groupId = MavenUtils.resolveGroupId(model); String artifactId = model.getArtifactId(); String type = MavenUtils.packagingToType(model.getPackaging()); String version = MavenUtils.resolveVersion(model); return convertToExtension(model, groupId, artifactId, null, type, version); }  @Override G convert(Type targetType, Object sourceValue); static final ParameterizedType ROLE; }