use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.
the class MetaIntTest method testFetchResourcesWithNestedAttributesAndTypes.
@Test
public void testFetchResourcesWithNestedAttributesAndTypes() {
QuerySpec querySpec = new QuerySpec(MetaResource.class);
QuerySpec dataObjectSpec = querySpec.getOrCreateQuerySpec(MetaDataObject.class);
dataObjectSpec.includeRelation(Arrays.asList("attributes"));
QuerySpec attrSpec = querySpec.getOrCreateQuerySpec(MetaAttribute.class);
attrSpec.includeRelation(Arrays.asList("type"));
QuerySpec typeSpec = querySpec.getOrCreateQuerySpec(MetaType.class);
typeSpec.includeRelation(Arrays.asList("attributes", "type", "elementType", "attributes"));
typeSpec.includeRelation(Arrays.asList("elementType"));
typeSpec.includeRelation(Arrays.asList("superType"));
ResourceList<MetaResource> list = client.getRepositoryForType(MetaResource.class).findAll(querySpec);
Assert.assertFalse(list.isEmpty());
for (MetaResource elem : list) {
checkDataObjectLoaded(elem, new HashSet<String>());
}
}
use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.
the class MetaIntTest method testIdNaming.
public void testIdNaming() {
QuerySpec querySpec = new QuerySpec(MetaElement.class);
Assert.assertNotNull(repository.findOne("io.crnk.meta.metaElement", querySpec));
Assert.assertNotNull(repository.findOne("io.crnk.meta.metaElement$List", querySpec));
Assert.assertNotNull(repository.findOne("io.crnk.meta.metaAttribute", querySpec));
Assert.assertNotNull(repository.findOne("io.crnk.meta.metaType", querySpec));
Assert.assertNotNull(repository.findOne("io.crnk.jpa.metaEmbeddableAttribute.laz", querySpec));
Assert.assertNotNull(repository.findOne("io.crnk.meta.metaType$primaryKey", querySpec));
}
use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.
the class MetaRelationshipRepositoryImplTest method findManyTargetReturnsResult.
@Test
public void findManyTargetReturnsResult() {
MetaResource resource = resourceProvider.getMeta(Task.class);
ResourceList<MetaElement> children = repo.findManyTargets(resource.getId(), "children", new QuerySpec(MetaElement.class));
Assert.assertNotEquals(0, children.size());
}
use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.
the class MetaRelationshipRepositoryImplTest method findOneTargetReturnsNull.
@Test
public void findOneTargetReturnsNull() {
MetaResource resource = resourceProvider.getMeta(Task.class);
resource.setPrimaryKey(null);
MetaKey key = (MetaKey) repo.findOneTarget(resource.getId(), "primaryKey", new QuerySpec(MetaElement.class));
Assert.assertNull(key);
}
use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.
the class MetaRelationshipRepositoryImplTest method findManyTargetCannotBeUsedForSingeValuesRelations.
@Test(expected = ClassCastException.class)
public void findManyTargetCannotBeUsedForSingeValuesRelations() {
MetaResource resource = resourceProvider.getMeta(Task.class);
repo.findManyTargets(resource.getId(), "primaryKey", new QuerySpec(MetaElement.class));
}
Aggregations