use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class MetadataWorkflowControllerTest method testGetProposals.
@Test
void testGetProposals() {
String proposalId = postAddProposal("My Unit", "OU1");
assertNotNull(proposalId);
JsonObject page = GET("/metadata/proposals/").content();
assertTrue(page.has("pager", "proposals"));
assertEquals(1, page.getArray("proposals").size());
assertEquals(proposalId, page.getArray("proposals").getObject(0).getString("id").string());
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class AbstractDataValueControllerTest method setUp.
@BeforeEach
void setUp() {
orgUnitId = assertStatus(HttpStatus.CREATED, POST("/organisationUnits/", "{'name':'My Unit', 'shortName':'OU1', 'openingDate': '2020-01-01'}"));
// add OU to users hierarchy
assertStatus(HttpStatus.OK, POST("/users/{id}/organisationUnits", getCurrentUser().getUid(), Body("{'additions':[{'id':'" + orgUnitId + "'}]}")));
JsonObject ccDefault = GET("/categoryCombos/gist?fields=id,categoryOptionCombos::ids&pageSize=1&headless=true&filter=name:eq:default").content().getObject(0);
categoryComboId = ccDefault.getString("id").string();
categoryOptionId = ccDefault.getArray("categoryOptionCombos").getString(0).string();
dataElementId = assertStatus(HttpStatus.CREATED, POST("/dataElements/", "{'name':'My data element', 'shortName':'DE1', 'code':'DE1', 'valueType':'INTEGER', " + "'aggregationType':'SUM', 'zeroIsSignificant':false, 'domainType':'AGGREGATE', " + "'categoryCombo': {'id': '" + categoryComboId + "'}}"));
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class AbstractGistControllerTest method assertHasPager.
static void assertHasPager(JsonObject response, int page, int pageSize, Integer total) {
JsonObject pager = response.getObject("pager");
assertTrue(pager.exists(), "Pager is missing");
assertEquals(page, pager.getNumber("page").intValue());
assertEquals(pageSize, pager.getNumber("pageSize").intValue());
if (total != null) {
assertEquals(total.intValue(), pager.getNumber("total").intValue());
assertEquals((int) Math.ceil(total / (double) pageSize), pager.getNumber("pageCount").intValue());
}
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class AbstractCrudControllerTest method testPutJsonObject_skipSharing.
@Test
void testPutJsonObject_skipSharing() {
String groupId = assertStatus(HttpStatus.CREATED, POST("/userGroups/", "{'name':'My Group'}"));
JsonObject group = GET("/userGroups/{id}", groupId).content();
String groupWithoutSharing = group.getObject("sharing").node().replaceWith("null").toString();
assertStatus(HttpStatus.OK, PUT("/userGroups/" + groupId + "?skipSharing=true", groupWithoutSharing));
assertEquals("rw------", GET("/userGroups/{id}", groupId).content().as(JsonGeoMap.class).getSharing().getPublic().string());
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class DataSetControllerTest method testGetVersion.
@Test
void testGetVersion() {
JsonObject info = GET("/dataSets/{id}/version", dsId).content(HttpStatus.OK);
assertTrue(info.isObject());
assertEquals(1, info.size());
assertEquals(0, info.getNumber("version").intValue());
}
Aggregations