Search in sources :

Example 1 with User

use of org.apache.servicecomb.demo.server.User in project incubator-servicecomb-java-chassis by apache.

the class CodeFirstJaxrs method response.

@ApiResponse(code = 200, response = User.class, message = "")
@ResponseHeaders({ @ResponseHeader(name = "h1", response = String.class), @ResponseHeader(name = "h2", response = String.class) })
@Path("/response")
@GET
public Response response(InvocationContext c1) {
    Response response = Response.createSuccess(Status.ACCEPTED, new User());
    Headers headers = response.getHeaders();
    headers.addHeader("h1", "h1v " + c1.getContext().toString());
    InvocationContext c2 = ContextUtils.getInvocationContext();
    headers.addHeader("h2", "h2v " + c2.getContext().toString());
    return response;
}
Also used : ApiResponse(io.swagger.annotations.ApiResponse) Response(org.apache.servicecomb.swagger.invocation.Response) User(org.apache.servicecomb.demo.server.User) ResponseHeaders(org.apache.servicecomb.swagger.extend.annotations.ResponseHeaders) Headers(org.apache.servicecomb.swagger.invocation.response.Headers) InvocationContext(org.apache.servicecomb.swagger.invocation.context.InvocationContext) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) ResponseHeaders(org.apache.servicecomb.swagger.extend.annotations.ResponseHeaders) ApiResponse(io.swagger.annotations.ApiResponse)

Example 2 with User

use of org.apache.servicecomb.demo.server.User in project incubator-servicecomb-java-chassis by apache.

the class SpringMvcIntegrationTestBase method userOfNames.

private User userOfNames(String... names) {
    User user1 = new User();
    user1.setNames(names);
    return user1;
}
Also used : User(org.apache.servicecomb.demo.server.User)

Example 3 with User

use of org.apache.servicecomb.demo.server.User in project incubator-servicecomb-java-chassis by apache.

the class TestImpl method doTest.

private User doTest(int index, User user, List<User> users, byte[] data) {
    if (user == null) {
        user = new User();
    }
    user.setIndex(index);
    int userCount = (users == null) ? 0 : users.size();
    user.setName(user.getName() + ",  users count:" + userCount);
    return user;
}
Also used : User(org.apache.servicecomb.demo.server.User)

Example 4 with User

use of org.apache.servicecomb.demo.server.User in project incubator-servicecomb-java-chassis by apache.

the class PojoIntegrationTestBase method remoteTestPojo_wrapParam.

@Test
public void remoteTestPojo_wrapParam() {
    // when request is null
    User result = PojoService.test.wrapParam(null);
    assertThat(result, is(nullValue()));
    // when request is not null
    User user = new User();
    byte[] buffer = new byte[1024];
    TestRequest request = new TestRequest();
    request.setUser(user);
    request.setIndex(0);
    request.setData(buffer);
    request.getUsers().add(user);
    result = PojoService.test.wrapParam(request);
    assertThat(result.toString(), is("User [name=nameA,  users count:1, age=100, index=0]"));
}
Also used : User(org.apache.servicecomb.demo.server.User) TestRequest(org.apache.servicecomb.demo.server.TestRequest) Test(org.junit.Test)

Example 5 with User

use of org.apache.servicecomb.demo.server.User in project incubator-servicecomb-java-chassis by apache.

the class PojoIntegrationTestBase method remoteCodeFirstPojo_testUserArray.

@Test
public void remoteCodeFirstPojo_testUserArray() {
    User user1 = new User();
    user1.setNames(new String[] { "u1", "u2" });
    User user2 = new User();
    user2.setNames(new String[] { "u3", "u4" });
    User[] users = new User[] { user1, user2 };
    List<User> result = PojoService.codeFirst.testUserArray(Arrays.asList(users));
    assertThat(result.get(0).getNames()[0], is("u1"));
    assertThat(result.get(0).getNames()[1], is("u2"));
    assertThat(result.get(1).getNames()[0], is("u3"));
    assertThat(result.get(1).getNames()[1], is("u4"));
}
Also used : User(org.apache.servicecomb.demo.server.User) Test(org.junit.Test)

Aggregations

User (org.apache.servicecomb.demo.server.User)56 HashMap (java.util.HashMap)9 Response (org.apache.servicecomb.swagger.invocation.Response)9 InvocationContext (org.apache.servicecomb.swagger.invocation.context.InvocationContext)9 Test (org.junit.Test)8 ApiResponse (io.swagger.annotations.ApiResponse)7 ResponseHeaders (org.apache.servicecomb.swagger.extend.annotations.ResponseHeaders)7 TestRequest (org.apache.servicecomb.demo.server.TestRequest)6 GET (javax.ws.rs.GET)4 Path (javax.ws.rs.Path)4 Generic (org.apache.servicecomb.demo.Generic)4 Headers (org.apache.servicecomb.swagger.invocation.response.Headers)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 DecodeTestResponse (org.apache.servicecomb.demo.springmvc.decoderesponse.DecodeTestResponse)2 HttpHeaders (org.springframework.http.HttpHeaders)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 Map (java.util.Map)1 Holder (javax.xml.ws.Holder)1 Holder (org.apache.servicecomb.foundation.common.Holder)1