nus-yam/ex-repair huggingface dataset:
Program: 52757
Project: 52757
Buggy source:
public SecuritiesTable(Composite parent,AbstractFinanceView view){
  this.view=view;
  Composite container=new Composite(parent,SWT.NONE);
  TableColumnLayout layout=new TableColumnLayout();
  container.setLayout(layout);
  this.securities=new TableViewer(container,SWT.FULL_SELECTION);
  ColumnEditingSupport.prepare(securities);
  support=new ShowHideColumnHelper(SecuritiesTable.class.getName(),getClient(),view.getPreferenceStore(),securities,layout);
  addMasterDataColumns();
  addColumnLatestPrice();
  addDeltaColumn();
  addColumnDateOfLatestPrice();
  addColumnDateOfLatestHistoricalPrice();
  for (  Taxonomy taxonomy : getClient().getTaxonomies()) {
    Column column=new TaxonomyColumn(taxonomy);
    column.setVisible(false);
    support.addColumn(column);
  }
  addAttributeColumns();
  support.createColumns();
  securities.getTable().setHeaderVisible(true);
  securities.getTable().setLinesVisible(true);
  securities.setContentProvider(new SimpleListContentProvider());
  securities.addDragSupport(DND.DROP_MOVE,new Transfer[]{SecurityTransfer.getTransfer()},new SecurityDragListener(securities));
  if (!support.isUserConfigured())   ViewerHelper.pack(securities);
  securities.refresh();
  hookContextMenu();
}

Fixed version (ground truth):
public SecuritiesTable(Composite parent,AbstractFinanceView view){
  this.view=view;
  Composite container=new Composite(parent,SWT.NONE);
  TableColumnLayout layout=new TableColumnLayout();
  container.setLayout(layout);
  this.securities=new TableViewer(container,SWT.FULL_SELECTION);
  ColumnEditingSupport.prepare(securities);
  support=new ShowHideColumnHelper(SecuritiesTable.class.getName(),getClient(),view.getPreferenceStore(),securities,layout);
  addMasterDataColumns();
  addColumnLatestPrice();
  addDeltaColumn();
  addColumnDateOfLatestPrice();
  addColumnDateOfLatestHistoricalPrice();
  for (  Taxonomy taxonomy : getClient().getTaxonomies()) {
    Column column=new TaxonomyColumn(taxonomy);
    column.setVisible(false);
    support.addColumn(column);
  }
  addAttributeColumns();
  support.createColumns();
  securities.getTable().setHeaderVisible(true);
  securities.getTable().setLinesVisible(true);
  securities.setContentProvider(new SimpleListContentProvider());
  securities.addDragSupport(DND.DROP_MOVE,new Transfer[]{SecurityTransfer.getTransfer()},new SecurityDragListener(securities));
  ViewerHelper.pack(securities);
  securities.refresh();
  hookContextMenu();
}
Program: 52758
Project: 52758
Buggy source:
protected Composite createEventsTable(Composite parent){
  Composite container=new Composite(parent,SWT.NONE);
  TableColumnLayout layout=new TableColumnLayout();
  container.setLayout(layout);
  events=new TableViewer(container,SWT.FULL_SELECTION);
  ShowHideColumnHelper support=new ShowHideColumnHelper(SecurityListView.class.getSimpleName() + "String_Node_Str",getPreferenceStore(),events,layout);
  Column column=new Column(Messages.ColumnDate,SWT.None,80);
  column.setLabelProvider(new ColumnLabelProvider(){
    @Override public String getText(    Object element){
      return Values.Date.format(((SecurityEvent)element).getDate());
    }
  }
);
  support.addColumn(column);
  column=new Column(Messages.ColumnTransactionType,SWT.None,80);
  column.setLabelProvider(new ColumnLabelProvider(){
    @Override public String getText(    Object element){
      return ((SecurityEvent)element).getType().toString();
    }
  }
);
  support.addColumn(column);
  column=new Column(Messages.ColumnDetails,SWT.None,80);
  column.setLabelProvider(new ColumnLabelProvider(){
    @Override public String getText(    Object element){
      return ((SecurityEvent)element).getDetails();
    }
  }
);
  support.addColumn(column);
  support.createColumns();
  events.getTable().setHeaderVisible(true);
  events.getTable().setLinesVisible(true);
  events.setContentProvider(new SimpleListContentProvider(true));
  return container;
}

Fixed version (ground truth):
protected Composite createEventsTable(Composite parent){
  Composite container=new Composite(parent,SWT.NONE);
  TableColumnLayout layout=new TableColumnLayout();
  container.setLayout(layout);
  events=new TableViewer(container,SWT.FULL_SELECTION);
  ShowHideColumnHelper support=new ShowHideColumnHelper(SecurityListView.class.getSimpleName() + "String_Node_Str",getPreferenceStore(),events,layout);
  Column column=new Column(Messages.ColumnDate,SWT.None,80);
  column.setLabelProvider(new ColumnLabelProvider(){
    @Override public String getText(    Object element){
      return Values.Date.format(((SecurityEvent)element).getDate());
    }
  }
);
  support.addColumn(column);
  column=new Column(Messages.ColumnTransactionType,SWT.None,80);
  column.setLabelProvider(new ColumnLabelProvider(){
    @Override public String getText(    Object element){
      return ((SecurityEvent)element).getType().toString();
    }
  }
);
  support.addColumn(column);
  column=new Column(Messages.ColumnDetails,SWT.None,80);
  column.setLabelProvider(new ColumnLabelProvider(){
    @Override public String getText(    Object element){
      return ((SecurityEvent)element).getDetails();
    }
  }
);
  support.addColumn(column);
  support.createColumns();
  events.getTable().setHeaderVisible(true);
  events.getTable().setLinesVisible(true);
  events.setContentProvider(new SimpleListContentProvider(true));
  ViewerHelper.pack(events);
  return container;
}
Program: 52762
Project: 52762
Buggy source:
public void run(){
  markDirty();
  if (view != null)   view.notifyModelUpdated();
}

Fixed version (ground truth):
public void run(){
  markDirty();
  if (view != null && view.getControl() != null && !view.getControl().isDisposed())   view.notifyModelUpdated();
}
Program: 52763
Project: 52763
Buggy source:
@PreDestroy public void destroy(MPart part){
  if (clientFile != null)   storePreferences();
}

