Search in sources :

Example 1 with Name

use of org.structr.core.graph.attribute.Name in project structr by structr.

the class PagingAndSortingTest method testRelationshipResourcePagingOnCollectionResource.

@Test
public void testRelationshipResourcePagingOnCollectionResource() {
    final Class testUserType = createTestUserType();
    final PropertyKey<String> passwordKey = StructrApp.key(testUserType, "password");
    Principal tester = null;
    try (final Tx tx = app.tx()) {
        tester = app.create(testUserType, new Name("tester"), new NodeAttribute<>(passwordKey, "test"));
        tx.success();
    } catch (FrameworkException fex) {
        fex.printStackTrace();
    }
    final App app = StructrApp.getInstance(SecurityContext.getInstance(tester, AccessMode.Backend));
    try (final Tx tx = app.tx()) {
        app.create(TestOne.class, "TestOne1");
        app.create(TestOne.class, "TestOne2");
        tx.success();
    } catch (FrameworkException fex) {
        fex.printStackTrace();
    }
    RestAssured.given().contentType("application/json; charset=UTF-8").filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(200)).expect().statusCode(200).body("result_count", equalTo(4)).body("page_size", equalTo(2)).body("page_count", equalTo(2)).body("result", hasSize(2)).body("result[0].type", equalTo("PrincipalOwnsNode")).body("result[1].type", equalTo("Security")).when().get("/TestOne/in?pageSize=2");
}
Also used : StructrApp(org.structr.core.app.StructrApp) App(org.structr.core.app.App) NodeAttribute(org.structr.core.graph.NodeAttribute) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) Principal(org.structr.core.entity.Principal) Name(org.structr.core.graph.attribute.Name) Test(org.junit.Test) StructrRestTest(org.structr.rest.common.StructrRestTest)

Example 2 with Name

use of org.structr.core.graph.attribute.Name in project structr by structr.

the class PagingAndSortingTest method testRelationshipResourcePagingOnEntityResource.

@Test
public void testRelationshipResourcePagingOnEntityResource() {
    final Class testUserType = createTestUserType();
    final PropertyKey<String> passwordKey = StructrApp.key(testUserType, "password");
    Principal tester = null;
    try (final Tx tx = app.tx()) {
        tester = app.create(testUserType, new Name("tester"), new NodeAttribute<>(passwordKey, "test"));
        tx.success();
    } catch (FrameworkException fex) {
        fex.printStackTrace();
    }
    final App app = StructrApp.getInstance(SecurityContext.getInstance(tester, AccessMode.Backend));
    try (final Tx tx = app.tx()) {
        app.create(TestOne.class, "TestOne1");
        app.create(TestOne.class, "TestOne2");
        tx.success();
    } catch (FrameworkException fex) {
        fex.printStackTrace();
    }
    RestAssured.given().contentType("application/json; charset=UTF-8").filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(200)).expect().statusCode(200).body("result_count", equalTo(4)).body("page_size", equalTo(2)).body("page_count", equalTo(2)).body("result", hasSize(2)).body("result[0].type", equalTo("PrincipalOwnsNode")).body("result[1].type", equalTo("Security")).when().get("/TestUser/" + tester.getUuid() + "/out?pageSize=2");
}
Also used : StructrApp(org.structr.core.app.StructrApp) App(org.structr.core.app.App) NodeAttribute(org.structr.core.graph.NodeAttribute) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) Principal(org.structr.core.entity.Principal) Name(org.structr.core.graph.attribute.Name) Test(org.junit.Test) StructrRestTest(org.structr.rest.common.StructrRestTest)

Aggregations

Test (org.junit.Test)2 FrameworkException (org.structr.common.error.FrameworkException)2 App (org.structr.core.app.App)2 StructrApp (org.structr.core.app.StructrApp)2 Principal (org.structr.core.entity.Principal)2 NodeAttribute (org.structr.core.graph.NodeAttribute)2 Tx (org.structr.core.graph.Tx)2 Name (org.structr.core.graph.attribute.Name)2 StructrRestTest (org.structr.rest.common.StructrRestTest)2