use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class GistTransformControllerTest method testTransform_Pluck_NoArgument.
@Test
void testTransform_Pluck_NoArgument() {
JsonObject gist = GET("/users/{uid}/userGroups/gist?fields=name,users::pluck", getSuperuserUid()).content();
assertHasPager(gist, 1, 50);
assertEquals(getSuperuserUid(), gist.getArray("userGroups").getObject(0).getArray("users").getString(0).string());
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class GistTransformControllerTest method testTransform_NotMember.
@Test
void testTransform_NotMember() {
String url = "/users/{uid}/userGroups/gist?fields=name,users::not-member({uid})";
// not-member(id) with a user that is a member
JsonObject gist = GET(url, getSuperuserUid(), getSuperuserUid()).content();
assertFalse(gist.getArray("userGroups").getObject(0).getBoolean("users").booleanValue());
// not-member(id) with a user that is not a member
gist = GET(url, getSuperuserUid(), "non-existing-user-uid").content();
assertTrue(gist.getArray("userGroups").getObject(0).getBoolean("users").booleanValue());
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class GistTransformControllerTest method testTransform_Member.
@Test
void testTransform_Member() {
String url = "/users/{uid}/userGroups/gist?fields=name,users::member({uid})";
// member(id) with a user that is a member
JsonObject gist = GET(url, getSuperuserUid(), getSuperuserUid()).content();
assertTrue(gist.getArray("userGroups").getObject(0).getBoolean("users").booleanValue());
// member(id) with a user that is not a member
gist = GET(url, getSuperuserUid(), "non-existing-user-uid").content();
assertFalse(gist.getArray("userGroups").getObject(0).getBoolean("users").booleanValue());
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class GistTransformControllerTest method testTransform_Pluck.
@Test
void testTransform_Pluck() {
JsonObject gist = GET("/users/{uid}/userGroups/gist?fields=name,users::pluck(surname)", getSuperuserUid()).content();
assertHasPager(gist, 1, 50);
assertEquals("admin", gist.getArray("userGroups").getObject(0).getArray("users").getString(0).string());
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class InterpretationControllerTest method testDeleteComment.
@Test
void testDeleteComment() {
String cuid = assertStatus(HttpStatus.CREATED, POST("/interpretations/" + uid + "/comments", "text/plain:comment"));
assertStatus(HttpStatus.NO_CONTENT, DELETE("/interpretations/" + uid + "/comments/" + cuid));
JsonObject comments = GET("/interpretations/{uid}/comments", uid).content(HttpStatus.OK);
assertEquals(0, comments.getArray("comments").size());
}
Aggregations