use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class MessageConversationsActions method waitForNotification.
public ApiResponse waitForNotification(int expectedCount) {
boolean isReceived = false;
int attemptCount = 20;
ApiResponse response = null;
while (!isReceived && attemptCount > 0) {
response = this.get("", new QueryParamsBuilder().add("fields=subject"));
isReceived = (response.extractList("messageConversations").size() == expectedCount);
attemptCount--;
}
return response;
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class DataItemQueryTests method testWhenFilteringByNonExistingNameWithoutPagination.
@Test
public void testWhenFilteringByNonExistingNameWithoutPagination() {
// Given
final String theDimensionType = "PROGRAM_INDICATOR";
final String aNonExistingName = "non-existing-name";
final String theUrlParams = "?filter=dimensionItemType:in:[%s]&filter=name:ilike:%s&paging=false";
// When
final ApiResponse response = dataItemActions.get(format(theUrlParams, theDimensionType, aNonExistingName));
// Then
response.validate().statusCode(is(OK));
response.validate().body("pager", is(nullValue()));
response.validate().body("dataItems", is(empty()));
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class DataItemQueryTests method testGetAllDataItemsUsingDefaultPagination.
@Test
public void testGetAllDataItemsUsingDefaultPagination() {
// When
final ApiResponse response = dataItemActions.get();
// Then
response.validate().statusCode(is(OK));
response.validate().body("pager", isA(Object.class));
response.validate().body("dataItems", is(not(empty())));
response.validate().body("dataItems.dimensionItemType", (anyOf(hasItem("PROGRAM_INDICATOR"), hasItem("DATA_ELEMENT"))));
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class DataItemQueryTests method testWhenDataIsNotFoundUsingDefaultPagination.
@Test
public void testWhenDataIsNotFoundUsingDefaultPagination() {
// Given
final String theDimensionType = "PROGRAM_INDICATOR";
final String aNonExistingName = "non-existing-Name";
final String aValidFilteringAttribute = "name";
final String theUrlParams = "?filter=dimensionItemType:in:[%s]&filter=" + aValidFilteringAttribute + ":ilike:%s";
// When
final ApiResponse response = dataItemActions.get(format(theUrlParams, theDimensionType, aNonExistingName));
// Then
response.validate().statusCode(is(OK));
response.validate().body("dataItems", is(empty()));
}
use of org.hisp.dhis.dto.ApiResponse in project dhis2-core by dhis2.
the class DataItemQueryTests method testGetAllDataItemsWithoutPagination.
@Test
public void testGetAllDataItemsWithoutPagination() {
// Given
final String noPagination = "?paging=false";
// When
final ApiResponse response = dataItemActions.get(noPagination);
// Then
response.validate().statusCode(is(OK));
response.validate().body("pager", is(nullValue()));
response.validate().body("dataItems", is(not(empty())));
response.validate().body("dataItems.dimensionItemType", hasItem("PROGRAM_INDICATOR"));
response.validate().body("dataItems.dimensionItemType", hasItem("DATA_ELEMENT"));
}
Aggregations