Fixed version (ground truth):
@PreDestroy public void destroy(MPart part){
  if (clientFile != null)   storePreferences();
  if (regularQuoteUpdateJob != null)   regularQuoteUpdateJob.cancel();
}
Program: 52764
Project: 52764
Buggy source:
private void scheduleOnlineUpdateJobs(){
  if (!"String_Node_Str".equals(System.getProperty("String_Node_Str"))) {
    new UpdateQuotesJob(client,false,1000 * 60 * 10){
      @Override protected void notifyFinished(){
        notifyModelUpdated();
      }
    }
.schedule(500);
    new UpdateQuotesJob(client){
      @Override protected void notifyFinished(){
        notifyModelUpdated();
      }
    }
.schedule(1000);
    new UpdateCPIJob(client){
      @Override protected void notifyFinished(){
        notifyModelUpdated();
      }
    }
.schedule(700);
  }
}

Fixed version (ground truth):
private void scheduleOnlineUpdateJobs(){
  if (!"String_Node_Str".equals(System.getProperty("String_Node_Str"))) {
    regularQuoteUpdateJob=new UpdateQuotesJob(client,false,1000 * 60 * 10){
      @Override protected void notifyFinished(){
        notifyModelUpdated();
      }
    }
;
    regularQuoteUpdateJob.schedule(500);
    new UpdateQuotesJob(client){
      @Override protected void notifyFinished(){
        notifyModelUpdated();
      }
    }
.schedule(1000);
    new UpdateCPIJob(client){
      @Override protected void notifyFinished(){
        notifyModelUpdated();
      }
    }
.schedule(700);
  }
}
Program: 52765
Project: 52765
Buggy source:
public void notifyModelUpdated(){
  Display.getDefault().asyncExec(new Runnable(){
    public void run(){
      markDirty();
      if (view != null)       view.notifyModelUpdated();
    }
  }
);
}

Fixed version (ground truth):
public void notifyModelUpdated(){
  Display.getDefault().asyncExec(new Runnable(){
    public void run(){
      markDirty();
      if (view != null && view.getControl() != null && !view.getControl().isDisposed())       view.notifyModelUpdated();
    }
  }
);
}
Program: 52766
Project: 52766
Buggy source:
protected long asQuote(Element value) throws ParseException {
  String text=value.text();
  double quote=decimalFormat.parse(text).doubleValue();
  return Math.round(quote * 100);
}

Fixed version (ground truth):
protected long asQuote(Element value) throws ParseException {
  String text=value.text();
  double quote=DECIMAL_FORMAT.get().parse(text).doubleValue();
  return Math.round(quote * 100);
}
Program: 52767
Project: 52767
Buggy source:
@Execute public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell){
  try {
    new ProgressMonitorDialog(shell).run(true,true,new IRunnableWithProgress(){
      @Override public void run(      IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
        try {
          UpdateHelper updateHelper=new UpdateHelper();
          updateHelper.runUpdate(monitor,false);
        }
 catch (        CoreException e) {
          throw new InvocationTargetException(e);
        }
      }
    }
);
  }
 catch (  InvocationTargetException e) {
    PortfolioPlugin.log(e.getCause());
    IStatus status=e.getCause() instanceof CoreException ? ((CoreException)e.getCause()).getStatus() : new Status(Status.ERROR,PortfolioPlugin.PLUGIN_ID,e.getCause().getMessage(),e.getCause());
    ErrorDialog.openError(Display.getDefault().getActiveShell(),Messages.LabelError,e.getCause().getMessage(),status);
  }
catch (  InterruptedException ignore) {
  }
}

