Example usage for org.springframework.http HttpEntity getBody

List of usage examples for org.springframework.http HttpEntity getBody

Introduction

In this page you can find the example usage for org.springframework.http HttpEntity getBody.

Prototype

@Nullable
public T getBody() 

Source Link

Document

Returns the body of this entity.

Usage

From source file:com.mtt.myapp.home.controller.HomeControllerTest.java

@Test
public void testHealthCheck() {
    MockHttpServletResponse res = new MockHttpServletResponse();
    homeController.healthCheck(res);//  w w w.j a v  a  2s .c o m
    HttpEntity<String> message = homeController.healthCheckSlowly(500, res);
    assertThat(message.getBody()).contains("NONE");
}

From source file:org.ngrinder.home.controller.HomeControllerTest.java

@Test
public void testHealthCheck() {
    MockHttpServletResponse res = new MockHttpServletResponse();
    homeController.healthCheck(res);//  w  w w.  j  a  va2 s.c  o  m
    HttpEntity<String> message = homeController.healthCheckSlowly(500, res);
    assertThat(message.getBody(), containsString("NONE"));
}

From source file:com.appleframework.monitor.action.MetricAction.java

@RequestMapping(value = "/projects/{projectName}/setting/timeRange", method = RequestMethod.POST)
public @ResponseBody String timeRange(@PathVariable String projectName, HttpEntity<TimeRange> entity) {
    TimeRange timeRange = entity.getBody();
    Assert.notNull(timeRange, "time rage should not be null");
    Project project = projectService.findProject(projectName);
    project.setTimeRange(timeRange);//w ww . j a v  a  2s .  co m
    projectService.saveProject(project);
    return "true";
}

From source file:com.appleframework.monitor.action.MetricAction.java

@RequestMapping(value = "/projects/{projectName}/metrics/add", method = RequestMethod.POST)
public @ResponseBody ChartView addMetricView(ModelMap map, @PathVariable String projectName,
        HttpEntity<ChartView> entity) {
    ChartView chartView = entity.getBody();
    Assert.notNull(chartView.getTitle());
    Project project = projectService.findProject(projectName);
    project.getChartViews().add(chartView);
    projectService.saveProject(project);
    return chartView;
}

From source file:com.companyname.plat.commons.client.HttpRestfulClientTest.java

/**
 * Test of getHttpRequest method, of class HttpRestfulClient.
 *//*from   ww  w  .jav  a  2s . c o  m*/
@Test
public void testGetHttpRequest() {
    logger.info("start test: HttpRestfulClient.testGetHttpRequest()");
    Map<String, String> params = new HashMap<>();
    params.put("user", "my-user-id");
    params.put("direction", "north");
    HttpEntity<Object> httpEntity = instance.getHttpRequest(params);
    String result = httpEntity.getBody().toString();

    logger.info("test request parameters: " + result);

    notNull(result);
}

From source file:com.appleframework.monitor.action.AdminAction.java

@RequestMapping(value = "/admin/views/save")
public @ResponseBody WebResult createView(HttpEntity<View> entity, ModelMap map) {
    WebResult result = new WebResult();
    try {//  www . j  av a 2s .  c  o m
        View view = entity.getBody();
        Assert.isTrue(view.getName().length() > 0, "name should not be null");
        logger.debug("save view ={}", view);
        viewService.saveView(view);
    } catch (Exception e) {
        result.setSuccess(false);
        result.setMessage(e.getMessage());
    }
    return result;
}

From source file:com.skymobi.monitor.action.AdminAction.java

@RequestMapping(value = "/admin/views/save")
public @ResponseBody WebResult createView(HttpEntity<View> entity, ModelMap map) {
    WebResult result = new WebResult();
    try {/*from  w  ww .j  ava  2 s. co m*/
        View view = entity.getBody();
        Assert.isTrue(view.getName().length() > 0, "name should not be null");
        logger.debug("save view ={}", view);
        viewService.saveView(view);
    } catch (Exception e) {
        result.setSuccess(false);
        result.setMessage(e.getMessage());
    }

    return result;
}

From source file:com.skymobi.monitor.action.MetricAction.java

@RequestMapping(value = "/projects/{projectName}/setting/timeRange", method = RequestMethod.POST)
public @ResponseBody String timeRange(@PathVariable String projectName, HttpEntity<TimeRange> entity) {
    TimeRange timeRange = entity.getBody();
    Assert.notNull(timeRange, "time rage should not be null");
    Project project = projectService.findProject(projectName);

    project.setTimeRange(timeRange);//from  w  w w . j  av a  2s.  c  o  m

    projectService.saveProject(project);
    return "true";
}

From source file:be.ordina.msdashboard.controllers.NodesControllerTest.java

@Test
public void getDependenciesGraphJson() {
    doReturn(Collections.emptyMap()).when(graphRetriever).retrieve();

    HttpEntity<Map<String, Object>> httpEntity = nodesController.getDependenciesGraphJson();

    assertThat(httpEntity.getBody()).isEmpty();
}

From source file:com.mtt.myapp.user.controller.UserControllerTest.java

@Test
public void testDuplication() {
    HttpEntity<String> rtnStr = userController.checkUserExist("not-exist");
    assertThat(rtnStr.getBody()).isEqualTo(userController.returnSuccess());

    rtnStr = userController.checkUserExist(getTestUser().getUserId());
    assertThat(rtnStr.getBody()).isEqualTo(userController.returnError());
}