nus-yam/ex-repair huggingface dataset:
Program: 52718
Project: 52718
Buggy source:
public static AccountSnapshot create(Account account,CurrencyConverter converter,LocalDate date){
  long funds=0;
  for (  AccountTransaction t : account.getTransactions()) {
    if (!t.getDate().isAfter(date)) {
switch (t.getType()) {
case DEPOSIT:
case DIVIDENDS:
case INTEREST:
case SELL:
case TRANSFER_IN:
case TAX_REFUND:
        funds+=t.getAmount();
      break;
case FEES:
case TAXES:
case REMOVAL:
case BUY:
case TRANSFER_OUT:
    funds-=t.getAmount();
  break;
default :
throw new RuntimeException("String_Node_Str" + t.getType());
}
}
}
return new AccountSnapshot(account,date,converter,Money.of(account.getCurrencyCode(),funds));
}

Fixed version (ground truth):
public static AccountSnapshot create(Account account,CurrencyConverter converter,LocalDate date){
  long funds=0;
  for (  AccountTransaction t : account.getTransactions()) {
    if (!t.getDate().isAfter(date)) {
      if (t.getType().isNegative())       funds-=t.getAmount();
 else       funds+=t.getAmount();
    }
  }
  return new AccountSnapshot(account,date,converter,Money.of(account.getCurrencyCode(),funds));
}
Program: 52719
Project: 52719
Buggy source:
@Override public Object convert(Object fromObject){
  String value=(String)fromObject;
  value=value.trim();
  try {
    long result=0;
    for (    String part : value.split("String_Node_Str"))     result+=convertToLong(part);
    return Long.valueOf(result);
  }
 catch (  ParseException e) {
    throw new IllegalArgumentException(e);
  }
}

Fixed version (ground truth):
@Override public Object convert(Object fromObject){
  String value=(String)fromObject;
  value=value.trim();
  try {
    long result=0;
    for (    String part : value.split("String_Node_Str"))     result+=convertToLong(part.trim());
    return Long.valueOf(result);
  }
 catch (  ParseException e) {
    throw new IllegalArgumentException(e);
  }
}
Program: 52720
Project: 52720
Buggy source:
private long convertToLong(String part) throws ParseException {
  Matcher m=pattern.matcher(String.valueOf(part));
  if (!m.matches())   throw new IllegalArgumentException(String.format(Messages.CellEditor_NotANumber,part));
  String strBefore=m.group(1);
  Number before=strBefore.trim().length() > 0 ? full.parse(strBefore) : Long.valueOf(0);
  String strAfter=m.group(3);
  int after=0;
  if (strAfter != null && strAfter.length() > 0) {
    after=Integer.parseInt(strAfter);
    int length=(int)Math.log10(factor);
    for (int ii=strAfter.length(); ii > length; ii--)     after/=10;
    for (int ii=strAfter.length(); ii < length; ii++)     after*=10;
  }
  long resultValue=before.longValue() * (int)factor + after;
  return resultValue;
}

Fixed version (ground truth):
private long convertToLong(String part) throws ParseException {
  Matcher m=pattern.matcher(String.valueOf(part));
  if (!m.matches())   throw new IllegalArgumentException(String.format(Messages.CellEditor_NotANumber,part));
  String strBefore=m.group(1);
  Number before=strBefore.trim().length() > 0 ? full.parse(strBefore) : Long.valueOf(0);
  String strAfter=m.group(3);
  long after=0;
  if (strAfter != null && strAfter.length() > 0) {
    int length=(int)Math.log10(factor);
    if (strAfter.length() > length)     strAfter=strAfter.substring(0,length);
    after=Long.parseLong(strAfter);
    for (int ii=strAfter.length(); ii < length; ii++)     after*=10;
  }
  long resultValue=before.longValue() * factor + after;
  return resultValue;
}
Program: 52721
Project: 52721
Buggy source:
public StringToCurrencyConverter(Values<?> type){
  this.factor=type.divider();
  DecimalFormatSymbols symbols=new DecimalFormatSymbols();
  pattern=Pattern.compile("String_Node_Str" + symbols.getGroupingSeparator() + "String_Node_Str"+ symbols.getDecimalSeparator()+ "String_Node_Str");
  full=new DecimalFormat("String_Node_Str");
}

Fixed version (ground truth):
public StringToCurrencyConverter(Values<?> type){
  this.factor=type.factor();
  DecimalFormatSymbols symbols=new DecimalFormatSymbols();
  pattern=Pattern.compile("String_Node_Str" + symbols.getGroupingSeparator() + "String_Node_Str"+ symbols.getDecimalSeparator()+ "String_Node_Str");
  full=new DecimalFormat("String_Node_Str");
}
Program: 52722
Project: 52722
Buggy source:
private void assertDividendTransaction(Security security,Optional<Item> item){
}

Fixed version (ground truth):
private void assertDividendTransaction(Security security,Optional<Item> item){
  assertThat(item.isPresent(),is(true));
  assertThat(item.get().getSubject(),instanceOf(AccountTransaction.class));
  AccountTransaction transaction=(AccountTransaction)item.get().getSubject();
  assertThat(transaction.getType(),is(AccountTransaction.Type.DIVIDENDS));
  assertThat(transaction.getSecurity(),is(security));
  assertThat(transaction.getDate(),is(Dates.date("String_Node_Str")));
  assertThat(transaction.getAmount(),is(Values.Amount.factorize(444)));
  assertThat(transaction.getShares(),is(Values.Share.factorize(370)));
}
Program: 52723
Project: 52723
Buggy source:
@Test public void testWertpapierKauf() throws IOException {
}

