You can use REST Assured , which makes it very easy to test and test Java REST services from JUnit or TestNG. For instance. say a GET request to a service called "/ lotto" returns the next JSON
{
"lotto":{
"lottoId":5,
"winning-numbers":[2,45,34,23,7,5,3],
"winners":[{
"winnerId":23,
"numbers":[2,45,34,23,3,5]
},{
"winnerId":54,
"numbers":[52,3,12,11,18,22]
}]
}
}
then you can make a request and check the response (in this case, the lotto identifier is 5) using REST Assured, like this:
expect().body("lotto.lottoId", equalTo(5)).when().get("/lotto");