use of org.hisp.dhis.android.core.category.Category in project dhis2-android-sdk by dhis2.
the class CategoryCallFactory method create.
@NonNull
public static CategoryEndpointCall create(Retrofit retrofit, DatabaseAdapter databaseAdapter) {
CategoryService categoryService = retrofit.create(CategoryService.class);
ResponseValidator<Category> categoryResponseValidator = new ResponseValidator<>();
CategoryHandler categoryHandler = HandlerFactory.createCategoryHandler(databaseAdapter);
ResourceHandler resourceHandler = HandlerFactory.createResourceHandler(databaseAdapter);
CategoryQuery categoryQuery = CategoryQuery.defaultQuery();
CategoryEndpointCall categoryEndpointCall = new CategoryEndpointCall(categoryQuery, categoryService, categoryResponseValidator, categoryHandler, resourceHandler, databaseAdapter, new Date());
return categoryEndpointCall;
}
use of org.hisp.dhis.android.core.category.Category in project dhis2-android-sdk by dhis2.
the class CategoryShould method map_from_json_string.
@Test
public void map_from_json_string() throws IOException, ParseException {
ObjectMapper objectMapper = Inject.objectMapper();
Category category = objectMapper.readValue("{\"" + "lastUpdated\":\"2014-11-19T12:58:52.558\"," + "\"id\":\"KfdsGBcoiCa\"," + "\"href\":\"https://play.dhis2.org/demo/api/categories/KfdsGBcoiCa\"," + "\"created\":\"2011-12-24T12:24:25.155\"," + "\"name\":\"Births attended by\"," + "\"shortName\":\"Births attended by\"," + "\"dataDimensionType\":\"DISAGGREGATION\"," + "\"dimensionType\":\"CATEGORY\"," + "\"displayName\":\"Births attended by\"," + "\"publicAccess\":\"rw------\"," + "\"displayShortName\":\"Births attended by\"," + "\"externalAccess\":false," + "\"dimension\":\"KfdsGBcoiCa\"," + "\"allItems\":false," + "\"dataDimension\":false," + "\"user\":{\"id\":\"GOLswS44mh8\"}," + "\"translations\":[]," + "\"categoryCombos\":[{\"id\":\"m2jTvAj5kkm\"}]," + "\"categoryOptions\":[" + "{\"id\":\"TNYQzTHdoxL\"}," + "{\"id\":\"TXGfLxZlInA\"}," + "{\"id\":\"QgULqw9YDu2\"}," + "{\"id\":\"OjIOxG7vgna\"}," + "{\"id\":\"uZUnebiT5DI\"}," + "{\"id\":\"HTHvCohKoXt\"}]," + "\"userGroupAccesses\":[]" + "}", Category.class);
assertThat(category.uid()).isEqualTo("KfdsGBcoiCa");
assertThat(category.created()).isEqualTo(BaseIdentifiableObject.DATE_FORMAT.parse("2011-12-24T12:24:25.155"));
assertThat(category.lastUpdated()).isEqualTo(BaseIdentifiableObject.DATE_FORMAT.parse("2014-11-19T12:58:52.558"));
// names
assertThat(category.name()).isEqualTo("Births attended by");
assertThat(category.shortName()).isEqualTo("Births attended by");
assertThat(category.displayName()).isEqualTo("Births attended by");
assertThat(category.displayShortName()).isEqualTo("Births attended by");
// checking options
assertThat(category.categoryOptions().get(0).uid()).isEqualTo("TNYQzTHdoxL");
assertThat(category.categoryOptions().get(1).uid()).isEqualTo("TXGfLxZlInA");
assertThat(category.categoryOptions().get(2).uid()).isEqualTo("QgULqw9YDu2");
assertThat(category.categoryOptions().get(3).uid()).isEqualTo("OjIOxG7vgna");
assertThat(category.categoryOptions().get(4).uid()).isEqualTo("uZUnebiT5DI");
assertThat(category.categoryOptions().get(5).uid()).isEqualTo("HTHvCohKoXt");
}
Aggregations