Fixed version (ground truth):
@Test public void testWertpapierKauf() throws IOException {
  DABPDFExctractor extractor=new DABPDFExctractor(new Client()){
    @Override String strip(    File file) throws IOException {
      return from(file.getName());
    }
  }
;
  List<Exception> errors=new ArrayList<Exception>();
  List<Item> results=extractor.extract(Arrays.asList(new File("String_Node_Str")),errors);
  assertThat(errors,empty());
  assertThat(results.size(),is(2));
  Security security=getSecurity(results);
  assertThat(security.getIsin(),is("String_Node_Str"));
  assertThat(security.getName(),is("String_Node_Str"));
  Optional<Item> item=results.stream().filter(i -> i instanceof BuySellEntryItem).findFirst();
  assertThat(item.isPresent(),is(true));
  assertThat(item.get().getSubject(),instanceOf(BuySellEntry.class));
  BuySellEntry entry=(BuySellEntry)item.get().getSubject();
  assertThat(entry.getPortfolioTransaction().getType(),is(PortfolioTransaction.Type.BUY));
  assertThat(entry.getAccountTransaction().getType(),is(AccountTransaction.Type.BUY));
  assertThat(entry.getPortfolioTransaction().getAmount(),is(Values.Amount.factorize(150.00)));
  assertThat(entry.getPortfolioTransaction().getDate(),is(Dates.date("String_Node_Str")));
  assertThat(entry.getPortfolioTransaction().getShares(),is(Values.Share.factorize(0.91920)));
  assertThat(entry.getPortfolioTransaction().getFees(),is(0L));
}
Program: 52724
Project: 52724
Buggy source:
@Test public void testDividend() throws IOException {
}

Fixed version (ground truth):
@Test public void testDividend() throws IOException {
  DABPDFExctractor extractor=new DABPDFExctractor(new Client()){
    @Override String strip(    File file) throws IOException {
      return from(file.getName());
    }
  }
;
  List<Exception> errors=new ArrayList<Exception>();
  List<Item> results=extractor.extract(Arrays.asList(new File("String_Node_Str")),errors);
  assertThat(errors,empty());
  assertThat(results.size(),is(2));
  Security security=getSecurity(results);
  assertThat(security.getIsin(),is("String_Node_Str"));
  assertThat(security.getName(),is("String_Node_Str"));
  Optional<Item> item=results.stream().filter(i -> i instanceof TransactionItem).findFirst();
  assertThat(item.isPresent(),is(true));
  assertThat(item.get().getSubject(),instanceOf(AccountTransaction.class));
  AccountTransaction transaction=(AccountTransaction)item.get().getSubject();
  assertThat(transaction.getType(),is(AccountTransaction.Type.DIVIDENDS));
  assertThat(transaction.getSecurity(),is(security));
  assertThat(transaction.getAmount(),is(Values.Amount.factorize(326)));
  assertThat(transaction.getDate(),is(Dates.date("String_Node_Str")));
  assertThat(transaction.getShares(),is(Values.Share.factorize(100)));
}
Program: 52725
Project: 52725
Buggy source:
@Test public void testWertpapierKauf() throws IOException {
}

Fixed version (ground truth):
@Test public void testWertpapierKauf() throws IOException {
  DeutscheBankPDFExctractor extractor=new DeutscheBankPDFExctractor(new Client()){
    @Override String strip(    File file) throws IOException {
      return from("String_Node_Str");
    }
  }
;
  List<Exception> errors=new ArrayList<Exception>();
  List<Item> results=extractor.extract(Arrays.asList(new File("String_Node_Str")),errors);
  assertThat(errors,empty());
  assertThat(results.size(),is(2));
  assertSecurity(results);
  Optional<Item> item=results.stream().filter(i -> i instanceof BuySellEntryItem).findFirst();
  assertThat(item.isPresent(),is(true));
  assertThat(item.get().getSubject(),instanceOf(BuySellEntry.class));
  BuySellEntry entry=(BuySellEntry)item.get().getSubject();
  assertThat(entry.getPortfolioTransaction().getType(),is(PortfolioTransaction.Type.BUY));
  assertThat(entry.getAccountTransaction().getType(),is(AccountTransaction.Type.BUY));
  assertThat(entry.getPortfolioTransaction().getAmount(),is(Values.Amount.factorize(675.50)));
  assertThat(entry.getPortfolioTransaction().getDate(),is(Dates.date("String_Node_Str")));
  assertThat(entry.getPortfolioTransaction().getShares(),is(Values.Share.factorize(19)));
  assertThat(entry.getPortfolioTransaction().getFees(),is(Values.Amount.factorize(10.50)));
}
Program: 52726
Project: 52726
Buggy source:
@Test public void testWertpapierVerkauf() throws IOException {
}

Fixed version (ground truth):
@Test public void testWertpapierVerkauf() throws IOException {
  DeutscheBankPDFExctractor extractor=new DeutscheBankPDFExctractor(new Client()){
    @Override String strip(    File file) throws IOException {
      return from("String_Node_Str");
    }
  }
;
  List<Exception> errors=new ArrayList<Exception>();
  List<Item> results=extractor.extract(Arrays.asList(new File("String_Node_Str")),errors);
  assertThat(errors,empty());
  assertThat(results.size(),is(2));
  assertSecurity(results);
  Optional<Item> item=results.stream().filter(i -> i instanceof BuySellEntryItem).findFirst();
  assertThat(item.isPresent(),is(true));
  assertThat(item.get().getSubject(),instanceOf(BuySellEntry.class));
  BuySellEntry entry=(BuySellEntry)item.get().getSubject();
  assertThat(entry.getPortfolioTransaction().getType(),is(PortfolioTransaction.Type.SELL));
  assertThat(entry.getAccountTransaction().getType(),is(AccountTransaction.Type.SELL));
  assertThat(entry.getPortfolioTransaction().getAmount(),is(Values.Amount.factorize(2074.71)));
  assertThat(entry.getPortfolioTransaction().getDate(),is(Dates.date("String_Node_Str")));
  assertThat(entry.getPortfolioTransaction().getShares(),is(Values.Share.factorize(61)));
  assertThat(entry.getPortfolioTransaction().getTaxes(),is(Values.Amount.factorize(122.94) + Values.Amount.factorize(6.76)));
  assertThat(entry.getPortfolioTransaction().getFees(),is(Values.Amount.factorize(7.90) + Values.Amount.factorize(0.60) + Values.Amount.factorize(2)));
}
Program: 52727
Project: 52727
Buggy source:
@Test public void testErtragsgutschrift() throws IOException {
}

