@Test public void test_find_by_id() throws Exception { server.expect(once(), requestTo("http: .andExpect(method(HttpMethod.POST)) .andRespond(withSuccess(resources.getFileContents("surrenderreason/search_by_id_response.json"), MediaType.APPLICATION_JSON_UTF8)); SurrenderReasonContract surrenderReasonContract = new SurrenderReasonContract(); surrenderReasonContract.setId("1"); surrenderReasonContract.setTenantId("default"); final SurrenderReasonContract response = surrenderReasonContractRepository.findById(surrenderReasonContract); server.verify(); assertEquals("1", response.getId()); assertEquals("default", response.getTenantId()); }
public SurrenderReasonContract findById(SurrenderReasonContract surrenderReasonContract) { String url = String.format("%s%s", hostUrl, SEARCH_URL); StringBuffer content = new StringBuffer(); if (surrenderReasonContract.getId() != null) content.append("id=" + surrenderReasonContract.getId()); if (surrenderReasonContract.getTenantId() != null) content.append("&tenantId=" + surrenderReasonContract.getTenantId()); url = url + content.toString(); SurrenderReasonResponse result = restTemplate.postForObject(url, null, SurrenderReasonResponse.class); if (result.getSurrenderReasons() != null && result.getSurrenderReasons().size() == 1) return result.getSurrenderReasons().get(0); else return null; }
SurrenderReasonContractRepository { public SurrenderReasonContract findById(SurrenderReasonContract surrenderReasonContract) { String url = String.format("%s%s", hostUrl, SEARCH_URL); StringBuffer content = new StringBuffer(); if (surrenderReasonContract.getId() != null) content.append("id=" + surrenderReasonContract.getId()); if (surrenderReasonContract.getTenantId() != null) content.append("&tenantId=" + surrenderReasonContract.getTenantId()); url = url + content.toString(); SurrenderReasonResponse result = restTemplate.postForObject(url, null, SurrenderReasonResponse.class); if (result.getSurrenderReasons() != null && result.getSurrenderReasons().size() == 1) return result.getSurrenderReasons().get(0); else return null; } }
SurrenderReasonContractRepository { public SurrenderReasonContract findById(SurrenderReasonContract surrenderReasonContract) { String url = String.format("%s%s", hostUrl, SEARCH_URL); StringBuffer content = new StringBuffer(); if (surrenderReasonContract.getId() != null) content.append("id=" + surrenderReasonContract.getId()); if (surrenderReasonContract.getTenantId() != null) content.append("&tenantId=" + surrenderReasonContract.getTenantId()); url = url + content.toString(); SurrenderReasonResponse result = restTemplate.postForObject(url, null, SurrenderReasonResponse.class); if (result.getSurrenderReasons() != null && result.getSurrenderReasons().size() == 1) return result.getSurrenderReasons().get(0); else return null; } SurrenderReasonContractRepository(@Value("${egf.instrument.host.url}") String hostUrl,
            RestTemplate restTemplate); }
SurrenderReasonContractRepository { public SurrenderReasonContract findById(SurrenderReasonContract surrenderReasonContract) { String url = String.format("%s%s", hostUrl, SEARCH_URL); StringBuffer content = new StringBuffer(); if (surrenderReasonContract.getId() != null) content.append("id=" + surrenderReasonContract.getId()); if (surrenderReasonContract.getTenantId() != null) content.append("&tenantId=" + surrenderReasonContract.getTenantId()); url = url + content.toString(); SurrenderReasonResponse result = restTemplate.postForObject(url, null, SurrenderReasonResponse.class); if (result.getSurrenderReasons() != null && result.getSurrenderReasons().size() == 1) return result.getSurrenderReasons().get(0); else return null; } SurrenderReasonContractRepository(@Value("${egf.instrument.host.url}") String hostUrl,
            RestTemplate restTemplate); SurrenderReasonContract findById(SurrenderReasonContract surrenderReasonContract); }
SurrenderReasonContractRepository { public SurrenderReasonContract findById(SurrenderReasonContract surrenderReasonContract) { String url = String.format("%s%s", hostUrl, SEARCH_URL); StringBuffer content = new StringBuffer(); if (surrenderReasonContract.getId() != null) content.append("id=" + surrenderReasonContract.getId()); if (surrenderReasonContract.getTenantId() != null) content.append("&tenantId=" + surrenderReasonContract.getTenantId()); url = url + content.toString(); SurrenderReasonResponse result = restTemplate.postForObject(url, null, SurrenderReasonResponse.class); if (result.getSurrenderReasons() != null && result.getSurrenderReasons().size() == 1) return result.getSurrenderReasons().get(0); else return null; } SurrenderReasonContractRepository(@Value("${egf.instrument.host.url}") String hostUrl,
            RestTemplate restTemplate); SurrenderReasonContract findById(SurrenderReasonContract surrenderReasonContract); static final String SEARCH_URL; }