Skip to content

Commit

Permalink
Merge pull request #741 from gsmet/json-serialization-registerforrefl…
Browse files Browse the repository at this point in the history
…ection

Add a test for @RegisterForReflection/Response JSON serialization
  • Loading branch information
stuartwdouglas committed Feb 6, 2019
2 parents 43c305c + e1d6dfa commit 7459a47
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.xml.bind.annotation.XmlRootElement;

import org.jboss.shamrock.runtime.annotations.RegisterForReflection;

import io.reactivex.Single;

@Path("/test")
Expand Down Expand Up @@ -146,6 +149,16 @@ public MyInterface implementor() {
return child;
}

@GET
@Path("/response")
@Produces("application/json")
public Response response() {
MyEntity entity = new MyEntity();
entity.setName("my entity name");
entity.setValue("my entity value");
return Response.ok(entity).build();
}

@GET
@Path("/fooprovider")
@Produces("application/foo")
Expand Down Expand Up @@ -261,4 +274,26 @@ public interface MyInterface {

String getName();
}

@RegisterForReflection
public static class MyEntity {
private String name;
private String value;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,11 @@ public void testImplementor() {
.body("name", is("my name"),
"value", is("my value"));
}

@Test
public void testResponse() {
RestAssured.when().get("/test/response").then()
.body("name", is("my entity name"),
"value", is("my entity value"));
}
}

0 comments on commit 7459a47

Please sign in to comment.