Fixed version (ground truth):
@Test public void testErtragsgutschrift() throws IOException {
  DeutscheBankPDFExctractor extractor=new DeutscheBankPDFExctractor(new Client()){
    @Override String strip(    File file) throws IOException {
      return from("String_Node_Str");
    }
  }
;
  List<Exception> errors=new ArrayList<Exception>();
  List<Item> results=extractor.extract(Arrays.asList(new File("String_Node_Str")),errors);
  assertThat(errors,empty());
  assertThat(results.size(),is(2));
  Security security=assertSecurity(results);
  Optional<Item> item=results.stream().filter(i -> i instanceof TransactionItem).findFirst();
  assertThat(item.isPresent(),is(true));
  assertThat(item.get().getSubject(),instanceOf(AccountTransaction.class));
  AccountTransaction transaction=(AccountTransaction)item.get().getSubject();
  assertThat(transaction.getType(),is(AccountTransaction.Type.DIVIDENDS));
  assertThat(transaction.getSecurity(),is(security));
  assertThat(transaction.getDate(),is(Dates.date("String_Node_Str")));
  assertThat(transaction.getAmount(),is(1495L));
  assertThat(transaction.getShares(),is(Values.Share.factorize(123)));
}
Program: 52728
Project: 52728
Buggy source:
@Test public void testWertpapierKauf2() throws IOException {
}

Fixed version (ground truth):
@Test public void testWertpapierKauf2() throws IOException {
  DeutscheBankPDFExctractor extractor=new DeutscheBankPDFExctractor(new Client()){
    @Override String strip(    File file) throws IOException {
      return from("String_Node_Str");
    }
  }
;
  List<Exception> errors=new ArrayList<Exception>();
  List<Item> results=extractor.extract(Arrays.asList(new File("String_Node_Str")),errors);
  assertThat(errors,empty());
  assertThat(results.size(),is(2));
  assertSecurity(results);
  Optional<Item> item=results.stream().filter(i -> i instanceof BuySellEntryItem).findFirst();
  assertThat(item.isPresent(),is(true));
  assertThat(item.get().getSubject(),instanceOf(BuySellEntry.class));
  BuySellEntry entry=(BuySellEntry)item.get().getSubject();
  assertThat(entry.getPortfolioTransaction().getType(),is(PortfolioTransaction.Type.BUY));
  assertThat(entry.getAccountTransaction().getType(),is(AccountTransaction.Type.BUY));
  assertThat(entry.getPortfolioTransaction().getAmount(),is(Values.Amount.factorize(3524.98)));
  assertThat(entry.getPortfolioTransaction().getDate(),is(Dates.date("String_Node_Str")));
  assertThat(entry.getPortfolioTransaction().getShares(),is(Values.Share.factorize(36)));
  assertThat(entry.getPortfolioTransaction().getFees(),is(Values.Amount.factorize(11.38)));
}
Program: 52729
Project: 52729
Buggy source:
@Test public void testErtragsgutschrift() throws IOException {
}

Fixed version (ground truth):
@Test public void testErtragsgutschrift() throws IOException {
  FlatexPDFExctractor extractor=new FlatexPDFExctractor(new Client()){
    @Override String strip(    File file) throws IOException {
      return from("String_Node_Str");
    }
  }
;
  List<Exception> errors=new ArrayList<Exception>();
  List<Item> results=extractor.extract(Arrays.asList(new File("String_Node_Str")),errors);
  assertThat(errors,empty());
  assertThat(results.size(),is(2));
  Optional<Item> item=results.stream().filter(i -> i instanceof SecurityItem).findFirst();
  assertThat(item.isPresent(),is(true));
  Security security=((SecurityItem)item.get()).getSecurity();
  assertThat(security.getIsin(),is("String_Node_Str"));
  assertThat(security.getWkn(),is("String_Node_Str"));
  assertThat(security.getName(),is("String_Node_Str"));
  item=results.stream().filter(i -> i instanceof TransactionItem).findFirst();
  assertThat(item.isPresent(),is(true));
  assertThat(item.get().getSubject(),instanceOf(AccountTransaction.class));
  AccountTransaction transaction=(AccountTransaction)item.get().getSubject();
  assertThat(transaction.getType(),is(AccountTransaction.Type.DIVIDENDS));
  assertThat(transaction.getSecurity(),is(security));
  assertThat(transaction.getDate(),is(Dates.date("String_Node_Str")));
  assertThat(transaction.getAmount(),is(Values.Amount.factorize(795.15)));
  assertThat(transaction.getShares(),is(Values.Share.factorize(360)));
}
Program: 52730
Project: 52730
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,0));
  portfolio.addTransaction(new PortfolioTransaction(Dates.date(2011,Calendar.JANUARY,15),security,PortfolioTransaction.Type.BUY,100000,9900,0,0));
  client.addPortfolio(portfolio);
  ClientPerformanceSnapshot snapshot=new ClientPerformanceSnapshot(client,startDate,endDate);
  Map<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());
}

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,Values.Share.factorize(10),100,0,0));
  portfolio.addTransaction(new PortfolioTransaction(Dates.date(2011,Calendar.JANUARY,15),security,PortfolioTransaction.Type.BUY,Values.Share.factorize(1),9900,0,0));
  client.addPortfolio(portfolio);
  ClientPerformanceSnapshot snapshot=new ClientPerformanceSnapshot(client,startDate,endDate);
  Map<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: 52731
