use of org.hisp.dhis.android.core.resource.ResourceHandler in project dhis2-android-sdk by dhis2.
the class OptionSetCallShould method setUp.
@Override
@Before
public void setUp() throws IOException {
super.setUp();
mockWebServer = new MockWebServer();
mockWebServer.start();
MockResponse mockResponse = new MockResponse();
mockResponse.setBody("{\n" + "\n" + " \"pager\": {\n" + " \"page\": 1,\n" + " \"pageCount\": 1,\n" + " \"total\": 1,\n" + " \"pageSize\": 50\n" + " },\n" + " \"optionSets\": [\n" + " {\n" + " \"lastUpdated\": \"2012-09-20T16:05:17.555\",\n" + " \"created\": \"2012-09-20T16:05:17.555\",\n" + " \"name\": \"MNCH PMTCT code\",\n" + " \"id\": \"POc7DkGU3QU\",\n" + " \"displayName\": \"MNCH PMTCT code\",\n" + " \"valueType\": \"TEXT\",\n" + " \"version\": 1,\n" + " \"options\": [\n" + " {\n" + " \"code\": \"C\",\n" + " \"created\": \"2014-08-18T12:39:16.000\",\n" + " \"lastUpdated\": \"2014-08-18T12:39:16.000\",\n" + " \"name\": \"C\",\n" + " \"id\": \"s2gIL3CEyKL\",\n" + " \"displayName\": \"C\",\n" + " \"externalAccess\": false,\n" + " \"sortOrder\": 1,\n" + " \"optionSet\": {\n" + " \"id\": \"POc7DkGU3QU\"\n" + " },\n" + " \"userGroupAccesses\": [ ],\n" + " \"attributeValues\": [ ],\n" + " \"translations\": [ ],\n" + " \"userAccesses\": [ ]\n" + " },\n" + " {\n" + " \"code\": \"TR\",\n" + " \"created\": \"2014-08-18T12:39:16.000\",\n" + " \"lastUpdated\": \"2014-08-18T12:39:16.000\",\n" + " \"name\": \"TR\",\n" + " \"id\": \"poM80hUlVi9\",\n" + " \"displayName\": \"TR\",\n" + " \"externalAccess\": false,\n" + " \"sortOrder\": 2,\n" + " \"optionSet\": {\n" + " \"id\": \"POc7DkGU3QU\"\n" + " },\n" + " \"userGroupAccesses\": [ ],\n" + " \"attributeValues\": [ ],\n" + " \"translations\": [ ],\n" + " \"userAccesses\": [ ]\n" + " },\n" + " {\n" + " \"code\": \"TRR\",\n" + " \"created\": \"2014-08-18T12:39:16.000\",\n" + " \"lastUpdated\": \"2014-08-18T12:39:16.000\",\n" + " \"name\": \"TRR\",\n" + " \"id\": \"hcvPpAy3kb2\",\n" + " \"displayName\": \"TRR\",\n" + " \"externalAccess\": false,\n" + " \"sortOrder\": 3,\n" + " \"optionSet\": {\n" + " \"id\": \"POc7DkGU3QU\"\n" + " },\n" + " \"userGroupAccesses\": [ ],\n" + " \"attributeValues\": [ ],\n" + " \"translations\": [ ],\n" + " \"userAccesses\": [ ]\n" + " },\n" + " {\n" + " \"code\": \"TRRDm\",\n" + " \"created\": \"2014-08-18T12:39:16.000\",\n" + " \"lastUpdated\": \"2014-08-18T12:39:16.000\",\n" + " \"name\": \"TRRDm\",\n" + " \"id\": \"u4wsy7OPQIg\",\n" + " \"displayName\": \"TRRDm\",\n" + " \"externalAccess\": false,\n" + " \"sortOrder\": 4,\n" + " \"optionSet\": {\n" + " \"id\": \"POc7DkGU3QU\"\n" + " },\n" + " \"userGroupAccesses\": [ ],\n" + " \"attributeValues\": [ ],\n" + " \"translations\": [ ],\n" + " \"userAccesses\": [ ]\n" + " }\n" + " ]\n" + " }\n" + " ]\n" + "\n" + "}");
mockWebServer.enqueue(mockResponse);
// ToDo: consider moving this out
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setDateFormat(BaseIdentifiableObject.DATE_FORMAT.raw());
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
Retrofit retrofit = new Retrofit.Builder().baseUrl(mockWebServer.url("/")).addConverterFactory(JacksonConverterFactory.create(objectMapper)).addConverterFactory(FieldsConverterFactory.create()).build();
OptionSetService optionSetService = retrofit.create(OptionSetService.class);
ResourceStore resourceStore = new ResourceStoreImpl(databaseAdapter());
Set<String> uids = new HashSet<>();
uids.add("POc7DkGU3QU");
// TODO fix
GenericCallData data = GenericCallData.create(databaseAdapter(), new ResourceHandler(resourceStore), retrofit);
GenericHandler<OptionSet, OptionSetModel> optionSetHandler = OptionSetHandler.create(databaseAdapter());
optionSetCall = new OptionSetCall(data, optionSetService, optionSetHandler, uids);
}
use of org.hisp.dhis.android.core.resource.ResourceHandler in project dhis2-android-sdk by dhis2.
the class DataValueEndpointCallRealIntegrationShould method createCall.
private DataValueEndpointCall createCall() {
ResourceHandler resourceHandler = new ResourceHandler(new ResourceStoreImpl(databaseAdapter()));
GenericCallData data = GenericCallData.create(databaseAdapter(), resourceHandler, d2.retrofit());
return DataValueEndpointCall.FACTORY.create(data, getDataSetUids(), getPeriodIds(), getOrgUnitUids());
}
Aggregations