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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations