Search in sources :

Example 1 with NullPropertiesProvider

use of io.crnk.core.engine.properties.NullPropertiesProvider in project crnk-framework by crnk-project.

the class JpaPartialEntityExposureTest method testInformationBuilder.

@Test
public void testInformationBuilder() {
    EntityManager em = null;
    JpaResourceInformationProvider builder = new JpaResourceInformationProvider(new NullPropertiesProvider());
    ResourceInformation info = builder.build(TestEntity.class);
    List<ResourceField> relationshipFields = info.getRelationshipFields();
    Assert.assertEquals(0, relationshipFields.size());
}
Also used : JpaResourceInformationProvider(io.crnk.jpa.internal.JpaResourceInformationProvider) ResourceField(io.crnk.core.engine.information.resource.ResourceField) EntityManager(javax.persistence.EntityManager) ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) NullPropertiesProvider(io.crnk.core.engine.properties.NullPropertiesProvider)

Example 2 with NullPropertiesProvider

use of io.crnk.core.engine.properties.NullPropertiesProvider in project crnk-framework by crnk-project.

the class ClientDocumentMapperTest method setup.

@Before
public void setup() {
    boot = new CrnkBoot();
    boot.addModule(new TestModule());
    boot.boot();
    NullPropertiesProvider properties = new NullPropertiesProvider();
    documentMapper = new ClientDocumentMapper(boot.getModuleRegistry(), boot.getObjectMapper(), properties);
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) NullPropertiesProvider(io.crnk.core.engine.properties.NullPropertiesProvider) TestModule(io.crnk.test.mock.TestModule) Before(org.junit.Before)

Example 3 with NullPropertiesProvider

use of io.crnk.core.engine.properties.NullPropertiesProvider in project crnk-framework by crnk-project.

the class ResourceIdControllerTest method checkPatchResource.

private Resource checkPatchResource(Resource resource) {
    JsonPath path = pathBuilder.build("/relationIdTest/" + resource.getId());
    resource.getRelationships().put("testLookupAlways", new Relationship(schedule2Id));
    Document newDocument = createDocument(resource);
    // WHEN PATCH
    ResourcePatch sut = new ResourcePatch(resourceRegistry, new NullPropertiesProvider(), typeParser, objectMapper, documentMapper, modificationFilters);
    Response taskResponse = sut.handle(path, emptyTaskQuery, null, newDocument);
    // THEN PATCH
    assertThat(taskResponse.getHttpStatus()).isEqualTo(HttpStatus.OK_200);
    Resource updatedResource = taskResponse.getDocument().getSingleData().get();
    Assert.assertEquals(resource.getType(), updatedResource.getType());
    Assert.assertEquals(resource.getId(), updatedResource.getId());
    Assert.assertEquals(resource.getAttributes().get("name"), updatedResource.getAttributes().get("name"));
    Relationship relationship = updatedResource.getRelationships().get("testLookupAlways");
    Assert.assertTrue(relationship.getData().isPresent());
    Assert.assertEquals(schedule2Id, relationship.getData().get());
    // validate relationship not accessed, only id set => performance
    RelationIdTestResource entity = repository.findOne(1L, new QuerySpec(RelationIdTestResource.class));
    Assert.assertEquals(schedule2.getId(), entity.getTestLookupAlwaysId());
    Assert.assertNull(entity.getTestLookupAlways());
    return updatedResource;
}
Also used : Response(io.crnk.core.engine.dispatcher.Response) Relationship(io.crnk.core.engine.document.Relationship) NullPropertiesProvider(io.crnk.core.engine.properties.NullPropertiesProvider) Resource(io.crnk.core.engine.document.Resource) RelationIdTestResource(io.crnk.core.mock.models.RelationIdTestResource) JsonPath(io.crnk.core.engine.internal.dispatcher.path.JsonPath) Document(io.crnk.core.engine.document.Document) ResourcePatch(io.crnk.core.engine.internal.dispatcher.controller.ResourcePatch) RelationshipsResourcePatch(io.crnk.core.engine.internal.dispatcher.controller.RelationshipsResourcePatch) QuerySpec(io.crnk.core.queryspec.QuerySpec) RelationIdTestResource(io.crnk.core.mock.models.RelationIdTestResource)

Example 4 with NullPropertiesProvider

use of io.crnk.core.engine.properties.NullPropertiesProvider in project crnk-framework by crnk-project.

the class FallbackServiceDiscoveryFactoryTest method returnDefaultDiscoveryIfAvailable.

@Test
public void returnDefaultDiscoveryIfAvailable() {
    PropertiesProvider propertiesProvider = new NullPropertiesProvider();
    DefaultServiceDiscoveryFactory defaultFactory = new DefaultServiceDiscoveryFactory();
    FallbackServiceDiscoveryFactory fallbackFactory = new FallbackServiceDiscoveryFactory(defaultFactory, new SampleJsonServiceLocator(), propertiesProvider);
    Assert.assertTrue(fallbackFactory.getInstance() instanceof TestServiceDiscovery);
}
Also used : PropertiesProvider(io.crnk.core.engine.properties.PropertiesProvider) NullPropertiesProvider(io.crnk.core.engine.properties.NullPropertiesProvider) NullPropertiesProvider(io.crnk.core.engine.properties.NullPropertiesProvider) SampleJsonServiceLocator(io.crnk.legacy.locator.SampleJsonServiceLocator) Test(org.junit.Test)

Example 5 with NullPropertiesProvider

use of io.crnk.core.engine.properties.NullPropertiesProvider in project crnk-framework by crnk-project.

the class AbstractQueryParamsTest method setup.

@Before
public void setup() {
    JsonServiceLocator jsonServiceLocator = new SampleJsonServiceLocator();
    ResourceInformationProvider resourceInformationProvider = new DefaultResourceInformationProvider(new NullPropertiesProvider(), (PagingBehavior) null, new DefaultResourceFieldInformationProvider(), new JacksonResourceFieldInformationProvider());
    SimpleModule testModule = new SimpleModule("test");
    CrnkBoot boot = new CrnkBoot();
    boot.addModule(testModule);
    boot.boot();
    moduleRegistry = boot.getModuleRegistry();
    resourceRegistry = boot.getResourceRegistry();
    converter = new DefaultQueryParamsConverter(resourceRegistry);
    paramsToSpecConverter = new DefaultQuerySpecConverter(moduleRegistry);
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) NullPropertiesProvider(io.crnk.core.engine.properties.NullPropertiesProvider) SampleJsonServiceLocator(io.crnk.legacy.locator.SampleJsonServiceLocator) DefaultResourceInformationProvider(io.crnk.core.engine.internal.information.resource.DefaultResourceInformationProvider) JsonServiceLocator(io.crnk.legacy.locator.JsonServiceLocator) SampleJsonServiceLocator(io.crnk.legacy.locator.SampleJsonServiceLocator) ResourceInformationProvider(io.crnk.core.engine.information.resource.ResourceInformationProvider) DefaultResourceInformationProvider(io.crnk.core.engine.internal.information.resource.DefaultResourceInformationProvider) JacksonResourceFieldInformationProvider(io.crnk.core.engine.internal.jackson.JacksonResourceFieldInformationProvider) DefaultQuerySpecConverter(io.crnk.legacy.internal.DefaultQuerySpecConverter) SimpleModule(io.crnk.core.module.SimpleModule) DefaultResourceFieldInformationProvider(io.crnk.core.engine.internal.information.resource.DefaultResourceFieldInformationProvider) Before(org.junit.Before)

Aggregations

NullPropertiesProvider (io.crnk.core.engine.properties.NullPropertiesProvider)11 Before (org.junit.Before)5 CrnkBoot (io.crnk.core.boot.CrnkBoot)4 DefaultInformationBuilder (io.crnk.core.engine.internal.information.DefaultInformationBuilder)3 DefaultResourceFieldInformationProvider (io.crnk.core.engine.internal.information.resource.DefaultResourceFieldInformationProvider)3 DefaultResourceInformationProvider (io.crnk.core.engine.internal.information.resource.DefaultResourceInformationProvider)3 JacksonResourceFieldInformationProvider (io.crnk.core.engine.internal.jackson.JacksonResourceFieldInformationProvider)3 JpaResourceInformationProvider (io.crnk.jpa.internal.JpaResourceInformationProvider)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Response (io.crnk.core.engine.dispatcher.Response)2 Document (io.crnk.core.engine.document.Document)2 Relationship (io.crnk.core.engine.document.Relationship)2 Resource (io.crnk.core.engine.document.Resource)2 ResourceField (io.crnk.core.engine.information.resource.ResourceField)2 ResourceFieldAccess (io.crnk.core.engine.information.resource.ResourceFieldAccess)2 ResourceFieldAccessor (io.crnk.core.engine.information.resource.ResourceFieldAccessor)2 ResourceInformation (io.crnk.core.engine.information.resource.ResourceInformation)2 ResourceInformationProvider (io.crnk.core.engine.information.resource.ResourceInformationProvider)2 JsonPath (io.crnk.core.engine.internal.dispatcher.path.JsonPath)2 TypeParser (io.crnk.core.engine.parser.TypeParser)2