ModelMapper { public License getLicense(final DbLicense dbLicense) { final License license = DataModelFactory.createLicense(dbLicense.getName(), dbLicense.getLongName(), dbLicense.getComments(), dbLicense.getRegexp(), dbLicense.getUrl()); if (dbLicense.isApproved() != null) { license.setApproved(dbLicense.isApproved()); }else{ license.setPending(true); } if (license.getLongName().isEmpty() && license.getComments().isEmpty() && license.getUrl().isEmpty() && license.getRegexp().isEmpty()) { license.setUnknown(true); } return license; } 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 testGetLicense() throws Exception { final DbLicense dbLicense = new DbLicense() ; dbLicense.setName("name"); dbLicense.setLongName("long name"); dbLicense.setComments("comment"); dbLicense.setRegexp("regexp"); dbLicense.setUrl("url"); final ModelMapper modelMapper = new ModelMapper(mock(RepositoryHandler.class)); final License license = modelMapper.getLicense(dbLicense); assertEquals(dbLicense.getName(), license.getName()); assertEquals(dbLicense.getLongName(), license.getLongName()); assertEquals(dbLicense.getComments(), license.getComments()); assertEquals(dbLicense.getRegexp(), license.getRegexp()); assertEquals(dbLicense.getUrl(), license.getUrl()); }
@Test public void testGetUnknownLicense() throws Exception { final DbLicense dbLicense = new DbLicense() ; dbLicense.setName("name"); dbLicense.setLongName(""); dbLicense.setComments(""); dbLicense.setRegexp(""); dbLicense.setUrl(""); final ModelMapper modelMapper = new ModelMapper(mock(RepositoryHandler.class)); final License license = modelMapper.getLicense(dbLicense); assertEquals(true, license.isUnknown()); }
@Test public void testGetPendingLicense() throws Exception { final DbLicense dbLicense = new DbLicense() ; dbLicense.setName("name"); dbLicense.setLongName("longName"); dbLicense.setComments("comments"); dbLicense.setRegexp("regexp"); dbLicense.setUrl("url"); final ModelMapper modelMapper = new ModelMapper(mock(RepositoryHandler.class)); final License license = modelMapper.getLicense(dbLicense); assertEquals(true, license.isPending()); }