public void _testCreateAircraft(String acceptType) {
Form form = new Form("manufacturer", "Cesna")
.param("type", "680")
.param("capacity", "9");
Aircraft aircraft = target("aircrafts").queryParam("user", "admin")
.request(acceptType)
.post(Entity.form(form), Aircraft.class);
assertNotNull("Aircraft", aircraft);
assertNotNull("Aircraft id", aircraft.getId());
assertNotNull("Aircraft type", aircraft.getType());
assertNotNull("Aircraft location", aircraft.getLocation());
assertEquals("Aircraft location x pos.", 0, aircraft.getLocation().getX());
assertEquals("Aircraft location y pos.", 0, aircraft.getLocation().getY());
assertTrue("Aircraft not available", aircraft.isAvailable());
final List<Aircraft> availableAircrafts = target("aircrafts/available")
.request(acceptType)
.get(new GenericType<List<Aircraft>>() {});
for (Aircraft a : availableAircrafts) {
if (aircraft.getId().equals(a.getId())) {
// passed
return;
}
}
fail("New aircraft not found in the list of available aircrafts.");