Program: 62126
Project: 62126
Buggy source:
/** 
 * Check the constraints on an unwrapped property value (basically a string, map or list) and get events through the given consumer parameter when missing properties on complex data type are found. Note that the property value cannot be null and the required characteristic of the initial property definition will NOT be checked.
 * @param propertyName The name of the property.
 * @param propertyValue The value of the property to check.
 * @param propertyDefinition The property definition that defines the property to check.
 * @param missingPropertyConsumer A consumer to receive events when a required property is not defined on a complex type sub-field.
 * @throws ConstraintValueDoNotMatchPropertyTypeException In case the value type doesn't match the type of the property as defined.
 * @throws ConstraintViolationException In case the value doesn't match one of the constraints defined on the property.
 */
public static void checkPropertyConstraint(String propertyName,Object propertyValue,PropertyDefinition propertyDefinition,Consumer<String> missingPropertyConsumer) throws ConstraintValueDoNotMatchPropertyTypeException, ConstraintViolationException {
  Object value=propertyValue;
  if (propertyValue instanceof PropertyValue) {
    value=((PropertyValue)propertyValue).getValue();
  }
  boolean isTypeDerivedFromPrimitive=false;
  DataType dataType=null;
  String typeName=propertyDefinition.getType();
  if (!ToscaTypes.isPrimitive(typeName)) {
    dataType=ToscaContext.get(DataType.class,typeName);
    if (dataType instanceof PrimitiveDataType) {
      isTypeDerivedFromPrimitive=true;
    }
  }
  if (value instanceof String) {
    if (ToscaTypes.isSimple(typeName)) {
      checkSimplePropertyConstraint(propertyName,(String)value,propertyDefinition);
    }
 else     if (isTypeDerivedFromPrimitive) {
      checkComplexPropertyDerivedFromPrimitiveTypeConstraints(propertyName,(String)value,propertyDefinition,dataType);
    }
 else {
      throw new ConstraintValueDoNotMatchPropertyTypeException("String_Node_Str" + value.getClass().getName());
    }
  }
 else   if (value instanceof Map) {
    if (ToscaTypes.MAP.equals(typeName)) {
      checkMapPropertyConstraint(propertyName,(Map<String,Object>)value,propertyDefinition,missingPropertyConsumer);
    }
 else {
      checkDataTypePropertyConstraint(propertyName,(Map<String,Object>)value,propertyDefinition,missingPropertyConsumer);
    }
  }
 else   if (value instanceof List) {
    if (ToscaTypes.RANGE.equals(typeName)) {
      checkRangePropertyConstraint(propertyName,(List<Object>)value,propertyDefinition);
    }
 else {
      checkListPropertyConstraint(propertyName,(List<Object>)value,propertyDefinition,missingPropertyConsumer);
    }
  }
 else {
    throw new InvalidArgumentException("String_Node_Str" + value.getClass().getName());
  }
}

Fixed version (ground truth):
/** 
 * Check the constraints on an unwrapped property value (basically a string, map or list) and get events through the given consumer parameter when missing properties on complex data type are found. Note that the property value cannot be null and the required characteristic of the initial property definition will NOT be checked.
 * @param propertyName The name of the property.
 * @param propertyValue The value of the property to check.
 * @param propertyDefinition The property definition that defines the property to check.
 * @param missingPropertyConsumer A consumer to receive events when a required property is not defined on a complex type sub-field.
 * @throws ConstraintValueDoNotMatchPropertyTypeException In case the value type doesn't match the type of the property as defined.
 * @throws ConstraintViolationException In case the value doesn't match one of the constraints defined on the property.
 */
public static void checkPropertyConstraint(String propertyName,Object propertyValue,PropertyDefinition propertyDefinition,Consumer<String> missingPropertyConsumer) throws ConstraintValueDoNotMatchPropertyTypeException, ConstraintViolationException {
  Object value=propertyValue;
  if (propertyValue instanceof PropertyValue) {
    value=((PropertyValue)propertyValue).getValue();
  }
  boolean isTypeDerivedFromPrimitive=false;
  DataType dataType=null;
  String typeName=propertyDefinition.getType();
  if (!ToscaTypes.isPrimitive(typeName)) {
    dataType=ToscaContext.get(DataType.class,typeName);
    if (dataType instanceof PrimitiveDataType) {
      isTypeDerivedFromPrimitive=true;
    }
  }
  if (value instanceof String) {
    if (ToscaTypes.isSimple(typeName)) {
      checkSimplePropertyConstraint(propertyName,(String)value,propertyDefinition);
    }
 else     if (isTypeDerivedFromPrimitive) {
      checkComplexPropertyDerivedFromPrimitiveTypeConstraints(propertyName,(String)value,propertyDefinition,dataType);
    }
 else {
      throwConstraintValueDoNotMatchPropertyTypeException("String_Node_Str" + propertyDefinition.getType(),propertyName,propertyDefinition.getType(),value);
    }
  }
 else   if (value instanceof Map) {
    if (ToscaTypes.MAP.equals(typeName)) {
      checkMapPropertyConstraint(propertyName,(Map<String,Object>)value,propertyDefinition,missingPropertyConsumer);
    }
 else {
      checkDataTypePropertyConstraint(propertyName,(Map<String,Object>)value,propertyDefinition,missingPropertyConsumer);
    }
  }
 else   if (value instanceof List) {
    if (ToscaTypes.RANGE.equals(typeName)) {
      checkRangePropertyConstraint(propertyName,(List<Object>)value,propertyDefinition);
    }
 else {
      checkListPropertyConstraint(propertyName,(List<Object>)value,propertyDefinition,missingPropertyConsumer);
    }
  }
 else {
    throw new InvalidArgumentException("String_Node_Str" + value.getClass().getName());
  }
}