@Bean
        public SamlIdPMetadataLocator samlIdPMetadataLocator() throws Throwable {
            val locator = mock(SamlIdPMetadataLocator.class);
            when(locator.exists(argThat(Optional::isEmpty))).thenAnswer((Answer<Boolean>) invocationOnMock -> {
                var property = System.getProperty("test.runtime");
                if (property != null && "fail".equals(property)) {
                    throw new RuntimeException("Failed");
                }
                return true;
            });
            return locator;
        }
This is {@link DefaultSamlIdPCasEventListenerTests}.

@author Misagh Moayyed
@since 6.5.0
support/cas-server-support-saml-idp/src/test/java/org/apereo/cas/support/saml/idp/DefaultSamlIdPCasEventListenerTests.java