@Test public void testTriggerDataLoad() throws IOException, URISyntaxException, ResponseStatusException { final URI location = new URI("https: mockServer.expect(requestTo("https: .andExpect(method(HttpMethod.PUT)).andRespond(withCreatedEntity(location)); final URI response = strategy.triggerDataLoad(config, "data-id=00987123"); Assert.assertEquals(location, response); }
@Override public URI triggerDataLoad(final InstanceConfig config, final String dataId) throws ResponseStatusException { Preconditions.checkArgument(config != null); Preconditions.checkArgument(StringUtils.isNotBlank(dataId)); final RestTemplate restTemplate = restTemplateProvider.createTemplate(config.getHost(), config.getPort(), config.getUsername(), config.getPassword()); final URI url = createUri(config.getScheme(), config.getHost(), config.getPort(), config.getServername(), TRIGGER_PATH, Collections.emptyList()); final HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); final HttpEntity<String> httpEntity = new HttpEntity<>(dataId, headers); final ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.PUT, httpEntity, String.class); final HttpStatus status = response.getStatusCode(); if (status.equals(HttpStatus.CREATED)) { return response.getHeaders().getLocation(); } else { throw new ResponseStatusException( "HttpStatus " + status.toString() + " response received. Load trigger creation failed."); } }
RestPublishingStrategy implements PublishingStrategy { @Override public URI triggerDataLoad(final InstanceConfig config, final String dataId) throws ResponseStatusException { Preconditions.checkArgument(config != null); Preconditions.checkArgument(StringUtils.isNotBlank(dataId)); final RestTemplate restTemplate = restTemplateProvider.createTemplate(config.getHost(), config.getPort(), config.getUsername(), config.getPassword()); final URI url = createUri(config.getScheme(), config.getHost(), config.getPort(), config.getServername(), TRIGGER_PATH, Collections.emptyList()); final HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); final HttpEntity<String> httpEntity = new HttpEntity<>(dataId, headers); final ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.PUT, httpEntity, String.class); final HttpStatus status = response.getStatusCode(); if (status.equals(HttpStatus.CREATED)) { return response.getHeaders().getLocation(); } else { throw new ResponseStatusException( "HttpStatus " + status.toString() + " response received. Load trigger creation failed."); } } }
RestPublishingStrategy implements PublishingStrategy { @Override public URI triggerDataLoad(final InstanceConfig config, final String dataId) throws ResponseStatusException { Preconditions.checkArgument(config != null); Preconditions.checkArgument(StringUtils.isNotBlank(dataId)); final RestTemplate restTemplate = restTemplateProvider.createTemplate(config.getHost(), config.getPort(), config.getUsername(), config.getPassword()); final URI url = createUri(config.getScheme(), config.getHost(), config.getPort(), config.getServername(), TRIGGER_PATH, Collections.emptyList()); final HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); final HttpEntity<String> httpEntity = new HttpEntity<>(dataId, headers); final ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.PUT, httpEntity, String.class); final HttpStatus status = response.getStatusCode(); if (status.equals(HttpStatus.CREATED)) { return response.getHeaders().getLocation(); } else { throw new ResponseStatusException( "HttpStatus " + status.toString() + " response received. Load trigger creation failed."); } }  }
RestPublishingStrategy implements PublishingStrategy { @Override public URI triggerDataLoad(final InstanceConfig config, final String dataId) throws ResponseStatusException { Preconditions.checkArgument(config != null); Preconditions.checkArgument(StringUtils.isNotBlank(dataId)); final RestTemplate restTemplate = restTemplateProvider.createTemplate(config.getHost(), config.getPort(), config.getUsername(), config.getPassword()); final URI url = createUri(config.getScheme(), config.getHost(), config.getPort(), config.getServername(), TRIGGER_PATH, Collections.emptyList()); final HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); final HttpEntity<String> httpEntity = new HttpEntity<>(dataId, headers); final ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.PUT, httpEntity, String.class); final HttpStatus status = response.getStatusCode(); if (status.equals(HttpStatus.CREATED)) { return response.getHeaders().getLocation(); } else { throw new ResponseStatusException( "HttpStatus " + status.toString() + " response received. Load trigger creation 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 URI triggerDataLoad(final InstanceConfig config, final String dataId) throws ResponseStatusException { Preconditions.checkArgument(config != null); Preconditions.checkArgument(StringUtils.isNotBlank(dataId)); final RestTemplate restTemplate = restTemplateProvider.createTemplate(config.getHost(), config.getPort(), config.getUsername(), config.getPassword()); final URI url = createUri(config.getScheme(), config.getHost(), config.getPort(), config.getServername(), TRIGGER_PATH, Collections.emptyList()); final HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); final HttpEntity<String> httpEntity = new HttpEntity<>(dataId, headers); final ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.PUT, httpEntity, String.class); final HttpStatus status = response.getStatusCode(); if (status.equals(HttpStatus.CREATED)) { return response.getHeaders().getLocation(); } else { throw new ResponseStatusException( "HttpStatus " + status.toString() + " response received. Load trigger creation 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);  }