Search in sources :

Example 1 with TestJobConfiguration

use of org.fakekoji.jobmanager.model.TestJobConfiguration in project jenkins-scm-koji-plugin by judovana.

the class ReverseJDKProjectParser method parseJDKTestProjectJobs.

public Result<JDKTestProject, String> parseJDKTestProjectJobs(Set<TestJob> jobs) {
    return validateJobs(jobs, getTestJobValidator()).flatMap(projectRepresentingJob -> {
        final Set<BuildPlatformConfig> buildPlatforms = new HashSet<>();
        for (final TestJob job : jobs) {
            final String platformProvider = job.getPlatformProvider();
            final Platform bp = job.getBuildPlatform();
            final Map<String, String> bv = variantsMapToStringMap(job.getBuildVariants());
            final Platform tp = job.getPlatform();
            final Task tt = job.getTask();
            final Map<String, String> tv = variantsMapToStringMap(job.getVariants());
            final VariantsConfig testVariants;
            final BuildPlatformConfig bpc = findOrCreatePlatform(buildPlatforms, bp.getId());
            final VariantsConfig buildVariants = findOrCreateVariants(bpc.getVariants(), bv);
            final PlatformConfig testPlatform = findOrCreatePlatform(buildVariants.getPlatforms(), tp.getId(), platformProvider);
            final TaskConfig task = findOrCreateTask(testPlatform.getTasks(), tt.getId());
            final Optional<VariantsConfig> tvOptional = findVariants(task.getVariants(), tv);
            if (tvOptional.isPresent()) {
                return Result.err("Duplicate job: " + job.getName());
            } else {
                testVariants = new VariantsConfig(tv);
                task.getVariants().add(testVariants);
            }
        }
        return Result.ok(new JDKTestProject(projectRepresentingJob.getProjectName(), projectRepresentingJob.getProduct(), projectRepresentingJob.getBuildProviders().stream().map(BuildProvider::getId).collect(Collectors.toSet()), projectRepresentingJob.getProjectSubpackageBlacklist(), projectRepresentingJob.getProjectSubpackageWhitelist(), new TestJobConfiguration(buildPlatforms), projectRepresentingJob.getProjectVariables()));
    });
}
Also used : Task(org.fakekoji.model.Task) TestJob(org.fakekoji.jobmanager.model.TestJob) Platform(org.fakekoji.model.Platform) BuildPlatformConfig(org.fakekoji.jobmanager.model.BuildPlatformConfig) TaskConfig(org.fakekoji.jobmanager.model.TaskConfig) TestJobConfiguration(org.fakekoji.jobmanager.model.TestJobConfiguration) PlatformConfig(org.fakekoji.jobmanager.model.PlatformConfig) BuildPlatformConfig(org.fakekoji.jobmanager.model.BuildPlatformConfig) VariantsConfig(org.fakekoji.jobmanager.model.VariantsConfig) JDKTestProject(org.fakekoji.jobmanager.model.JDKTestProject) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 BuildPlatformConfig (org.fakekoji.jobmanager.model.BuildPlatformConfig)1 JDKTestProject (org.fakekoji.jobmanager.model.JDKTestProject)1 PlatformConfig (org.fakekoji.jobmanager.model.PlatformConfig)1 TaskConfig (org.fakekoji.jobmanager.model.TaskConfig)1 TestJob (org.fakekoji.jobmanager.model.TestJob)1 TestJobConfiguration (org.fakekoji.jobmanager.model.TestJobConfiguration)1 VariantsConfig (org.fakekoji.jobmanager.model.VariantsConfig)1 Platform (org.fakekoji.model.Platform)1 Task (org.fakekoji.model.Task)1