use of org.springframework.web.client.HttpClientErrorException in project promregator by promregator.
the class SingleTargetMetricsEndpoint method filterInstanceList.
@Override
protected List<Instance> filterInstanceList(List<Instance> instanceList) {
String instanceId = String.format("%s:%s", applicationId, instanceNumber);
Instance selectedInstance = null;
for (Instance instance : instanceList) {
if (instance.getInstanceId().equals(instanceId)) {
selectedInstance = instance;
break;
}
}
if (selectedInstance == null) {
throw new HttpClientErrorException(HttpStatus.NOT_FOUND);
}
List<Instance> response = new LinkedList<Instance>();
response.add(selectedInstance);
return response;
}
use of org.springframework.web.client.HttpClientErrorException in project elastest-torm by elastest.
the class TJobService method executeTJob.
public TJobExecution executeTJob(Long tJobId, List<Parameter> parameters, List<Parameter> sutParameters) throws HttpClientErrorException {
TJob tJob = tJobRepo.findOne(tJobId);
SutSpecification sut = tJob.getSut();
// activating yet
if (sut != null && sut.isInstrumentedByElastest() && sut.getEimMonitoringConfig() != null && sut.getEimMonitoringConfig().getBeatsStatus() == BeatsStatusEnum.ACTIVATING) {
throw new HttpClientErrorException(HttpStatus.ACCEPTED);
}
TJobExecution tJobExec = new TJobExecution();
tJobExec.setStartDate(new Date());
if (tJob.getSut() != null && sutParameters != null && !sutParameters.isEmpty()) {
tJob.getSut().setParameters(sutParameters);
}
tJobExec.setTjob(tJob);
if (parameters != null && !parameters.isEmpty()) {
tJobExec.setParameters(parameters);
}
tJobExec = tJobExecRepositoryImpl.save(tJobExec);
// After first save, get real Id
tJobExec.generateMonitoringIndex();
tJobExec = tJobExecRepositoryImpl.save(tJobExec);
Future<Void> asyncExec;
if (!tJob.isExternal()) {
asyncExec = tJobExecOrchestratorService.executeTJob(tJobExec, tJob.getSelectedServices());
asyncExecs.put(getMapNameByTJobExec(tJobExec), asyncExec);
} else {
tJobExecOrchestratorService.executeExternalJob(tJobExec);
}
return tJobExec;
}
use of org.springframework.web.client.HttpClientErrorException in project nextprot-api by calipho-sib.
the class SparqlProxyEndpointImpl method sparqlInternal.
private ResponseEntity<String> sparqlInternal(String queryString) {
ResponseEntity<String> responseEntity;
String url = sparqlEndpoint.getUrl() + ((queryString != null) ? ("?" + queryString) : "");
try {
RestTemplate template = new RestTemplate();
responseEntity = template.getForEntity(new URI(url), String.class);
return responseEntity;
} catch (HttpServerErrorException | HttpClientErrorException e) {
throw new NextProtException(e.getResponseBodyAsString(), e);
} catch (RestClientException | URISyntaxException e) {
throw new NextProtException(e);
}
}
use of org.springframework.web.client.HttpClientErrorException in project x-pipe by ctripcorp.
the class RetryNTimesTest method testGetOriginalException.
@Test
public void testGetOriginalException() {
assertTrue(RetryNTimes.getOriginalException(new IOException("test")) instanceof IOException);
assertTrue(RetryNTimes.getOriginalException(new ExecutionException(new IllegalArgumentException("test"))) instanceof IllegalArgumentException);
assertTrue(RetryNTimes.getOriginalException(new ExecutionException(null)) instanceof ExecutionException);
assertTrue(RetryNTimes.getOriginalException(new ExecutionException(new InvocationTargetException(new HttpClientErrorException(HttpStatus.BAD_REQUEST, "test")))) instanceof HttpClientErrorException);
assertTrue(RetryNTimes.getOriginalException(new ExecutionException(new InvocationTargetException(null))) instanceof InvocationTargetException);
assertTrue(RetryNTimes.getOriginalException(new InvocationTargetException(new IOException("test"))) instanceof IOException);
assertTrue(RetryNTimes.getOriginalException(new InvocationTargetException(null)) instanceof InvocationTargetException);
assertFalse(RetryNTimes.getOriginalException(new InvocationTargetException(new IOException())) instanceof InvocationTargetException);
assertFalse(RetryNTimes.getOriginalException(new ExecutionException(new InvocationTargetException(new IOException("test")))) instanceof ExecutionException);
}
use of org.springframework.web.client.HttpClientErrorException in project spring-framework by spring-projects.
the class SimpleUrlHandlerMappingIntegrationTests method testHandlerNotFound.
@ParameterizedHttpServerTest
void testHandlerNotFound(HttpServer httpServer) throws Exception {
startServer(httpServer);
URI url = new URI("http://localhost:" + this.port + "/oops");
RequestEntity<Void> request = RequestEntity.get(url).build();
try {
new RestTemplate().exchange(request, byte[].class);
} catch (HttpClientErrorException ex) {
assertThat(ex.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
}
}
Aggregations