public static <T> RestResponse ok(T payload, int code) { return new RestResponse<T>().success(true).payload(payload).code(code); }
public static <T> RestResponse fail(int code, String message) { return new RestResponse<T>().success(false).message(message).code(code); }
public static <T> RestResponse<T> ok(T payload) { return new RestResponse<T>().success(true).payload(payload); }
public static <T> RestResponse<T> fail() { return new RestResponse<T>().success(false); }
public static <T> RestResponse<T> fail(String message) { return new RestResponse<T>().success(false).message(message); }
@Test public void testRestResponse() { RestResponse<String> restResponse = new RestResponse<>(); Assert.assertEquals(true, restResponse.getTimestamp() > 0); RestResponse restResponse2 = new RestResponse<>(true); Assert.assertEquals(true, restResponse2.isSuccess()); RestResponse restResponse3 = new RestResponse<>(true, "biezhi"); Assert.assertEquals(true, restResponse3.isSuccess()); Assert.assertEquals("biezhi", restResponse3.getPayload()); }
@Test public void testModelAndView2(){ ModelAndView modelAndView = new ModelAndView("index.html"); Assert.assertEquals("index.html", modelAndView.getView()); }
@Test public void testOk() { Assert.assertEquals(true, RestResponse.ok().isSuccess()); Assert.assertEquals("Hello", RestResponse.ok("Hello").getPayload()); RestResponse ok = RestResponse.ok("Hello", 200); Assert.assertEquals("Hello", ok.getPayload()); Assert.assertEquals(true, ok.isSuccess()); }
@Before public void before() { htmlCreator = new HtmlCreator(); }
@JSON @PostRoute("api_test/:size") public RestResponse<Integer> api_portal(@PathParam Integer size) { return RestResponse.ok(size); }
public static <T> RestResponse ok(T payload, int code) { return new RestResponse<T>().success(true).payload(payload).code(code); }
public static <T> RestResponse fail(int code, String message) { return new RestResponse<T>().success(false).message(message).code(code); }
public static <T> RestResponse<T> ok() { return new RestResponse<T>().success(true); }
public static <T> RestResponse<T> ok(T payload) { return new RestResponse<T>().success(true).payload(payload); }
public static <T> RestResponse<T> fail(String message) { return new RestResponse<T>().success(false).message(message); }
public static <T> RestResponse<T> fail() { return new RestResponse<T>().success(false); }
public static <T> RestResponse<T> ok() { return new RestResponse<T>().success(true); }