@Test public void testCheckStatus() throws IOException, URISyntaxException, ResponseStatusException { final URI location = new URI("https: mockServer .expect(requestTo("https: .andExpect(method(HttpMethod.GET)).andRespond(withSuccess("SUCCESS", MediaType.TEXT_PLAIN)); final String response = strategy.checkStatus(config, location); Assert.assertTrue(response.contains("SUCCESS")); }
@Override public String checkStatus(final InstanceConfig config, final URI triggerUrl) throws ResponseStatusException { Preconditions.checkArgument(config != null); Preconditions.checkArgument(triggerUrl != null); final RestTemplate restTemplate = restTemplateProvider.createTemplate(config.getHost(), config.getPort(), config.getUsername(), config.getPassword()); final URI url = triggerUrl.resolve(triggerUrl.getPath() + STATUS_PATH); final HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); final HttpEntity<String> httpEntity = new HttpEntity<>(headers); final ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, String.class); final HttpStatus status = response.getStatusCode(); if (status.equals(HttpStatus.OK)) { return response.getBody(); } else { throw new ResponseStatusException( "HttpStatus " + status.toString() + " response received. Load trigger monitoring failed."); } }
RestPublishingStrategy implements PublishingStrategy { @Override public String checkStatus(final InstanceConfig config, final URI triggerUrl) throws ResponseStatusException { Preconditions.checkArgument(config != null); Preconditions.checkArgument(triggerUrl != null); final RestTemplate restTemplate = restTemplateProvider.createTemplate(config.getHost(), config.getPort(), config.getUsername(), config.getPassword()); final URI url = triggerUrl.resolve(triggerUrl.getPath() + STATUS_PATH); final HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); final HttpEntity<String> httpEntity = new HttpEntity<>(headers); final ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, String.class); final HttpStatus status = response.getStatusCode(); if (status.equals(HttpStatus.OK)) { return response.getBody(); } else { throw new ResponseStatusException( "HttpStatus " + status.toString() + " response received. Load trigger monitoring failed."); } } }
RestPublishingStrategy implements PublishingStrategy { @Override public String checkStatus(final InstanceConfig config, final URI triggerUrl) throws ResponseStatusException { Preconditions.checkArgument(config != null); Preconditions.checkArgument(triggerUrl != null); final RestTemplate restTemplate = restTemplateProvider.createTemplate(config.getHost(), config.getPort(), config.getUsername(), config.getPassword()); final URI url = triggerUrl.resolve(triggerUrl.getPath() + STATUS_PATH); final HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); final HttpEntity<String> httpEntity = new HttpEntity<>(headers); final ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, String.class); final HttpStatus status = response.getStatusCode(); if (status.equals(HttpStatus.OK)) { return response.getBody(); } else { throw new ResponseStatusException( "HttpStatus " + status.toString() + " response received. Load trigger monitoring failed."); } }  }
RestPublishingStrategy implements PublishingStrategy { @Override public String checkStatus(final InstanceConfig config, final URI triggerUrl) throws ResponseStatusException { Preconditions.checkArgument(config != null); Preconditions.checkArgument(triggerUrl != null); final RestTemplate restTemplate = restTemplateProvider.createTemplate(config.getHost(), config.getPort(), config.getUsername(), config.getPassword()); final URI url = triggerUrl.resolve(triggerUrl.getPath() + STATUS_PATH); final HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); final HttpEntity<String> httpEntity = new HttpEntity<>(headers); final ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, String.class); final HttpStatus status = response.getStatusCode(); if (status.equals(HttpStatus.OK)) { return response.getBody(); } else { throw new ResponseStatusException( "HttpStatus " + status.toString() + " response received. Load trigger monitoring failed."); } }  @Override String uploadDataSet(final InstanceConfig config, final File file); @Override URI triggerDataLoad(final InstanceConfig config, final String dataId); @Override String checkStatus(final InstanceConfig config, final URI triggerUrl); RestTemplateProvider getRestTemplateProvider(); @Required void setRestTemplateProvider(final RestTemplateProvider restTemplateProvider); }
RestPublishingStrategy implements PublishingStrategy { @Override public String checkStatus(final InstanceConfig config, final URI triggerUrl) throws ResponseStatusException { Preconditions.checkArgument(config != null); Preconditions.checkArgument(triggerUrl != null); final RestTemplate restTemplate = restTemplateProvider.createTemplate(config.getHost(), config.getPort(), config.getUsername(), config.getPassword()); final URI url = triggerUrl.resolve(triggerUrl.getPath() + STATUS_PATH); final HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); final HttpEntity<String> httpEntity = new HttpEntity<>(headers); final ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, String.class); final HttpStatus status = response.getStatusCode(); if (status.equals(HttpStatus.OK)) { return response.getBody(); } else { throw new ResponseStatusException( "HttpStatus " + status.toString() + " response received. Load trigger monitoring failed."); } }  @Override String uploadDataSet(final InstanceConfig config, final File file); @Override URI triggerDataLoad(final InstanceConfig config, final String dataId); @Override String checkStatus(final InstanceConfig config, final URI triggerUrl); RestTemplateProvider getRestTemplateProvider(); @Required void setRestTemplateProvider(final RestTemplateProvider restTemplateProvider);  }