Project: 52731
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,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);
  Map<CategoryType,Category> result=snapshot.getCategoryMap();
  assertEquals(5000,result.get(CategoryType.EARNINGS).getValuation());
}

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,Values.Share.factorize(0.0001),100,0,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);
  Map<CategoryType,Category> result=snapshot.getCategoryMap();
  assertEquals(5000,result.get(CategoryType.EARNINGS).getValuation());
}
Program: 52732
Project: 52732
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,0));
  client.addPortfolio(portfolio);
  ClientPerformanceSnapshot snapshot=new ClientPerformanceSnapshot(client,startDate,endDate);
  Map<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());
}

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,Values.Share.factorize(10),100,0,0));
  client.addPortfolio(portfolio);
  ClientPerformanceSnapshot snapshot=new ClientPerformanceSnapshot(client,startDate,endDate);
  Map<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());
}
Program: 52733
Project: 52733
Buggy source:
@Test public void testCapitalGainsWithPartialSellDuringReportPeriod(){
  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,0));
  portfolio.addTransaction(new PortfolioTransaction(Dates.date(2011,Calendar.JANUARY,15),security,PortfolioTransaction.Type.SELL,100000,9900,0,0));
  client.addPortfolio(portfolio);
  ClientPerformanceSnapshot snapshot=new ClientPerformanceSnapshot(client,startDate,endDate);
  Map<CategoryType,Category> result=snapshot.getCategoryMap();
  assertEquals(100000,result.get(CategoryType.INITIAL_VALUE).getValuation());
  assertEquals(0,result.get(CategoryType.EARNINGS).getValuation());
  assertEquals(1000 * 9 + (9900 - 10000),result.get(CategoryType.CAPITAL_GAINS).getValuation());
  assertEquals(11000 * 9,result.get(CategoryType.FINAL_VALUE).getValuation());
}

Fixed version (ground truth):
@Test public void testCapitalGainsWithPartialSellDuringReportPeriod(){
  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,Values.Share.factorize(10),100,0,0));
  portfolio.addTransaction(new PortfolioTransaction(Dates.date(2011,Calendar.JANUARY,15),security,PortfolioTransaction.Type.SELL,Values.Share.factorize(1),9900,0,0));
  client.addPortfolio(portfolio);
  ClientPerformanceSnapshot snapshot=new ClientPerformanceSnapshot(client,startDate,endDate);
  Map<CategoryType,Category> result=snapshot.getCategoryMap();
  assertEquals(100000,result.get(CategoryType.INITIAL_VALUE).getValuation());
  assertEquals(0,result.get(CategoryType.EARNINGS).getValuation());
  assertEquals(1000 * 9 + (9900 - 10000),result.get(CategoryType.CAPITAL_GAINS).getValuation());
  assertEquals(11000 * 9,result.get(CategoryType.FINAL_VALUE).getValuation());
}
Program: 52734
Project: 52734
Buggy source:
@Test public void testCapitalGainsWithPartialSellDuringReportPeriodWithFees(){
  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,0));
  portfolio.addTransaction(new PortfolioTransaction(Dates.date(2011,Calendar.JANUARY,15),security,PortfolioTransaction.Type.SELL,100000,9900,1,0));
  client.addPortfolio(portfolio);
  ClientPerformanceSnapshot snapshot=new ClientPerformanceSnapshot(client,startDate,endDate);
  Map<CategoryType,Category> result=snapshot.getCategoryMap();
  assertEquals(1000 * 9 + (9900 - 10000) + 1,result.get(CategoryType.CAPITAL_GAINS).getValuation());
  assertEquals(1,result.get(CategoryType.FEES).getValuation());
}

Fixed version (ground truth):
@Test public void testCapitalGainsWithPartialSellDuringReportPeriodWithFees(){
  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,Values.Share.factorize(10),100,0,0));
  portfolio.addTransaction(new PortfolioTransaction(Dates.date(2011,Calendar.JANUARY,15),security,PortfolioTransaction.Type.SELL,Values.Share.factorize(1),9900,1,0));
  client.addPortfolio(portfolio);
  ClientPerformanceSnapshot snapshot=new ClientPerformanceSnapshot(client,startDate,endDate);
  Map<CategoryType,Category> result=snapshot.getCategoryMap();
  assertEquals(1000 * 9 + (9900 - 10000) + 1,result.get(CategoryType.CAPITAL_GAINS).getValuation());
  assertEquals(1,result.get(CategoryType.FEES).getValuation());
}
Program: 52735
Project: 52735
Buggy source:
@Test public void testSecuritiesWithoutAssignment(){
  Client client=new Client();
  Taxonomy taxonomy=new TaxonomyBuilder().addClassification("String_Node_Str").addTo(client);
  Security a=new SecurityBuilder().addPrice("String_Node_Str",1000).addTo(client);
  Portfolio portfolio=new PortfolioBuilder().inbound_delivery(a,"String_Node_Str",1000000,10000).addTo(client);
  PortfolioSnapshot snapshot=PortfolioSnapshot.create(portfolio,new DateTime("String_Node_Str").toDate());
  assertNotNull(snapshot);
  GroupByTaxonomy grouping=snapshot.groupByTaxonomy(taxonomy);
  AssetCategory debt=grouping.byClassification(taxonomy.getClassificationById("String_Node_Str"));
  assertThat(debt,nullValue());
  List<AssetCategory> categories=grouping.asList();
  assertThat(categories.size(),is(1));
  AssetCategory unassigned=categories.get(0);
  assertThat(unassigned.getValuation(),is(10000L));
  assertThat(unassigned.getPositions().size(),is(1));
}

