@Test
    void verifyFindByName() {
        val component = mock(ServiceRegistry.class);

        when(component.findServiceByExactServiceName(anyString())).thenReturn(null);
        when(component.findServiceByExactServiceName(anyString(), any())).thenCallRealMethod();
        assertNull(component.findServiceByExactServiceName("test", BaseMockRegisteredService.class));

        val service = mock(RegisteredService.class);
        when(component.findServiceByExactServiceName(anyString())).thenReturn(service);
        assertThrows(ClassCastException.class,
            () -> component.findServiceByExactServiceName("test", BaseMockRegisteredService.class));
    }
This is {@link ServiceRegistryTests}.

@author Misagh Moayyed
@since 6.3.0
api/cas-server-core-api-services/src/test/java/org/apereo/cas/services/ServiceRegistryTests.java