Search in sources :

Example 1 with Tuple

use of org.fakekoji.functional.Tuple in project jenkins-scm-koji-plugin by judovana.

the class PlatformBumperTest method bumpJDKProjectJobsWithMatchTestOnly.

@Test
public void bumpJDKProjectJobsWithMatchTestOnly() {
    final Platform from = DataGenerator.getRHEL7x64();
    final Platform to = DataGenerator.getF29x64();
    final Set<Job> jobs = DataGenerator.getJDKProjectJobs();
    final PlatformBumper bumper = new PlatformBumper(settings, from, to, PlatformBumpVariant.TEST_ONLY, Optional.empty());
    final Set<Tuple<Job, Optional<Job>>> tuples = jobs.stream().map(bumper.getTransformFunction()).collect(Collectors.toSet());
    Assert.assertEquals(2, tuples.stream().filter(tuple -> tuple.y.isPresent()).count());
    Assert.assertTrue(tuples.stream().allMatch(tuple -> {
        if (tuple.x instanceof TestJob) {
            // is test job
            final TestJob testJob = (TestJob) tuple.x;
            if (!tuple.y.isPresent()) {
                // if job is not bumped, then its platform should not be equal to 'from' platform
                return !testJob.getPlatform().equals(from);
            }
            final TestJob bumped = (TestJob) tuple.y.get();
            // bumped job's platform should equal to 'to' platform
            return bumped.getPlatform().equals(to);
        }
        // if is not test job, should not be bumped
        return !tuple.y.isPresent();
    }));
}
Also used : PlatformBumper(org.fakekoji.jobmanager.bumpers.impl.PlatformBumper) Platform(org.fakekoji.model.Platform) Tuple(org.fakekoji.functional.Tuple) Predicate(java.util.function.Predicate) Job(org.fakekoji.jobmanager.model.Job) Set(java.util.Set) Test(org.junit.Test) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) TaskJob(org.fakekoji.jobmanager.model.TaskJob) PlatformBumpVariant(org.fakekoji.jobmanager.model.PlatformBumpVariant) TestJob(org.fakekoji.jobmanager.model.TestJob) Rule(org.junit.Rule) PlatformBumper(org.fakekoji.jobmanager.bumpers.impl.PlatformBumper) Optional(java.util.Optional) BuildJob(org.fakekoji.jobmanager.model.BuildJob) Pattern(java.util.regex.Pattern) Assert(org.junit.Assert) DataGenerator(org.fakekoji.DataGenerator) TemporaryFolder(org.junit.rules.TemporaryFolder) AccessibleSettings(org.fakekoji.core.AccessibleSettings) Before(org.junit.Before) Platform(org.fakekoji.model.Platform) TestJob(org.fakekoji.jobmanager.model.TestJob) Job(org.fakekoji.jobmanager.model.Job) TaskJob(org.fakekoji.jobmanager.model.TaskJob) TestJob(org.fakekoji.jobmanager.model.TestJob) BuildJob(org.fakekoji.jobmanager.model.BuildJob) Tuple(org.fakekoji.functional.Tuple) Test(org.junit.Test)

Example 2 with Tuple

use of org.fakekoji.functional.Tuple in project jenkins-scm-koji-plugin by judovana.

the class PlatformBumperTest method bumpJDKProjectJobsWithMatch.

@Test
public void bumpJDKProjectJobsWithMatch() {
    final Platform from = DataGenerator.getRHEL7x64();
    final Platform to = DataGenerator.getF29x64();
    final Set<Job> jobs = DataGenerator.getJDKProjectJobs();
    final PlatformBumper bumper = new PlatformBumper(settings, from, to, PlatformBumpVariant.BOTH, Optional.empty());
    final Set<Tuple<Job, Optional<Job>>> tuples = jobs.stream().map(bumper.getTransformFunction()).collect(Collectors.toSet());
    Assert.assertEquals(4, tuples.stream().filter(tuple -> tuple.y.isPresent()).count());
    Assert.assertTrue(tuples.stream().allMatch(isOk(from, to)));
}
Also used : PlatformBumper(org.fakekoji.jobmanager.bumpers.impl.PlatformBumper) Platform(org.fakekoji.model.Platform) Job(org.fakekoji.jobmanager.model.Job) TaskJob(org.fakekoji.jobmanager.model.TaskJob) TestJob(org.fakekoji.jobmanager.model.TestJob) BuildJob(org.fakekoji.jobmanager.model.BuildJob) Tuple(org.fakekoji.functional.Tuple) Test(org.junit.Test)

Example 3 with Tuple

use of org.fakekoji.functional.Tuple in project jenkins-scm-koji-plugin by judovana.

the class PlatformBumperTest method bumpJDKTestProjectJobsWithSomeMatchingFitlered.

