* Test checks PUT on the "flights" resource in "application/json" format.
*/
@Test
public void testPutOnFlightsJSONFormat() {
// get the initial representation
Flights flights = r.path("flights").
accept("application/json").get(Flights.class);
// check that there are two flight entries
assertEquals("Expected number of initial entries not found",
2, flights.getFlight().size());
// remove the second flight entry
if (flights.getFlight().size() > 1) {
flights.getFlight().remove(1);
}
// update the first entry
flights.getFlight().get(0).setNumber(125);
flights.getFlight().get(0).setFlightId("OK125");
// and send the updated list back to the server
r.path("flights").type("application/json").put(flights);
// get the updated list out from the server:
Flights updatedFlights = r.path("flights").
accept("application/json").get(Flights.class);
//check that there is only one flight entry
assertEquals("Remaining number of flight entries do not match the expected value",
1, updatedFlights.getFlight().size());
// check that the flight entry in retrieved list has FlightID OK!@%
assertEquals("Retrieved flight ID doesn't match the expected value",
"OK125", updatedFlights.getFlight().get(0).getFlightId());
}