@Test public void pullDataFromParent_shouldCallRestClient() { SyncClient resourceManager = new SyncClient(); Object pulledObject = resourceManager.pullData(PATIENT_CATEGORY, REST_CLIENT_KEY, REST_FULL_RESOURCE_URL, PARENT); assertThat((Patient) pulledObject, is(expectedPatient)); }
public Object pullData(SyncCategory category, String clientName, String resourceUrl, OpenMRSSyncInstance instance) { Object result = null; setUpCredentials(clientName, instance); ClientHelper clientHelper = ClientHelperFactory.createClient(clientName); prepareRestTemplate(clientHelper); String destinationUrl = getDestinationUri(instance, clientName); try { result = retrieveObject(category, resourceUrl, destinationUrl, clientName, instance); } catch (HttpClientErrorException e) { if (e.getStatusCode().equals(HttpStatus.UNAUTHORIZED)) { throw new SyncException("Unauthorized error during reading parent object: ", e); } if (!e.getStatusCode().equals(HttpStatus.NOT_FOUND)) { throw new SyncException("Error during reading local object: ", e); } } catch (URISyntaxException e) { LOGGER.error(e.getMessage()); } return result; }
SyncClient { public Object pullData(SyncCategory category, String clientName, String resourceUrl, OpenMRSSyncInstance instance) { Object result = null; setUpCredentials(clientName, instance); ClientHelper clientHelper = ClientHelperFactory.createClient(clientName); prepareRestTemplate(clientHelper); String destinationUrl = getDestinationUri(instance, clientName); try { result = retrieveObject(category, resourceUrl, destinationUrl, clientName, instance); } catch (HttpClientErrorException e) { if (e.getStatusCode().equals(HttpStatus.UNAUTHORIZED)) { throw new SyncException("Unauthorized error during reading parent object: ", e); } if (!e.getStatusCode().equals(HttpStatus.NOT_FOUND)) { throw new SyncException("Error during reading local object: ", e); } } catch (URISyntaxException e) { LOGGER.error(e.getMessage()); } return result; } }
SyncClient { public Object pullData(SyncCategory category, String clientName, String resourceUrl, OpenMRSSyncInstance instance) { Object result = null; setUpCredentials(clientName, instance); ClientHelper clientHelper = ClientHelperFactory.createClient(clientName); prepareRestTemplate(clientHelper); String destinationUrl = getDestinationUri(instance, clientName); try { result = retrieveObject(category, resourceUrl, destinationUrl, clientName, instance); } catch (HttpClientErrorException e) { if (e.getStatusCode().equals(HttpStatus.UNAUTHORIZED)) { throw new SyncException("Unauthorized error during reading parent object: ", e); } if (!e.getStatusCode().equals(HttpStatus.NOT_FOUND)) { throw new SyncException("Error during reading local object: ", e); } } catch (URISyntaxException e) { LOGGER.error(e.getMessage()); } return result; }  }
SyncClient { public Object pullData(SyncCategory category, String clientName, String resourceUrl, OpenMRSSyncInstance instance) { Object result = null; setUpCredentials(clientName, instance); ClientHelper clientHelper = ClientHelperFactory.createClient(clientName); prepareRestTemplate(clientHelper); String destinationUrl = getDestinationUri(instance, clientName); try { result = retrieveObject(category, resourceUrl, destinationUrl, clientName, instance); } catch (HttpClientErrorException e) { if (e.getStatusCode().equals(HttpStatus.UNAUTHORIZED)) { throw new SyncException("Unauthorized error during reading parent object: ", e); } if (!e.getStatusCode().equals(HttpStatus.NOT_FOUND)) { throw new SyncException("Error during reading local object: ", e); } } catch (URISyntaxException e) { LOGGER.error(e.getMessage()); } return result; }  Object pullData(SyncCategory category, String clientName, String resourceUrl, OpenMRSSyncInstance instance); ResponseEntity<String> pushData(SyncCategory category, Object object, String clientName,
			String resourceUrl, String action, OpenMRSSyncInstance instance); }
SyncClient { public Object pullData(SyncCategory category, String clientName, String resourceUrl, OpenMRSSyncInstance instance) { Object result = null; setUpCredentials(clientName, instance); ClientHelper clientHelper = ClientHelperFactory.createClient(clientName); prepareRestTemplate(clientHelper); String destinationUrl = getDestinationUri(instance, clientName); try { result = retrieveObject(category, resourceUrl, destinationUrl, clientName, instance); } catch (HttpClientErrorException e) { if (e.getStatusCode().equals(HttpStatus.UNAUTHORIZED)) { throw new SyncException("Unauthorized error during reading parent object: ", e); } if (!e.getStatusCode().equals(HttpStatus.NOT_FOUND)) { throw new SyncException("Error during reading local object: ", e); } } catch (URISyntaxException e) { LOGGER.error(e.getMessage()); } return result; }  Object pullData(SyncCategory category, String clientName, String resourceUrl, OpenMRSSyncInstance instance); ResponseEntity<String> pushData(SyncCategory category, Object object, String clientName,
			String resourceUrl, String action, OpenMRSSyncInstance instance);  }