Fixed version (ground truth):
@Execute public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell){
  try {
    new ProgressMonitorDialog(shell).run(true,true,new IRunnableWithProgress(){
      @Override public void run(      IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
        try {
          UpdateHelper updateHelper=new UpdateHelper();
          updateHelper.runUpdate(monitor,false);
        }
 catch (        CoreException e) {
          throw new InvocationTargetException(e);
        }
      }
    }
);
  }
 catch (  InvocationTargetException e) {
    PortfolioPlugin.log(e.getCause());
    IStatus status=e.getCause() instanceof CoreException ? ((CoreException)e.getCause()).getStatus() : new Status(Status.ERROR,PortfolioPlugin.PLUGIN_ID,e.getCause().getMessage(),e.getCause());
    ErrorDialog.openError(Display.getDefault().getActiveShell(),Messages.LabelError,Messages.MsgErrorUpdating,status);
  }
catch (  InterruptedException ignore) {
  }
}
Program: 52768
Project: 52768
Buggy source:
public Object execute(ExecutionEvent event) throws ExecutionException {
  try {
    new ProgressMonitorDialog(null).run(true,true,new IRunnableWithProgress(){
      @Override public void run(      IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
        try {
          UpdateHelper updateHelper=new UpdateHelper();
          updateHelper.runUpdate(monitor,false);
        }
 catch (        CoreException e) {
          throw new InvocationTargetException(e);
        }
      }
    }
);
  }
 catch (  InvocationTargetException e) {
    PortfolioPlugin.log(e.getCause());
    IStatus status=e.getCause() instanceof CoreException ? ((CoreException)e.getCause()).getStatus() : new Status(Status.ERROR,PortfolioPlugin.PLUGIN_ID,e.getCause().getMessage(),e.getCause());
    ErrorDialog.openError(Display.getDefault().getActiveShell(),Messages.LabelError,e.getCause().getMessage(),status);
    return false;
  }
catch (  InterruptedException e) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
public Object execute(ExecutionEvent event) throws ExecutionException {
  try {
    new ProgressMonitorDialog(null).run(true,true,new IRunnableWithProgress(){
      @Override public void run(      IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
        try {
          UpdateHelper updateHelper=new UpdateHelper();
          updateHelper.runUpdate(monitor,false);
        }
 catch (        CoreException e) {
          throw new InvocationTargetException(e);
        }
      }
    }
);
  }
 catch (  InvocationTargetException e) {
    PortfolioPlugin.log(e.getCause());
    IStatus status=e.getCause() instanceof CoreException ? ((CoreException)e.getCause()).getStatus() : new Status(Status.ERROR,PortfolioPlugin.PLUGIN_ID,e.getCause().getMessage(),e.getCause());
    ErrorDialog.openError(Display.getDefault().getActiveShell(),Messages.LabelError,Messages.MsgErrorUpdating,status);
    return false;
  }
catch (  InterruptedException e) {
    return false;
  }
  return true;
}
Program: 52769
Project: 52769
Buggy source:
static public long amountFractionPerShare(long amount,long shares){
  if (shares == 0)   return 0;
  return Math.round((double)(amount * (Values.AmountFraction.factor() / Values.Amount.factor()) * Values.Share.divider()) / (double)shares);
}

Fixed version (ground truth):
static long amountFractionPerShare(long amount,long shares){
  if (shares == 0)   return 0;
  return Math.round((double)(amount * (Values.AmountFraction.factor() / Values.Amount.factor()) * Values.Share.divider()) / (double)shares);
}
Program: 52770
Project: 52770
Buggy source:
private static void extractSecurityRelatedAccountTransactions(Account account,Date startDate,Date endDate,Map<Security,SecurityPerformanceRecord> records){
  for (  AccountTransaction t : account.getTransactions()) {
    if (t.getDate().getTime() > startDate.getTime() && t.getDate().getTime() <= endDate.getTime()) {
switch (t.getType()) {
case INTEREST:
case DIVIDENDS:
        if (t.getSecurity() != null) {
          DividendTransaction dt=new DividendTransaction();
          dt.setDate(t.getDate());
          dt.setSecurity(t.getSecurity());
          dt.setAccount(account);
          dt.setAmount(t.getAmount());
          dt.setShares(t.getShares());
          dt.setNote(t.getNote());
          records.get(t.getSecurity()).addTransaction(dt);
        }
      break;
case FEES:
case TAXES:
case DEPOSIT:
case REMOVAL:
case BUY:
case SELL:
case TRANSFER_IN:
case TRANSFER_OUT:
    break;
default :
  throw new UnsupportedOperationException();
}
}
}
}

Fixed version (ground truth):
private static void extractSecurityRelatedAccountTransactions(Account account,Date startDate,Date endDate,Map<Security,SecurityPerformanceRecord> records){
  for (  AccountTransaction t : account.getTransactions()) {
    if (t.getSecurity() == null)     continue;
    if (t.getType() != AccountTransaction.Type.DIVIDENDS && t.getType() != AccountTransaction.Type.INTEREST)     continue;
    if (t.getDate().getTime() <= startDate.getTime())     continue;
    if (t.getDate().getTime() > endDate.getTime())     continue;
    DividendTransaction dt=new DividendTransaction();
    dt.setDate(t.getDate());
    dt.setSecurity(t.getSecurity());
    dt.setAccount(account);
    dt.setAmount(t.getAmount());
    dt.setShares(t.getShares());
    dt.setNote(t.getNote());
    records.get(t.getSecurity()).addTransaction(dt);
  }
}
Program: 52771
Project: 52771
Buggy source:
private static SecurityPerformanceSnapshot doCreateSnapshot(Map<Security,SecurityPerformanceRecord> records,ReportingPeriod period){
  List<SecurityPerformanceRecord> list=new ArrayList<SecurityPerformanceRecord>(records.values());
  for (Iterator<SecurityPerformanceRecord> iter=list.iterator(); iter.hasNext(); ) {
    SecurityPerformanceRecord record=iter.next();
    if (record.getTransactions().isEmpty()) {
      iter.remove();
    }
 else {
      record.calculate(client,period);
    }
  }
  return new SecurityPerformanceSnapshot(list);
}

Fixed version (ground truth):
private static SecurityPerformanceSnapshot doCreateSnapshot(Client client,Map<Security,SecurityPerformanceRecord> records,ReportingPeriod period){
  List<SecurityPerformanceRecord> list=new ArrayList<SecurityPerformanceRecord>(records.values());
  for (Iterator<SecurityPerformanceRecord> iter=list.iterator(); iter.hasNext(); ) {
    SecurityPerformanceRecord record=iter.next();
    if (record.getTransactions().isEmpty()) {
      iter.remove();
    }
 else {
      record.calculate(client,period);
    }
  }
  return new SecurityPerformanceSnapshot(list);
}
Program: 52772
Project: 52772
Buggy source:
public static SecurityPerformanceSnapshot create(Client client,Portfolio portfolio,ReportingPeriod period){
  Map<Security,SecurityPerformanceRecord> transactions=initRecords(client);
  Date startDate=period.getStartDate();
  Date endDate=period.getEndDate();
  if (portfolio.getReferenceAccount() != null)   extractSecurityRelatedAccountTransactions(portfolio.getReferenceAccount(),startDate,endDate,transactions);
  extractSecurityRelatedPortfolioTransactions(portfolio,startDate,endDate,transactions);
  addPseudoValuationTansactions(portfolio,startDate,endDate,transactions);
  return doCreateSnapshot(transactions,period);
}

Fixed version (ground truth):
public static SecurityPerformanceSnapshot create(Client client,Portfolio portfolio,ReportingPeriod period){
  Map<Security,SecurityPerformanceRecord> transactions=initRecords(client);
  Date startDate=period.getStartDate();
  Date endDate=period.getEndDate();
  if (portfolio.getReferenceAccount() != null)   extractSecurityRelatedAccountTransactions(portfolio.getReferenceAccount(),startDate,endDate,transactions);
  extractSecurityRelatedPortfolioTransactions(portfolio,startDate,endDate,transactions);
  addPseudoValuationTansactions(portfolio,startDate,endDate,transactions);
  return doCreateSnapshot(client,transactions,period);
}
Program: 52773
Project: 52773
Buggy source:
public void addMarkerLine(Date date,RGB color,String label){
  this.markerLines.add(new MarkerLine(date,color,label));
  Collections.sort(this.markerLines);
}

Fixed version (ground truth):
public void addMarkerLine(Date date,RGB color,String label){
  this.markerLines.add(new MarkerLine(date,color,label));
  Collections.sort(this.markerLines,new Comparator<MarkerLine>(){
    @Override public int compare(    MarkerLine ml1,    MarkerLine ml2){
      return ml1.date.compareTo(ml2.date);
    }
  }
);
}
Program: 52775
Project: 52775
Buggy source:
private void refreshChart(){
  for (  ISeries s : chart.getSeriesSet().getSeries())   chart.getSeriesSet().deleteSeries(s.getId());
  if (getClient().getConsumerPriceIndeces() == null || getClient().getConsumerPriceIndeces().isEmpty())   return;
  List<ConsumerPriceIndex> indeces=new ArrayList<ConsumerPriceIndex>(getClient().getConsumerPriceIndeces());
  Collections.sort(indeces);
  Date[] dates=new Date[indeces.size()];
  double[] cpis=new double[indeces.size()];
  int ii=0;
  for (  ConsumerPriceIndex index : indeces) {
    dates[ii]=Dates.date(index.getYear(),index.getMonth(),1);
    cpis[ii]=(double)index.getIndex() / Values.Index.divider();
    ii++;
  }
  chart.addDateSeries(dates,cpis,Colors.CPI,Messages.LabelConsumerPriceIndex);
  chart.getAxisSet().adjustRange();
  chart.redraw();
}

Fixed version (ground truth):
private void refreshChart(){
  for (  ISeries s : chart.getSeriesSet().getSeries())   chart.getSeriesSet().deleteSeries(s.getId());
  if (getClient().getConsumerPriceIndeces() == null || getClient().getConsumerPriceIndeces().isEmpty())   return;
  List<ConsumerPriceIndex> indeces=new ArrayList<ConsumerPriceIndex>(getClient().getConsumerPriceIndeces());
  Collections.sort(indeces,new ConsumerPriceIndex.ByDate());
  Date[] dates=new Date[indeces.size()];
  double[] cpis=new double[indeces.size()];
  int ii=0;
  for (  ConsumerPriceIndex index : indeces) {
    dates[ii]=Dates.date(index.getYear(),index.getMonth(),1);
    cpis[ii]=(double)index.getIndex() / Values.Index.divider();
    ii++;
  }
  chart.addDateSeries(dates,cpis,Colors.CPI,Messages.LabelConsumerPriceIndex);
  chart.getAxisSet().adjustRange();
  chart.redraw();
}
Program: 52776
Project: 52776
Buggy source:
@Override protected Control createBody(Composite parent){
  canvas=new PieChart(parent,SWT.NONE);
  ClientSnapshot snapshot=ClientSnapshot.create(getClient(),Dates.today());
  List<PieChart.Slice> slices=new ArrayList<PieChart.Slice>();
  for (  AccountSnapshot a : snapshot.getAccounts())   slices.add(new PieChart.Slice(a.getFunds(),a.getAccount().getName(),null));
  for (  SecurityPosition position : snapshot.getJointPortfolio().getPositions())   slices.add(new PieChart.Slice(position.calculateValue(),position.getSecurity().getName(),null));
  Collections.sort(slices);
  ColorWheel colors=new ColorWheel(canvas,slices.size());
  for (int ii=0; ii < slices.size(); ii++)   slices.get(ii).setColor(colors.getSegment(ii).getColor());
  canvas.setSlices(slices);
  canvas.redraw();
  return canvas;
}

Fixed version (ground truth):
@Override protected Control createBody(Composite parent){
  canvas=new PieChart(parent,SWT.NONE);
  ClientSnapshot snapshot=ClientSnapshot.create(getClient(),Dates.today());
  List<PieChart.Slice> slices=new ArrayList<PieChart.Slice>();
  for (  AccountSnapshot a : snapshot.getAccounts())   slices.add(new PieChart.Slice(a.getFunds(),a.getAccount().getName(),null));
  for (  SecurityPosition position : snapshot.getJointPortfolio().getPositions())   slices.add(new PieChart.Slice(position.calculateValue(),position.getSecurity().getName(),null));
  Collections.sort(slices,new Slice.ByValue());
  ColorWheel colors=new ColorWheel(canvas,slices.size());
  for (int ii=0; ii < slices.size(); ii++)   slices.get(ii).setColor(colors.getSegment(ii).getColor());
  canvas.setSlices(slices);
  canvas.redraw();
  return canvas;
}
Program: 52778
Project: 52778
Buggy source:
private void updatePieSlices(){
  List<PieChart.Slice> slices=new ArrayList<PieChart.Slice>();
  for (  TaxonomyNode child : getModel().getRootNode().getChildren()) {
    slices.add(new PieChart.Slice(child.getActual(),child.getName(),getRenderer().getColorFor(child)));
  }
  Collections.sort(slices);
  pieChart.setSlices(slices);
  pieChart.redraw();
}

Fixed version (ground truth):
private void updatePieSlices(){
  List<PieChart.Slice> slices=new ArrayList<PieChart.Slice>();
  for (  TaxonomyNode child : getModel().getRootNode().getChildren()) {
    slices.add(new PieChart.Slice(child.getActual(),child.getName(),getRenderer().getColorFor(child)));
  }
  Collections.sort(slices,new Slice.ByValue());
  pieChart.setSlices(slices);
  pieChart.redraw();
}
Program: 52779
Project: 52779
Buggy source:
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) @Override public Object[] getElements(Object inputElement){
  if (mapFormat == null)   return new Object[0];
  Entry<?>[] elements=new Entry[mapFormat.map().size()];
  int ii=0;
  for (  Enum<?> entry : mapFormat.map().keySet())   elements[ii++]=new Entry(mapFormat.map(),entry);
  Arrays.sort(elements);
  return elements;
}

