use of org.jboss.pnc.model.BuildEnvironment in project pnc by project-ncl.
the class Producers method buildEnv.
BuildEnvironment buildEnv() {
final String name = randomAlphabetic(10);
BuildEnvironment environment = BuildEnvironment.Builder.newBuilder().name(name).systemImageRepositoryUrl("https://example.com/" + name).systemImageType(SystemImageType.DOCKER_IMAGE).systemImageId(randomNumeric(10)).build();
buildEnvironmentRepository.save(environment);
return environment;
}
use of org.jboss.pnc.model.BuildEnvironment in project pnc by project-ncl.
the class RSQLPredicateProducerTest method testCriteriaPredicateEmbeded.
@Test
public void testCriteriaPredicateEmbeded() {
org.jboss.pnc.spi.datastore.repositories.api.Predicate<BuildRecord> criteriaPredicate = producer.getCriteriaPredicate(BuildRecord.class, "environment.name==fooEnv");
CriteriaBuilder cb = mock(CriteriaBuilder.class);
Root<BuildRecord> root = mock(Root.class);
Join<BuildRecord, BuildEnvironment> join = mock(Join.class);
SingularAttributePath<String> namePath = mock(SingularAttributePath.class);
when(root.join(BuildRecord_.buildEnvironment)).thenReturn(join);
when(join.get(BuildEnvironment_.name)).thenReturn(namePath);
Mockito.doReturn(String.class).when(namePath).getJavaType();
SingularAttribute pathAttribute = mock(SingularAttribute.class);
java.lang.reflect.Member javaMember = mock(java.lang.reflect.Member.class);
Mockito.doReturn(BuildEnvironment.class).when(javaMember).getDeclaringClass();
Mockito.doReturn(javaMember).when(pathAttribute).getJavaMember();
Mockito.doReturn("name").when(pathAttribute).getName();
Mockito.doReturn(pathAttribute).when(namePath).getAttribute();
criteriaPredicate.apply(root, null, cb);
Mockito.verify(cb).equal(namePath, "fooEnv");
}
Aggregations