### Question:
RegistryCredentialRetriever { static Optional<Credential> getBaseImageCredential(BuildContext buildContext) throws CredentialRetrievalException { return retrieve(buildContext.getBaseImageConfiguration(), buildContext.getEventHandlers()); }    }### Answer:
@Test public void testCall_exception() throws CacheDirectoryCreationException { CredentialRetrievalException credentialRetrievalException = Mockito.mock(CredentialRetrievalException.class); BuildContext buildContext = makeFakeBuildContext( Collections.singletonList( () -> { throw credentialRetrievalException; }), Collections.emptyList()); try { RegistryCredentialRetriever.getBaseImageCredential(buildContext); Assert.fail("Should have thrown exception"); } catch (CredentialRetrievalException ex) { Assert.assertSame(credentialRetrievalException, ex); } }