### Question:
SingleQueueLlamaAM extends LlamaAMImpl implements
    RMListener { @Override public void stoppedByRM() { LOG.warn("Stopped by '{}'", rmConnector.getClass().getSimpleName()); loseAllReservations(); IntraLlamaAMsCallback localReference = this.callback; if (localReference != null) { localReference.discardAM(queue); } } SingleQueueLlamaAM(Configuration conf, String queue,
                            ScheduledExecutorService stp); static Class<? extends RMConnector> getRMConnectorClass(
      Configuration conf); void setCallback(IntraLlamaAMsCallback callback); @Override void start(); RMConnector getRMConnector(); @Override boolean isRunning(); @Override synchronized void stop(); @Override List<NodeInfo> getNodes(); void deleteAllYarnApplications(); @Override @SuppressWarnings("unchecked") void reserve(UUID reservationId,
      final Reservation reservation); @Override PlacedReservation getReservation(final UUID reservationId); @Override PlacedReservation releaseReservation(UUID handle,
      final UUID reservationId, boolean doNotCache); @SuppressWarnings("unchecked") PlacedReservation releaseReservation(UUID handle,
      final UUID reservationId, boolean doNotCache, boolean doNotDispatch); @Override @SuppressWarnings("unchecked") List<PlacedReservation> releaseReservationsForHandle(UUID handle,
      boolean doNotCache); @Override List<PlacedReservation> releaseReservationsForQueue(String queue,
      boolean doNotCache); @Override void emptyCacheForQueue(String queue); @Override @SuppressWarnings("unchecked") void onEvent(final List<RMEvent> rmEvents); @Override void stoppedByRM(); static final List<String> METRIC_TEMPLATE_KEYS; }### Answer:
@Test public void testStoppedByRm() throws Exception { SingleQueueLlamaAM llama = createLlamaAM(); DummyLlamaAMListener listener = new DummyLlamaAMListener(); try { llama.start(); llama.addListener(listener); UUID cId1 = UUID.randomUUID(); UUID cId2 = UUID.randomUUID(); UUID reservationId1 = llama.reserve(TestUtils.createReservation(cId1, "u", "queue", Arrays.asList(RESOURCE1), true)); UUID reservationId2 = llama.reserve(TestUtils.createReservation(cId1, "u", "queue", Arrays.asList(RESOURCE2), true)); UUID reservationId3 = llama.reserve(TestUtils.createReservation(cId2, "u", "queue", Arrays.asList(RESOURCE3), true)); llama.stoppedByRM(); Assert.assertNull(llama._getReservation(reservationId1)); Assert.assertNull(llama._getReservation(reservationId2)); Assert.assertNull(llama._getReservation(reservationId3)); Assert.assertEquals(3, TestUtils.getReservations(listener.events, PlacedReservation.Status.LOST, false).size()); } finally { llama.stop(); } }