### Question:
EphemeralKeyManager { void retrieveEphemeralKey(@Nullable String actionString, Map<String, Object> arguments) { if (shouldRefreshKey( mEphemeralKey, mTimeBufferInSeconds, mOverrideCalendar)) { mEphemeralKeyProvider.createEphemeralKey( StripeApiHandler.API_VERSION, new ClientKeyUpdateListener(this, actionString, arguments)); } else { mListener.onKeyUpdate(mEphemeralKey, actionString, arguments); } } EphemeralKeyManager(
            @NonNull EphemeralKeyProvider ephemeralKeyProvider,
            @NonNull KeyManagerListener keyManagerListener,
            long timeBufferInSeconds,
            @Nullable Calendar overrideCalendar);   }### Answer:
@Test @SuppressWarnings("unchecked") public void retrieveEphemeralKey_whenUpdateNecessary_returnsUpdateAndArguments() { EphemeralKey testKey = EphemeralKey.fromString(FIRST_SAMPLE_KEY_RAW); assertNotNull(testKey); Calendar fixedCalendar = Calendar.getInstance(); long currentTimeInMillis = fixedCalendar.getTimeInMillis(); long timeAgoInMillis = currentTimeInMillis - 100L; testKey.setExpires(TimeUnit.MILLISECONDS.toSeconds(timeAgoInMillis)); mTestEphemeralKeyProvider.setNextRawEphemeralKey(FIRST_SAMPLE_KEY_RAW); EphemeralKeyManager keyManager = new EphemeralKeyManager( mTestEphemeralKeyProvider, mKeyManagerListener, TEST_SECONDS_BUFFER, fixedCalendar); reset(mKeyManagerListener); final String ACTION_STRING = "action"; final Map<String, Object> ACTION_ARGS = new HashMap<>(); ACTION_ARGS.put("key", "value"); keyManager.retrieveEphemeralKey(ACTION_STRING, ACTION_ARGS); ArgumentCaptor<EphemeralKey> keyArgumentCaptor = ArgumentCaptor.forClass(EphemeralKey.class); ArgumentCaptor<String> stringArgumentCaptor = ArgumentCaptor.forClass(String.class); ArgumentCaptor<Map<String, Object>> mapArgumentCaptor = ArgumentCaptor.forClass(Map.class); verify(mKeyManagerListener, times(1)).onKeyUpdate( keyArgumentCaptor.capture(), stringArgumentCaptor.capture(), mapArgumentCaptor.capture()); Map<String, Object> capturedMap = mapArgumentCaptor.getValue(); assertNotNull(capturedMap); assertNotNull(keyArgumentCaptor.getValue()); assertEquals(1, capturedMap.size()); assertEquals("value", capturedMap.get("key")); assertEquals(ACTION_STRING, stringArgumentCaptor.getValue()); }