Fixed version (ground truth):
@Test public void testSecuritiesWithoutAssignment(){
  Client client=new Client();
  Taxonomy taxonomy=new TaxonomyBuilder().addClassification("String_Node_Str").addTo(client);
  Security a=new SecurityBuilder().addPrice("String_Node_Str",1000).addTo(client);
  Portfolio portfolio=new PortfolioBuilder().inbound_delivery(a,"String_Node_Str",Values.Share.factorize(10),10000).addTo(client);
  PortfolioSnapshot snapshot=PortfolioSnapshot.create(portfolio,new DateTime("String_Node_Str").toDate());
  assertNotNull(snapshot);
  GroupByTaxonomy grouping=snapshot.groupByTaxonomy(taxonomy);
  AssetCategory debt=grouping.byClassification(taxonomy.getClassificationById("String_Node_Str"));
  assertThat(debt,nullValue());
  List<AssetCategory> categories=grouping.asList();
  assertThat(categories.size(),is(1));
  AssetCategory unassigned=categories.get(0);
  assertThat(unassigned.getValuation(),is(10000L));
  assertThat(unassigned.getPositions().size(),is(1));
}
Program: 52737
Project: 52737
Buggy source:
@Test public void testThatPartialAssignmentsInSubClassificationsAreMerged(){
  Client client=new Client();
  Taxonomy taxonomy=new TaxonomyBuilder().addClassification("String_Node_Str").addClassification("String_Node_Str","String_Node_Str").addClassification("String_Node_Str","String_Node_Str").addTo(client);
  Security a=new SecurityBuilder().addPrice("String_Node_Str",1000).assign(taxonomy,"String_Node_Str",Classification.ONE_HUNDRED_PERCENT / 2).assign(taxonomy,"String_Node_Str",Classification.ONE_HUNDRED_PERCENT / 2).addTo(client);
  Portfolio portfolio=new PortfolioBuilder().inbound_delivery(a,"String_Node_Str",1000000,10000).addTo(client);
  PortfolioSnapshot snapshot=PortfolioSnapshot.create(portfolio,new DateTime("String_Node_Str").toDate());
  assertNotNull(snapshot);
  GroupByTaxonomy grouping=snapshot.groupByTaxonomy(taxonomy);
  assertThat(grouping.asList().size(),is(1));
  AssetCategory debt=grouping.byClassification(taxonomy.getClassificationById("String_Node_Str"));
  assertThat(debt.getPositions().size(),is(1));
  assertThat(debt.getValuation(),is(10000L));
}

Fixed version (ground truth):
@Test public void testThatPartialAssignmentsInSubClassificationsAreMerged(){
  Client client=new Client();
  Taxonomy taxonomy=new TaxonomyBuilder().addClassification("String_Node_Str").addClassification("String_Node_Str","String_Node_Str").addClassification("String_Node_Str","String_Node_Str").addTo(client);
  Security a=new SecurityBuilder().addPrice("String_Node_Str",1000).assign(taxonomy,"String_Node_Str",Classification.ONE_HUNDRED_PERCENT / 2).assign(taxonomy,"String_Node_Str",Classification.ONE_HUNDRED_PERCENT / 2).addTo(client);
  Portfolio portfolio=new PortfolioBuilder().inbound_delivery(a,"String_Node_Str",Values.Share.factorize(10),10000).addTo(client);
  PortfolioSnapshot snapshot=PortfolioSnapshot.create(portfolio,new DateTime("String_Node_Str").toDate());
  assertNotNull(snapshot);
  GroupByTaxonomy grouping=snapshot.groupByTaxonomy(taxonomy);
  assertThat(grouping.asList().size(),is(1));
  AssetCategory debt=grouping.byClassification(taxonomy.getClassificationById("String_Node_Str"));
  assertThat(debt.getPositions().size(),is(1));
  assertThat(debt.getValuation(),is(10000L));
}
Program: 52738
Project: 52738
Buggy source:
@Test public void testSecuritiesWithPartialAssignment(){
  Client client=new Client();
  Taxonomy taxonomy=new TaxonomyBuilder().addClassification("String_Node_Str").addTo(client);
  Security a=new SecurityBuilder().addPrice("String_Node_Str",1000).assign(taxonomy,"String_Node_Str",Classification.ONE_HUNDRED_PERCENT / 2).addTo(client);
  Portfolio portfolio=new PortfolioBuilder().inbound_delivery(a,"String_Node_Str",1000000,10000).addTo(client);
  PortfolioSnapshot snapshot=PortfolioSnapshot.create(portfolio,new DateTime("String_Node_Str").toDate());
  assertNotNull(snapshot);
  GroupByTaxonomy grouping=snapshot.groupByTaxonomy(taxonomy);
  assertThat(grouping.asList().size(),is(2));
  AssetCategory debt=grouping.byClassification(taxonomy.getClassificationById("String_Node_Str"));
  assertThat(debt.getValuation(),is(5000L));
  assertThat(debt.getPositions().size(),is(1));
  AssetCategory unassigned=null;
  for (  AssetCategory category : grouping.asList())   if (category.getClassification().getId().equals(Classification.UNASSIGNED_ID))   unassigned=category;
  assertThat(unassigned,notNullValue());
  assertThat(unassigned.getValuation(),is(5000L));
  assertThat(unassigned.getPositions().size(),is(1));
}

Fixed version (ground truth):
@Test public void testSecuritiesWithPartialAssignment(){
  Client client=new Client();
  Taxonomy taxonomy=new TaxonomyBuilder().addClassification("String_Node_Str").addTo(client);
  Security a=new SecurityBuilder().addPrice("String_Node_Str",1000).assign(taxonomy,"String_Node_Str",Classification.ONE_HUNDRED_PERCENT / 2).addTo(client);
  Portfolio portfolio=new PortfolioBuilder().inbound_delivery(a,"String_Node_Str",Values.Share.factorize(10),10000).addTo(client);
  PortfolioSnapshot snapshot=PortfolioSnapshot.create(portfolio,new DateTime("String_Node_Str").toDate());
  assertNotNull(snapshot);
  GroupByTaxonomy grouping=snapshot.groupByTaxonomy(taxonomy);
  assertThat(grouping.asList().size(),is(2));
  AssetCategory debt=grouping.byClassification(taxonomy.getClassificationById("String_Node_Str"));
  assertThat(debt.getValuation(),is(5000L));
  assertThat(debt.getPositions().size(),is(1));
  AssetCategory unassigned=null;
  for (  AssetCategory category : grouping.asList())   if (category.getClassification().getId().equals(Classification.UNASSIGNED_ID))   unassigned=category;
  assertThat(unassigned,notNullValue());
  assertThat(unassigned.getValuation(),is(5000L));
  assertThat(unassigned.getPositions().size(),is(1));
}
Program: 52739
Project: 52739
Buggy source:
@Test public void testThatPartialAssignmentsAreSeparated(){
  Client client=new Client();
  Taxonomy taxonomy=new TaxonomyBuilder().addClassification("String_Node_Str").addClassification("String_Node_Str").addTo(client);
  Security a=new SecurityBuilder().addPrice("String_Node_Str",1000).assign(taxonomy,"String_Node_Str",Classification.ONE_HUNDRED_PERCENT / 2).assign(taxonomy,"String_Node_Str",Classification.ONE_HUNDRED_PERCENT / 2).addTo(client);
  Portfolio portfolio=new PortfolioBuilder().inbound_delivery(a,"String_Node_Str",1000000,10000).addTo(client);
  PortfolioSnapshot snapshot=PortfolioSnapshot.create(portfolio,new DateTime("String_Node_Str").toDate());
  assertNotNull(snapshot);
  GroupByTaxonomy grouping=snapshot.groupByTaxonomy(taxonomy);
  AssetCategory debt=grouping.byClassification(taxonomy.getClassificationById("String_Node_Str"));
  assertThat(debt.getValuation(),is(5000L));
  assertThat(debt.getPositions().size(),is(1));
  AssetCategory equity=grouping.byClassification(taxonomy.getClassificationById("String_Node_Str"));
  assertThat(equity.getValuation(),is(5000L));
  assertThat(equity.getPositions().size(),is(1));
}

