nus-yam/ex-repair huggingface dataset:
Program: 158830
Project: 158830
Buggy source:
@Override public String getText(Mode mode){
  if (staticText != null && !staticText.isEmpty()) {
    return staticText;
  }
  StringBuilder sb=new StringBuilder();
  Target target=mode.getTargets().get(0);
  if (target.getMaxNumberOfTargets() > 1) {
    if (target.getNumberOfTargets() < target.getMaxNumberOfTargets()) {
      sb.append("String_Node_Str");
    }
    sb.append(target.getMaxNumberOfTargets()).append("String_Node_Str").append(target.getTargetName()).append("String_Node_Str");
  }
 else {
    if (!target.getTargetName().toUpperCase().startsWith("String_Node_Str")) {
      sb.append("String_Node_Str");
    }
    sb.append(target.getTargetName()).append("String_Node_Str");
  }
  if (durationPhaseStep != null) {
    sb.append("String_Node_Str").append(durationPhaseStep.toString().toLowerCase(Locale.ENGLISH));
  }
  if (!duration.toString().isEmpty()) {
    sb.append(ability.getRule()).append("String_Node_Str").append(duration.toString());
  }
  return sb.toString();
}

Fixed version (ground truth):
@Override public String getText(Mode mode){
  if (staticText != null && !staticText.isEmpty()) {
    return staticText;
  }
  StringBuilder sb=new StringBuilder();
  Target target=mode.getTargets().get(0);
  if (target.getMaxNumberOfTargets() > 1) {
    if (target.getNumberOfTargets() < target.getMaxNumberOfTargets()) {
      sb.append("String_Node_Str");
    }
    sb.append(target.getMaxNumberOfTargets()).append("String_Node_Str").append(target.getTargetName()).append("String_Node_Str");
  }
 else {
    if (!target.getTargetName().toUpperCase().startsWith("String_Node_Str")) {
      sb.append("String_Node_Str");
    }
    sb.append(target.getTargetName()).append("String_Node_Str");
  }
  sb.append(ability.getRule());
  if (durationPhaseStep != null) {
    sb.append("String_Node_Str").append(durationPhaseStep.toString().toLowerCase(Locale.ENGLISH));
  }
 else   if (!duration.toString().isEmpty()) {
    sb.append("String_Node_Str").append(duration.toString());
  }
  return sb.toString();
}
Program: 158831
Project: 158831
Buggy source:
private void logLastPick(DraftPickView pickView){
  if (!isLogging()) {
    return;
  }
  if (currentBooster != null) {
    String lastPick=getCardName(getLastPick(pickView.getPicks().values()));
    if (lastPick != null) {
      logPick(lastPick);
    }
    currentBooster=null;
  }
  setCurrentBoosterForLog(pickView.getBooster());
  if (currentBooster.length == 1) {
    logPick(currentBooster[0]);
  }
}

Fixed version (ground truth):
private void logLastPick(DraftPickView pickView){
  if (!isLogging()) {
    return;
  }
  if (currentBooster != null) {
    String lastPick=getCardName(getLastPick(pickView.getPicks().values()));
    if (lastPick != null && currentBooster.length > 1) {
      logPick(lastPick);
    }
    currentBooster=null;
  }
  setCurrentBoosterForLog(pickView.getBooster());
  if (currentBooster.length == 1) {
    logPick(currentBooster[0]);
  }
}
Program: 158832
Project: 158832
Buggy source:
/** 
 * Creates new form DraftPanel 
 */
