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