Program: 76708
Project: 76708
Buggy source:
/** 
 * Tests addcolumnBinding method.
 * @throws SemanticException
 * @throws DesignFileException
 */
public void testColumnBinding() throws SemanticException {
  createDesign();
  TableHandle tableHandle=designHandle.getElementFactory().newTableItem("String_Node_Str");
  designHandle.getBody().add(tableHandle);
  tableHandle=(TableHandle)designHandle.findElement("String_Node_Str");
  ComputedColumn col=StructureFactory.createComputedColumn();
  col.setName(null);
  col.setExpression("String_Node_Str");
  assertNull(tableHandle.addColumnBinding(null,true));
  try {
    tableHandle.addColumnBinding(col,true);
    fail();
  }
 catch (  SemanticException e) {
    assertEquals(PropertyValueException.DESIGN_EXCEPTION_VALUE_REQUIRED,e.getErrorCode());
  }
  col.setName("String_Node_Str");
  tableHandle.addColumnBinding(col,true);
  ComputedColumn col2=StructureFactory.createComputedColumn();
  col2.setName("String_Node_Str");
  col2.setExpression("String_Node_Str");
  try {
    tableHandle.addColumnBinding(col2,true);
    fail();
  }
 catch (  SemanticException e) {
    assertEquals(PropertyValueException.DESIGN_EXCEPTION_VALUE_EXISTS,e.getErrorCode());
  }
  col=StructureFactory.createComputedColumn();
  col.setName("String_Node_Str");
  col.setExpression("String_Node_Str");
  try {
    tableHandle.addColumnBinding(col,true);
    fail();
  }
 catch (  SemanticException e) {
    assertEquals(PropertyValueException.DESIGN_EXCEPTION_VALUE_EXISTS,e.getErrorCode());
  }
  col=StructureFactory.createComputedColumn();
  col.setName("String_Node_Str");
  col.setExpression("String_Node_Str");
  tableHandle.addColumnBinding(col,true);
  col=(ComputedColumn)((ComputedColumnHandle)tableHandle.columnBindingsIterator().next()).getStructure();
  PropertyHandle propertyHandle=tableHandle.getPropertyHandle(IReportItemModel.BOUND_DATA_COLUMNS_PROP);
  ComputedColumn newCol=StructureFactory.createComputedColumn();
  newCol.setName(null);
  newCol.setExpression("String_Node_Str");
  try {
    propertyHandle.replaceItem(col,newCol);
    fail();
  }
 catch (  SemanticException e) {
    assertTrue(e instanceof PropertyValueException);
  }
  newCol.setName("String_Node_Str");
  try {
    propertyHandle.replaceItem(col,newCol);
    fail();
  }
 catch (  SemanticException e) {
    assertEquals(PropertyValueException.DESIGN_EXCEPTION_VALUE_EXISTS,e.getErrorCode());
  }
  newCol.setName("String_Node_Str");
  propertyHandle.replaceItem(col,newCol);
}

Fixed version (ground truth):
/** 
 * Tests addcolumnBinding method.
 * @throws SemanticException
 * @throws DesignFileException
 */
public void testColumnBinding() throws SemanticException {
  createDesign();
  TableHandle tableHandle=designHandle.getElementFactory().newTableItem("String_Node_Str");
  designHandle.getBody().add(tableHandle);
  tableHandle=(TableHandle)designHandle.findElement("String_Node_Str");
  ComputedColumn col=StructureFactory.createComputedColumn();
  col.setName(null);
  col.setExpression("String_Node_Str");
  assertNull(tableHandle.addColumnBinding(null,true));
  try {
    tableHandle.addColumnBinding(col,true);
    fail();
  }
 catch (  SemanticException e) {
    assertEquals(PropertyValueException.DESIGN_EXCEPTION_VALUE_REQUIRED,e.getErrorCode());
  }
  col.setName("String_Node_Str");
  tableHandle.addColumnBinding(col,true);
  ComputedColumn col2=StructureFactory.createComputedColumn();
  col2.setName("String_Node_Str");
  col2.setExpression("String_Node_Str");
  try {
    tableHandle.addColumnBinding(col2,true);
    fail();
  }
 catch (  SemanticException e) {
    assertEquals(PropertyValueException.DESIGN_EXCEPTION_VALUE_EXISTS,e.getErrorCode());
  }
  col=StructureFactory.createComputedColumn();
  col.setName("String_Node_Str");
  col.setExpression("String_Node_Str");
  try {
    tableHandle.addColumnBinding(col,true);
    fail();
  }
 catch (  SemanticException e) {
    assertEquals(PropertyValueException.DESIGN_EXCEPTION_VALUE_EXISTS,e.getErrorCode());
  }
  col=StructureFactory.createComputedColumn();
  col.setName("String_Node_Str");
  col.setExpression("String_Node_Str");
  tableHandle.addColumnBinding(col,true);
  col=(ComputedColumn)((ComputedColumnHandle)tableHandle.columnBindingsIterator().next()).getStructure();
  PropertyHandle propertyHandle=tableHandle.getPropertyHandle(IReportItemModel.BOUND_DATA_COLUMNS_PROP);
  ComputedColumn newCol=StructureFactory.createComputedColumn();
  newCol.setName(null);
  newCol.setExpression("String_Node_Str");
  try {
    propertyHandle.replaceItem(col,newCol);
    fail();
  }
 catch (  SemanticException e) {
    assertTrue(e instanceof PropertyValueException);
  }
  newCol.setName("String_Node_Str");
  try {
    propertyHandle.replaceItem(col,newCol);
    fail();
  }
 catch (  SemanticException e) {
    assertEquals(PropertyValueException.DESIGN_EXCEPTION_VALUE_EXISTS,e.getErrorCode());
  }
  newCol.setName("String_Node_Str");
  propertyHandle.replaceItem(col,newCol);
  tableHandle.clearProperty(IReportItemModel.BOUND_DATA_COLUMNS_PROP);
  assertNull(tableHandle.getListProperty(IReportItemModel.BOUND_DATA_COLUMNS_PROP));
  GroupHandle groupHandle=designHandle.getElementFactory().newTableGroup();
  groupHandle.setName("String_Node_Str");
  tableHandle.getGroups().add(groupHandle);
  ComputedColumn groupCol=StructureFactory.createComputedColumn();
  groupCol.setName("String_Node_Str");
  groupCol.setExpression("String_Node_Str");
  groupCol.setAggregateOn("String_Node_Str");
  groupCol.setDataType(DesignChoiceConstants.PARAM_TYPE_STRING);
  tableHandle.addColumnBinding(groupCol,false);
  ComputedColumn tableCol=StructureFactory.createComputedColumn();
  tableCol.setName("String_Node_Str");
  tableCol.setExpression("String_Node_Str");
  tableCol.setAggregateOn("String_Node_Str");
  tableCol.setDataType(DesignChoiceConstants.PARAM_TYPE_STRING);
  tableHandle.addColumnBinding(tableCol,false);
  List boundList=tableHandle.getListProperty(IReportItemModel.BOUND_DATA_COLUMNS_PROP);
  assertEquals(2,boundList.size());
  assertEquals("String_Node_Str",((ComputedColumn)boundList.get(0)).getName());
  assertEquals("String_Node_Str",((ComputedColumn)boundList.get(0)).getAggregateOn());
  assertEquals("String_Node_Str",((ComputedColumn)boundList.get(1)).getName());
  assertEquals("String_Node_Str",((ComputedColumn)boundList.get(1)).getAggregateOn());
}