Fixed version (ground truth):
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) @Override public Object[] getElements(Object inputElement){
  if (mapFormat == null)   return new Object[0];
  List<Entry<?>> elements=new ArrayList<Entry<?>>();
  for (  Enum<?> entry : mapFormat.map().keySet())   elements.add(new Entry(mapFormat.map(),entry));
  Collections.sort(elements,new Comparator<Entry<?>>(){
    @Override public int compare(    Entry<?> e1,    Entry<?> e2){
      return e1.key.name().compareTo(e2.key.name());
    }
  }
);
  return elements.toArray();
}
Program: 52780
Project: 52780
Buggy source:
private void collectAccountTransactions(){
  for (  Account account : client.getAccounts()) {
    for (    AccountTransaction t : account.getTransactions()) {
      if (t.getCrossEntry() != null)       continue;
switch (t.getType()) {
case BUY:
case SELL:
case TRANSFER_IN:
case TRANSFER_OUT:
        accountTransactions.add(new AccountEntry(account,t));
      break;
default :
  }
}
}
}

Fixed version (ground truth):
private void collectAccountTransactions(){
  for (  Account account : client.getAccounts()) {
    for (    AccountTransaction t : account.getTransactions()) {
      if (t.getCrossEntry() != null)       continue;
switch (t.getType()) {
case BUY:
case SELL:
case TRANSFER_IN:
case TRANSFER_OUT:
        accountTransactions.add(new AccountEntry(account,t));
      break;
default :
    break;
}
}
}
}
Program: 52781
Project: 52781
Buggy source:
private void collectPortfolioTransactions(){
  for (  Portfolio portfolio : client.getPortfolios()) {
    for (    PortfolioTransaction t : portfolio.getTransactions()) {
      if (t.getCrossEntry() != null)       continue;
switch (t.getType()) {
case BUY:
case SELL:
case TRANSFER_IN:
case TRANSFER_OUT:
        portfolioTransactions.add(new PortfolioEntry(portfolio,t));
      break;
default :
  }
}
}
}

Fixed version (ground truth):
private void collectPortfolioTransactions(){
  for (  Portfolio portfolio : client.getPortfolios()) {
    for (    PortfolioTransaction t : portfolio.getTransactions()) {
      if (t.getCrossEntry() != null)       continue;
switch (t.getType()) {
case BUY:
case SELL:
case TRANSFER_IN:
case TRANSFER_OUT:
        portfolioTransactions.add(new PortfolioEntry(portfolio,t));
      break;
default :
    break;
}
}
}
}
Program: 52782
Project: 52782
Buggy source:
public void setConsumerPriceIndeces(List<ConsumerPriceIndex> prices){
  this.consumerPriceIndeces=prices;
  Collections.sort(this.consumerPriceIndeces);
}