public DraftPanel(){
  initComponents();
  draftBooster.setOpaque(false);
  draftPicks.setSortSetting(SortSettingDraft.getInstance());
  draftPicks.setOpaque(false);
  popupMenuPickedArea=new JPopupMenu();
  addPopupMenuPickArea();
  this.add(popupMenuPickedArea);
  popupMenuCardPanel=new JPopupMenu();
  addPopupMenuCardPanel();
  this.add(popupMenuCardPanel);
  draftLeftPane.setOpaque(false);
  countdown=new Timer(1000,new ActionListener(){
    @Override public void actionPerformed(    ActionEvent e){
      if (--timeout > 0) {
        setTimeout(timeout);
      }
 else {
        setTimeout(0);
        countdown.stop();
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Creates new form DraftPanel
 */
public DraftPanel(){
  initComponents();
  draftBooster.setOpaque(false);
  draftPicks.setSortSetting(SortSettingDraft.getInstance());
  draftPicks.setOpaque(false);
  popupMenuPickedArea=new JPopupMenu();
  addPopupMenuPickArea();
  this.add(popupMenuPickedArea);
  popupMenuCardPanel=new JPopupMenu();
  addPopupMenuCardPanel();
  this.add(popupMenuCardPanel);
  draftLeftPane.setOpaque(false);
  countdown=new Timer(1000,new ActionListener(){
    @Override public void actionPerformed(    ActionEvent e){
      if (--timeout > 0) {
        setTimeout(timeout);
      }
 else {
        setTimeout(0);
        countdown.stop();
      }
    }
  }
);
}
Program: 158833
Project: 158833
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  StackAbility stackAbility=(StackAbility)game.getStack().getStackObject(event.getSourceId());
  if (stackAbility.getAbilityType() == AbilityType.ACTIVATED) {
    this.getTargets().get(0).add(event.getPlayerId(),game);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  StackAbility stackAbility=(StackAbility)game.getStack().getStackObject(event.getSourceId());
  if (stackAbility != null && stackAbility.getAbilityType() == AbilityType.ACTIVATED) {
    this.getTargets().get(0).add(event.getPlayerId(),game);
    return true;
  }
  return false;
}
Program: 158834
Project: 158834
Buggy source:
@Override public void mouseClicked(MouseEvent e){
  this.hideDialog();
}

Fixed version (ground truth):
@Override public void mouseClicked(MouseEvent e){
  if (e.getSource() instanceof CardPanel) {
    this.hideDialog();
  }
}
Program: 158835
Project: 158835
Buggy source:
@Override public boolean moveCardToHandWithInfo(Card card,UUID sourceId,Game game,boolean withName){
  boolean result=false;
  Zone fromZone=game.getState().getZone(card.getId());
  if (card.moveToZone(Zone.HAND,sourceId,game,false)) {
    if (card instanceof PermanentCard) {
      card=game.getCard(card.getId());
    }
    if (!game.isSimulation()) {
      StringBuilder sb=new StringBuilder(this.getLogName()).append("String_Node_Str").append(withName ? card.getLogName() : (card.isFaceDown(game) ? "String_Node_Str" : "String_Node_Str"));
switch (fromZone) {
case EXILED:
        sb.append("String_Node_Str");
      break;
default :
    sb.append(fromZone != null ? new StringBuilder("String_Node_Str").append(fromZone.toString().toLowerCase(Locale.ENGLISH)).append("String_Node_Str") : "String_Node_Str");
  break;
}
sb.append(card.getOwnerId().equals(this.getId()) ? "String_Node_Str" : "String_Node_Str");
game.informPlayers(sb.toString());
}
result=true;
}
return result;
}

Fixed version (ground truth):
@Override public boolean moveCardToHandWithInfo(Card card,UUID sourceId,Game game,boolean withName){
  boolean result=false;
  Zone fromZone=game.getState().getZone(card.getId());
  if (fromZone.equals(Zone.BATTLEFIELD) && !(card instanceof Permanent)) {
    card=game.getPermanent(card.getId());
  }
  if (card.moveToZone(Zone.HAND,sourceId,game,false)) {
    if (card instanceof PermanentCard) {
      card=game.getCard(card.getId());
    }
    if (!game.isSimulation()) {
      game.informPlayers(this.getLogName() + "String_Node_Str" + (withName ? card.getLogName() : (card.isFaceDown(game) ? "String_Node_Str" : "String_Node_Str"))+ "String_Node_Str"+ fromZone.toString().toLowerCase(Locale.ENGLISH)+ "String_Node_Str"+ (card.getOwnerId().equals(this.getId()) ? "String_Node_Str" : "String_Node_Str"));
    }
    result=true;
  }
  return result;
}
Program: 158837
Project: 158837
Buggy source:
private static List<Class> findClasses(File directory,String packageName,Class<?> type){
  List<Class> cards=new ArrayList<Class>();
  if (!directory.exists()) {
    return cards;
  }
  for (  File file : directory.listFiles()) {
    if (file.getName().endsWith("String_Node_Str")) {
      try {
        Class<?> clazz=Class.forName(packageName + '.' + file.getName().substring(0,file.getName().length() - 6));
        if (type.isAssignableFrom(clazz)) {
          cards.add(clazz);
        }
      }
 catch (      ClassNotFoundException ex) {
      }
    }
  }
  return cards;
}

Fixed version (ground truth):
private static List<Class> findClasses(File directory,String packageName,Class<?> type){
  List<Class> cards=new ArrayList<>();
  if (!directory.exists()) {
    return cards;
  }
  for (  File file : directory.listFiles()) {
    if (file.getName().endsWith("String_Node_Str")) {
      try {
        Class<?> clazz=Class.forName(packageName + '.' + file.getName().substring(0,file.getName().length() - 6));
        if (type.isAssignableFrom(clazz)) {
          cards.add(clazz);
        }
      }
 catch (      ClassNotFoundException ex) {
      }
    }
  }
  return cards;
}
Program: 158838
Project: 158838
Buggy source:
private static List<Class> findClassesInJar(File file,List<String> packages,Class<?> type){
  List<Class> cards=new ArrayList<Class>();
  if (!file.exists()) {
    return cards;
  }
  JarInputStream jarFile=null;
  try {
    jarFile=new JarInputStream(new FileInputStream(file));
    while (true) {
      JarEntry jarEntry=jarFile.getNextJarEntry();
      if (jarEntry == null) {
        break;
      }
      if (jarEntry.getName().endsWith("String_Node_Str")) {
        String className=jarEntry.getName().replace('/','.').replace("String_Node_Str","String_Node_Str");
        int packageNameEnd=className.lastIndexOf('.');
        String packageName=packageNameEnd != -1 ? className.substring(0,packageNameEnd) : "String_Node_Str";
        if (packages.contains(packageName)) {
          Class<?> clazz;
          try {
            clazz=Class.forName(className);
            if (type.isAssignableFrom(clazz)) {
              cards.add(clazz);
            }
          }
 catch (          ClassNotFoundException ex) {
          }
        }
      }
    }
  }
 catch (  IOException ex) {
  }
 finally {
    try {
      jarFile.close();
    }
 catch (    IOException ex) {
    }
  }
  return cards;
}

Fixed version (ground truth):
private static List<Class> findClassesInJar(File file,List<String> packages,Class<?> type){
  List<Class> cards=new ArrayList<>();
  if (!file.exists()) {
    return cards;
  }
  JarInputStream jarFile=null;
  try {
    jarFile=new JarInputStream(new FileInputStream(file));
    while (true) {
      JarEntry jarEntry=jarFile.getNextJarEntry();
      if (jarEntry == null) {
        break;
      }
      if (jarEntry.getName().endsWith("String_Node_Str")) {
        String className=jarEntry.getName().replace("String_Node_Str","String_Node_Str").replace('/','.');
        int packageNameEnd=className.lastIndexOf('.');
        String packageName=packageNameEnd != -1 ? className.substring(0,packageNameEnd) : "String_Node_Str";
        if (packages.contains(packageName)) {
          Class<?> clazz;
          try {
            clazz=Class.forName(className);
            if (type.isAssignableFrom(clazz)) {
              cards.add(clazz);
            }
          }
 catch (          ClassNotFoundException ex) {
          }
        }
      }
    }
  }
 catch (  IOException ex) {
  }
 finally {
    try {
      jarFile.close();
    }
 catch (    IOException ex) {
    }
  }
  return cards;
}
Program: 158840
Project: 158840
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Permanent p=game.getPermanent(source.getSourceId());
  if (p != null) {
    int amount=p.getCounters().getCount(CounterType.TIME);
    if (amount > 0) {
      p.removeCounters(CounterType.TIME.createInstance(),game);
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Permanent p=game.getPermanent(source.getSourceId());
  if (p != null) {
    int amount=p.getCounters().getCount(CounterType.TIME);
    if (amount > 0) {
      p.removeCounters(CounterType.TIME.createInstance(),game);
      game.informPlayers("String_Node_Str" + p.getLogName() + "String_Node_Str"+ amount+ "String_Node_Str");
    }
    return true;
  }
  return false;
}
Program: 158841
Project: 158841
Buggy source:
@Override public String getRule(){
  return new StringBuilder("String_Node_Str").append(vanishingAmount).append("String_Node_Str").append(CardUtil.numberToText(vanishingAmount)).append("String_Node_Str").toString();
}

Fixed version (ground truth):
@Override public String getRule(){
  return "String_Node_Str" + vanishingAmount + "String_Node_Str"+ CardUtil.numberToText(vanishingAmount)+ "String_Node_Str";
}
Program: 158842
Project: 158842
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (((DamagedPlayerEvent)event).isCombatDamage() && game.getOpponents(this.controllerId).contains(((DamagedPlayerEvent)event).getPlayerId())) {
    Permanent creature=game.getPermanent(event.getSourceId());
    if (creature != null && creature.getControllerId().equals(controllerId)) {
      return true;
    }
  }
  return false;
}
Program: 158843
Project: 158843
Buggy source:
@Override public boolean apply(Game game,Ability source){
  int maxDiscarded=0;
  Player sourcePlayer=game.getPlayer(source.getControllerId());
  for (  UUID playerId : sourcePlayer.getInRange()) {
    Player player=game.getPlayer(playerId);
    if (player != null) {
      int discarded=0;
      for (      Card c : player.getHand().getCards(game)) {
        if (player.discard(c,source,game))         discarded++;
      }
      if (discarded > maxDiscarded)       maxDiscarded=discarded;
    }
  }
  for (  UUID playerId : sourcePlayer.getInRange()) {
    Player player=game.getPlayer(playerId);
    if (player != null) {
      player.drawCards(maxDiscarded,game);
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  int maxDiscarded=0;
  Player controller=game.getPlayer(source.getControllerId());
  for (  UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
    Player player=game.getPlayer(playerId);
    if (player != null) {
      int discarded=player.getHand().size();
      player.discard(discarded,false,source,game);
      if (discarded > maxDiscarded) {
        maxDiscarded=discarded;
      }
    }
  }
  for (  UUID playerId : game.getState().getPlayersInRange(controller.getId(),game)) {
    Player player=game.getPlayer(playerId);
    if (player != null) {
      player.drawCards(maxDiscarded,game);
    }
  }
  return true;
}
Program: 158845
Project: 158845
Buggy source:
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (((ZoneChangeEvent)event).getToZone() == Zone.GRAVEYARD) {
    Card card=game.getCard(event.getTargetId());
    if (card != null && filter.match(card,getSourceId(),getControllerId(),game)) {
switch (setTargetPointer) {
case CARD:
        for (        Effect effect : getEffects()) {
          effect.setTargetPointer(new FixedTarget(card.getId()));
        }
      break;
case PLAYER:
    for (    Effect effect : getEffects()) {
      effect.setTargetPointer(new FixedTarget(card.getOwnerId()));
    }
  break;
}
return true;
}
}
return false;
}

Fixed version (ground truth):
@Override public boolean checkTrigger(GameEvent event,Game game){
  if (((ZoneChangeEvent)event).getToZone() == Zone.GRAVEYARD) {
    Card card=game.getCard(event.getTargetId());
    if (card != null && filter.match(card,getSourceId(),getControllerId(),game)) {
switch (setTargetPointer) {
case CARD:
        for (        Effect effect : getEffects()) {
          effect.setTargetPointer(new FixedTarget(card.getId(),card.getZoneChangeCounter(game)));
        }
      break;
case PLAYER:
    for (    Effect effect : getEffects()) {
      effect.setTargetPointer(new FixedTarget(card.getOwnerId(),0));
    }
  break;
}
return true;
}
}
return false;
}
Program: 158846
Project: 158846
Buggy source:
public ConditionalTriggeredAbility(final ConditionalTriggeredAbility triggered){
  super(triggered);
  this.ability=triggered.ability;
  this.condition=triggered.condition;
  this.text=triggered.text;
}

Fixed version (ground truth):
public ConditionalTriggeredAbility(final ConditionalTriggeredAbility triggered){
  super(triggered);
  this.ability=triggered.ability.copy();
  this.condition=triggered.condition;
  this.text=triggered.text;
}
Program: 158847
Project: 158847
Buggy source:
@Override public Effects getEffects(){
  return ability.getEffects();
}

Fixed version (ground truth):
@Override public Effects getEffects(Game game,EffectType effectType){
  return ability.getEffects(game,effectType);
}
Program: 158848
Project: 158848
Buggy source:
@Override public boolean applies(GameEvent event,Ability source,Game game){
  MageObject object=game.getObject(event.getSourceId());
  return object != null && object.getName().equals(game.getState().getValue(source.getSourceId().toString() + NameACardEffect.INFO_KEY));
}

Fixed version (ground truth):
@Override public boolean applies(GameEvent event,Ability source,Game game){
  MageObject object=game.getObject(event.getSourceId());
  return object != null && !object.isCopy() && object.getName().equals(game.getState().getValue(source.getSourceId().toString() + NameACardEffect.INFO_KEY));
}
Program: 158849
Project: 158849
Buggy source:
/** 
 * Adds the ability to continuous or triggered abilities
 * @param attachedTo
 * @param ability
 */
public void addOtherAbility(Card attachedTo,Ability ability){
  ability.setSourceId(attachedTo.getId());
  ability.setControllerId(attachedTo.getOwnerId());
  if (!cardState.containsKey(attachedTo.getId())) {
    cardState.put(attachedTo.getId(),new CardState());
  }
  cardState.get(attachedTo.getId()).addAbility(ability);
  addAbility(ability,attachedTo.getId(),attachedTo);
}

Fixed version (ground truth):
/** 
 * Adds the ability to continuous or triggered abilities
 * @param attachedTo
 * @param ability
 */
public void addOtherAbility(Card attachedTo,Ability ability){
  Ability newAbility;
  if (ability instanceof MageSingleton) {
    newAbility=ability;
  }
 else {
    newAbility=ability.copy();
  }
  newAbility.setSourceId(attachedTo.getId());
  newAbility.setControllerId(attachedTo.getOwnerId());
  if (!cardState.containsKey(attachedTo.getId())) {
    cardState.put(attachedTo.getId(),new CardState());
  }
  cardState.get(attachedTo.getId()).addAbility(newAbility);
  addAbility(newAbility,attachedTo.getId(),attachedTo);
}
Program: 158850
Project: 158850
Buggy source:
public ThrummingStoneGainAbilitySpellsEffect(final ThrummingStoneGainAbilitySpellsEffect effect){
  super(effect);
  this.ability=effect.ability;
  this.filter=effect.filter;
}

Fixed version (ground truth):
public ThrummingStoneGainAbilitySpellsEffect(final ThrummingStoneGainAbilitySpellsEffect effect){
  super(effect);
  this.ability=effect.ability.copy();
  this.filter=effect.filter.copy();
}
Program: 158851
Project: 158851
Buggy source:
@Test @Ignore public void testApplyForNoneRippleCardsWhenMultiRipple() throws Exception {
  removeAllCardsFromLibrary(playerA);
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str");
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.LIBRARY,playerA,"String_Node_Str");
  addCard(Zone.LIBRARY,playerA,"String_Node_Str",3);
  addCard(Zone.LIBRARY,playerA,"String_Node_Str");
  skipInitShuffling();
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  setChoice(playerA,"String_Node_Str");
  setStopAt(2,PhaseStep.POSTCOMBAT_MAIN);
  execute();
  assertPermanentCount(playerA,"String_Node_Str",3);
}

Fixed version (ground truth):
@Test public void testApplyForNoneRippleCardsWhenMultiRipple() throws Exception {
  removeAllCardsFromLibrary(playerA);
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str");
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.LIBRARY,playerA,"String_Node_Str");
  addCard(Zone.LIBRARY,playerA,"String_Node_Str",3);
  addCard(Zone.LIBRARY,playerA,"String_Node_Str");
  skipInitShuffling();
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  setChoice(playerA,"String_Node_Str");
  setStopAt(2,PhaseStep.POSTCOMBAT_MAIN);
  execute();
  assertPermanentCount(playerA,"String_Node_Str",3);
}
Program: 158852
Project: 158852
Buggy source:
@Override public boolean apply(Game game,Ability source){
  DynamicValue value=new MultikickerCount();
  int damage=value.calculate(game,source,this) * 2;
  Player player=game.getPlayer(source.getFirstTarget());
  if (player != null) {
    player.damage(damage,id,game,false,true);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  DynamicValue value=new MultikickerCount();
  int damage=value.calculate(game,source,this) * 2;
  Player player=game.getPlayer(source.getFirstTarget());
  if (player != null) {
    player.damage(damage,source.getSourceId(),game,false,true);
    return true;
  }
  return false;
}
Program: 158853
Project: 158853
Buggy source:
/** 
 * Returns a text suffix for the game log, that can be added to the cast message.
 * @param position - if there are multiple costs, it's the postion the cost is set (starting with 0)
 * @return
 */
@Override public String getCastSuffixMessage(int position){
  StringBuilder sb=new StringBuilder();
  if (isActivated() && (!isRepeatable() || getActivateCount() > 0)) {
    sb.append(position > 0 ? "String_Node_Str" : "String_Node_Str").append("String_Node_Str");
    if (isRepeatable()) {
      sb.append(getActivateCount()).append(getActivateCount() > 1 ? "String_Node_Str" : "String_Node_Str");
    }
    sb.append(name);
  }
  return sb.toString();
}

Fixed version (ground truth):
/** 
 * Returns a text suffix for the game log, that can be added to the cast message.
 * @param position - if there are multiple costs, it's the postion the costis set (starting with 0)
 * @return
 */
@Override public String getCastSuffixMessage(int position){
  StringBuilder sb=new StringBuilder();
  if (isActivated() && (!isRepeatable() || getActivateCount() > 0)) {
    sb.append(position > 0 ? "String_Node_Str" : "String_Node_Str").append("String_Node_Str");
    if (isRepeatable()) {
      sb.append(getActivateCount()).append(getActivateCount() > 1 ? "String_Node_Str" : "String_Node_Str");
    }
    sb.append(name);
  }
  return sb.toString();
}
Program: 158855
Project: 158855
Buggy source:
@Override public synchronized void rollbackTurns(int turnsToRollback){
  if (gameOptions.rollbackTurnsAllowed) {
    int turnToGoTo=getTurnNum() - turnsToRollback;
    if (turnToGoTo < 1 || !gameStatesRollBack.containsKey(turnToGoTo)) {
      informPlayers(GameLog.getPlayerRequestColoredText("String_Node_Str" + turnsToRollback + "String_Node_Str"));
    }
 else {
      GameState restore=gameStatesRollBack.get(turnToGoTo);
      if (restore != null) {
        informPlayers(GameLog.getPlayerRequestColoredText("String_Node_Str" + restore.getTurnNum()));
        for (        Player playerObject : getPlayers().values()) {
          if (playerObject.isHuman() && playerObject.isInGame()) {
            playerObject.abort();
          }
        }
        state.restoreForRollBack(restore);
        playerList.setCurrent(state.getActivePlayerId());
        gameStatesRollBack.put(getTurnNum(),state.copy());
        executingRollback=true;
        fireUpdatePlayersEvent();
      }
    }
  }
}

Fixed version (ground truth):
@Override public synchronized void rollbackTurns(int turnsToRollback){
  if (gameOptions.rollbackTurnsAllowed) {
    int turnToGoTo=getTurnNum() - turnsToRollback;
    if (turnToGoTo < 1 || !gameStatesRollBack.containsKey(turnToGoTo)) {
      informPlayers(GameLog.getPlayerRequestColoredText("String_Node_Str" + turnsToRollback + "String_Node_Str"));
    }
 else {
      GameState restore=gameStatesRollBack.get(turnToGoTo);
      if (restore != null) {
        informPlayers(GameLog.getPlayerRequestColoredText("String_Node_Str" + restore.getTurnNum()));
        state.restoreForRollBack(restore);
        playerList.setCurrent(state.getActivePlayerId());
        gameStatesRollBack.put(getTurnNum(),state.copy());
        executingRollback=true;
        for (        Player playerObject : getPlayers().values()) {
          if (playerObject.isHuman() && playerObject.isInGame()) {
            playerObject.abort();
          }
        }
        fireUpdatePlayersEvent();
      }
    }
  }
}
Program: 158857
Project: 158857
Buggy source:
@Override public boolean moveCards(List<Card> cards,Zone fromZone,Zone toZone,Ability source,Game game){
  if (cards.isEmpty()) {
    return true;
  }
  game.fireEvent(new ZoneChangeGroupEvent(cards,source == null ? null : source.getSourceId(),this.getId(),fromZone,toZone));
switch (toZone) {
case EXILED:
    boolean result=false;
  for (  Card card : cards) {
    result|=moveCardToExileWithInfo(card,null,"String_Node_Str",source == null ? null : source.getSourceId(),game,fromZone,true);
  }
return result;
case GRAVEYARD:
return moveCardsToGraveyardWithInfo(cards,source,game,fromZone);
case HAND:
result=false;
for (Card card : cards) {
result|=moveCardToHandWithInfo(card,source == null ? null : source.getSourceId(),game,fromZone);
}
return result;
case BATTLEFIELD:
result=false;
for (Card card : cards) {
result|=putOntoBattlefieldWithInfo(card,game,fromZone,source == null ? null : source.getSourceId());
}
return result;
default :
throw new UnsupportedOperationException("String_Node_Str");
}
}

Fixed version (ground truth):
@Override public boolean moveCards(List<Card> cards,Zone fromZone,Zone toZone,Ability source,Game game){
  if (cards.isEmpty()) {
    return true;
  }
  game.fireEvent(new ZoneChangeGroupEvent(cards,source == null ? null : source.getSourceId(),this.getId(),fromZone,toZone));
switch (toZone) {
case EXILED:
    boolean result=false;
  for (  Card card : cards) {
    result|=moveCardToExileWithInfo(card,null,"String_Node_Str",source == null ? null : source.getSourceId(),game,fromZone,true);
  }
return result;
case GRAVEYARD:
return moveCardsToGraveyardWithInfo(cards,source,game,fromZone);
case HAND:
result=false;
for (Card card : cards) {
result|=moveCardToHandWithInfo(card,source == null ? null : source.getSourceId(),game,fromZone);
}
return result;
case BATTLEFIELD:
result=false;
for (Card card : cards) {
result|=putOntoBattlefieldWithInfo(card,game,fromZone,source == null ? null : source.getSourceId());
}
return result;
case LIBRARY:
result=false;
boolean withName=true;
if (fromZone.equals(Zone.HAND) || fromZone.equals(Zone.LIBRARY)) {
withName=false;
}
for (Card card : cards) {
result|=moveCardToLibraryWithInfo(card,source == null ? null : source.getSourceId(),game,fromZone,true,withName);
}
return result;
default :
throw new UnsupportedOperationException("String_Node_Str");
}
}
Program: 158858
Project: 158858
Buggy source:
DemonToken(){
  super("String_Node_Str","String_Node_Str");
  cardType.add(CardType.CREATURE);
  subtype.add("String_Node_Str");
  color.setBlack(true);
  power=new MageInt(5);
  toughness=new MageInt(5);
  addAbility(FlyingAbility.getInstance());
}

Fixed version (ground truth):
DemonToken(){
  super("String_Node_Str","String_Node_Str");
  cardType.add(CardType.CREATURE);
  subtype.add("String_Node_Str");
  setOriginalExpansionSetCode("String_Node_Str");
  color.setBlack(true);
  power=new MageInt(5);
  toughness=new MageInt(5);
  addAbility(FlyingAbility.getInstance());
}
Program: 158859
Project: 158859
Buggy source:
@Override public boolean removeFromBattlefield(Permanent permanent,Game game){
  permanent.removeFromCombat(game,false);
  game.getBattlefield().removePermanent(permanent.getId());
  if (permanent.getAttachedTo() != null) {
    Permanent attachedTo=game.getPermanent(permanent.getAttachedTo());
    if (attachedTo != null) {
      attachedTo.removeAttachment(permanent.getId(),game);
    }
 else {
      Player attachedToPlayer=game.getPlayer(permanent.getAttachedTo());
      if (attachedToPlayer != null) {
        attachedToPlayer.removeAttachment(permanent,game);
      }
    }
  }
  if (permanent.getPairedCard() != null) {
    Permanent pairedCard=game.getPermanent(permanent.getPairedCard());
    if (pairedCard != null) {
      pairedCard.clearPairedCard();
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean removeFromBattlefield(Permanent permanent,Game game){
  permanent.removeFromCombat(game,false);
  game.getBattlefield().removePermanent(permanent.getId());
  if (permanent.getAttachedTo() != null) {
    Permanent attachedTo=game.getPermanent(permanent.getAttachedTo());
    if (attachedTo != null) {
      attachedTo.removeAttachment(permanent.getId(),game);
    }
 else {
      Player attachedToPlayer=game.getPlayer(permanent.getAttachedTo());
      if (attachedToPlayer != null) {
        attachedToPlayer.removeAttachment(permanent,game);
      }
    }
  }
  if (permanent.getPairedCard() != null) {
    Permanent pairedCard=game.getPermanent(permanent.getPairedCard());
    if (pairedCard != null) {
      pairedCard.clearPairedCard();
    }
  }
  if (permanent instanceof PermanentToken) {
    game.getState().getTriggers().removeAbilitiesOfSource(permanent.getId());
  }
  return true;
}
Program: 158860
Project: 158860
Buggy source:
@Override public SpellAbility getSpellAbility(){
  if (spellAbility == null) {
    for (    Ability ability : abilities.getActivatedAbilities(Zone.HAND)) {
      if (ability instanceof SpellAbility && ability.toString().endsWith(getName())) {
        spellAbility=(SpellAbility)ability;
      }
    }
  }
  return spellAbility;
}

Fixed version (ground truth):
@Override public SpellAbility getSpellAbility(){
  if (spellAbility == null) {
    for (    Ability ability : abilities.getActivatedAbilities(Zone.HAND)) {
      if (ability instanceof SpellAbility) {
        spellAbility=(SpellAbility)ability;
      }
    }
  }
  return spellAbility;
}
Program: 158862
Project: 158862
Buggy source:
/** 
 * Test renown is gone after zone change / Test renown is gone after zone change
 */
@Test public void testRenownGoneAfterZoneChange(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",6);
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.HAND,playerA,"String_Node_Str");
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  castSpell(5,PhaseStep.POSTCOMBAT_MAIN,playerA,"String_Node_Str","String_Node_Str");
  attack(3,playerA,"String_Node_Str");
  attack(5,playerA,"String_Node_Str");
  attack(7,playerA,"String_Node_Str");
  setStopAt(7,PhaseStep.POSTCOMBAT_MAIN);
  execute();
  assertLife(playerA,20);
  assertLife(playerB,6);
  assertPowerToughness(playerA,"String_Node_Str",4,4);
  Permanent rhoxMaulers=getPermanent("String_Node_Str",playerA);
  Assert.assertEquals("String_Node_Str",false,rhoxMaulers.isRenown());
}

Fixed version (ground truth):
/** 
 * Test renown is gone after zone change / Test renown is gone after zone change
 */
@Test public void testRenownGoneAfterZoneChange(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",6);
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.HAND,playerA,"String_Node_Str");
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  castSpell(5,PhaseStep.POSTCOMBAT_MAIN,playerA,"String_Node_Str","String_Node_Str");
  attack(3,playerA,"String_Node_Str");
  attack(5,playerA,"String_Node_Str");
  attack(7,playerA,"String_Node_Str");
  setStopAt(7,PhaseStep.POSTCOMBAT_MAIN);
  execute();
  assertLife(playerA,20);
  assertLife(playerB,6);
  assertPowerToughness(playerA,"String_Node_Str",6,6);
  Permanent rhoxMaulers=getPermanent("String_Node_Str",playerA);
  Assert.assertEquals("String_Node_Str",true,rhoxMaulers.isRenown());
}
Program: 158864
Project: 158864
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  MageObject sourceObject=source.getSourceObject(game);
  if (controller != null && sourceObject != null) {
    int number=2;
    if (SpellMasteryCondition.getInstance().apply(game,source)) {
      number++;
    }
    TargetCardInLibrary target=new TargetCardInLibrary(0,number,filter);
    controller.chooseTarget(outcome,target,source,game);
    if (!target.getTargets().isEmpty()) {
      Cards cards=new CardsImpl(target.getTargets());
      controller.revealCards(sourceObject.getIdName(),cards,game);
      if (!cards.isEmpty()) {
        Card card=cards.getRandom(game);
        if (card != null) {
          cards.remove(card);
          controller.putOntoBattlefieldWithInfo(card,game,Zone.LIBRARY,source.getSourceId(),true);
          controller.moveCards(cards,Zone.LIBRARY,Zone.HAND,source,game);
        }
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  MageObject sourceObject=source.getSourceObject(game);
  if (controller != null && sourceObject != null) {
    int number=2;
    if (SpellMasteryCondition.getInstance().apply(game,source)) {
      number++;
    }
    TargetCardInLibrary target=new TargetCardInLibrary(0,number,filter);
    controller.searchLibrary(target,game);
    if (!target.getTargets().isEmpty()) {
      Cards cards=new CardsImpl(target.getTargets());
      controller.revealCards(sourceObject.getIdName(),cards,game);
      if (!cards.isEmpty()) {
        Card card=cards.getRandom(game);
        if (card != null) {
          cards.remove(card);
          controller.putOntoBattlefieldWithInfo(card,game,Zone.LIBRARY,source.getSourceId(),true);
          controller.moveCards(cards,Zone.LIBRARY,Zone.HAND,source,game);
        }
      }
    }
    return true;
  }
  return false;
}
Program: 158865
Project: 158865
Buggy source:
public MenaceAbility(MenaceAbility ability){
  super(ability);
}

Fixed version (ground truth):
public MenaceAbility(final MenaceAbility ability){
  super(ability);
}
Program: 158866
Project: 158866
Buggy source:
@Override public Ability copy(){
  return fINSTANCE;
}

Fixed version (ground truth):
@Override public Ability copy(){
  return new MenaceAbility(this);
}
Program: 158867
Project: 158867
Buggy source:
private void requestFocusIfPossible(){
  boolean requestFocusAllowed=true;
  if (connectedChatPanel != null && connectedChatPanel.getTxtMessageInputComponent() != null) {
    if (connectedChatPanel.getTxtMessageInputComponent().hasFocus()) {
      requestFocusAllowed=false;
    }
  }
  if (requestFocusAllowed) {
    this.btnRight.requestFocus();
    this.helper.requestFocus();
  }
}

Fixed version (ground truth):
private void requestFocusIfPossible(){
  boolean requestFocusAllowed=true;
  if (MageFrame.getInstance().getFocusOwner() == null) {
    requestFocusAllowed=false;
  }
 else   if (connectedChatPanel != null && connectedChatPanel.getTxtMessageInputComponent() != null) {
    if (connectedChatPanel.getTxtMessageInputComponent().hasFocus()) {
      requestFocusAllowed=false;
    }
  }
  if (requestFocusAllowed) {
    this.btnRight.requestFocus();
    this.helper.requestFocus();
  }
}
Program: 158869
Project: 158869
Buggy source:
private void setControllerForEffect(ContinuousEffectsList<?> effects,UUID cardId,UUID controllerId){
  for (  Effect effect : effects) {
    HashSet<Ability> abilities=effects.getAbility(effect.getId());
    for (    Ability ability : abilities) {
      if (ability.getSourceId() != null) {
        if (ability.getSourceId().equals(cardId)) {
          ability.setControllerId(controllerId);
        }
      }
 else {
        if (!ability.getZone().equals(Zone.COMMAND)) {
          logger.fatal(new StringBuilder("String_Node_Str").append(ability));
        }
      }
    }
  }
}

Fixed version (ground truth):
private void setControllerForEffect(ContinuousEffectsList<?> effects,UUID cardId,UUID controllerId){
  for (  Effect effect : effects) {
    HashSet<Ability> abilities=effects.getAbility(effect.getId());
    if (abilities != null) {
      for (      Ability ability : abilities) {
        if (ability.getSourceId() != null) {
          if (ability.getSourceId().equals(cardId)) {
            ability.setControllerId(controllerId);
          }
        }
 else {
          if (!ability.getZone().equals(Zone.COMMAND)) {
            logger.fatal(new StringBuilder("String_Node_Str").append(ability));
          }
        }
      }
    }
  }
}
Program: 158870
Project: 158870
Buggy source:
public List<ContinuousEffect> getLayeredEffects(Game game){
  List<ContinuousEffect> layerEffects=new ArrayList<>();
  for (  ContinuousEffect effect : layeredEffects) {
switch (effect.getDuration()) {
case WhileOnBattlefield:
case WhileOnStack:
case WhileInGraveyard:
      HashSet<Ability> abilities=layeredEffects.getAbility(effect.getId());
    for (    Ability ability : abilities) {
      if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game,null,null)) {
        layerEffects.add(effect);
        break;
      }
    }
  break;
default :
layerEffects.add(effect);
}
}
updateTimestamps(layerEffects);
Collections.sort(layerEffects,sorter);
return layerEffects;
}

Fixed version (ground truth):
public List<ContinuousEffect> getLayeredEffects(Game game){
  List<ContinuousEffect> layerEffects=new ArrayList<>();
  for (  ContinuousEffect effect : layeredEffects) {
switch (effect.getDuration()) {
case WhileOnBattlefield:
case WhileOnStack:
case WhileInGraveyard:
      HashSet<Ability> abilities=layeredEffects.getAbility(effect.getId());
    if (abilities != null) {
      for (      Ability ability : abilities) {
        if (!(ability instanceof StaticAbility) || ability.isInUseableZone(game,null,null)) {
          layerEffects.add(effect);
          break;
        }
      }
    }
 else {
      logger.error("String_Node_Str" + effect.toString());
    }
  break;
default :
layerEffects.add(effect);
}
}
updateTimestamps(layerEffects);
Collections.sort(layerEffects,sorter);
return layerEffects;
}
Program: 158871
Project: 158871
Buggy source:
protected UUID selectDefenderForAllAttack(Set<UUID> defenders,Game game){
  TargetDefender target=new TargetDefender(defenders,null);
  target.setNotTarget(true);
  if (chooseTarget(Outcome.Damage,target,null,game)) {
    response.getUUID();
  }
  return null;
}

Fixed version (ground truth):
protected UUID selectDefenderForAllAttack(Set<UUID> defenders,Game game){
  TargetDefender target=new TargetDefender(defenders,null);
  target.setNotTarget(true);
  if (chooseTarget(Outcome.Damage,target,null,game)) {
    return response.getUUID();
  }
  return null;
}
Program: 158875
Project: 158875
Buggy source:
@Override public boolean canChooseTarget(Game game){
  for (  Mode mode : modes.values()) {
    if (mode.getTargets().canChoose(sourceId,controllerId,game)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean canChooseTarget(Game game){
  int found=0;
  for (  Mode mode : modes.values()) {
    if (mode.getTargets().canChoose(sourceId,controllerId,game)) {
      found++;
      if (found >= getModes().getMinModes()) {
        return true;
      }
    }
  }
  return false;
}
Program: 158876
Project: 158876
Buggy source:
private synchronized void startModal(){
  try {
    if (SwingUtilities.isEventDispatchThread()) {
      EventQueue theQueue=getToolkit().getSystemEventQueue();
      while (isVisible()) {
        AWTEvent event=theQueue.getNextEvent();
        Object source=event.getSource();
        boolean dispatch=true;
        if (event.getSource() != null && event.getSource() instanceof TrayIcon) {
          return;
        }
        if (event instanceof MouseEvent && event.getSource() instanceof Component) {
          MouseEvent e=(MouseEvent)event;
          MouseEvent m=SwingUtilities.convertMouseEvent((Component)e.getSource(),e,this);
          if (!this.contains(m.getPoint()) && e.getID() != MouseEvent.MOUSE_DRAGGED) {
            dispatch=false;
          }
        }
        if (dispatch) {
          if (event instanceof ActiveEvent) {
            ((ActiveEvent)event).dispatch();
          }
 else           if (source instanceof Component) {
            ((Component)source).dispatchEvent(event);
          }
 else           if (source instanceof MenuComponent) {
            ((MenuComponent)source).dispatchEvent(event);
          }
 else {
            logger.warn("String_Node_Str" + event);
          }
        }
      }
    }
 else {
      while (isVisible()) {
        wait();
      }
    }
  }
 catch (  InterruptedException ignored) {
  }
}

Fixed version (ground truth):
private synchronized void startModal(){
  try {
    if (SwingUtilities.isEventDispatchThread()) {
      EventQueue theQueue=getToolkit().getSystemEventQueue();
      while (isVisible()) {
        AWTEvent event=theQueue.getNextEvent();
        Object source=event.getSource();
        boolean dispatch=true;
        if (event instanceof MouseEvent && event.getSource() instanceof Component) {
          MouseEvent e=(MouseEvent)event;
          MouseEvent m=SwingUtilities.convertMouseEvent((Component)e.getSource(),e,this);
          if (!this.contains(m.getPoint()) && e.getID() != MouseEvent.MOUSE_DRAGGED) {
            dispatch=false;
          }
        }
        if (dispatch) {
          if (event instanceof ActiveEvent) {
            ((ActiveEvent)event).dispatch();
          }
 else           if (source instanceof Component) {
            ((Component)source).dispatchEvent(event);
          }
 else           if (source instanceof MenuComponent) {
            ((MenuComponent)source).dispatchEvent(event);
          }
 else {
            logger.warn("String_Node_Str" + event);
          }
        }
      }
    }
 else {
      while (isVisible()) {
        wait();
      }
    }
  }
 catch (  InterruptedException ignored) {
  }
}
Program: 158877
Project: 158877
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getFirstTarget());
  if (controller != null) {
    ChoiceColor choice=new ChoiceColor();
    while (!choice.isChosen()) {
      controller.choose(outcome,choice,game);
      if (!controller.isInGame()) {
        return false;
      }
    }
    if (choice.getColor() == null) {
      return false;
    }
    Cards hand=controller.getHand();
    controller.revealCards("String_Node_Str",hand,game);
    Set<Card> cards=hand.getCards(game);
    for (    Card card : cards) {
      if (card != null && card.getColor(game).shares(choice.getColor())) {
        controller.discard(card,source,game);
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getFirstTarget());
  MageObject sourceObject=game.getObject(source.getSourceId());
  if (controller != null && sourceObject != null) {
    ChoiceColor choice=new ChoiceColor();
    while (!choice.isChosen()) {
      controller.choose(outcome,choice,game);
      if (!controller.isInGame()) {
        return false;
      }
    }
    if (choice.getColor() == null) {
      return false;
    }
    Cards hand=controller.getHand();
    controller.revealCards(sourceObject.getIdName(),hand,game);
    Set<Card> cards=hand.getCards(game);
    for (    Card card : cards) {
      if (card != null && card.getColor(game).shares(choice.getColor())) {
        controller.discard(card,source,game);
      }
    }
    return true;
  }
  return false;
}
Program: 158878
Project: 158878
Buggy source:
/** 
 * Mycosynth Golem Artifact Creature — Golem 4/5, 11 (11) Affinity for artifacts (This spell costs {1} less to cast for each  artifact you control.) Artifact creature spells you cast have affinity for artifacts. (They cost {1} less to cast for each artifact you control.)
 */
@Test public void testSpellsAffinity(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str");
  addCard(Zone.HAND,playerA,"String_Node_Str");
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  setStopAt(1,PhaseStep.BEGIN_COMBAT);
  execute();
  assertPermanentCount(playerA,"String_Node_Str",1);
  assertHandCount(playerA,"String_Node_Str",0);
  Permanent mountain=getPermanent("String_Node_Str",playerA);
  Permanent forest=getPermanent("String_Node_Str",playerA);
  int tappedLands=0;
  if (mountain.isTapped()) {
    tappedLands++;
  }
  if (forest.isTapped()) {
    tappedLands++;
  }
  Assert.assertEquals("String_Node_Str",1,tappedLands);
}

Fixed version (ground truth):
/** 
 * Mycosynth Golem Artifact Creature — Golem 4/5, 11 (11) Affinity for artifacts (This spell costs {1} less to cast for each artifact you control.) Artifact creature spells you cast have affinity for artifacts. (They cost {1} less to cast for each artifact you control.)
 */
@Test public void testSpellsAffinity(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str");
  addCard(Zone.HAND,playerA,"String_Node_Str");
  castSpell(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  setStopAt(1,PhaseStep.BEGIN_COMBAT);
  execute();
  assertPermanentCount(playerA,"String_Node_Str",1);
  assertHandCount(playerA,"String_Node_Str",0);
  Permanent mountain=getPermanent("String_Node_Str",playerA);
  Permanent forest=getPermanent("String_Node_Str",playerA);
  int tappedLands=0;
  if (mountain.isTapped()) {
    tappedLands++;
  }
  if (forest.isTapped()) {
    tappedLands++;
  }
  Assert.assertEquals("String_Node_Str",1,tappedLands);
}
Program: 158879
Project: 158879
Buggy source:
/** 
 * I activated the ability of Soulfire grand master, it resolved, then i cast Stoke the Flames  on Whisperwood Elemental, my opponenet sacrificed the elemental, so stoke didnt resolve,  but i still got the life from lifelink.
 */
@Test public void testSoulfireStokeTheFlames(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",8);
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str",1);
  activateAbility(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  castSpell(1,PhaseStep.POSTCOMBAT_MAIN,playerA,"String_Node_Str","String_Node_Str");
  activateAbility(1,PhaseStep.POSTCOMBAT_MAIN,playerB,"String_Node_Str",null,"String_Node_Str");
  setStopAt(1,PhaseStep.END_TURN);
  execute();
  assertGraveyardCount(playerA,"String_Node_Str",1);
  assertGraveyardCount(playerB,"String_Node_Str",1);
  assertLife(playerB,20);
  assertLife(playerA,20);
}

Fixed version (ground truth):
/** 
 * I activated the ability of Soulfire grand master, it resolved, then i cast Stoke the Flames on Whisperwood Elemental, my opponenet sacrificed the elemental, so stoke didnt resolve, but i still got the life from lifelink.
 */
@Test public void testSoulfireStokeTheFlames(){
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",8);
  addCard(Zone.HAND,playerA,"String_Node_Str");
  addCard(Zone.BATTLEFIELD,playerA,"String_Node_Str",1);
  addCard(Zone.BATTLEFIELD,playerB,"String_Node_Str",1);
  activateAbility(1,PhaseStep.PRECOMBAT_MAIN,playerA,"String_Node_Str");
  castSpell(1,PhaseStep.POSTCOMBAT_MAIN,playerA,"String_Node_Str","String_Node_Str");
  activateAbility(1,PhaseStep.POSTCOMBAT_MAIN,playerB,"String_Node_Str",null,"String_Node_Str");
  setStopAt(1,PhaseStep.END_TURN);
  execute();
  assertGraveyardCount(playerA,"String_Node_Str",1);
  assertGraveyardCount(playerB,"String_Node_Str",1);
  assertLife(playerB,20);
  assertLife(playerA,20);
}