@Test
public void bumpJDKTestProjectJobsWithSomeMatchingFitlered() {
    final Platform from = DataGenerator.getF29x64();
    final Platform to = DataGenerator.getRHEL7x64();
    final Set<Job> jobs = DataGenerator.getJDKTestProjectJobs();
    final PlatformBumper bumper = new PlatformBumper(settings, from, to, PlatformBumpVariant.BOTH, Optional.of(Pattern.compile(".*wayland.*")));
    final Set<Tuple<Job, Optional<Job>>> tuples = jobs.stream().map(bumper.getTransformFunction()).collect(Collectors.toSet());
    Assert.assertEquals(1, tuples.stream().filter(tuple -> tuple.y.isPresent()).count());
    Assert.assertFalse(tuples.stream().allMatch(isOk(from, to)));
}
Also used : PlatformBumper(org.fakekoji.jobmanager.bumpers.impl.PlatformBumper) Platform(org.fakekoji.model.Platform) Job(org.fakekoji.jobmanager.model.Job) TaskJob(org.fakekoji.jobmanager.model.TaskJob) TestJob(org.fakekoji.jobmanager.model.TestJob) BuildJob(org.fakekoji.jobmanager.model.BuildJob) Tuple(org.fakekoji.functional.Tuple) Test(org.junit.Test)

Example 4 with Tuple

use of org.fakekoji.functional.Tuple in project jenkins-scm-koji-plugin by judovana.

the class PlatformBumperTest method bumpJDKProjectJobsWithoutMatch.

@Test
public void bumpJDKProjectJobsWithoutMatch() {
    final Set<Job> jobs = DataGenerator.getJDKProjectJobs();
    final PlatformBumper bumper = new PlatformBumper(settings, DataGenerator.getF29x64(), DataGenerator.getRHEL7x64(), PlatformBumpVariant.BOTH, Optional.empty());
    final Set<Tuple<Job, Optional<Job>>> tuples = jobs.stream().map(bumper.getTransformFunction()).collect(Collectors.toSet());
    Assert.assertEquals(0, tuples.stream().filter(tuple -> tuple.y.isPresent()).count());
    Assert.assertEquals(jobs, tuples.stream().map(tuple -> tuple.y.orElse(tuple.x)).collect(Collectors.toSet()));
}
Also used : PlatformBumper(org.fakekoji.jobmanager.bumpers.impl.PlatformBumper) Job(org.fakekoji.jobmanager.model.Job) TaskJob(org.fakekoji.jobmanager.model.TaskJob) TestJob(org.fakekoji.jobmanager.model.TestJob) BuildJob(org.fakekoji.jobmanager.model.BuildJob) Tuple(org.fakekoji.functional.Tuple) Test(org.junit.Test)

Example 5 with Tuple

use of org.fakekoji.functional.Tuple in project jenkins-scm-koji-plugin by judovana.

the class ProductBumperTest method bumpJDKTestProjectJobsWithoutMatch.

@Test
public void bumpJDKTestProjectJobsWithoutMatch() {
    final String fromPackage = DataGenerator.getJDK11Product().getPackageName();
    final String toPackage = DataGenerator.getJDK8Product().getPackageName();
    final JDKVersion fromJDKVersion = DataGenerator.getJDKVersion11();
    final JDKVersion toJDKVersion = DataGenerator.getJDKVersion8();
    final Set<Job> jobs = DataGenerator.getJDKTestProjectJobs();
    final ProductBumper bumper = new ProductBumper(settings, fromPackage, toPackage, fromJDKVersion, toJDKVersion);
    final Set<Tuple<Job, Optional<Job>>> tuples = jobs.stream().map(bumper.getTransformFunction()).collect(Collectors.toSet());
    Assert.assertEquals(0, tuples.stream().filter(tuple -> tuple.y.isPresent()).count());
    Assert.assertEquals(jobs, tuples.stream().map(tuple -> tuple.y.orElse(tuple.x)).collect(Collectors.toSet()));
}
Also used : JDKVersion(org.fakekoji.model.JDKVersion) ProductBumper(org.fakekoji.jobmanager.bumpers.impl.ProductBumper) Job(org.fakekoji.jobmanager.model.Job) Tuple(org.fakekoji.functional.Tuple) Test(org.junit.Test)

Aggregations

Tuple (org.fakekoji.functional.Tuple)17 Job (org.fakekoji.jobmanager.model.Job)15 Test (org.junit.Test)13 BuildJob (org.fakekoji.jobmanager.model.BuildJob)11 TestJob (org.fakekoji.jobmanager.model.TestJob)11 PlatformBumper (org.fakekoji.jobmanager.bumpers.impl.PlatformBumper)9 TaskJob (org.fakekoji.jobmanager.model.TaskJob)9 Platform (org.fakekoji.model.Platform)8 JDKVersion (org.fakekoji.model.JDKVersion)5 IOException (java.io.IOException)4 Optional (java.util.Optional)4 Set (java.util.Set)4 Collectors (java.util.stream.Collectors)4 AccessibleSettings (org.fakekoji.core.AccessibleSettings)4 ProductBumper (org.fakekoji.jobmanager.bumpers.impl.ProductBumper)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2