Fixed version (ground truth):
public void setConsumerPriceIndeces(List<ConsumerPriceIndex> prices){
  this.consumerPriceIndeces=prices;
  Collections.sort(this.consumerPriceIndeces,new ConsumerPriceIndex.ByDate());
}
Program: 52783
Project: 52783
Buggy source:
private static void assignSharesToDividendTransactions(Client client){
  for (  Security security : client.getSecurities()) {
    List<Transaction> transactions=security.getTransactions(client);
    Transaction.sortByDate(transactions);
    long shares=0;
    for (    Transaction t : transactions) {
      if (t instanceof AccountTransaction && ((AccountTransaction)t).getType() == AccountTransaction.Type.DIVIDENDS) {
        ((AccountTransaction)t).setShares(shares);
      }
 else       if (t instanceof PortfolioTransaction) {
switch (((PortfolioTransaction)t).getType()) {
case BUY:
case TRANSFER_IN:
          shares+=((PortfolioTransaction)t).getShares();
        break;
case SELL:
case TRANSFER_OUT:
      shares-=((PortfolioTransaction)t).getShares();
    break;
default :
}
}
}
}
}

Fixed version (ground truth):
private static void assignSharesToDividendTransactions(Client client){
  for (  Security security : client.getSecurities()) {
    List<Transaction> transactions=security.getTransactions(client);
    Transaction.sortByDate(transactions);
    long shares=0;
    for (    Transaction t : transactions) {
      if (t instanceof AccountTransaction && ((AccountTransaction)t).getType() == AccountTransaction.Type.DIVIDENDS) {
        ((AccountTransaction)t).setShares(shares);
      }
 else       if (t instanceof PortfolioTransaction) {
switch (((PortfolioTransaction)t).getType()) {
case BUY:
case TRANSFER_IN:
          shares+=((PortfolioTransaction)t).getShares();
        break;
case SELL:
case TRANSFER_OUT:
      shares-=((PortfolioTransaction)t).getShares();
    break;
default :
  break;
}
}
}
}
}
Program: 52784
Project: 52784
Buggy source:
public static final <E extends Transaction>List<E> sortByDate(List<E> transactions){
  Collections.sort(transactions,new ByDateComparator());
  return transactions;
}

Fixed version (ground truth):
public static final <E extends Transaction>List<E> sortByDate(List<E> transactions){
  Collections.sort(transactions,new ByDate());
  return transactions;
}
Program: 52785
Project: 52785
Buggy source:
private boolean text(Text text) throws IOException {
  if (!insideColumn)   return true;
  String t=text.getText().trim();
  if (t.length() == 0)   t=null;
switch (columnIndex) {
case 0:
    item.setTime(parseDate(t));
  break;
case 1:
if (hasOnlyClosingQuote) item.setValue(parsePrice(t));
case 2:
if (!hasOnlyClosingQuote) item.setLow(parsePrice(t));
break;
case 3:
if (!hasOnlyClosingQuote) item.setHigh(parsePrice(t));
break;
case 4:
if (!hasOnlyClosingQuote) item.setValue(parsePrice(t));
break;
default :
}
return true;
}

Fixed version (ground truth):
private boolean text(Text text) throws IOException {
  if (!insideColumn)   return true;
  String t=text.getText().trim();
  if (t.length() == 0)   t=null;
switch (columnIndex) {
case 0:
    item.setTime(parseDate(t));
  break;
case 1:
if (hasOnlyClosingQuote) item.setValue(parsePrice(t));
break;
case 2:
if (!hasOnlyClosingQuote) item.setLow(parsePrice(t));
break;
case 3:
if (!hasOnlyClosingQuote) item.setHigh(parsePrice(t));
break;
case 4:
if (!hasOnlyClosingQuote) item.setValue(parsePrice(t));
break;
default :
break;
}
return true;
}
Program: 52786
Project: 52786
Buggy source:
public boolean text(Text text) throws IOException {
  if (!insideColumn)   return true;
  String t=text.getText().trim();
  if (t.length() == 0)   t=null;
switch (columnIndex) {
case 0:
    item.setSymbol(t);
  break;
case 1:
item.setName(t);
break;
case 2:
item.setIsin(t);
break;
case 3:
if (!"String_Node_Str".equals(t)) item.setLastTrade(parseIndex(t));
break;
case 4:
item.setType(t);
break;
case 5:
item.setExchange(t);
break;
default :
}
return true;
}

Fixed version (ground truth):
public boolean text(Text text) throws IOException {
  if (!insideColumn)   return true;
  String t=text.getText().trim();
  if (t.length() == 0)   t=null;
switch (columnIndex) {
case 0:
    item.setSymbol(t);
  break;
case 1:
item.setName(t);
break;
case 2:
item.setIsin(t);
break;
case 3:
if (!"String_Node_Str".equals(t)) item.setLastTrade(parseIndex(t));
break;
case 4:
item.setType(t);
break;
case 5:
item.setExchange(t);
break;
default :
break;
}
return true;
}
Program: 52787
Project: 52787
Buggy source:
void calculate(PerformanceIndex clientIndex){
  DateTime firstDataPoint=clientIndex.getFirstDataPoint();
  Interval interval=firstDataPoint != null ? new Interval(firstDataPoint,clientIndex.getReportInterval().toInterval().getEnd()) : clientIndex.getReportInterval().toInterval();
  List<ConsumerPriceIndex> cpiSeries=new ArrayList<ConsumerPriceIndex>(clientIndex.getClient().getConsumerPriceIndeces());
  Collections.sort(cpiSeries);
  List<Date> dates=new ArrayList<Date>();
  List<Double> accumulated=new ArrayList<Double>();
  int baseline=-1;
  for (  ConsumerPriceIndex cpi : cpiSeries) {
    DateMidnight date=new DateMidnight(cpi.getYear(),cpi.getMonth() + 1,1).dayOfMonth().withMaximumValue();
    if (interval.contains(date)) {
      if (baseline == -1)       baseline=cpi.getIndex();
      dates.add(date.toDate());
      accumulated.add(((double)cpi.getIndex() / (double)baseline) - 1);
    }
  }
  this.dates=dates.toArray(new Date[0]);
  this.accumulated=new double[accumulated.size()];
  for (int ii=0; ii < this.accumulated.length; ii++)   this.accumulated[ii]=accumulated.get(ii);
}

