Search in sources :

Example 1 with JsonApiUrlBuilder

use of io.crnk.core.engine.internal.utils.JsonApiUrlBuilder in project crnk-framework by crnk-project.

the class PagingSpecUrlBuilder method build.

public String build(QueryAdapter queryAdapter) {
    JsonApiUrlBuilder urlBuilder = new JsonApiUrlBuilder(resourceRegistry);
    Object relationshipSourceId = requestSpec.getId();
    ResourceField relationshipField = requestSpec.getRelationshipField();
    ResourceInformation rootInfo;
    if (relationshipField == null) {
        rootInfo = queryAdapter.getResourceInformation();
    } else {
        rootInfo = relationshipField.getParentResourceInformation();
    }
    return urlBuilder.buildUrl(rootInfo, relationshipSourceId, queryAdapter, relationshipField != null ? relationshipField.getJsonName() : null);
}
Also used : ResourceField(io.crnk.core.engine.information.resource.ResourceField) ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) JsonApiUrlBuilder(io.crnk.core.engine.internal.utils.JsonApiUrlBuilder)

Example 2 with JsonApiUrlBuilder

use of io.crnk.core.engine.internal.utils.JsonApiUrlBuilder in project crnk-framework by crnk-project.

the class DefaultQueryParamsSerializerTest method setup.

@Before
public void setup() {
    CrnkBoot boot = new CrnkBoot();
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://127.0.0.1"));
    boot.boot();
    resourceRegistry = boot.getResourceRegistry();
    urlBuilder = new JsonApiUrlBuilder(resourceRegistry);
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) JsonApiUrlBuilder(io.crnk.core.engine.internal.utils.JsonApiUrlBuilder) Before(org.junit.Before)

Example 3 with JsonApiUrlBuilder

use of io.crnk.core.engine.internal.utils.JsonApiUrlBuilder in project crnk-framework by crnk-project.

the class DefaultQueryParamsSerializerTest method testPort.

@Test
public void testPort() {
    CrnkBoot boot = new CrnkBoot();
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider("https://127.0.0.1:1234"));
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
    boot.boot();
    resourceRegistry = boot.getResourceRegistry();
    urlBuilder = new JsonApiUrlBuilder(boot.getResourceRegistry());
    check("https://127.0.0.1:1234/tasks", null, new QueryParams());
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) JsonApiUrlBuilder(io.crnk.core.engine.internal.utils.JsonApiUrlBuilder) Test(org.junit.Test)

Example 4 with JsonApiUrlBuilder

use of io.crnk.core.engine.internal.utils.JsonApiUrlBuilder in project crnk-framework by crnk-project.

the class DefaultQuerySpecSerializerTest method testHttpsSchema.

@Test
public void testHttpsSchema() {
    CrnkBoot boot = new CrnkBoot();
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider("https://127.0.0.1"));
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery(String.format("%s,io.crnk.core.queryspec.pagingspec", MockConstants.TEST_MODELS_PACKAGE)));
    boot.boot();
    urlBuilder = new JsonApiUrlBuilder(boot.getResourceRegistry());
    check("https://127.0.0.1/tasks", null, new QuerySpec(Task.class));
}
Also used : Task(io.crnk.core.mock.models.Task) CrnkBoot(io.crnk.core.boot.CrnkBoot) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) JsonApiUrlBuilder(io.crnk.core.engine.internal.utils.JsonApiUrlBuilder) Test(org.junit.Test)

Example 5 with JsonApiUrlBuilder

use of io.crnk.core.engine.internal.utils.JsonApiUrlBuilder in project crnk-framework by crnk-project.

the class DefaultQuerySpecSerializerTest method testPort.

@Test
public void testPort() {
    CrnkBoot boot = new CrnkBoot();
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider("https://127.0.0.1:1234"));
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery(String.format("%s,io.crnk.core.queryspec.pagingspec", MockConstants.TEST_MODELS_PACKAGE)));
    boot.boot();
    urlBuilder = new JsonApiUrlBuilder(boot.getResourceRegistry());
    check("https://127.0.0.1:1234/tasks", null, new QuerySpec(Task.class));
}
Also used : Task(io.crnk.core.mock.models.Task) CrnkBoot(io.crnk.core.boot.CrnkBoot) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) JsonApiUrlBuilder(io.crnk.core.engine.internal.utils.JsonApiUrlBuilder) Test(org.junit.Test)

Aggregations

JsonApiUrlBuilder (io.crnk.core.engine.internal.utils.JsonApiUrlBuilder)7 CrnkBoot (io.crnk.core.boot.CrnkBoot)6 ConstantServiceUrlProvider (io.crnk.core.engine.url.ConstantServiceUrlProvider)6 ReflectionsServiceDiscovery (io.crnk.core.module.discovery.ReflectionsServiceDiscovery)6 Test (org.junit.Test)4 Task (io.crnk.core.mock.models.Task)2 Before (org.junit.Before)2 ResourceField (io.crnk.core.engine.information.resource.ResourceField)1 ResourceInformation (io.crnk.core.engine.information.resource.ResourceInformation)1