ModelMapper { public Artifact getArtifact(final DbArtifact dbArtifact) { final Artifact artifact = DataModelFactory.createArtifact(dbArtifact.getGroupId(), dbArtifact.getArtifactId(), dbArtifact.getVersion(), dbArtifact.getClassifier(), dbArtifact.getType(), dbArtifact.getExtension()); artifact.setSha256(dbArtifact.getSha256()); artifact.setDescription(dbArtifact.getDescription()); artifact.setPromoted(dbArtifact.isPromoted()); artifact.setSize(dbArtifact.getSize()); artifact.setDownloadUrl(dbArtifact.getDownloadUrl()); artifact.setProvider(dbArtifact.getProvider()); artifact.setOrigin(dbArtifact.getOrigin()); artifact.setCreatedDateTime(dbArtifact.getCreatedDateTime()); artifact.setUpdatedDateTime(dbArtifact.getUpdatedDateTime()); for (final String licenseId : dbArtifact.getLicenses()) { artifact.addLicense(licenseId); } return artifact; } ModelMapper(final RepositoryHandler repoHandler); DbOrganization getDbOrganization(final Organization organization); Organization getOrganization(final DbOrganization dbOrganization); DbLicense getDbLicense(final License license); License getLicense(final DbLicense dbLicense); DbArtifact getDbArtifact(final Artifact artifact); Artifact getArtifact(final DbArtifact dbArtifact); DbModule getDbModule(final Module module); Module getModule(final DbModule dbModule); Dependency getDependency(final DbDependency dbDependency, final String sourceName, final String sourceVersion); Comment getComment(final DbComment dbComment); DbComment getDbComment(final Comment comment);  }
@Test public void testGetArtifact(){ final DbArtifact dbArtifact = new DbArtifact(); dbArtifact.setGroupId("groupId"); dbArtifact.setArtifactId("artifactId"); dbArtifact.setVersion("1.0.0-SNAPSHOT"); dbArtifact.setClassifier("win"); dbArtifact.setType("component"); dbArtifact.setExtension("jar"); dbArtifact.setDownloadUrl("nowhere"); dbArtifact.setSize("10Mo"); dbArtifact.setProvider("provider"); final DbLicense license = new DbLicense(); license.setName("licenseId"); dbArtifact.addLicense(license); final ModelMapper modelMapper = new ModelMapper(mock(RepositoryHandler.class)); final Artifact artifact = modelMapper.getArtifact(dbArtifact); assertEquals(dbArtifact.getGroupId(), artifact.getGroupId()); assertEquals(dbArtifact.getArtifactId(), artifact.getArtifactId()); assertEquals(dbArtifact.getVersion(), artifact.getVersion()); assertEquals(dbArtifact.getClassifier(), artifact.getClassifier()); assertEquals(dbArtifact.getType(), artifact.getType()); assertEquals(dbArtifact.getExtension(), artifact.getExtension()); assertEquals(dbArtifact.getSize(), artifact.getSize()); assertEquals(dbArtifact.getDownloadUrl(), artifact.getDownloadUrl()); assertEquals(dbArtifact.getProvider(), artifact.getProvider()); assertEquals(1, artifact.getLicenses().size()); assertEquals("licenseId", artifact.getLicenses().get(0)); }