use of org.springframework.web.client.RestTemplate in project androidannotations by androidannotations.
the class HttpMethodServiceTest method useOptionsHttpMethod.
@Test
@SuppressWarnings("unchecked")
public void useOptionsHttpMethod() {
HttpMethodsService_ service = new HttpMethodsService_(null);
RestTemplate restTemplate = mock(RestTemplate.class);
ResponseEntity<Object> response = mock(ResponseEntity.class);
when(restTemplate.exchange(Matchers.anyString(), Matchers.<HttpMethod>eq(HttpMethod.OPTIONS), Matchers.<HttpEntity<?>>any(), Matchers.<Class<Object>>any())).thenReturn(response);
HttpHeaders headers = mock(HttpHeaders.class);
when(response.getHeaders()).thenReturn(headers);
service.setRestTemplate(restTemplate);
service.options();
verify(restTemplate).exchange(Matchers.anyString(), Matchers.<HttpMethod>eq(HttpMethod.OPTIONS), Matchers.<HttpEntity<?>>any(), Matchers.<Class<Object>>any());
}
use of org.springframework.web.client.RestTemplate in project androidannotations by androidannotations.
the class HttpMethodServiceTest method usePostHttpMethod.
@Test
public void usePostHttpMethod() {
HttpMethodsService_ service = new HttpMethodsService_(null);
RestTemplate restTemplate = mock(RestTemplate.class);
service.setRestTemplate(restTemplate);
service.post();
verify(restTemplate).exchange(Matchers.anyString(), Matchers.<HttpMethod>eq(HttpMethod.POST), Matchers.<HttpEntity<?>>any(), Matchers.<Class<Object>>any());
}
use of org.springframework.web.client.RestTemplate in project spring-security-oauth by spring-projects.
the class OAuth2AccessTokenSupport method getRestTemplate.
protected RestOperations getRestTemplate() {
if (restTemplate == null) {
synchronized (this) {
if (restTemplate == null) {
RestTemplate restTemplate = new RestTemplate();
restTemplate.setErrorHandler(getResponseErrorHandler());
restTemplate.setRequestFactory(requestFactory);
restTemplate.setInterceptors(interceptors);
this.restTemplate = restTemplate;
}
}
}
if (messageConverters == null) {
setMessageConverters(new RestTemplate().getMessageConverters());
}
return restTemplate;
}
use of org.springframework.web.client.RestTemplate in project h2o-2 by h2oai.
the class h2oService method PredictGBMStatus.
public String PredictGBMStatus(String src_key) {
//http://localhost:54321/2/Inspect2.json?src_key=1111
String status;
String h2oUrlJobStatusEndPoint = H2O_HOST_URL + H2O_GBM_MODEL_PREDICT_STATUS_URL + "src_key=" + src_key;
System.out.println(h2oUrlJobStatusEndPoint);
System.out.println("@@@ Calling endpoint {} : " + h2oUrlJobStatusEndPoint);
log.debug("@@@ Calling endpoint {}", h2oUrlJobStatusEndPoint);
RestTemplate restTemplate = new RestTemplate();
try {
while (true) {
String responseBody = restTemplate.getForObject(h2oUrlJobStatusEndPoint, String.class);
JSONObject jsonobject = new JSONObject(responseBody);
JSONObject response_info = (JSONObject) jsonobject.get("response_info");
status = (String) response_info.get("status");
log.debug("!!!!!! JOB Status {}", status);
if (status.equalsIgnoreCase("done")) {
break;
}
//Should use futures here
Thread.sleep(2000L);
}
} catch (Exception ex) {
log.debug("!!!!!! Error Occured while getting job status {}", ex);
return null;
}
return status;
}
use of org.springframework.web.client.RestTemplate in project h2o-2 by h2oai.
the class h2oService method PredictGBM.
public String PredictGBM(String model, String new_data_key) {
//http://localhost:54321/2/Predict.html?model=gbmmodelDestinationKey&data=prostate_csv.hex&prediction=predict_1
String status;
String inspect_status;
String prediction_name = "Predict_GBM";
String h2oUrlPredictEndPoint = H2O_HOST_URL + H2O_GBM_MODEL_PREDICT_URL + "model=" + model + "&data=" + new_data_key + "&prediction=" + prediction_name;
System.out.println(h2oUrlPredictEndPoint);
log.debug("@@@ Calling endpoint {}", h2oUrlPredictEndPoint);
try {
RestTemplate restTemplate = new RestTemplate();
String responseBody = restTemplate.getForObject(h2oUrlPredictEndPoint, String.class);
JSONObject jsonobject = new JSONObject(responseBody);
JSONObject response_info = (JSONObject) jsonobject.get("response_info");
status = (String) response_info.get("status");
System.out.println("PREDICT GBM status: " + status);
inspect_status = PredictGBMStatus(prediction_name);
} catch (Exception ex) {
log.debug("!!!!!! Error Occurred while getting job status {}", ex);
ex.printStackTrace();
return null;
}
return inspect_status;
}
Aggregations