Program: 73438
Project: 73438
Buggy source:
/** 
 * Find the UnitConcept that represents the composition of the two input UnitConcepts which will be the result of either multiplication or division of the two units depending on the value of the _isMultiply class variable.
 * @param unit1 The first unit concept.
 * @param unit2 The second unit concept.
 * @return The unit concept that represents the multiplication or divisionof the two input concepts, or the top of the lattice if that unit does not exist in the ontology.
 * @throws IllegalActionException Thrown if either of the UnitConcep inputsis invalid.
 */
private Concept _findComposedUnitConcept(UnitConcept unit1,UnitConcept unit2) throws IllegalActionException {
  int exponentValue=0;
  ScalarToken newUnitFactor=null;
  if (_isMultiply) {
    exponentValue=1;
    newUnitFactor=(ScalarToken)unit1.getUnitFactor().multiply(unit2.getUnitFactor());
  }
 else {
    exponentValue=-1;
    newUnitFactor=(ScalarToken)unit1.getUnitFactor().divide(unit2.getUnitFactor());
  }
  DimensionRepresentativeConcept unit1Dimension=unit1.getDimension();
  DimensionRepresentativeConcept unit2Dimension=unit2.getDimension();
  Map<DimensionRepresentativeConcept,Integer> dimensionMap=null;
  Map<DimensionRepresentativeConcept,List<UnitConcept>> componentUnitsMap=null;
  if (unit1Dimension.equals(unit2Dimension)) {
    if (_isMultiply) {
      dimensionMap=new HashMap<DimensionRepresentativeConcept,Integer>();
      componentUnitsMap=new HashMap<DimensionRepresentativeConcept,List<UnitConcept>>();
      dimensionMap.put(unit1Dimension,new Integer(2));
      List<UnitConcept> unitsList=new ArrayList<UnitConcept>();
      unitsList.add(unit1);
      unitsList.add(unit2);
      componentUnitsMap.put(unit1Dimension,unitsList);
    }
 else {
      if (unit1.equals(unit2)) {
        return _getDimensionlessConceptOrTop();
      }
 else {
        return _topOfTheLattice;
      }
    }
  }
 else {
    dimensionMap=_createNewDimensionMap(unit2.getDimension(),exponentValue);
    componentUnitsMap=_createNewComponentUnitsMap(unit2);
    dimensionMap.put(unit1Dimension,new Integer(1));
    List<UnitConcept> unit1List=new ArrayList<UnitConcept>();
    unit1List.add(unit1);
    componentUnitsMap.put(unit1Dimension,unit1List);
  }
  return DerivedUnitConcept.findUnitByComponentMapsAndUnitFactor(dimensionMap,componentUnitsMap,newUnitFactor,_unitOntology);
}

Fixed version (ground truth):
/** 
 * Find the UnitConcept that represents the composition of the two input UnitConcepts which will be the result of either multiplication or division of the two units depending on the value of the _isMultiply class variable.
 * @param unit1 The first unit concept.
 * @param unit2 The second unit concept.
 * @return The unit concept that represents the multiplication or divisionof the two input concepts, or the top of the lattice if that unit does not exist in the ontology.
 * @throws IllegalActionException Thrown if either of the UnitConcep inputsis invalid.
 */
private Concept _findComposedUnitConcept(UnitConcept unit1,UnitConcept unit2) throws IllegalActionException {
  int exponentValue=0;
  ScalarToken newUnitFactor=null;
  if (_isMultiply) {
    exponentValue=1;
    newUnitFactor=(ScalarToken)unit1.getUnitFactor().multiply(unit2.getUnitFactor());
  }
 else {
    exponentValue=-1;
    newUnitFactor=(ScalarToken)unit1.getUnitFactor().divide(unit2.getUnitFactor());
  }
  DimensionRepresentativeConcept unit1Dimension=unit1.getDimension();
  DimensionRepresentativeConcept unit2Dimension=unit2.getDimension();
  Map<DimensionRepresentativeConcept,Integer> dimensionMap=null;
  Map<DimensionRepresentativeConcept,List<UnitConcept>> componentUnitsMap=null;
  if (unit1Dimension.equals(unit2Dimension)) {
    if (_isMultiply) {
      dimensionMap=new HashMap<DimensionRepresentativeConcept,Integer>();
      componentUnitsMap=new HashMap<DimensionRepresentativeConcept,List<UnitConcept>>();
      dimensionMap.put(unit1Dimension,Integer.valueOf(2));
      List<UnitConcept> unitsList=new ArrayList<UnitConcept>();
      unitsList.add(unit1);
      unitsList.add(unit2);
      componentUnitsMap.put(unit1Dimension,unitsList);
    }
 else {
      if (unit1.equals(unit2)) {
        return _getDimensionlessConceptOrTop();
      }
 else {
        return _topOfTheLattice;
      }
    }
  }
 else {
    dimensionMap=_createNewDimensionMap(unit2.getDimension(),exponentValue);
    componentUnitsMap=_createNewComponentUnitsMap(unit2);
    dimensionMap.put(unit1Dimension,Integer.valueOf(1));
    List<UnitConcept> unit1List=new ArrayList<UnitConcept>();
    unit1List.add(unit1);
    componentUnitsMap.put(unit1Dimension,unit1List);
  }
  return DerivedUnitConcept.findUnitByComponentMapsAndUnitFactor(dimensionMap,componentUnitsMap,newUnitFactor,_unitOntology);
}