@Test
    void verifyAttributeQueryNameID() throws Throwable {
        val service = getSamlRegisteredServiceForTestShib();
        service.setRequiredNameIdFormat(NameIDType.PERSISTENT);

        val aqNameId = mock(NameID.class);
        val nameIdValue = UUID.randomUUID().toString();
        when(aqNameId.getValue()).thenReturn(nameIdValue);
        when(aqNameId.getFormat()).thenReturn(NameIDType.UNSPECIFIED);
        val qualifier = UUID.randomUUID().toString();
        when(aqNameId.getSPNameQualifier()).thenReturn(qualifier);
        when(aqNameId.getNameQualifier()).thenReturn(qualifier);

        val aqSubject = mock(Subject.class);
        when(aqSubject.getNameID()).thenReturn(aqNameId);
        val attributeQuery = mock(AttributeQuery.class);
        when(attributeQuery.getSubject()).thenReturn(aqSubject);

        val adaptor = SamlRegisteredServiceMetadataAdaptor.get(samlRegisteredServiceCachingMetadataResolver,
            service, service.getServiceId()).orElseThrow();
        val buildContext = SamlProfileBuilderContext.builder()
            .samlRequest(attributeQuery)
            .httpRequest(new MockHttpServletRequest())
            .httpResponse(new MockHttpServletResponse())
            .authenticatedAssertion(Optional.of(getAssertion()))
            .registeredService(service)
            .adaptor(adaptor)
            .binding(SAMLConstants.SAML2_POST_BINDING_URI)
            .build();
        val subject = samlProfileSamlSubjectBuilder.build(buildContext);
        assertNotNull(subject.getNameID());

        assertEquals(nameIdValue, subject.getNameID().getValue());
        assertEquals(NameIDType.UNSPECIFIED, subject.getNameID().getFormat());
        assertEquals(qualifier, subject.getNameID().getSPNameQualifier());
        assertEquals(qualifier, subject.getNameID().getNameQualifier());
    }
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