Search in sources :

Example 51 with RegistryEntry

use of io.crnk.core.engine.registry.RegistryEntry in project crnk-framework by crnk-project.

the class ResourceRegistryTest method onNonExistingTypeShouldReturnNull.

@Test
public void onNonExistingTypeShouldReturnNull() {
    RegistryEntry entry = resourceRegistry.getEntry("nonExistingType");
    assertThat(entry).isNull();
}
Also used : RegistryEntry(io.crnk.core.engine.registry.RegistryEntry) Test(org.junit.Test)

Example 52 with RegistryEntry

use of io.crnk.core.engine.registry.RegistryEntry in project crnk-framework by crnk-project.

the class ResourceRegistryTest method onResourceGetEntryWithBackUp.

@Test
public void onResourceGetEntryWithBackUp() {
    String taskType = Task.class.getAnnotation(JsonApiResource.class).type();
    resourceRegistry.addEntry(Task.class, newRegistryEntry(Task.class, taskType));
    // WHEN
    RegistryEntry registryEntry = resourceRegistry.findEntry(Task.class);
    // THEN
    assertNotNull(registryEntry);
    assertNotNull(registryEntry.getResourceInformation().getResourceType(), taskType);
    // WHEN
    registryEntry = resourceRegistry.findEntry(Task.class);
    // THEN
    assertNotNull(registryEntry);
    assertNotNull(registryEntry.getResourceInformation().getResourceType(), taskType);
}
Also used : Task(io.crnk.core.mock.models.Task) JsonApiResource(io.crnk.core.resource.annotations.JsonApiResource) RegistryEntry(io.crnk.core.engine.registry.RegistryEntry) Test(org.junit.Test)

Example 53 with RegistryEntry

use of io.crnk.core.engine.registry.RegistryEntry in project crnk-framework by crnk-project.

the class DefaultQuerySpecSerializerTest method testFilterByMany.

@Test
public void testFilterByMany() throws InstantiationException, IllegalAccessException {
    QuerySpec querySpec = new QuerySpec(Task.class);
    querySpec.addFilter(new FilterSpec(Arrays.asList("name"), FilterOperator.EQ, Arrays.asList("value1", "value2")));
    RegistryEntry entry = resourceRegistry.getEntry(Task.class);
    String actualUrl = urlBuilder.buildUrl(entry.getResourceInformation(), null, querySpec);
    String expectedUrl0 = "http://127.0.0.1/tasks?filter[tasks][name][EQ]=value2&filter[tasks][name][EQ]=value1";
    String expectedUrl1 = "http://127.0.0.1/tasks?filter[tasks][name][EQ]=value1&filter[tasks][name][EQ]=value2";
    Assert.assertTrue(expectedUrl0.equals(actualUrl) || expectedUrl1.equals(actualUrl));
}
Also used : RegistryEntry(io.crnk.core.engine.registry.RegistryEntry) Test(org.junit.Test)

Example 54 with RegistryEntry

use of io.crnk.core.engine.registry.RegistryEntry in project crnk-framework by crnk-project.

the class DefaultQuerySpecSerializerTest method check.

private void check(String expectedUrl, Object id, QuerySpec querySpec) {
    RegistryEntry entry = resourceRegistry.getEntry(Task.class);
    String actualUrl = urlBuilder.buildUrl(entry.getResourceInformation(), id, querySpec);
    assertEquals(expectedUrl, actualUrl);
}
Also used : RegistryEntry(io.crnk.core.engine.registry.RegistryEntry)

Example 55 with RegistryEntry

use of io.crnk.core.engine.registry.RegistryEntry in project crnk-framework by crnk-project.

the class DefaultQuerySpecSerializerTest method testNestedFilterSpecNotYetSupported.

@Test(expected = UnsupportedOperationException.class)
public void testNestedFilterSpecNotYetSupported() throws InstantiationException, IllegalAccessException {
    QuerySpec querySpec = new QuerySpec(Task.class);
    querySpec.addFilter(FilterSpec.or(new FilterSpec(Arrays.asList("name"), FilterOperator.EQ, "test"), new FilterSpec(Arrays.asList("name"), FilterOperator.GE, "test")));
    RegistryEntry entry = resourceRegistry.getEntry(Task.class);
    urlBuilder.buildUrl(entry.getResourceInformation(), null, querySpec);
}
Also used : RegistryEntry(io.crnk.core.engine.registry.RegistryEntry) Test(org.junit.Test)

Aggregations

RegistryEntry (io.crnk.core.engine.registry.RegistryEntry)119 ResourceInformation (io.crnk.core.engine.information.resource.ResourceInformation)60 Test (org.junit.Test)38 ResourceField (io.crnk.core.engine.information.resource.ResourceField)36 ResourceRegistry (io.crnk.core.engine.registry.ResourceRegistry)19 QuerySpec (io.crnk.core.queryspec.QuerySpec)18 JsonApiResponse (io.crnk.core.repository.response.JsonApiResponse)14 Serializable (java.io.Serializable)14 Task (io.crnk.core.mock.models.Task)13 Response (io.crnk.core.engine.dispatcher.Response)12 Document (io.crnk.core.engine.document.Document)11 Resource (io.crnk.core.engine.document.Resource)11 ResourceRegistryTest (io.crnk.core.resource.registry.ResourceRegistryTest)10 ResourceRepositoryAdapter (io.crnk.core.engine.internal.repository.ResourceRepositoryAdapter)9 FilterSpec (io.crnk.core.queryspec.FilterSpec)9 QuerySpecAdapter (io.crnk.core.queryspec.internal.QuerySpecAdapter)8 Before (org.junit.Before)8 Collection (java.util.Collection)7 HashSet (java.util.HashSet)7 HttpMethod (io.crnk.core.engine.http.HttpMethod)6