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