use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class AbstractDataIntegrityControllerTest method getSummary.
protected final JsonDataIntegritySummary getSummary(String check) {
JsonObject content = GET("/dataIntegrity/summary?checks={check}&timeout=1000", check).content();
JsonDataIntegritySummary summary = content.get(check.replace('-', '_'), JsonDataIntegritySummary.class);
assertTrue(summary.exists());
assertTrue(summary.isObject());
return summary;
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class DomainJsonResponseTest method testCustomObjectTypeMap.
@Test
void testCustomObjectTypeMap() {
JsonObject response = createJSON("{'users': {'foo':{'id':'foo'}, 'bar':{'id':'bar'}}}");
JsonMap<JsonUser> usersById = response.getMap("users", JsonUser.class);
assertFalse(usersById.isEmpty());
assertEquals(2, usersById.size());
assertEquals("foo", usersById.get("foo").getId());
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class DomainJsonResponseTest method testDateType.
@Test
void testDateType() {
JsonObject response = createJSON("{'user': {'lastUpdated': '2021-01-21T15:14:54.000'}}");
JsonUser user = response.get("user", JsonUser.class);
assertEquals(LocalDateTime.of(2021, 1, 21, 15, 14, 54), user.getLastUpdated());
Assertions.assertNull(user.getCreated());
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class DomainJsonResponseTest method testCustomObjectTypeList.
@Test
void testCustomObjectTypeList() {
JsonObject response = createJSON("{'users': [ {'id':'foo'} ]}");
JsonList<JsonUser> users = response.getList("users", JsonUser.class);
assertEquals("foo", users.get(0).getId());
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class WebClientUtils method getCreatedId.
private static String getCreatedId(HttpResponse response) {
HttpStatus actual = response.status();
if (actual == HttpStatus.CREATED) {
JsonObject report = response.contentUnchecked().getObject("response");
if (report.exists()) {
return report.getString("uid").string();
}
}
String location = response.location();
return location == null ? null : location.substring(location.lastIndexOf('/') + 1);
}
Aggregations