コード例 #1
0
  public void testClassPermisions() {
    // ---------- PERMISSION TYPES FOR CLASSES
    SyncanoClass syncanoClass = new SyncanoClass(ExampleObject.class);
    syncanoClass.setOtherPermissions(SyncanoClassPermissions.CREATE_OBJECTS);

    Response<SyncanoClass> response = syncano.createSyncanoClass(syncanoClass).send();
    // -----------------------------

    assertEquals(Response.HTTP_CODE_CREATED, response.getHttpResultCode());
  }
コード例 #2
0
  public void testCreateObjectPermission() {
    createClass(ExampleObject.class);
    // ---------- Creating a Data Object with an owner_permissions example
    ExampleObject obj = new ExampleObject();
    obj.setOwnerPermissions(DataObjectPermissions.READ);
    obj.data = "I am sample data";
    Response<ExampleObject> response = obj.save();
    // -----------------------------

    assertEquals(Response.HTTP_CODE_CREATED, response.getHttpResultCode());
    assertNotNull(response.getData());
    assertEquals(DataObjectPermissions.READ, response.getData().getOwnerPermissions());
  }
コード例 #3
0
  public void testClassGroupPermisions() {
    String groupName = "group";

    Groups.deleteGroup(syncano, groupName);
    Response<Group> responseGroup = syncano.createGroup(new Group(groupName)).send();
    assertEquals(Response.HTTP_CODE_CREATED, responseGroup.getHttpResultCode());
    Group group = responseGroup.getData();
    assertNotNull(group);

    // ---------- Next, when creating a Class, you'd set group_permissions to
    // create_objects and pass a group id to the group parameter
    SyncanoClass syncanoClass = new SyncanoClass(ExampleObject.class);
    syncanoClass.setGroup(group.getId());
    syncanoClass.setGroupPermissions(SyncanoClassPermissions.CREATE_OBJECTS);

    Response<SyncanoClass> response = syncano.createSyncanoClass(syncanoClass).send();
    // -----------------------------

    assertEquals(Response.HTTP_CODE_CREATED, response.getHttpResultCode());
  }