@Test
    void verifyOperation() throws Throwable {
        assertEquals(Ordered.HIGHEST_PRECEDENCE, surrogateServiceTicketGeneratorAuthority.getOrder());

        val credential = new UsernamePasswordCredential();
        credential.getCredentialMetadata()
            .addTrait(new SurrogateCredentialTrait("surrogate"));
        credential.setUsername("casuser");
        val authenticationResult = authenticationResultBuilderFactory.newBuilder()
            .collect(RegisteredServiceTestUtils.getAuthentication(credential))
            .build();

        val service = RegisteredServiceTestUtils.getService(UUID.randomUUID().toString());
        val registeredService = RegisteredServiceTestUtils.getRegisteredService(service.getId(), Map.of());
        servicesManager.save(registeredService);

        registeredService.setSurrogatePolicy(new DefaultRegisteredServiceSurrogatePolicy().setEnabled(false));
        assertTrue(surrogateServiceTicketGeneratorAuthority.supports(authenticationResult, service));
        assertThrows(SurrogateAuthenticationException.class,
            () -> surrogateServiceTicketGeneratorAuthority.shouldGenerate(authenticationResult, service));

        registeredService.setSurrogatePolicy(new DefaultRegisteredServiceSurrogatePolicy().setEnabled(true));
        servicesManager.save(registeredService);
        assertTrue(surrogateServiceTicketGeneratorAuthority.shouldGenerate(authenticationResult, service));
    }
This is {@link SurrogateServiceTicketGeneratorAuthorityTests}.

@author Misagh Moayyed
@since 7.2.0
support/cas-server-support-surrogate-authentication/src/test/java/org/apereo/cas/ticket/SurrogateServiceTicketGeneratorAuthorityTests.java