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