@Test public void testGetReservationsById() { Plan plan = new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L, resCalc, minAlloc, maxAlloc, planName, replanner, true, context); ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId(); int[] alloc = { 10, 10, 10, 10, 10, 10 }; int start = 100; ReservationAllocation rAllocation = createReservationAllocation(reservationID, start, alloc); Assert.assertNull(plan.getReservationById(reservationID)); try { plan.addReservation(rAllocation, false); } catch (PlanningException e) { Assert.fail(e.getMessage()); } // Verify that get by reservation id works. Set<ReservationAllocation> rAllocations = plan.getReservations(reservationID, null, ""); Assert.assertTrue(rAllocations.size() == 1); Assert.assertTrue(rAllocation .compareTo((ReservationAllocation) rAllocations.toArray()[0]) == 0); // Verify that get by reservation id works even when time range // and user is invalid. ReservationInterval interval = new ReservationInterval(0, 0); rAllocations = plan.getReservations(reservationID, interval, "invalid"); Assert.assertTrue(rAllocations.size() == 1); Assert.assertTrue(rAllocation .compareTo((ReservationAllocation) rAllocations.toArray()[0]) == 0); }
@Test public void testGetReservationsWithNoInput() { Plan plan = new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L, resCalc, minAlloc, maxAlloc, planName, replanner, true, context); ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId(); int[] alloc = { 10, 10, 10, 10, 10, 10 }; int start = 100; ReservationAllocation rAllocation = createReservationAllocation(reservationID, start, alloc); Assert.assertNull(plan.getReservationById(reservationID)); try { plan.addReservation(rAllocation, false); } catch (PlanningException e) { Assert.fail(e.getMessage()); } // Verify that getReservations defaults to getting all reservations if no // reservationID, time interval, and user is provided, Set<ReservationAllocation> rAllocations = plan.getReservations(null, null, ""); Assert.assertTrue(rAllocations.size() == 1); Assert.assertTrue(rAllocation .compareTo((ReservationAllocation) rAllocations.toArray()[0]) == 0); }
@Test public void testGetReservationsAtTime() { Plan plan = new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L, resCalc, minAlloc, maxAlloc, planName, replanner, true, context); ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId(); int[] alloc = { 10, 10, 10, 10, 10, 10 }; int start = 100; ReservationAllocation rAllocation = createReservationAllocation(reservationID, start, alloc); Assert.assertNull(plan.getReservationById(reservationID)); try { plan.addReservation(rAllocation, false); } catch (PlanningException e) { Assert.fail(e.getMessage()); } Set<ReservationAllocation> rAllocations = plan.getReservationsAtTime(rAllocation.getStartTime()); Assert.assertTrue(rAllocations.size() == 1); Assert.assertTrue(rAllocation .compareTo((ReservationAllocation) rAllocations.toArray()[0]) == 0); }
Assert.assertTrue(rAllocations.size() == 1); Assert.assertTrue(rAllocation .compareTo((ReservationAllocation) rAllocations.toArray()[0]) == 0); Assert.assertTrue(rAllocations.size() == 1); Assert.assertTrue(rAllocation .compareTo((ReservationAllocation) rAllocations.toArray()[0]) == 0); Assert.assertTrue(rAllocations.size() == 1); Assert.assertTrue(rAllocation .compareTo((ReservationAllocation) rAllocations.toArray()[0]) == 0);