@Test public void test_should_index_object_instance() throws Exception { String expectedUri = "http: server.expect(once(), requestTo(expectedUri)) .andExpect(header("Authorization", "Basic dXNlcm5hbWU6cGFzc3dvcmQ=")) .andExpect(method(HttpMethod.PUT)) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(content().string(new Resources().getFileContents("esIndexRequestBody.json"))) .andRespond(withSuccess()); ServiceRequestDocument indexContent = new ServiceRequestDocument(); indexContent.setCrn("CRN"); indexContent.setId("id"); indexContent.setCreatedDate(esDateTimeFormatter.toESDateTimeString("23-12-2016 09:45:00")); indexContent.setLastModifiedDate(esDateTimeFormatter.toESDateTimeString("26-12-2016 23:15:40")); indexContent.setEscalationDate(esDateTimeFormatter.toESDateTimeString("30-12-2016 09:25:00")); indexContent.setDepartmentId("1"); indexContent.setDesignationId("1"); indexContent.setStateId("1"); elasticSearchRepository.index(indexContent); server.verify(); }
public void index(ServiceRequestDocument document) throws UnsupportedEncodingException { String url = String.format("%s%s/%s/%s", this.indexServiceHost, indexName, documentType, URLEncoder.encode(document.getId(), "UTF-8")); HttpHeaders headers = getHttpHeaders(); restTemplate.exchange(url, HttpMethod.PUT, new HttpEntity<>(document, headers), Map.class); }
ElasticSearchRepository { public void index(ServiceRequestDocument document) throws UnsupportedEncodingException { String url = String.format("%s%s/%s/%s", this.indexServiceHost, indexName, documentType, URLEncoder.encode(document.getId(), "UTF-8")); HttpHeaders headers = getHttpHeaders(); restTemplate.exchange(url, HttpMethod.PUT, new HttpEntity<>(document, headers), Map.class); } }
ElasticSearchRepository { public void index(ServiceRequestDocument document) throws UnsupportedEncodingException { String url = String.format("%s%s/%s/%s", this.indexServiceHost, indexName, documentType, URLEncoder.encode(document.getId(), "UTF-8")); HttpHeaders headers = getHttpHeaders(); restTemplate.exchange(url, HttpMethod.PUT, new HttpEntity<>(document, headers), Map.class); } ElasticSearchRepository(RestTemplate restTemplate,
                                   @Value("${egov.services.esindexer.host}") String indexServiceHost,
                                   @Value("${egov.services.esindexer.username}") String userName,
                                   @Value("${egov.services.esindexer.password}") String password,
                                   @Value("${es.index.name}") String indexName,
                                   @Value("${es.document.type}") String documentType); }
ElasticSearchRepository { public void index(ServiceRequestDocument document) throws UnsupportedEncodingException { String url = String.format("%s%s/%s/%s", this.indexServiceHost, indexName, documentType, URLEncoder.encode(document.getId(), "UTF-8")); HttpHeaders headers = getHttpHeaders(); restTemplate.exchange(url, HttpMethod.PUT, new HttpEntity<>(document, headers), Map.class); } ElasticSearchRepository(RestTemplate restTemplate,
                                   @Value("${egov.services.esindexer.host}") String indexServiceHost,
                                   @Value("${egov.services.esindexer.username}") String userName,
                                   @Value("${egov.services.esindexer.password}") String password,
                                   @Value("${es.index.name}") String indexName,
                                   @Value("${es.document.type}") String documentType); void index(ServiceRequestDocument document); }
ElasticSearchRepository { public void index(ServiceRequestDocument document) throws UnsupportedEncodingException { String url = String.format("%s%s/%s/%s", this.indexServiceHost, indexName, documentType, URLEncoder.encode(document.getId(), "UTF-8")); HttpHeaders headers = getHttpHeaders(); restTemplate.exchange(url, HttpMethod.PUT, new HttpEntity<>(document, headers), Map.class); } ElasticSearchRepository(RestTemplate restTemplate,
                                   @Value("${egov.services.esindexer.host}") String indexServiceHost,
                                   @Value("${egov.services.esindexer.username}") String userName,
                                   @Value("${egov.services.esindexer.password}") String password,
                                   @Value("${es.index.name}") String indexName,
                                   @Value("${es.document.type}") String documentType); void index(ServiceRequestDocument document);  }