Fixed version (ground truth):
@Test public void testThatPartialAssignmentsAreSeparated(){
  Client client=new Client();
  Taxonomy taxonomy=new TaxonomyBuilder().addClassification("String_Node_Str").addClassification("String_Node_Str").addTo(client);
  Security a=new SecurityBuilder().addPrice("String_Node_Str",1000).assign(taxonomy,"String_Node_Str",Classification.ONE_HUNDRED_PERCENT / 2).assign(taxonomy,"String_Node_Str",Classification.ONE_HUNDRED_PERCENT / 2).addTo(client);
  Portfolio portfolio=new PortfolioBuilder().inbound_delivery(a,"String_Node_Str",Values.Share.factorize(10),10000).addTo(client);
  PortfolioSnapshot snapshot=PortfolioSnapshot.create(portfolio,new DateTime("String_Node_Str").toDate());
  assertNotNull(snapshot);
  GroupByTaxonomy grouping=snapshot.groupByTaxonomy(taxonomy);
  AssetCategory debt=grouping.byClassification(taxonomy.getClassificationById("String_Node_Str"));
  assertThat(debt.getValuation(),is(5000L));
  assertThat(debt.getPositions().size(),is(1));
  AssetCategory equity=grouping.byClassification(taxonomy.getClassificationById("String_Node_Str"));
  assertThat(equity.getValuation(),is(5000L));
  assertThat(equity.getPositions().size(),is(1));
}
Program: 52740
Project: 52740
Buggy source:
@Before public void setUpClient(){
  client=new Client();
  securityA=new Security();
  securityA.addPrice(new SecurityPrice(Dates.date(2010,Calendar.JANUARY,1),1000));
  client.addSecurity(securityA);
  securityB=new Security();
  securityB.addPrice(new SecurityPrice(Dates.date(2010,Calendar.JANUARY,1),1100));
  client.addSecurity(securityB);
  securityX=new Security();
  securityX.addPrice(new SecurityPrice(Dates.date(2010,Calendar.JANUARY,1),1200));
  client.addSecurity(securityX);
  Portfolio portfolioA=new Portfolio();
  portfolioA.addTransaction(new PortfolioTransaction(Dates.date(2010,Calendar.JANUARY,1),securityA,PortfolioTransaction.Type.BUY,1000000,10000,0,0));
  portfolioA.addTransaction(new PortfolioTransaction(Dates.date(2010,Calendar.JANUARY,1),securityX,PortfolioTransaction.Type.BUY,1000000,12100,100,0));
  client.addPortfolio(portfolioA);
  Portfolio portfolioB=new Portfolio();
  portfolioB.addTransaction(new PortfolioTransaction(Dates.date(2010,Calendar.JANUARY,1),securityB,PortfolioTransaction.Type.BUY,1000000,11000,0,0));
  portfolioB.addTransaction(new PortfolioTransaction(Dates.date(2010,Calendar.JANUARY,1),securityX,PortfolioTransaction.Type.BUY,1000000,10000,0,0));
  client.addPortfolio(portfolioB);
}

Fixed version (ground truth):
@Before public void setUpClient(){
  client=new Client();
  securityA=new Security();
  securityA.addPrice(new SecurityPrice(Dates.date(2010,Calendar.JANUARY,1),1000));
  client.addSecurity(securityA);
  securityB=new Security();
  securityB.addPrice(new SecurityPrice(Dates.date(2010,Calendar.JANUARY,1),1100));
  client.addSecurity(securityB);
  securityX=new Security();
  securityX.addPrice(new SecurityPrice(Dates.date(2010,Calendar.JANUARY,1),1200));
  client.addSecurity(securityX);
  Portfolio portfolioA=new Portfolio();
  portfolioA.addTransaction(new PortfolioTransaction(Dates.date(2010,Calendar.JANUARY,1),securityA,PortfolioTransaction.Type.BUY,Values.Share.factorize(10),10000,0,0));
  portfolioA.addTransaction(new PortfolioTransaction(Dates.date(2010,Calendar.JANUARY,1),securityX,PortfolioTransaction.Type.BUY,Values.Share.factorize(10),12100,100,0));
  client.addPortfolio(portfolioA);
  Portfolio portfolioB=new Portfolio();
  portfolioB.addTransaction(new PortfolioTransaction(Dates.date(2010,Calendar.JANUARY,1),securityB,PortfolioTransaction.Type.BUY,Values.Share.factorize(10),11000,0,0));
  portfolioB.addTransaction(new PortfolioTransaction(Dates.date(2010,Calendar.JANUARY,1),securityX,PortfolioTransaction.Type.BUY,Values.Share.factorize(10),10000,0,0));
  client.addPortfolio(portfolioB);
}
Program: 52741
Project: 52741
Buggy source:
@Test public void testMergingPortfolioSnapshots(){
  ClientSnapshot snapshot=ClientSnapshot.create(client,referenceDate);
  assertNotNull(snapshot);
  PortfolioSnapshot jointPortfolio=snapshot.getJointPortfolio();
  SecurityPosition positionA=jointPortfolio.getPositionsBySecurity().get(securityA);
  assertEquals(1000000,positionA.getShares());
  assertEquals(10000,positionA.calculateValue());
  SecurityPosition positionB=jointPortfolio.getPositionsBySecurity().get(securityB);
  assertEquals(1000000,positionB.getShares());
  assertEquals(11000,positionB.calculateValue());
  SecurityPosition positionX=jointPortfolio.getPositionsBySecurity().get(securityX);
  assertEquals(2000000,positionX.getShares());
  assertEquals(24000,positionX.calculateValue());
}

