コード例 #1
0
 private boolean areEqual(Project a, Project b, boolean compareIDs) {
   if (compareIDs) {
     if (a.getId() != b.getId()) {
       return false;
     }
   }
   return (safeEquals(a.getTitle(), b.getTitle())
       && safeEquals(a.getRecordsperimage(), b.getRecordsperimage())
       && safeEquals(a.getFirstycoord(), b.getFirstycoord())
       && safeEquals(a.getRecordheight(), b.getRecordheight())
       && safeEquals(a.getNumfields(), b.getNumfields()));
 }
コード例 #2
0
  @Test
  public void testAdd() throws DatabaseException {

    Project census = new Project("census", 2, 3, 4, 5);
    Project births = new Project("births", 6, 7, 8, 9);

    dbProjects.add(census);
    dbProjects.add(births);

    List<Project> all = dbProjects.getAll();
    assertEquals(2, all.size());

    boolean foundAge = false;
    boolean foundPlace = false;

    for (Project p : all) {

      assertFalse(p.getId() == -1);

      if (!foundAge) {
        foundAge = areEqual(p, census, false);
      }
      if (!foundPlace) {
        foundPlace = areEqual(p, births, false);
      }
    }

    assertTrue(foundAge && foundPlace);
  }
コード例 #3
0
  @Test
  public void testGetNumFields() throws DatabaseException {
    Project census = new Project("census", 2, 3, 4, 5);
    dbProjects.add(census);

    assertEquals(dbProjects.getNumFields(census.getId()), 5);
  }
コード例 #4
0
  @Test
  public void testGetRecsPerImage() throws DatabaseException {
    Project census = new Project("census", 2, 3, 4, 5);
    dbProjects.add(census);

    assertEquals(dbProjects.getRecsPerImage(census.getId()), 2);
  }
コード例 #5
0
  @Override
  public OntrackSVNRevisionInfo getOntrackRevisionInfo(SVNRepository repository, long revision) {

    // Gets information about the revision
    SVNRevisionInfo basicInfo = svnService.getRevisionInfo(repository, revision);
    SVNChangeLogRevision changeLogRevision =
        svnService.createChangeLogRevision(repository, basicInfo);

    // Gets the first copy event on this path after this revision
    SVNLocation firstCopy = svnService.getFirstCopyAfter(repository, basicInfo.toLocation());

    // Data to collect
    Collection<BuildView> buildViews = new ArrayList<>();
    Collection<BranchStatusView> branchStatusViews = new ArrayList<>();
    // Loops over all authorised branches
    for (Project project : structureService.getProjectList()) {
      // Filter on SVN configuration: must be present and equal to the one the revision info is
      // looked into
      Property<SVNProjectConfigurationProperty> projectSvnConfig =
          propertyService.getProperty(project, SVNProjectConfigurationPropertyType.class);
      if (!projectSvnConfig.isEmpty()
          && repository
              .getConfiguration()
              .getName()
              .equals(projectSvnConfig.getValue().getConfiguration().getName())) {
        for (Branch branch : structureService.getBranchesForProject(project.getId())) {
          // Filter on branch type
          // Filter on SVN configuration: must be present
          if (branch.getType() != BranchType.TEMPLATE_DEFINITION
              && propertyService.hasProperty(branch, SVNBranchConfigurationPropertyType.class)) {
            // Identifies a possible build given the path/revision and the first copy
            Optional<Build> build = lookupBuild(basicInfo.toLocation(), firstCopy, branch);
            // Build found
            if (build.isPresent()) {
              // Gets the build view
              BuildView buildView = structureService.getBuildView(build.get());
              // Adds it to the list
              buildViews.add(buildView);
              // Collects the promotions for the branch
              branchStatusViews.add(structureService.getEarliestPromotionsAfterBuild(build.get()));
            }
          }
        }
      }
    }

    // OK
    return new OntrackSVNRevisionInfo(
        repository.getConfiguration(), changeLogRevision, buildViews, branchStatusViews);
  }