use of org.glassfish.jersey.examples.flight.model.Flight in project jersey by jersey.
the class DataStore method selectOpenFlights.
public static List<Flight> selectOpenFlights() {
final List<Flight> result = new ArrayList<>(DataStore.flights.values());
final Iterator<Flight> it = result.iterator();
while (it.hasNext()) {
final Flight flight = it.next();
if (!flight.isOpen()) {
it.remove();
}
}
Collections.sort(result, FLIGHT_COMPARATOR);
return result;
}
use of org.glassfish.jersey.examples.flight.model.Flight in project jersey by jersey.
the class FlightsDemoAppTest method _testAllFlights.
private void _testAllFlights(String acceptType) {
final List<Flight> flights = target("flights").request(acceptType).get(new GenericType<List<Flight>>() {
});
for (Flight flight : flights) {
assertNotNull("Flight id", flight.getId());
assertFalse("Flight id empty", flight.getId().isEmpty());
assertFalse("Aircraft not assigned to flight", flight.getAircraft().isAvailable());
}
}
use of org.glassfish.jersey.examples.flight.model.Flight in project jersey by jersey.
the class FlightsDemoAppTest method _testCreateFlight.
public void _testCreateFlight(String acceptType) {
final List<Aircraft> availableAircrafts = target("aircrafts/available").request(acceptType).get(new GenericType<List<Aircraft>>() {
});
final Aircraft aircraft = availableAircrafts.get(0);
final Form flightForm = new Form("aircraftId", aircraft.getId().toString());
Flight flight = target("flights").queryParam("user", "admin").request(acceptType).post(Entity.form(flightForm), Flight.class);
assertNotNull("Flight", flight);
assertNotNull("Flight.id", flight.getId());
assertNotNull("Flight.aircraft", flight.getAircraft());
assertEquals("Aircraft IDs do not match", aircraft.getId(), flight.getAircraft().getId());
assertFalse("Aircraft not assigned", flight.getAircraft().isAvailable());
}
use of org.glassfish.jersey.examples.flight.model.Flight in project jersey by jersey.
the class DataStore method generateData.
public static void generateData() {
flights.clear();
aircrafts.clear();
LinkedList<Aircraft> planes = new LinkedList<>();
while (planes.size() < MAX_GEN_AIRCRAFTS) {
Aircraft a = generateAircraft();
if (addAircraft(a)) {
planes.add(a);
}
}
int count = 0;
while (count < MAX_GEN_FLIGHTS) {
final Flight flight = generateFlight();
if (addFlight(flight)) {
count++;
final Aircraft aircraft = planes.remove(rnd.nextInt(planes.size()));
aircraft.marAssigned();
flight.setAircraft(aircraft);
}
}
}
use of org.glassfish.jersey.examples.flight.model.Flight in project jersey by jersey.
the class DataStore method generateFlight.
private static Flight generateFlight() {
final Flight flight = new Flight();
flight.setId(String.format("FL-%04d", rnd.nextInt(10000)));
return flight;
}
Aggregations