Fixed version (ground truth):
@Test public void testMergingPortfolioSnapshots(){
  ClientSnapshot snapshot=ClientSnapshot.create(client,referenceDate);
  assertNotNull(snapshot);
  PortfolioSnapshot jointPortfolio=snapshot.getJointPortfolio();
  SecurityPosition positionA=jointPortfolio.getPositionsBySecurity().get(securityA);
  assertEquals(Values.Share.factorize(10),positionA.getShares());
  assertEquals(10000,positionA.calculateValue());
  SecurityPosition positionB=jointPortfolio.getPositionsBySecurity().get(securityB);
  assertEquals(Values.Share.factorize(10),positionB.getShares());
  assertEquals(11000,positionB.calculateValue());
  SecurityPosition positionX=jointPortfolio.getPositionsBySecurity().get(securityX);
  assertEquals(Values.Share.factorize(10) * 2,positionX.getShares());
  assertEquals(24000,positionX.calculateValue());
}
Program: 52742
Project: 52742
Buggy source:
@Test public void testThatTransactionsAreMergedOnSecurityPosition(){
  ClientSnapshot snapshot=ClientSnapshot.create(client,referenceDate);
  assertNotNull(snapshot);
  PortfolioSnapshot jointPortfolio=snapshot.getJointPortfolio();
  SecurityPosition positionX=jointPortfolio.getPositionsBySecurity().get(securityX);
  assertEquals(2000000,positionX.getShares());
  assertEquals(24000,positionX.calculateValue());
  assertEquals(1100,positionX.getFIFOPurchasePrice());
  assertEquals(22100,positionX.getFIFOPurchaseValue());
  assertEquals(1900,positionX.getProfitLoss());
}

Fixed version (ground truth):
@Test public void testThatTransactionsAreMergedOnSecurityPosition(){
  ClientSnapshot snapshot=ClientSnapshot.create(client,referenceDate);
  assertNotNull(snapshot);
  PortfolioSnapshot jointPortfolio=snapshot.getJointPortfolio();
  SecurityPosition positionX=jointPortfolio.getPositionsBySecurity().get(securityX);
  assertEquals(Values.Share.factorize(10) * 2,positionX.getShares());
  assertEquals(24000,positionX.calculateValue());
  assertEquals(1100,positionX.getFIFOPurchasePrice());
  assertEquals(22100,positionX.getFIFOPurchaseValue());
  assertEquals(1900,positionX.getProfitLoss());
}
Program: 52746
Project: 52746
Buggy source:
protected void createBottomTable(Composite parent){
  CTabFolder folder=new CTabFolder(parent,SWT.BORDER);
  CTabItem item=new CTabItem(folder,SWT.NONE);
  item.setText(Messages.LabelStatementOfAssets);
  statementOfAssets=new StatementOfAssetsViewer(folder,this,getClient());
  item.setControl(statementOfAssets.getControl());
  hookContextMenu(statementOfAssets.getTableViewer().getControl(),new IMenuListener(){
    public void menuAboutToShow(    IMenuManager manager){
      statementOfAssets.hookMenuListener(manager,PortfolioListView.this);
    }
  }
);
  item=new CTabItem(folder,SWT.NONE);
  item.setText(Messages.TabTransactions);
  transactions=new PortfolioTransactionsViewer(folder,this);
  item.setControl(transactions.getControl());
  folder.setSelection(0);
  if (!getClient().getPortfolios().isEmpty())   portfolios.setSelection(new StructuredSelection(portfolios.getElementAt(0)),true);
  statementOfAssets.pack();
  transactions.pack();
}

Fixed version (ground truth):
protected void createBottomTable(Composite parent){
  CTabFolder folder=new CTabFolder(parent,SWT.BORDER);
  CTabItem item=new CTabItem(folder,SWT.NONE);
  item.setText(Messages.LabelStatementOfAssets);
  statementOfAssets=new StatementOfAssetsViewer(folder,this,getClient());
  item.setControl(statementOfAssets.getControl());
  hookContextMenu(statementOfAssets.getTableViewer().getControl(),new IMenuListener(){
    public void menuAboutToShow(    IMenuManager manager){
      statementOfAssets.hookMenuListener(manager,PortfolioListView.this);
    }
  }
);
  item=new CTabItem(folder,SWT.NONE);
  item.setText(Messages.TabTransactions);
  transactions=new PortfolioTransactionsViewer(folder,this);
  item.setControl(transactions.getControl());
  folder.setSelection(0);
  statementOfAssets.pack();
  transactions.pack();
  if (!getClient().getPortfolios().isEmpty())   portfolios.setSelection(new StructuredSelection(portfolios.getElementAt(0)),true);
}
Program: 52747
Project: 52747
Buggy source:
public void pack(){
  if (!support.isUserConfigured())   ViewerHelper.pack(tableViewer);
}

Fixed version (ground truth):
public void pack(){
  ViewerHelper.pack(tableViewer);
}
Program: 52748
Project: 52748
Buggy source:
public void pack(){
  if (!support.isUserConfigured())   ViewerHelper.pack(assets);
}

