Esempio n. 1
0
  @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));
  }
Esempio n. 2
0
  @Test
  public void testGetDbLicense() throws Exception {
    final License license =
        DataModelFactory.createLicense("name", "longName", "comments", "regexp", "url");
    final ModelMapper modelMapper = new ModelMapper(mock(RepositoryHandler.class));
    final DbLicense dbLicense = modelMapper.getDbLicense(license);

    assertEquals(license.getName(), dbLicense.getName());
    assertEquals(license.getLongName(), dbLicense.getLongName());
    assertEquals(license.getComments(), dbLicense.getComments());
    assertEquals(license.getRegexp(), dbLicense.getRegexp());
    assertEquals(license.getUrl(), dbLicense.getUrl());
  }
Esempio n. 3
0
  @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());
  }
Esempio n. 4
0
  @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());
  }