use of org.motechproject.mds.query.QueryParams in project motech by motech.
the class QueryParamsBuilderTest method shouldBuildDefaultQueryParams.
@Test
public void shouldBuildDefaultQueryParams() {
when(gridSettings.getPage()).thenReturn(null);
when(gridSettings.getRows()).thenReturn(null);
QueryParams queryParams = QueryParamsBuilder.buildQueryParams(gridSettings);
assertNotNull(queryParams);
assertPagination(queryParams, QueryParamsBuilder.DEFAULT_PAGE, QueryParamsBuilder.DEFAULT_PAGE_SIZE);
assertEquals(1, queryParams.getOrderList().size());
assertDefaultIdOrder(queryParams, 0);
}
use of org.motechproject.mds.query.QueryParams in project motech by motech.
the class QueryParamsBuilderTest method shouldNotAddIdOrderingIfItsPresent.
@Test
public void shouldNotAddIdOrderingIfItsPresent() {
when(gridSettings.getSortColumn()).thenReturn(Constants.Util.ID_FIELD_NAME);
when(gridSettings.getSortDirection()).thenReturn("descending");
QueryParams queryParams = QueryParamsBuilder.buildQueryParams(gridSettings);
assertNotNull(queryParams);
assertEquals(1, queryParams.getOrderList().size());
assertOrderPresent(queryParams, 0, Constants.Util.ID_FIELD_NAME, Order.Direction.DESC);
}
use of org.motechproject.mds.query.QueryParams in project motech by motech.
the class MdsRestFacadeTest method shouldExecuteLookupWithoutBlobField.
@Test
public void shouldExecuteLookupWithoutBlobField() {
Map<String, String> lookupMap = asLookupMap(null, "44");
QueryParams queryParams = mock(QueryParams.class);
when(dataService.supportedLookup(null, 44, queryParams)).thenReturn(asList(recordOne));
RestResponse result = (RestResponse) mdsRestFacade.executeLookup(SUPPORTED_LOOKUP_NAME, lookupMap, queryParams, false);
assertEquals(1, result.getData().size());
assertEquals(3, result.getData().get(0).size());
assertEquals(recordOne.getValue(), result.getData().get(0).get(VALUE_FIELD));
assertEquals(recordOne.getDate(), result.getData().get(0).get(DATE_FIELD));
assertNull(result.getData().get(0).get(BLOB_FIELD));
verify(dataService).supportedLookup(null, 44, queryParams);
}
use of org.motechproject.mds.query.QueryParams in project motech by motech.
the class MdsRestFacadeTest method shouldGetByQueryParamsWithBlobField.
@Test
public void shouldGetByQueryParamsWithBlobField() {
setUpCrudAccess(false, true, false, false);
QueryParams queryParams = new QueryParams(5, 20, new Order("value", Order.Direction.DESC));
RestResponse result = mdsRestFacade.get(queryParams, true);
verify(dataService).retrieveAll(queryParams);
assertEquals(1, result.getData().size());
assertEquals(3, result.getData().get(0).size());
assertEquals(recordOne.getValue(), result.getData().get(0).get(VALUE_FIELD));
assertEquals(recordOne.getDate(), result.getData().get(0).get(DATE_FIELD));
assertArrayEquals(encodedBlobField, (byte[]) result.getData().get(0).get(BLOB_FIELD));
}
use of org.motechproject.mds.query.QueryParams in project motech by motech.
the class MdsRestFacadeTest method shouldGetByQueryParamsWithoutBlobField.
// regular verifications
@Test
public void shouldGetByQueryParamsWithoutBlobField() {
setUpCrudAccess(false, true, false, false);
QueryParams queryParams = new QueryParams(5, 20, new Order("value", Order.Direction.DESC));
RestResponse result = mdsRestFacade.get(queryParams, false);
verify(dataService).retrieveAll(queryParams);
assertEquals(1, result.getData().size());
assertEquals(3, result.getData().get(0).size());
assertEquals(recordOne.getValue(), result.getData().get(0).get(VALUE_FIELD));
assertEquals(recordOne.getDate(), result.getData().get(0).get(DATE_FIELD));
assertNull(result.getData().get(0).get(BLOB_FIELD));
}
Aggregations