Program: 107821
Project: 107821
Buggy source:
/** 
 * Performs some sanity checks.
 * @param handle the data handle
 * @param config the configuration
 */
private void checkBeforeEncoding(final DataHandle handle,final ARXConfiguration config){
  if (handle == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (config.isPrivacyModelSpecified(LDiversity.class) || config.isPrivacyModelSpecified(TCloseness.class) || config.isPrivacyModelSpecified(DDisclosurePrivacy.class)|| config.isPrivacyModelSpecified(BasicBLikeness.class)|| config.isPrivacyModelSpecified(EnhancedBLikeness.class)) {
    if (handle.getDefinition().getSensitiveAttributes().size() == 0) {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
  if (config.getQualityModel() instanceof MetricSDClassification) {
    for (    String attribute : ((MetricSDClassification)config.getQualityModel()).getClassAttributes()) {
      if (!(handle.getDefinition().getSensitiveAttributes().contains(attribute) || handle.getDefinition().getInsensitiveAttributes().contains(attribute))) {
        throw new IllegalArgumentException("String_Node_Str");
      }
    }
  }
  for (  String attribute : handle.getDefinition().getQuasiIdentifiersWithGeneralization()) {
    if (handle.getDefinition().getHierarchy(attribute) == null) {
      throw new IllegalStateException("String_Node_Str" + attribute + "String_Node_Str");
    }
  }
  for (  String attr : handle.getDefinition().getSensitiveAttributes()) {
    boolean found=false;
    for (    LDiversity c : config.getPrivacyModels(LDiversity.class)) {
      if (c.getAttribute().equals(attr)) {
        found=true;
        break;
      }
    }
    if (!found) {
      for (      TCloseness c : config.getPrivacyModels(TCloseness.class)) {
        if (c.getAttribute().equals(attr)) {
          found=true;
          break;
        }
      }
    }
    if (!found) {
      for (      DDisclosurePrivacy c : config.getPrivacyModels(DDisclosurePrivacy.class)) {
        if (c.getAttribute().equals(attr)) {
          found=true;
          break;
        }
      }
    }
    if (!found) {
      for (      BasicBLikeness c : config.getPrivacyModels(BasicBLikeness.class)) {
        if (c.getAttribute().equals(attr)) {
          found=true;
          break;
        }
      }
    }
    if (!found) {
      for (      EnhancedBLikeness c : config.getPrivacyModels(EnhancedBLikeness.class)) {
        if (c.getAttribute().equals(attr)) {
          found=true;
          break;
        }
      }
    }
    if (!found) {
      throw new IllegalArgumentException("String_Node_Str" + attr + "String_Node_Str");
    }
  }
  for (  LDiversity c : config.getPrivacyModels(LDiversity.class)) {
    if (handle.getDefinition().getAttributeType(c.getAttribute()) != AttributeType.SENSITIVE_ATTRIBUTE) {
      throw new RuntimeException("String_Node_Str" + c.getAttribute() + "String_Node_Str");
    }
  }
  for (  TCloseness c : config.getPrivacyModels(TCloseness.class)) {
    if (handle.getDefinition().getAttributeType(c.getAttribute()) != AttributeType.SENSITIVE_ATTRIBUTE) {
      throw new RuntimeException("String_Node_Str" + c.getAttribute() + "String_Node_Str");
    }
  }
  for (  DDisclosurePrivacy c : config.getPrivacyModels(DDisclosurePrivacy.class)) {
    if (handle.getDefinition().getAttributeType(c.getAttribute()) != AttributeType.SENSITIVE_ATTRIBUTE) {
      throw new RuntimeException("String_Node_Str" + c.getAttribute() + "String_Node_Str");
    }
  }
  for (  BasicBLikeness c : config.getPrivacyModels(BasicBLikeness.class)) {
    if (handle.getDefinition().getAttributeType(c.getAttribute()) != AttributeType.SENSITIVE_ATTRIBUTE) {
      throw new RuntimeException("String_Node_Str" + c.getAttribute() + "String_Node_Str");
    }
  }
  for (  EnhancedBLikeness c : config.getPrivacyModels(EnhancedBLikeness.class)) {
    if (handle.getDefinition().getAttributeType(c.getAttribute()) != AttributeType.SENSITIVE_ATTRIBUTE) {
      throw new RuntimeException("String_Node_Str" + c.getAttribute() + "String_Node_Str");
    }
  }
  if (!(handle instanceof DataHandleInput)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  DataDefinition definition=handle.getDefinition();
  Set<String> attributes=new HashSet<String>();
  for (int i=0; i < handle.getNumColumns(); i++) {
    attributes.add(handle.getAttributeName(i));
  }
  for (  String attribute : handle.getDefinition().getSensitiveAttributes()) {
    if (!attributes.contains(attribute)) {
      throw new IllegalArgumentException("String_Node_Str" + attribute + "String_Node_Str");
    }
  }
  for (  String attribute : handle.getDefinition().getInsensitiveAttributes()) {
    if (!attributes.contains(attribute)) {
      throw new IllegalArgumentException("String_Node_Str" + attribute + "String_Node_Str");
    }
  }
  for (  String attribute : handle.getDefinition().getIdentifyingAttributes()) {
    if (!attributes.contains(attribute)) {
      throw new IllegalArgumentException("String_Node_Str" + attribute + "String_Node_Str");
    }
  }
  for (  String attribute : handle.getDefinition().getQuasiIdentifyingAttributes()) {
    if (!attributes.contains(attribute)) {
      throw new IllegalArgumentException("String_Node_Str" + attribute + "String_Node_Str");
    }
  }
  for (  String attribute : handle.getDefinition().getQuasiIdentifiersWithMicroaggregation()) {
    if (handle.getDefinition().getMicroAggregationFunction(attribute) == null) {
      throw new IllegalArgumentException("String_Node_Str" + attribute + "String_Node_Str");
    }
    MicroAggregationFunction f=(MicroAggregationFunction)definition.getMicroAggregationFunction(attribute);
    DataType<?> t=definition.getDataType(attribute);
    if (!t.getDescription().getScale().provides(f.getRequiredScale())) {
      throw new IllegalArgumentException("String_Node_Str" + attribute + "String_Node_Str"+ f.getRequiredScale());
    }
  }
  if (config.isPrivacyModelSpecified(EDDifferentialPrivacy.class)) {
    if (!definition.getQuasiIdentifiersWithMicroaggregation().isEmpty()) {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
  Set<String> genQis=definition.getQuasiIdentifiersWithGeneralization();
  if ((config.getMaxOutliers() < 0d) || (config.getMaxOutliers() > 1d)) {
    throw new IllegalArgumentException("String_Node_Str" + config.getMaxOutliers() + "String_Node_Str");
  }
  if (genQis.size() == 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (genQis.size() > maxQuasiIdentifiers) {
    throw new IllegalArgumentException("String_Node_Str" + genQis.size() + "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Performs some sanity checks.
 * @param handle the data handle
 * @param config the configuration
 */
private void checkBeforeEncoding(final DataHandle handle,final ARXConfiguration config){
  if (handle == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (config.isPrivacyModelSpecified(LDiversity.class) || config.isPrivacyModelSpecified(TCloseness.class) || config.isPrivacyModelSpecified(DDisclosurePrivacy.class)|| config.isPrivacyModelSpecified(BasicBLikeness.class)|| config.isPrivacyModelSpecified(EnhancedBLikeness.class)) {
    if (handle.getDefinition().getSensitiveAttributes().size() == 0) {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
  if (config.getQualityModel() instanceof MetricSDClassification) {
    for (    String attribute : ((MetricSDClassification)config.getQualityModel()).getClassAttributes()) {
      if (!(handle.getDefinition().getSensitiveAttributes().contains(attribute) || handle.getDefinition().getInsensitiveAttributes().contains(attribute))) {
        throw new IllegalArgumentException("String_Node_Str");
      }
    }
  }
  for (  String attribute : handle.getDefinition().getQuasiIdentifiersWithGeneralization()) {
    if (handle.getDefinition().getHierarchy(attribute) == null) {
      throw new IllegalStateException("String_Node_Str" + attribute + "String_Node_Str");
    }
  }
  for (  String attr : handle.getDefinition().getSensitiveAttributes()) {
    boolean found=false;
    for (    LDiversity c : config.getPrivacyModels(LDiversity.class)) {
      if (c.getAttribute().equals(attr)) {
        found=true;
        break;
      }
    }
    if (!found) {
      for (      TCloseness c : config.getPrivacyModels(TCloseness.class)) {
        if (c.getAttribute().equals(attr)) {
          found=true;
          break;
        }
      }
    }
    if (!found) {
      for (      DDisclosurePrivacy c : config.getPrivacyModels(DDisclosurePrivacy.class)) {
        if (c.getAttribute().equals(attr)) {
          found=true;
          break;
        }
      }
    }
    if (!found) {
      for (      BasicBLikeness c : config.getPrivacyModels(BasicBLikeness.class)) {
        if (c.getAttribute().equals(attr)) {
          found=true;
          break;
        }
      }
    }
    if (!found) {
      for (      EnhancedBLikeness c : config.getPrivacyModels(EnhancedBLikeness.class)) {
        if (c.getAttribute().equals(attr)) {
          found=true;
          break;
        }
      }
    }
    if (!found) {
      throw new IllegalArgumentException("String_Node_Str" + attr + "String_Node_Str");
    }
  }
  for (  LDiversity c : config.getPrivacyModels(LDiversity.class)) {
    if (handle.getDefinition().getAttributeType(c.getAttribute()) != AttributeType.SENSITIVE_ATTRIBUTE) {
      throw new RuntimeException("String_Node_Str" + c.getAttribute() + "String_Node_Str");
    }
  }
  for (  TCloseness c : config.getPrivacyModels(TCloseness.class)) {
    if (handle.getDefinition().getAttributeType(c.getAttribute()) != AttributeType.SENSITIVE_ATTRIBUTE) {
      throw new RuntimeException("String_Node_Str" + c.getAttribute() + "String_Node_Str");
    }
  }
  for (  DDisclosurePrivacy c : config.getPrivacyModels(DDisclosurePrivacy.class)) {
    if (handle.getDefinition().getAttributeType(c.getAttribute()) != AttributeType.SENSITIVE_ATTRIBUTE) {
      throw new RuntimeException("String_Node_Str" + c.getAttribute() + "String_Node_Str");
    }
  }
  for (  BasicBLikeness c : config.getPrivacyModels(BasicBLikeness.class)) {
    if (handle.getDefinition().getAttributeType(c.getAttribute()) != AttributeType.SENSITIVE_ATTRIBUTE) {
      throw new RuntimeException("String_Node_Str" + c.getAttribute() + "String_Node_Str");
    }
  }
  for (  EnhancedBLikeness c : config.getPrivacyModels(EnhancedBLikeness.class)) {
    if (handle.getDefinition().getAttributeType(c.getAttribute()) != AttributeType.SENSITIVE_ATTRIBUTE) {
      throw new RuntimeException("String_Node_Str" + c.getAttribute() + "String_Node_Str");
    }
  }
  if (!(handle instanceof DataHandleInput)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  DataDefinition definition=handle.getDefinition();
  Set<String> attributes=new HashSet<String>();
  for (int i=0; i < handle.getNumColumns(); i++) {
    attributes.add(handle.getAttributeName(i));
  }
  for (  String attribute : handle.getDefinition().getSensitiveAttributes()) {
    if (!attributes.contains(attribute)) {
      throw new IllegalArgumentException("String_Node_Str" + attribute + "String_Node_Str");
    }
  }
  for (  String attribute : handle.getDefinition().getInsensitiveAttributes()) {
    if (!attributes.contains(attribute)) {
      throw new IllegalArgumentException("String_Node_Str" + attribute + "String_Node_Str");
    }
  }
  for (  String attribute : handle.getDefinition().getIdentifyingAttributes()) {
    if (!attributes.contains(attribute)) {
      throw new IllegalArgumentException("String_Node_Str" + attribute + "String_Node_Str");
    }
  }
  for (  String attribute : handle.getDefinition().getQuasiIdentifyingAttributes()) {
    if (!attributes.contains(attribute)) {
      throw new IllegalArgumentException("String_Node_Str" + attribute + "String_Node_Str");
    }
  }
  for (  String attribute : handle.getDefinition().getQuasiIdentifiersWithMicroaggregation()) {
    if (handle.getDefinition().getMicroAggregationFunction(attribute) == null) {
      throw new IllegalArgumentException("String_Node_Str" + attribute + "String_Node_Str");
    }
    MicroAggregationFunction f=(MicroAggregationFunction)definition.getMicroAggregationFunction(attribute);
    DataType<?> t=definition.getDataType(attribute);
    if (!t.getDescription().getScale().provides(f.getRequiredScale())) {
      throw new IllegalArgumentException("String_Node_Str" + attribute + "String_Node_Str"+ f.getRequiredScale());
    }
  }
  if (config.isPrivacyModelSpecified(EDDifferentialPrivacy.class)) {
    if (!definition.getQuasiIdentifiersWithMicroaggregation().isEmpty()) {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
  Set<String> genQis=definition.getQuasiIdentifiersWithGeneralization();
  Set<String> clusterQis=definition.getQuasiIdentifiersWithClusteringAndMicroaggregation();
  if ((config.getMaxOutliers() < 0d) || (config.getMaxOutliers() > 1d)) {
    throw new IllegalArgumentException("String_Node_Str" + config.getMaxOutliers() + "String_Node_Str");
  }
  if ((genQis.size() + clusterQis.size()) == 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if ((genQis.size() + clusterQis.size()) > maxQuasiIdentifiers) {
    throw new IllegalArgumentException("String_Node_Str" + genQis.size() + "String_Node_Str");
  }
}