Search in sources :

Example 21 with BuildConfiguration

use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.

the class RSQLPredicateProducerTest method testStreamPredicateEmbeded.

@Test
public void testStreamPredicateEmbeded() {
    Predicate<BuildConfiguration> streamPredicate = producer.getStreamPredicate("project.name==\"Bar Project\"");
    Project projBar = Project.builder().name("Bar Project").build();
    Project projBaz = Project.builder().name("Baz Project").build();
    BuildConfiguration fooBar = BuildConfiguration.builder().project(projBar).build();
    BuildConfiguration fooBaz = BuildConfiguration.builder().project(projBaz).build();
    List<BuildConfiguration> filtered = Arrays.asList(fooBar, fooBaz).stream().filter(streamPredicate).collect(Collectors.toList());
    assertEquals(1, filtered.size());
    assertEquals("Bar Project", filtered.get(0).getProject().getName());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) Project(org.jboss.pnc.dto.Project) Test(org.junit.Test)

Example 22 with BuildConfiguration

use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.

the class RSQLPredicateProducerTest method testPredicateCompareValue.

@Test
public void testPredicateCompareValue() {
    Predicate<BuildConfiguration> streamPredicate = producer.getStreamPredicate("id>1");
    BuildConfiguration fooBarG = BuildConfiguration.builder().id("1").name("FooBar").buildType(BuildType.GRADLE).build();
    BuildConfiguration fooBarM = BuildConfiguration.builder().id("2").name("FooBar").buildType(BuildType.MVN).build();
    BuildConfiguration fooBazG = BuildConfiguration.builder().id("3").name("FooBaz").buildType(BuildType.GRADLE).build();
    List<BuildConfiguration> filtered = Arrays.asList(fooBarG, fooBarM, fooBazG).stream().filter(streamPredicate).collect(Collectors.toList());
    assertEquals(2, filtered.size());
    assertEquals("2", filtered.get(0).getId());
    assertEquals("FooBar", filtered.get(0).getName());
    assertEquals(BuildType.MVN, filtered.get(0).getBuildType());
    assertEquals("3", filtered.get(1).getId());
    assertEquals("FooBaz", filtered.get(1).getName());
    assertEquals(BuildType.GRADLE, filtered.get(1).getBuildType());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) Test(org.junit.Test)

Example 23 with BuildConfiguration

use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.

the class RSQLPredicateProducerTest method testPredicateIn.

@Test
public void testPredicateIn() {
    Predicate<BuildConfiguration> streamPredicate = producer.getStreamPredicate("id=in=(2,3)");
    BuildConfiguration fooBarG = BuildConfiguration.builder().id("1").name("FooBar").buildType(BuildType.GRADLE).build();
    BuildConfiguration fooBarM = BuildConfiguration.builder().id("2").name("FooBar").buildType(BuildType.MVN).build();
    BuildConfiguration fooBazG = BuildConfiguration.builder().id("3").name("FooBaz").buildType(BuildType.GRADLE).build();
    List<BuildConfiguration> filtered = Arrays.asList(fooBarG, fooBarM, fooBazG).stream().filter(streamPredicate).collect(Collectors.toList());
    assertEquals(2, filtered.size());
    assertEquals("2", filtered.get(0).getId());
    assertEquals("FooBar", filtered.get(0).getName());
    assertEquals(BuildType.MVN, filtered.get(0).getBuildType());
    assertEquals("3", filtered.get(1).getId());
    assertEquals("FooBaz", filtered.get(1).getName());
    assertEquals(BuildType.GRADLE, filtered.get(1).getBuildType());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) Test(org.junit.Test)

Example 24 with BuildConfiguration

use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.

the class RSQLPredicateProducerTest method testPredicateWithTwoField.

@Test
public void testPredicateWithTwoField() {
    Predicate<BuildConfiguration> streamPredicate = producer.getStreamPredicate("name==\"FooBar\";buildType==GRADLE");
    BuildConfiguration fooBarG = BuildConfiguration.builder().name("FooBar").buildType(BuildType.GRADLE).build();
    BuildConfiguration fooBarM = BuildConfiguration.builder().name("FooBar").buildType(BuildType.MVN).build();
    BuildConfiguration fooBazG = BuildConfiguration.builder().name("FooBaz").buildType(BuildType.GRADLE).build();
    List<BuildConfiguration> filtered = Arrays.asList(fooBarG, fooBarM, fooBazG).stream().filter(streamPredicate).collect(Collectors.toList());
    assertEquals(1, filtered.size());
    assertEquals("FooBar", filtered.get(0).getName());
    assertEquals(BuildType.GRADLE, filtered.get(0).getBuildType());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) Test(org.junit.Test)

Example 25 with BuildConfiguration

use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.

the class RSQLPredicateProducerTest method testPredicateIsNotNull.

@Test
public void testPredicateIsNotNull() {
    Predicate<BuildConfiguration> streamPredicate = producer.getStreamPredicate("name=ISNULL=false");
    BuildConfiguration fooBarG = BuildConfiguration.builder().name("FooBar").buildType(BuildType.GRADLE).build();
    BuildConfiguration nullName = BuildConfiguration.builder().name(null).buildType(BuildType.MVN).build();
    List<BuildConfiguration> filtered = Arrays.asList(fooBarG, nullName).stream().filter(streamPredicate).collect(Collectors.toList());
    assertEquals(1, filtered.size());
    assertNotNull(filtered.get(0).getName());
    assertEquals(BuildType.GRADLE, filtered.get(0).getBuildType());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) Test(org.junit.Test)

Aggregations

BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)90 Test (org.junit.Test)65 ContainerTest (org.jboss.pnc.test.category.ContainerTest)45 BuildConfigurationClient (org.jboss.pnc.client.BuildConfigurationClient)31 HashMap (java.util.HashMap)17 InSequence (org.jboss.arquillian.junit.InSequence)17 Build (org.jboss.pnc.dto.Build)13 GroupBuild (org.jboss.pnc.dto.GroupBuild)12 SCMRepository (org.jboss.pnc.dto.SCMRepository)10 Test (org.junit.jupiter.api.Test)10 BuildConfigurationRef (org.jboss.pnc.dto.BuildConfigurationRef)9 Instant (java.time.Instant)8 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)7 BuildStatus (org.jboss.pnc.enums.BuildStatus)7 GroupConfigurationClient (org.jboss.pnc.client.GroupConfigurationClient)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 ArrayList (java.util.ArrayList)4 BuildConfigurationRevision (org.jboss.pnc.dto.BuildConfigurationRevision)4 HashSet (java.util.HashSet)3