Search in sources :

Example 56 with QuerySpec

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>());
    }
}
Also used : MetaResource(io.crnk.meta.model.resource.MetaResource) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test)

Example 57 with QuerySpec

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));
}
Also used : QuerySpec(io.crnk.core.queryspec.QuerySpec)

Example 58 with 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());
}
Also used : MetaElement(io.crnk.meta.model.MetaElement) MetaResource(io.crnk.meta.model.resource.MetaResource) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test)

Example 59 with QuerySpec

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);
}
Also used : MetaKey(io.crnk.meta.model.MetaKey) MetaResource(io.crnk.meta.model.resource.MetaResource) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test)

Example 60 with QuerySpec

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));
}
Also used : MetaElement(io.crnk.meta.model.MetaElement) MetaResource(io.crnk.meta.model.resource.MetaResource) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test)

Aggregations

QuerySpec (io.crnk.core.queryspec.QuerySpec)306 Test (org.junit.Test)233 FilterSpec (io.crnk.core.queryspec.FilterSpec)51 Document (io.crnk.core.engine.document.Document)45 Resource (io.crnk.core.engine.document.Resource)43 Set (java.util.Set)39 HashMap (java.util.HashMap)37 HashSet (java.util.HashSet)36 AbstractQuerySpecTest (io.crnk.core.queryspec.AbstractQuerySpecTest)34 QuerySpecAdapter (io.crnk.core.queryspec.internal.QuerySpecAdapter)32 AbstractJpaJerseyTest (io.crnk.jpa.AbstractJpaJerseyTest)32 Task (io.crnk.test.mock.models.Task)32 Project (io.crnk.core.mock.models.Project)28 Relationship (io.crnk.core.engine.document.Relationship)26 Task (io.crnk.core.mock.models.Task)26 TestEntity (io.crnk.jpa.model.TestEntity)26 ResourceIdentifier (io.crnk.core.engine.document.ResourceIdentifier)25 Serializable (java.io.Serializable)24 RelatedEntity (io.crnk.jpa.model.RelatedEntity)21 ResourceRegistryTest (io.crnk.core.resource.registry.ResourceRegistryTest)20