/**
   * Assert that the attributes returned from the data connector match the provided attributes.
   *
   * @param dataConnectorName the data connector name
   * @param principalName the principalName
   * @param correctMap the correct attributes
   */
  private void runAttributeDefinitionTest(
      String dataConnectorName,
      String principalName,
      AttributeMap correctMap,
      String attributeDefinitionName) {
    try {
      GenericApplicationContext gContext =
          BaseDataConnectorTest.createSpringContext(RESOLVER_CONFIG);
      ShibbolethResolutionContext ctx = getShibContext(principalName);

      // resolve data connector dependency
      GroupDataConnector gdc = (GroupDataConnector) gContext.getBean(dataConnectorName);
      gdc.resolve(ctx);
      ctx.getResolvedPlugins().put(gdc.getId(), gdc);

      // resolve attribute definition
      AttributeDefinition ad = (AttributeDefinition) gContext.getBean(attributeDefinitionName);
      BaseAttribute attr = ad.resolve(ctx);

      // assert equality
      AttributeMap currentMap = new AttributeMap();
      currentMap.setAttribute(attr);
      LOG.debug("correctMap\n{}", correctMap);
      LOG.debug("currentMap\n{}", currentMap);
      assertEquals(correctMap, currentMap);
    } catch (Exception e) {
      e.printStackTrace();
      throw new RuntimeException(e);
    }
  }
  /** {@inheritDoc} */
  protected BaseAttribute<String> doResolve(ShibbolethResolutionContext resolutionContext) {
    BasicAttribute<String> attribute = new BasicAttribute<String>();
    attribute.setId(getId());

    String authnMethod =
        resolutionContext.getAttributeRequestContext().getPrincipalAuthenticationMethod();
    if (!DatatypeHelper.isEmpty(authnMethod)) {
      attribute.getValues().add(authnMethod);
    }

    return attribute;
  }
  /**
   * Builds a name ID. The provided value is the textual content of the NameIdentifier. If a {@link
   * #nameIdQualifier} is not null it is used as the NameIdentifier's name qualifier, otherwise the
   * attribute issuer's entity id is used.
   *
   * @param nameIdValue value of the NameIdentifier
   * @param resolutionContext current resolution context
   * @return the constructed NameIdentifier
   */
  protected NameIdentifier buildNameId(
      String nameIdValue, ShibbolethResolutionContext resolutionContext) {
    NameIdentifier nameId = nameIdBuilder.buildObject();
    nameId.setNameIdentifier(nameIdValue);

    if (nameIdFormat != null) {
      nameId.setFormat(nameIdFormat);
    }

    if (nameIdQualifier != null) {
      nameId.setNameQualifier(nameIdQualifier);
    } else {
      nameId.setNameQualifier(resolutionContext.getAttributeRequestContext().getLocalEntityId());
    }

    return nameId;
  }