private AttributeQuery getAttributeQuery(final String nameIdFormat, final String nameIdValue) {
            var builder = (SAMLObjectBuilder) openSamlConfigBean.getBuilderFactory()
                .getBuilder(AttributeQuery.DEFAULT_ELEMENT_NAME);
            val query = (AttributeQuery) builder.buildObject();
            builder = (SAMLObjectBuilder) openSamlConfigBean.getBuilderFactory()
                .getBuilder(Issuer.DEFAULT_ELEMENT_NAME);
            val issuer = (Issuer) builder.buildObject();
            issuer.setValue(samlRegisteredService.getServiceId());
            query.setIssuer(issuer);

            builder = (SAMLObjectBuilder) openSamlConfigBean.getBuilderFactory()
                .getBuilder(NameID.DEFAULT_ELEMENT_NAME);
            val nameId = (NameID) builder.buildObject();
            nameId.setValue(nameIdValue);
            nameId.setFormat(nameIdFormat);

            builder = (SAMLObjectBuilder) openSamlConfigBean.getBuilderFactory()
                .getBuilder(Subject.DEFAULT_ELEMENT_NAME);
            val subject = (Subject) builder.buildObject();

            if (nameIdFormat.equals(NameIDType.ENCRYPTED)) {
                val facade = SamlRegisteredServiceMetadataAdaptor.get(defaultSamlRegisteredServiceCachingMetadataResolver,
                    samlRegisteredService, samlRegisteredService.getServiceId()).get();
                val encryptedId = samlIdPObjectEncrypter.encode(nameId, samlRegisteredService, facade);
                subject.setEncryptedID(encryptedId);
            } else {
                subject.setNameID(nameId);
            }
            query.setSubject(subject);

            builder = (SAMLObjectBuilder) openSamlConfigBean.getBuilderFactory()
                .getBuilder(Attribute.DEFAULT_ELEMENT_NAME);
            val attr1 = (Attribute) builder.buildObject();
            attr1.setName("cn");

            val value1 = (AttributeValue) ((SAMLObjectBuilder) openSamlConfigBean.getBuilderFactory()
                .getBuilder(AttributeValue.DEFAULT_ELEMENT_NAME)).buildObject();
            value1.setTextContent("CAS");
            attr1.getAttributeValues().add(value1);
            query.getAttributes().add(attr1);

            val attr2 = (Attribute) builder.buildObject();
            attr2.setName("event-type");

            val value2 = (AttributeValue) ((SAMLObjectBuilder) openSamlConfigBean.getBuilderFactory()
                .getBuilder(AttributeValue.DEFAULT_ELEMENT_NAME)).buildObject();
            value2.setTextContent("saml1-attr-query");
            attr2.getAttributeValues().add(value2);

            query.getAttributes().add(attr2);
            return query;
        }
This is {@link SamlIdPSaml2AttributeQueryProfileHandlerControllerTests}.

@author Misagh Moayyed
@since 6.2.0
support/cas-server-support-saml-idp/src/test/java/org/apereo/cas/support/saml/web/idp/profile/query/SamlIdPSaml2AttributeQueryProfileHandlerControllerTests.java