Fixed version (ground truth):
void calculate(PerformanceIndex clientIndex){
  DateTime firstDataPoint=clientIndex.getFirstDataPoint();
  Interval interval=firstDataPoint != null ? new Interval(firstDataPoint,clientIndex.getReportInterval().toInterval().getEnd()) : clientIndex.getReportInterval().toInterval();
  List<ConsumerPriceIndex> cpiSeries=new ArrayList<ConsumerPriceIndex>(clientIndex.getClient().getConsumerPriceIndeces());
  Collections.sort(cpiSeries,new ConsumerPriceIndex.ByDate());
  List<Date> dates=new ArrayList<Date>();
  List<Double> accumulated=new ArrayList<Double>();
  int baseline=-1;
  for (  ConsumerPriceIndex cpi : cpiSeries) {
    DateMidnight date=new DateMidnight(cpi.getYear(),cpi.getMonth() + 1,1).dayOfMonth().withMaximumValue();
    if (interval.contains(date)) {
      if (baseline == -1)       baseline=cpi.getIndex();
      dates.add(date.toDate());
      accumulated.add(((double)cpi.getIndex() / (double)baseline) - 1);
    }
  }
  this.dates=dates.toArray(new Date[0]);
  this.accumulated=new double[accumulated.size()];
  for (int ii=0; ii < this.accumulated.length; ii++)   this.accumulated[ii]=accumulated.get(ii);
}
Program: 52788
Project: 52788
Buggy source:
public static ClientIRRYield create(Client client,ClientSnapshot snapshotStart,ClientSnapshot snapshotEnd){
  Date start=snapshotStart.getTime();
  Date end=snapshotEnd.getTime();
  List<Transaction> transactions=new ArrayList<Transaction>();
  collectAccountTransactions(client,start,end,transactions);
  collectPortfolioTransactions(client,start,end,transactions);
  Collections.sort(transactions);
  List<Date> dates=new ArrayList<Date>();
  List<Double> values=new ArrayList<Double>();
  collectDatesAndValues(start,end,snapshotStart,snapshotEnd,transactions,dates,values);
  double irr=IRR.calculate(dates,values);
  return new ClientIRRYield(snapshotStart,snapshotEnd,transactions,irr * 100);
}

Fixed version (ground truth):
public static ClientIRRYield create(Client client,ClientSnapshot snapshotStart,ClientSnapshot snapshotEnd){
  Date start=snapshotStart.getTime();
  Date end=snapshotEnd.getTime();
  List<Transaction> transactions=new ArrayList<Transaction>();
  collectAccountTransactions(client,start,end,transactions);
  collectPortfolioTransactions(client,start,end,transactions);
  Collections.sort(transactions,new Transaction.ByDate());
  List<Date> dates=new ArrayList<Date>();
  List<Double> values=new ArrayList<Double>();
  collectDatesAndValues(start,end,snapshotStart,snapshotEnd,transactions,dates,values);
  double irr=IRR.calculate(dates,values);
  return new ClientIRRYield(snapshotStart,snapshotEnd,transactions,irr * 100);
}
Program: 52790
Project: 52790
Buggy source:
private Control createHeader(Composite parent){
  Composite header=new Composite(parent,SWT.NONE);
  header.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
  Font boldFont=resourceManager.createFont(FontDescriptor.createFrom(JFaceResources.getFont(JFaceResources.HEADER_FONT)).setStyle(SWT.BOLD));
  Label title=new Label(header,SWT.NONE);
  title.setText(getTitle());
  title.setFont(boldFont);
  title.setForeground(resourceManager.createColor(Colors.HEADINGS.swt()));
  title.setBackground(header.getBackground());
  ToolBar toolBar=new ToolBar(header,SWT.FLAT);
  toolBar.setBackground(header.getBackground());
  addButtons(toolBar);
  GridLayoutFactory.fillDefaults().numColumns(2).margins(5,5).applyTo(header);
  GridDataFactory.fillDefaults().grab(true,false).applyTo(title);
  GridDataFactory.fillDefaults().applyTo(toolBar);
  return header;
}

Fixed version (ground truth):
private Control createHeader(Composite parent){
  Composite header=new Composite(parent,SWT.NONE);
  header.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
  Font boldFont=resourceManager.createFont(FontDescriptor.createFrom(JFaceResources.getFont(JFaceResources.HEADER_FONT)).setStyle(SWT.BOLD));
  Label title=new Label(header,SWT.NONE);
  title.setText(getTitle());
  title.setFont(boldFont);
  title.setForeground(resourceManager.createColor(Colors.HEADINGS.swt()));
  title.setBackground(header.getBackground());
  ToolBar toolBar=new ToolBar(header,SWT.FLAT | SWT.RIGHT);
  toolBar.setBackground(header.getBackground());
  addButtons(toolBar);
  GridLayoutFactory.fillDefaults().numColumns(2).margins(5,5).applyTo(header);
  GridDataFactory.fillDefaults().grab(true,false).applyTo(title);
  GridDataFactory.fillDefaults().applyTo(toolBar);
  return header;
}
Program: 52792
Project: 52792
Buggy source:
@Override Control createViewControl(Composite parent){
  Composite composite=new Composite(parent,SWT.NONE);
  composite.setBackground(parent.getBackground());
  Label headingClassification=createHeading(composite,taxonomy.getRootCategory().getLabel());
  valueSector=new Label(composite,SWT.NONE);
  valueIndustryGroup=new Label(composite,SWT.NONE);
  valueIndustry=new Label(composite,SWT.NONE);
  valueSubIndustry=new Label(composite,SWT.NONE);
  FormLayout layout=new FormLayout();
  layout.marginLeft=5;
  layout.marginRight=5;
  composite.setLayout(layout);
  FormData data=new FormData();
  data.top=new FormAttachment(0,5);
  headingClassification.setLayoutData(data);
  data=new FormData();
  data.top=new FormAttachment(headingClassification,5);
  data.left=new FormAttachment(0);
  data.right=new FormAttachment(100);
  valueSector.setLayoutData(data);
  below(valueSector,valueIndustryGroup);
  below(valueIndustryGroup,valueIndustry);
  below(valueIndustry,valueSubIndustry);
  return composite;
}

