### Question:
RegisterApplicationMasterResponseReflector { @VisibleForTesting List<Container> getContainersFromPreviousAttemptsUnsafe(final Object response) { if (method != null && response != null) { try { @SuppressWarnings("unchecked") final List<Container> containers = (List<Container>) method.invoke(response); if (containers != null && !containers.isEmpty()) { return containers; } } catch (Exception t) { logger.error("Error invoking 'getContainersFromPreviousAttempts()'", t); } } return Collections.emptyList(); } RegisterApplicationMasterResponseReflector(final Logger log); @VisibleForTesting  RegisterApplicationMasterResponseReflector(final Logger log, final Class<?> clazz);   }### Answer:
@Test public void testCallsMethodIfPresent() { final RegisterApplicationMasterResponseReflector registerApplicationMasterResponseReflector = new RegisterApplicationMasterResponseReflector(LOG, HasMethod.class); final List<Container> containersFromPreviousAttemptsUnsafe = registerApplicationMasterResponseReflector.getContainersFromPreviousAttemptsUnsafe(new HasMethod()); assertThat(containersFromPreviousAttemptsUnsafe, hasSize(1)); }
@Test public void testDoesntCallMethodIfAbsent() { final RegisterApplicationMasterResponseReflector registerApplicationMasterResponseReflector = new RegisterApplicationMasterResponseReflector(LOG, HasMethod.class); final List<Container> containersFromPreviousAttemptsUnsafe = registerApplicationMasterResponseReflector.getContainersFromPreviousAttemptsUnsafe(new Object()); assertThat(containersFromPreviousAttemptsUnsafe, empty()); }