@Test
    void verifySkipTransient() throws Throwable {
        val authnRequest = mock(AuthnRequest.class);
        val issuer = mock(Issuer.class);
        when(issuer.getValue()).thenReturn("https://idp.example.org");
        when(authnRequest.getIssuer()).thenReturn(issuer);

        val policy = mock(NameIDPolicy.class);
        when(policy.getFormat()).thenReturn(NameIDType.TRANSIENT);
        when(authnRequest.getNameIDPolicy()).thenReturn(policy);

        val service = new SamlRegisteredService();
        service.setServiceId("entity-id");
        service.setSkipGeneratingTransientNameId(true);
        service.setRequiredNameIdFormat(NameIDType.TRANSIENT);
        val facade = mock(SamlRegisteredServiceMetadataAdaptor.class);
        when(facade.getEntityId()).thenReturn(service.getServiceId());
        when(facade.getSupportedNameIdFormats()).thenReturn(CollectionUtils.wrapList(NameIDType.TRANSIENT));

        val buildContext = SamlProfileBuilderContext.builder()
            .samlRequest(authnRequest)
            .httpRequest(new MockHttpServletRequest())
            .httpResponse(new MockHttpServletResponse())
            .authenticatedAssertion(Optional.of(getAssertion()))
            .registeredService(service)
            .adaptor(facade)
            .binding(SAMLConstants.SAML2_POST_BINDING_URI)
            .build();
        val result = (NameID) samlProfileSamlNameIdBuilder.build(buildContext);
        assertNotNull(result);
        assertEquals(NameIDType.TRANSIENT, result.getFormat());
        assertEquals("casuser", result.getValue());
    }
This is {@link SamlProfileSamlNameIdBuilderTests}.

@author Misagh Moayyed
@since 5.3.0
support/cas-server-support-saml-idp/src/test/java/org/apereo/cas/support/saml/web/idp/profile/builders/nameid/SamlProfileSamlNameIdBuilderTests.java