Fixed version (ground truth):
@Override Control createViewControl(Composite parent){
  Composite composite=new Composite(parent,SWT.NONE);
  Label headingClassification=createHeading(composite,taxonomy.getRootCategory().getLabel());
  valueSector=new Label(composite,SWT.NONE);
  valueIndustryGroup=new Label(composite,SWT.NONE);
  valueIndustry=new Label(composite,SWT.NONE);
  valueSubIndustry=new Label(composite,SWT.NONE);
  FormLayout layout=new FormLayout();
  layout.marginLeft=5;
  layout.marginRight=5;
  composite.setLayout(layout);
  FormData data=new FormData();
  data.top=new FormAttachment(0,5);
  headingClassification.setLayoutData(data);
  data=new FormData();
  data.top=new FormAttachment(headingClassification,5);
  data.left=new FormAttachment(0);
  data.right=new FormAttachment(100);
  valueSector.setLayoutData(data);
  below(valueSector,valueIndustryGroup);
  below(valueIndustryGroup,valueIndustry);
  below(valueIndustry,valueSubIndustry);
  return composite;
}
Program: 52793
Project: 52793
Buggy source:
public void SecurityDetailsViewer(Composite parent,int style,Facet... facets){
  container=new Composite(parent,style);
  container.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
  LocalResourceManager resources=new LocalResourceManager(JFaceResources.getResources(),container);
  Font boldFont=resources.createFont(FontDescriptor.createFrom(container.getFont()).setStyle(SWT.BOLD));
  Color color=resources.createColor(Colors.HEADINGS.swt());
  GridLayoutFactory.fillDefaults().numColumns(1).applyTo(container);
  for (  Facet facet : facets) {
    try {
      SecurityFacet child=facet.create(boldFont,color);
      Control control=child.createViewControl(container);
      GridDataFactory.fillDefaults().grab(true,false).applyTo(control);
      children.add(child);
    }
 catch (    Exception e) {
      PortfolioPlugin.log(e);
    }
  }
}

Fixed version (ground truth):
public void SecurityDetailsViewer(Composite parent,int style,Facet... facets){
  container=new Composite(parent,style);
  container.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
  container.setBackgroundMode(SWT.INHERIT_FORCE);
  LocalResourceManager resources=new LocalResourceManager(JFaceResources.getResources(),container);
  Font boldFont=resources.createFont(FontDescriptor.createFrom(container.getFont()).setStyle(SWT.BOLD));
  Color color=resources.createColor(Colors.HEADINGS.swt());
  GridLayoutFactory.fillDefaults().numColumns(1).applyTo(container);
  for (  Facet facet : facets) {
    try {
      SecurityFacet child=facet.create(boldFont,color);
      Control control=child.createViewControl(container);
      GridDataFactory.fillDefaults().grab(true,false).applyTo(control);
      children.add(child);
    }
 catch (    Exception e) {
      PortfolioPlugin.log(e);
    }
  }
}
Program: 52794
Project: 52794
Buggy source:
public void setRootItem(TreeMapItem rootItem){
  this.rootItem=rootItem;
  for (  Control control : this.getChildren())   control.dispose();
  boolean hasParent=false;
  List<TreeMapItem> path=rootItem.getPath();
  for (int ii=1; ii < path.size(); ii++) {
    hasParent=true;
    TreeMapItem item=path.get(ii);
    new LegendItem(this,item);
  }
  if (hasParent && !rootItem.getChildren().isEmpty()) {
    Label l=new Label(this,SWT.NONE);
    l.setText("String_Node_Str");
  }
  for (  TreeMapItem child : rootItem.getChildren())   new LegendItem(this,child);
  pack();
  getParent().layout();
}

Fixed version (ground truth):
public void setRootItem(TreeMapItem rootItem){
  this.rootItem=rootItem;
  for (  Control control : this.getChildren())   control.dispose();
  boolean hasParent=false;
  List<TreeMapItem> path=rootItem.getPath();
  for (int ii=1; ii < path.size(); ii++) {
    hasParent=true;
    TreeMapItem item=path.get(ii);
    new LegendItem(this,item);
  }
  if (hasParent && !rootItem.getChildren().isEmpty()) {
    Label l=new Label(this,SWT.NONE);
    l.setText("String_Node_Str");
    l.setBackground(this.getBackground());
  }
  for (  TreeMapItem child : rootItem.getChildren())   new LegendItem(this,child);
  pack();
  getParent().layout();
}
Program: 52795
Project: 52795
Buggy source:
@Test public void testCapitalGainsWithBuyDuringReportPeriod(){
  Client client=new Client();
  Security security=new Security();
  security.addPrice(new SecurityPrice(Dates.date(2010,Calendar.JANUARY,1),10000));
  security.addPrice(new SecurityPrice(Dates.date(2011,Calendar.JUNE,1),11000));
  client.addSecurity(security);
  Portfolio portfolio=new Portfolio();
  portfolio.addTransaction(new PortfolioTransaction(Dates.date(2010,Calendar.JANUARY,1),security,PortfolioTransaction.Type.BUY,1000000,100,0));
  portfolio.addTransaction(new PortfolioTransaction(Dates.date(2011,Calendar.JANUARY,15),security,PortfolioTransaction.Type.BUY,100000,9900,0));
  client.addPortfolio(portfolio);
  ClientPerformanceSnapshot snapshot=new ClientPerformanceSnapshot(client,startDate,endDate);
  EnumMap<CategoryType,Category> result=snapshot.getCategoryMap();
  assertEquals(100000,result.get(CategoryType.INITIAL_VALUE).valuation);
  assertEquals(0,result.get(CategoryType.EARNINGS).valuation);
  assertEquals(10000 + (11000 - 9900),result.get(CategoryType.CAPITAL_GAINS).valuation);
  assertEquals(121000,result.get(CategoryType.FINAL_VALUE).valuation);
}

Fixed version (ground truth):
@Test public void testCapitalGainsWithBuyDuringReportPeriod(){
  Client client=new Client();
  Security security=new Security();
  security.addPrice(new SecurityPrice(Dates.date(2010,Calendar.JANUARY,1),10000));
  security.addPrice(new SecurityPrice(Dates.date(2011,Calendar.JUNE,1),11000));
  client.addSecurity(security);
  Portfolio portfolio=new Portfolio();
  portfolio.addTransaction(new PortfolioTransaction(Dates.date(2010,Calendar.JANUARY,1),security,PortfolioTransaction.Type.BUY,1000000,100,0));
  portfolio.addTransaction(new PortfolioTransaction(Dates.date(2011,Calendar.JANUARY,15),security,PortfolioTransaction.Type.BUY,100000,9900,0));
  client.addPortfolio(portfolio);
  ClientPerformanceSnapshot snapshot=new ClientPerformanceSnapshot(client,startDate,endDate);
  EnumMap<CategoryType,Category> result=snapshot.getCategoryMap();
  assertEquals(100000,result.get(CategoryType.INITIAL_VALUE).getValuation());
  assertEquals(0,result.get(CategoryType.EARNINGS).getValuation());
  assertEquals(10000 + (11000 - 9900),result.get(CategoryType.CAPITAL_GAINS).getValuation());
  assertEquals(121000,result.get(CategoryType.FINAL_VALUE).getValuation());
}
Program: 52796
Project: 52796
Buggy source:
@Test public void testEarningsFromSecurity(){
  Client client=new Client();
  Security security=new Security();
  client.addSecurity(security);
  Portfolio portfolio=new Portfolio();
  portfolio.addTransaction(new PortfolioTransaction(Dates.date(2010,Calendar.JANUARY,1),security,PortfolioTransaction.Type.BUY,10,100,0));
  client.addPortfolio(portfolio);
  Account account=new Account();
  account.addTransaction(new AccountTransaction(Dates.date(2011,Calendar.JANUARY,31),security,AccountTransaction.Type.INTEREST,5000));
  client.addAccount(account);
  ClientPerformanceSnapshot snapshot=new ClientPerformanceSnapshot(client,startDate,endDate);
  EnumMap<CategoryType,Category> result=snapshot.getCategoryMap();
  assertEquals(5000,result.get(CategoryType.EARNINGS).valuation);
}