Fixed version (ground truth):
public void pack(){
  ViewerHelper.pack(assets);
}
Program: 52751
Project: 52751
Buggy source:
@Override protected void createTopTable(Composite parent){
  Composite container=new Composite(parent,SWT.NONE);
  TableColumnLayout layout=new TableColumnLayout();
  container.setLayout(layout);
  records=new TableViewer(container,SWT.FULL_SELECTION);
  recordColumns=new ShowHideColumnHelper(DividendsPerformanceView.class.getName(),getClient(),getPreferenceStore(),records,layout);
  ColumnViewerToolTipSupport.enableFor(records,ToolTip.NO_RECREATE);
  ColumnEditingSupport.prepare(records);
  createCommonColumns();
  createDividendColumns();
  createAdditionalColumns();
  recordColumns.createColumns();
  records.getTable().setHeaderVisible(true);
  records.getTable().setLinesVisible(true);
  records.setContentProvider(new SimpleListContentProvider());
  records.addDragSupport(DND.DROP_MOVE,new Transfer[]{SecurityTransfer.getTransfer()},new SecurityDragListener(records));
  hookContextMenu(records.getTable(),new IMenuListener(){
    public void menuAboutToShow(    IMenuManager manager){
      fillContextMenu(manager);
    }
  }
);
  records.addSelectionChangedListener(new ISelectionChangedListener(){
    public void selectionChanged(    SelectionChangedEvent event){
      SecurityPerformanceRecord record=(SecurityPerformanceRecord)((IStructuredSelection)event.getSelection()).getFirstElement();
      transactions.setInput(record != null ? record.getTransactions() : Collections.emptyList());
      transactions.refresh();
    }
  }
);
  reportingPeriodUpdated();
  ViewerHelper.pack(records);
}

Fixed version (ground truth):
@Override protected void createTopTable(Composite parent){
  Composite container=new Composite(parent,SWT.NONE);
  TableColumnLayout layout=new TableColumnLayout();
  container.setLayout(layout);
  records=new TableViewer(container,SWT.FULL_SELECTION);
  recordColumns=new ShowHideColumnHelper(DividendsPerformanceView.class.getName(),getClient(),getPreferenceStore(),records,layout);
  ColumnViewerToolTipSupport.enableFor(records,ToolTip.NO_RECREATE);
  ColumnEditingSupport.prepare(records);
  createCommonColumns();
  createDividendColumns();
  createAdditionalColumns();
  recordColumns.createColumns();
  records.getTable().setHeaderVisible(true);
  records.getTable().setLinesVisible(true);
  records.setContentProvider(new SimpleListContentProvider());
  ViewerHelper.pack(records);
  records.addDragSupport(DND.DROP_MOVE,new Transfer[]{SecurityTransfer.getTransfer()},new SecurityDragListener(records));
  hookContextMenu(records.getTable(),new IMenuListener(){
    public void menuAboutToShow(    IMenuManager manager){
      fillContextMenu(manager);
    }
  }
);
  records.addSelectionChangedListener(new ISelectionChangedListener(){
    public void selectionChanged(    SelectionChangedEvent event){
      SecurityPerformanceRecord record=(SecurityPerformanceRecord)((IStructuredSelection)event.getSelection()).getFirstElement();
      transactions.setInput(record != null ? record.getTransactions() : Collections.emptyList());
      transactions.refresh();
    }
  }
);
  reportingPeriodUpdated();
}
Program: 52752
Project: 52752
Buggy source:
@Override protected void createTopTable(Composite parent){
  Composite container=new Composite(parent,SWT.NONE);
  TableColumnLayout layout=new TableColumnLayout();
  container.setLayout(layout);
  plans=new TableViewer(container,SWT.FULL_SELECTION);
  ColumnEditingSupport.prepare(plans);
  planColumns=new ShowHideColumnHelper(InvestmentPlanListView.class.getSimpleName() + "String_Node_Str",getPreferenceStore(),plans,layout);
  addColumns(planColumns);
  planColumns.createColumns();
  plans.getTable().setHeaderVisible(true);
  plans.getTable().setLinesVisible(true);
  plans.setContentProvider(ArrayContentProvider.getInstance());
  plans.setInput(getClient().getPlans());
  if (!planColumns.isUserConfigured())   ViewerHelper.pack(plans);
  plans.addSelectionChangedListener(new ISelectionChangedListener(){
    public void selectionChanged(    SelectionChangedEvent event){
      InvestmentPlan plan=(InvestmentPlan)((IStructuredSelection)event.getSelection()).getFirstElement();
      if (plan != null)       transactions.setInput(plan.getPortfolio(),plan.getTransactions());
 else       transactions.setInput(null,null);
      transactions.refresh();
    }
  }
);
  hookContextMenu(plans.getTable(),new IMenuListener(){
    public void menuAboutToShow(    IMenuManager manager){
      fillPlansContextMenu(manager);
    }
  }
);
}

Fixed version (ground truth):
@Override protected void createTopTable(Composite parent){
  Composite container=new Composite(parent,SWT.NONE);
  TableColumnLayout layout=new TableColumnLayout();
  container.setLayout(layout);
  plans=new TableViewer(container,SWT.FULL_SELECTION);
  ColumnEditingSupport.prepare(plans);
  planColumns=new ShowHideColumnHelper(InvestmentPlanListView.class.getSimpleName() + "String_Node_Str",getPreferenceStore(),plans,layout);
  addColumns(planColumns);
  planColumns.createColumns();
  plans.getTable().setHeaderVisible(true);
  plans.getTable().setLinesVisible(true);
  plans.setContentProvider(ArrayContentProvider.getInstance());
  plans.setInput(getClient().getPlans());
  ViewerHelper.pack(plans);
  plans.addSelectionChangedListener(new ISelectionChangedListener(){
    public void selectionChanged(    SelectionChangedEvent event){
      InvestmentPlan plan=(InvestmentPlan)((IStructuredSelection)event.getSelection()).getFirstElement();
      if (plan != null)       transactions.setInput(plan.getPortfolio(),plan.getTransactions());
 else       transactions.setInput(null,null);
      transactions.refresh();
    }
  }
);
  hookContextMenu(plans.getTable(),new IMenuListener(){
    public void menuAboutToShow(    IMenuManager manager){
      fillPlansContextMenu(manager);
    }
  }
);
}