示例#1
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);
  }
 @Before
 public void before() {
   SecurityService securityService = mock(SecurityService.class);
   ValidationRunStatusService validationRunStatusService = mock(ValidationRunStatusService.class);
   structureRepository = mock(StructureRepository.class);
   EventPostService eventService = mock(EventPostService.class);
   EventFactory eventFactory = mock(EventFactory.class);
   ExtensionManager extensionManager = mock(ExtensionManager.class);
   PropertyService propertyService = mock(PropertyService.class);
   PredefinedPromotionLevelService predefinedPromotionLevelService =
       mock(PredefinedPromotionLevelService.class);
   PredefinedValidationStampService predefinedValidationStampService =
       mock(PredefinedValidationStampService.class);
   DecorationService decorationService = mock(DecorationService.class);
   ProjectFavouriteService projectFavouriteService = mock(ProjectFavouriteService.class);
   service =
       new StructureServiceImpl(
           securityService,
           eventService,
           eventFactory,
           validationRunStatusService,
           structureRepository,
           extensionManager,
           propertyService,
           predefinedPromotionLevelService,
           predefinedValidationStampService,
           decorationService,
           projectFavouriteService);
   // Model
   Project project = Project.of(nd("P", "Project")).withId(ID.of(1));
   Branch branch = Branch.of(project, nd("B", "Branch")).withId(ID.of(1));
   copper = PromotionLevel.of(branch, nd("COPPER", "")).withId(ID.of(1));
   build = Build.of(branch, nd("1", "Build 1"), Signature.of("test")).withId(ID.of(1));
 }