### Question:
StartableMethods { public static void stopSequentially(Iterable<? extends Startable> entities) { List<Exception> exceptions = Lists.newArrayList(); List<Startable> failedEntities = Lists.newArrayList(); for (final Startable entity : entities) { if (!Entities.isManaged((Entity)entity)) { log.debug("Not stopping {} because it is not managed; continuing", entity); continue; } try { TaskAdaptable<Void> task = TaskTags.markInessential(Effectors.invocation((Entity)entity, Startable.STOP, Collections.emptyMap())); DynamicTasks.submit(task, (Entity)entity).getUnchecked(); } catch (Exception e) { log.warn("Error stopping "+entity+"; continuing with shutdown", e); exceptions.add(e); failedEntities.add(entity); } } if (exceptions.size() > 0) { throw new CompoundRuntimeException("Error stopping "+(failedEntities.size() > 1 ? "entities" : "entity")+": "+failedEntities, exceptions); } } private  StartableMethods(); static void start(EntityLocal e, Collection<? extends Location> locations); static void stop(EntityLocal e); static void restart(EntityLocal e); static void stopSequentially(Iterable<? extends Startable> entities); static TaskAdaptable<?> startingChildren(Entity entity); static TaskAdaptable<?> startingChildren(Entity entity, Location location); static TaskAdaptable<?> startingChildren(Entity entity, Iterable<? extends Location> locations); static TaskAdaptable<?> stoppingChildren(Entity entity); static TaskAdaptable<?> restartingChildren(Entity entity, ConfigBag parameters); static TaskAdaptable<?> restartingChildren(Entity entity); static final Logger log; }### Answer:
@Test public void testStopSequentially() { entity = app.createAndManageChild(EntitySpec.create(FailingEntity.class) .configure(FailingEntity.LISTENER, listener)); entity2 = app.createAndManageChild(EntitySpec.create(FailingEntity.class) .configure(FailingEntity.LISTENER, listener)); app.start(ImmutableList.of(loc)); listener.events.clear(); StartableMethods.stopSequentially(ImmutableList.of(entity, entity2)); assertEquals(listener.events.get(0)[0], entity); assertEquals(listener.events.get(1)[0], entity2); }