plan.getResourceCalculator(), plan.getMinimumAllocation()); if (oldReservation != null) { return plan.updateReservation(capReservation); } else { return plan.addReservation(capReservation);
plan.getResourceCalculator(), plan.getMinimumAllocation()); if (oldReservation != null) { return plan.updateReservation(capReservation); } else { return plan.addReservation(capReservation);
@Test public void testUpdateNonExistingReservation() { Plan plan = new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L, resCalc, minAlloc, maxAlloc, planName, replanner, true, context); ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId(); // Try to update a reservation without adding int[] alloc = { 10, 10, 10, 10, 10, 10 }; int start = 100; ReservationAllocation rAllocation = createReservationAllocation(reservationID, start, alloc); Assert.assertNull(plan.getReservationById(reservationID)); try { plan.updateReservation(rAllocation); Assert.fail("Update should fail as it does not exist in the plan"); } catch (IllegalArgumentException e) { Assert.assertTrue(e.getMessage().endsWith("does not exist in the plan")); } catch (PlanningException e) { Assert.fail(e.getMessage()); } Assert.assertNull(plan.getReservationById(reservationID)); }
@Test public void testUpdateNonExistingReservation() { Plan plan = new InMemoryPlan(queueMetrics, policy, agent, totalCapacity, 1L, resCalc, minAlloc, maxAlloc, planName, replanner, true); ReservationId reservationID = ReservationSystemTestUtil.getNewReservationId(); // Try to update a reservation without adding int[] alloc = { 10, 10, 10, 10, 10, 10 }; int start = 100; Map<ReservationInterval, ReservationRequest> allocations = generateAllocation(start, alloc, false); ReservationDefinition rDef = createSimpleReservationDefinition(start, start + alloc.length, alloc.length, allocations.values()); ReservationAllocation rAllocation = new InMemoryReservationAllocation(reservationID, rDef, user, planName, start, start + alloc.length, allocations, resCalc, minAlloc); Assert.assertNull(plan.getReservationById(reservationID)); try { plan.updateReservation(rAllocation); Assert.fail("Update should fail as it does not exist in the plan"); } catch (IllegalArgumentException e) { Assert.assertTrue(e.getMessage().endsWith("does not exist in the plan")); } catch (PlanningException e) { Assert.fail(e.getMessage()); } Assert.assertNull(plan.getReservationById(reservationID)); }
return plan.updateReservation(capReservation); } else { return plan.addReservation(capReservation, false);
rAllocation.setPeriodicity(period); try { plan.updateReservation(rAllocation); } catch (PlanningException e) { Assert.fail(e.getMessage());
start, start + updatedAlloc.length, allocations, resCalc, minAlloc); try { plan.updateReservation(rAllocation); } catch (PlanningException e) { Assert.fail(e.getMessage());
createReservationAllocation(reservationID, start, updatedAlloc, true); try { plan.updateReservation(rAllocation); } catch (PlanningException e) { Assert.fail(e.getMessage());