Fixed version (ground truth):
@Test public void testEarningsFromSecurity(){
  Client client=new Client();
  Security security=new Security();
  client.addSecurity(security);
  Portfolio portfolio=new Portfolio();
  portfolio.addTransaction(new PortfolioTransaction(Dates.date(2010,Calendar.JANUARY,1),security,PortfolioTransaction.Type.BUY,10,100,0));
  client.addPortfolio(portfolio);
  Account account=new Account();
  account.addTransaction(new AccountTransaction(Dates.date(2011,Calendar.JANUARY,31),security,AccountTransaction.Type.INTEREST,5000));
  client.addAccount(account);
  ClientPerformanceSnapshot snapshot=new ClientPerformanceSnapshot(client,startDate,endDate);
  EnumMap<CategoryType,Category> result=snapshot.getCategoryMap();
  assertEquals(5000,result.get(CategoryType.EARNINGS).getValuation());
}
Program: 52797
Project: 52797
Buggy source:
@Test public void testDepositPlusInterest(){
  Client client=new Client();
  Account account=new Account();
  account.addTransaction(new AccountTransaction(Dates.date(2010,Calendar.JANUARY,1),null,AccountTransaction.Type.DEPOSIT,100000));
  account.addTransaction(new AccountTransaction(Dates.date(2011,Calendar.JUNE,1),null,AccountTransaction.Type.INTEREST,5000));
  client.addAccount(account);
  ClientPerformanceSnapshot snapshot=new ClientPerformanceSnapshot(client,startDate,endDate);
  assertNotNull(snapshot);
  assertNotNull(snapshot.getStartClientSnapshot());
  assertEquals(startDate,snapshot.getStartClientSnapshot().getTime());
  assertNotNull(snapshot.getEndClientSnapshot());
  assertEquals(endDate,snapshot.getEndClientSnapshot().getTime());
  List<Category> categories=snapshot.getCategories();
  assertNotNull(categories);
  assertEquals(8,categories.size());
  EnumMap<CategoryType,Category> result=snapshot.getCategoryMap();
  assertEquals(100000,result.get(CategoryType.INITIAL_VALUE).valuation);
  assertEquals(5000,result.get(CategoryType.EARNINGS).valuation);
  assertEquals(105000,result.get(CategoryType.FINAL_VALUE).valuation);
}

Fixed version (ground truth):
@Test public void testDepositPlusInterest(){
  Client client=new Client();
  Account account=new Account();
  account.addTransaction(new AccountTransaction(Dates.date(2010,Calendar.JANUARY,1),null,AccountTransaction.Type.DEPOSIT,100000));
  account.addTransaction(new AccountTransaction(Dates.date(2011,Calendar.JUNE,1),null,AccountTransaction.Type.INTEREST,5000));
  client.addAccount(account);
  ClientPerformanceSnapshot snapshot=new ClientPerformanceSnapshot(client,startDate,endDate);
  assertNotNull(snapshot);
  assertNotNull(snapshot.getStartClientSnapshot());
  assertEquals(startDate,snapshot.getStartClientSnapshot().getTime());
  assertNotNull(snapshot.getEndClientSnapshot());
  assertEquals(endDate,snapshot.getEndClientSnapshot().getTime());
  List<Category> categories=snapshot.getCategories();
  assertNotNull(categories);
  assertEquals(8,categories.size());
  EnumMap<CategoryType,Category> result=snapshot.getCategoryMap();
  assertEquals(100000,result.get(CategoryType.INITIAL_VALUE).getValuation());
  assertEquals(5000,result.get(CategoryType.EARNINGS).getValuation());
  assertEquals(105000,result.get(CategoryType.FINAL_VALUE).getValuation());
}
Program: 52798
Project: 52798
Buggy source:
@Test public void testCapitalGains(){
  Client client=new Client();
  Security security=new Security();
  security.addPrice(new SecurityPrice(Dates.date(2010,Calendar.JANUARY,1),10000));
  security.addPrice(new SecurityPrice(Dates.date(2011,Calendar.JUNE,1),11000));
  client.addSecurity(security);
  Portfolio portfolio=new Portfolio();
  portfolio.addTransaction(new PortfolioTransaction(Dates.date(2010,Calendar.JANUARY,1),security,PortfolioTransaction.Type.BUY,1000000,100,0));
  client.addPortfolio(portfolio);
  ClientPerformanceSnapshot snapshot=new ClientPerformanceSnapshot(client,startDate,endDate);
  EnumMap<CategoryType,Category> result=snapshot.getCategoryMap();
  assertEquals(100000,result.get(CategoryType.INITIAL_VALUE).valuation);
  assertEquals(0,result.get(CategoryType.EARNINGS).valuation);
  assertEquals(10000,result.get(CategoryType.CAPITAL_GAINS).valuation);
  assertEquals(110000,result.get(CategoryType.FINAL_VALUE).valuation);
}

Fixed version (ground truth):
@Test public void testCapitalGains(){
  Client client=new Client();
  Security security=new Security();
  security.addPrice(new SecurityPrice(Dates.date(2010,Calendar.JANUARY,1),10000));
  security.addPrice(new SecurityPrice(Dates.date(2011,Calendar.JUNE,1),11000));
  client.addSecurity(security);
  Portfolio portfolio=new Portfolio();
  portfolio.addTransaction(new PortfolioTransaction(Dates.date(2010,Calendar.JANUARY,1),security,PortfolioTransaction.Type.BUY,1000000,100,0));
  client.addPortfolio(portfolio);
  ClientPerformanceSnapshot snapshot=new ClientPerformanceSnapshot(client,startDate,endDate);
  EnumMap<CategoryType,Category> result=snapshot.getCategoryMap();
  assertEquals(100000,result.get(CategoryType.INITIAL_VALUE).getValuation());
  assertEquals(0,result.get(CategoryType.EARNINGS).getValuation());
  assertEquals(10000,result.get(CategoryType.CAPITAL_GAINS).getValuation());
  assertEquals(110000,result.get(CategoryType.FINAL_VALUE).getValuation());
}