ReservationInputValidator { public Plan validateReservationListRequest( ReservationSystem reservationSystem, ReservationListRequest request) throws YarnException { String queue = request.getQueue(); if (request.getEndTime() < request.getStartTime()) { String errorMessage = "The specified end time must be greater than " + "the specified start time."; RMAuditLogger.logFailure("UNKNOWN", AuditConstants.LIST_RESERVATION_REQUEST, "validate list reservation input", "ClientRMService", errorMessage); throw RPCUtil.getRemoteException(errorMessage); } return getPlanFromQueue(reservationSystem, queue, AuditConstants.LIST_RESERVATION_REQUEST); } ReservationInputValidator(Clock clock); Plan validateReservationSubmissionRequest(
      ReservationSystem reservationSystem, ReservationSubmissionRequest request,
      ReservationId reservationId); Plan validateReservationUpdateRequest(
      ReservationSystem reservationSystem, ReservationUpdateRequest request); Plan validateReservationListRequest(
      ReservationSystem reservationSystem, ReservationListRequest request); Plan validateReservationDeleteRequest(
      ReservationSystem reservationSystem, ReservationDeleteRequest request);  }
@Test public void testListReservationsNormal() { ReservationListRequest request = new ReservationListRequestPBImpl(); request.setQueue(ReservationSystemTestUtil.reservationQ); request.setEndTime(1000); request.setStartTime(0); when(rSystem.getPlan(ReservationSystemTestUtil.reservationQ)).thenReturn (this.plan); Plan plan = null; try { plan = rrValidator.validateReservationListRequest(rSystem, request); } catch (YarnException e) { Assert.fail(e.getMessage()); } Assert.assertNotNull(plan); }
@Test public void testListReservationsInvalidTimeIntervalDefaults() { ReservationListRequest request = new ReservationListRequestPBImpl(); request.setQueue(ReservationSystemTestUtil.reservationQ); request.setEndTime(-2); request.setStartTime(-1); when(rSystem.getPlan(ReservationSystemTestUtil.reservationQ)).thenReturn (this.plan); Plan plan = null; try { plan = rrValidator.validateReservationListRequest(rSystem, request); } catch (YarnException e) { Assert.fail(e.getMessage()); } Assert.assertNotNull(plan); }
@Test public void testListReservationsInvalidTimeInterval() { ReservationListRequest request = new ReservationListRequestPBImpl(); request.setQueue(ReservationSystemTestUtil.reservationQ); request.setEndTime(1000); request.setStartTime(2000); when(rSystem.getPlan(ReservationSystemTestUtil.reservationQ)).thenReturn (this.plan); Plan plan = null; try { plan = rrValidator.validateReservationListRequest(rSystem, request); Assert.fail(); } catch (YarnException e) { Assert.assertNull(plan); String message = e.getMessage(); Assert.assertTrue(message.equals("The specified end time must be " + "greater than the specified start time.")); LOG.info(message); } }
@Test public void testListReservationsEmptyQueue() { ReservationListRequest request = new ReservationListRequestPBImpl(); request.setQueue(""); Plan plan = null; try { plan = rrValidator.validateReservationListRequest(rSystem, request); Assert.fail(); } catch (YarnException e) { Assert.assertNull(plan); String message = e.getMessage(); Assert.assertTrue(message.equals( "The queue is not specified. Please try again with a valid " + "reservable queue.")); LOG.info(message); } }
@Test public void testListReservationsNullPlan() { ReservationListRequest request = new ReservationListRequestPBImpl(); request.setQueue(ReservationSystemTestUtil.reservationQ); when(rSystem.getPlan(ReservationSystemTestUtil.reservationQ)).thenReturn (null); Plan plan = null; try { plan = rrValidator.validateReservationListRequest(rSystem, request); Assert.fail(); } catch (YarnException e) { Assert.assertNull(plan); String message = e.getMessage(); Assert.assertTrue(message.equals( "The specified queue: " + ReservationSystemTestUtil.reservationQ + " is not managed by reservation system." + " Please try again with a valid reservable queue." )); LOG.info(message); } }