nus-yam/ex-repair huggingface dataset:
Program: 39579
Project: 39579
Buggy source:
/** 
 * The folder location in the file system where the transformed application should be placed. </br> If null, it defaults to same location where original application is. n this case the transformed application is placed under a new folder whose named is same as original folder, plus a "-transformed-yyyyMMddHHmmssSSS" suffix
 * @param outputFolder the output folder where the transformed application issupposed to be placed
 */
public void setOutputFolder(File outputFolder){
  if (outputFolder != null && (!outputFolder.exists() || !outputFolder.isDirectory())) {
    throw new IllegalArgumentException(String.format("String_Node_Str",outputFolder));
  }
  this.outputFolder=outputFolder;
}

Fixed version (ground truth):
/** 
 * The folder location in the file system where the transformed application should be placed. <br> If null, it defaults to same location where original application is. n this case the transformed application is placed under a new folder whose named is same as original folder, plus a "-transformed-yyyyMMddHHmmssSSS" suffix
 * @param outputFolder the output folder where the transformed application issupposed to be placed
 */
public void setOutputFolder(File outputFolder){
  if (outputFolder != null && (!outputFolder.exists() || !outputFolder.isDirectory())) {
    throw new IllegalArgumentException(String.format("String_Node_Str",outputFolder));
  }
  this.outputFolder=outputFolder;
}
Program: 39580
Project: 39580
Buggy source:
/** 
 * Operation to copy a directory and its content from one location to another. The files to be copied include sub-folders and their files, coming rom relative or absolute location. The path to the files to be copied are preserved, and those folders are also copied to the destination location. If the destination directory does not exist, it is created. But, if it does, then the content to be copied is merged with the destination content, with the source taking precedence.
 * @author facarvalho
 */
public CopyDirectory(){
  super(DESCRIPTION);
}

Fixed version (ground truth):
/** 
 * Operation to copy a directory and its content from one location to another. The files to be copied include sub-folders and their files, coming rom relative or absolute location. The path to the files to be copied are preserved, and those folders are also copied to the destination location. If the destination directory does not exist, it is created. But, if it does, then the content to be copied is merged with the destination content, with the source taking precedence.
 */
public CopyDirectory(){
  super(DESCRIPTION);
}
Program: 39581
Project: 39581
Buggy source:
/** 
 * Moves a directory and its content from one location to another. The directory to be moved is specified from relative or absolute location. If the destination directory does not exist, it is created.
 * @author facarvalho
 */
public MoveDirectory(){
  super(DESCRIPTION);
}

Fixed version (ground truth):
/** 
 * Moves a directory and its content from one location to another. The directory to be moved is specified from relative or absolute location. If the destination directory does not exist, it is created.
 */
public MoveDirectory(){
  super(DESCRIPTION);
}
Program: 39582
Project: 39582
Buggy source:
/** 
 * Operation to replace text in a text file based on a regular expression.
 * @param regex the regular expression to find replacement points
 * @param replacement the replacement text
 * @author facarvalho
 */
public ReplaceText(String regex,String replacement){
  setRegex(regex);
  setReplacement(replacement);
}

Fixed version (ground truth):
/** 
 * Operation to replace text in a text file based on a regular expression.
 * @param regex the regular expression to find replacement points
 * @param replacement the replacement text
 */
public ReplaceText(String regex,String replacement){
  setRegex(regex);
  setReplacement(replacement);
}
Program: 39584
Project: 39584
Buggy source:
private void registerError(ButterflyCliRun run,String errorMessage,Exception exception){
  if (exception == null) {
    logger.error(errorMessage);
  }
 else {
    logger.error(errorMessage,exception);
    run.setExceptionMessage(exception.getMessage());
  }
  run.setErrorMessage(errorMessage);
  run.setExitStatus(1);
}

Fixed version (ground truth):
private void registerError(ButterflyCliRun run,String errorMessage,Exception exception){
  if (exception == null || !logConfigurator.isVerboseMode()) {
    logger.error(errorMessage);
  }
 else {
    logger.error(errorMessage,exception);
  }
  if (exception != null) {
    run.setExceptionMessage(exception.getMessage());
  }
  run.setErrorMessage(errorMessage);
  run.setExitStatus(1);
}
Program: 39585
Project: 39585
Buggy source:
@Override public void setVerboseMode(boolean on){
  PatternLayoutEncoder patternLayoutEncoder=new PatternLayoutEncoder();
  patternLayoutEncoder.setPattern("String_Node_Str");
  patternLayoutEncoder.setContext(loggerContext);
  patternLayoutEncoder.start();
  Appender<ILoggingEvent> consoleAppender=new ConsoleAppender();
  ((OutputStreamAppender)consoleAppender).setEncoder(patternLayoutEncoder);
  consoleAppender.setContext(loggerContext);
  consoleAppender.start();
  loggerContext.getLogger("String_Node_Str").detachAppender("String_Node_Str");
  loggerContext.getLogger("String_Node_Str").addAppender(consoleAppender);
}

Fixed version (ground truth):
@Override public void setVerboseMode(boolean verboseMode){
  this.verboseMode=verboseMode;
  if (verboseMode) {
    PatternLayoutEncoder patternLayoutEncoder=new PatternLayoutEncoder();
    patternLayoutEncoder.setPattern("String_Node_Str");
    patternLayoutEncoder.setContext(loggerContext);
    patternLayoutEncoder.start();
    Appender<ILoggingEvent> consoleAppender=new ConsoleAppender();
    ((OutputStreamAppender)consoleAppender).setEncoder(patternLayoutEncoder);
    consoleAppender.setContext(loggerContext);
    consoleAppender.start();
    loggerContext.getLogger("String_Node_Str").detachAppender("String_Node_Str");
    loggerContext.getLogger("String_Node_Str").addAppender(consoleAppender);
  }
 else {
  }
}
Program: 39586
Project: 39586
Buggy source:
private void setAbsoluteFile(File transformedAppFolder,TransformationContext transformationContext) throws TransformationUtilityException {
  if (absoluteFileFromContextAttribute != null) {
    absoluteFile=(File)transformationContext.get(absoluteFileFromContextAttribute);
    if (absoluteFile == null) {
      String exceptionMessage=String.format("String_Node_Str",absoluteFileFromContextAttribute,name);
      TransformationUtilityException exception=new TransformationUtilityException(exceptionMessage);
      throw exception;
    }
    if (additionalRelativePath != null) {
      absoluteFile=new File(absoluteFile,additionalRelativePath);
      logger.debug("String_Node_Str",name,absoluteFileFromContextAttribute,absoluteFile.getAbsolutePath());
    }
 else {
      logger.debug("String_Node_Str",name,absoluteFileFromContextAttribute);
    }
    setRelativePath(transformedAppFolder,absoluteFile);
    logger.debug("String_Node_Str",name,relativePath);
  }
 else {
    if (relativePath == null) {
      String exceptionMessage=String.format("String_Node_Str",name);
      TransformationUtilityException exception=new TransformationUtilityException(exceptionMessage);
      throw exception;
    }
    absoluteFile=new File(transformedAppFolder,relativePath);
  }
}

Fixed version (ground truth):
private void setAbsoluteFile(File transformedAppFolder,TransformationContext transformationContext) throws TransformationUtilityException {
  if (absoluteFileFromContextAttribute != null) {
    absoluteFile=(File)transformationContext.get(absoluteFileFromContextAttribute);
    if (absoluteFile == null) {
      String exceptionMessage=String.format("String_Node_Str",absoluteFileFromContextAttribute,name);
      throw new TransformationUtilityException(exceptionMessage);
    }
    if (additionalRelativePath != null) {
      absoluteFile=new File(absoluteFile,additionalRelativePath);
      logger.debug("String_Node_Str",name,absoluteFileFromContextAttribute,absoluteFile.getAbsolutePath());
    }
 else {
      logger.debug("String_Node_Str",name,absoluteFileFromContextAttribute);
    }
    setRelativePath(transformedAppFolder,absoluteFile);
    logger.debug("String_Node_Str",name,relativePath);
  }
 else {
    if (relativePath == null) {
      String exceptionMessage=String.format("String_Node_Str",name);
      throw new TransformationUtilityException(exceptionMessage);
    }
    absoluteFile=new File(transformedAppFolder,relativePath);
  }
}
Program: 39587
Project: 39587
Buggy source:
public static void main(String... arguments) throws IOException {
  setButterflyHome();
  setEnvironment(arguments);
  logger=LoggerFactory.getLogger(ButterflyCliApp.class);
  setBanner();
  ConfigurableApplicationContext applicationContext=SpringApplication.run(ButterflyCliApp.class,arguments);
  ButterflyCliRunner butterflyCliRunner=applicationContext.getBean(ButterflyCliRunner.class);
  ButterflyCliRun run=butterflyCliRunner.run();
  if (optionSet != null && optionSet.has(CLI_OPTION_RESULT_FILE)) {
    run.setInputArguments(arguments);
    writeResultFile(run);
  }
  System.exit(run.getExitStatus());
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public static void main(String... arguments) throws IOException {
  setButterflyHome();
  setEnvironment(arguments);
  logger=LoggerFactory.getLogger(ButterflyCliApp.class);
  setBanner();
  ConfigurableApplicationContext applicationContext=SpringApplication.run(ButterflyCliApp.class,arguments);
  ButterflyCliRunner butterflyCliRunner=applicationContext.getBean(ButterflyCliRunner.class);
  ButterflyCliRun run=butterflyCliRunner.run();
  if (optionSet != null && optionSet.has(CLI_OPTION_RESULT_FILE)) {
    run.setInputArguments(arguments);
    writeResultFile(run);
  }
  System.exit(run.getExitStatus());
}
Program: 39588
Project: 39588
Buggy source:
private static void setEnvironment(String[] arguments){
  if (arguments.length != 0) {
    try {
      setOptionSet(arguments);
      File applicationFolder=getApplicationFolder();
      boolean debug=optionSet.has(CLI_OPTION_DEBUG);
      LogFileDefiner.setLogFileName(applicationFolder,debug);
    }
 catch (    OptionException e) {
      Logger logger=LoggerFactory.getLogger(ButterflyCliApp.class);
      setBanner();
      logger.info(getBanner());
      logger.error(e.getMessage());
      System.exit(1);
    }
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private static void setEnvironment(String[] arguments){
  if (arguments.length != 0) {
    try {
      setOptionSet(arguments);
      File applicationFolder=getApplicationFolder();
      boolean debug=optionSet.has(CLI_OPTION_DEBUG);
      LogFileDefiner.setLogFileName(applicationFolder,debug);
    }
 catch (    OptionException e) {
      Logger logger=LoggerFactory.getLogger(ButterflyCliApp.class);
      setBanner();
      logger.info(getBanner());
      logger.error(e.getMessage());
      System.exit(1);
    }
  }
}
Program: 39589
Project: 39589
Buggy source:
void registerResult(PerformResult result){
  ExecutionResult executionResult=null;
switch (result.getType()) {
case ERROR:
    performResults.errorCount++;
  break;
case EXECUTION_RESULT:
performResults.executionResultCount++;
executionResult=result.getExecutionResult();
break;
case SKIPPED_CONDITION:
performResults.skippedConditionCount++;
break;
case SKIPPED_DEPENDENCY:
performResults.skippedDependencyCount++;
break;
default :
logger.error("String_Node_Str",result.getType());
}
TransformationUtility source=result.getSource();
if (source instanceof TransformationOperation) {
operationsCount++;
if (executionResult != null) {
TOExecutionResult toExecutionResult=(TOExecutionResult)executionResult;
switch (toExecutionResult.getType()) {
case NO_OP:
executionResults.operations.noOpCount++;
break;
case SUCCESS:
executionResults.operations.successCount++;
break;
case WARNING:
executionResults.operations.warningCount++;
break;
case ERROR:
executionResults.operations.errorCount++;
break;
default :
logger.error("String_Node_Str",result.getType());
}
}
}
 else {
utilitiesCount++;
if (executionResult != null) {
TUExecutionResult tuExecutionResult=(TUExecutionResult)executionResult;
switch (tuExecutionResult.getType()) {
case NULL:
executionResults.utilities.nullCount++;
break;
case VALUE:
executionResults.utilities.valueCount++;
break;
case WARNING:
executionResults.utilities.warningCount++;
break;
case ERROR:
executionResults.utilities.errorCount++;
break;
default :
logger.error("String_Node_Str",result.getType());
}
}
}
}

Fixed version (ground truth):
void registerResult(PerformResult result){
  ExecutionResult executionResult=null;
switch (result.getType()) {
case ERROR:
    performResults.errorCount++;
  break;
case EXECUTION_RESULT:
performResults.executionResultCount++;
executionResult=result.getExecutionResult();
break;
case SKIPPED_CONDITION:
performResults.skippedConditionCount++;
break;
case SKIPPED_DEPENDENCY:
performResults.skippedDependencyCount++;
break;
default :
logger.error("String_Node_Str",result.getType());
break;
}
TransformationUtility source=result.getSource();
if (source instanceof TransformationOperation) {
operationsCount++;
if (executionResult != null) {
TOExecutionResult toExecutionResult=(TOExecutionResult)executionResult;
switch (toExecutionResult.getType()) {
case NO_OP:
executionResults.operations.noOpCount++;
break;
case SUCCESS:
executionResults.operations.successCount++;
break;
case WARNING:
executionResults.operations.warningCount++;
break;
case ERROR:
executionResults.operations.errorCount++;
break;
default :
logger.error("String_Node_Str",result.getType());
break;
}
}
}
 else {
utilitiesCount++;
if (executionResult != null) {
TUExecutionResult tuExecutionResult=(TUExecutionResult)executionResult;
switch (tuExecutionResult.getType()) {
case NULL:
executionResults.utilities.nullCount++;
break;
case VALUE:
executionResults.utilities.valueCount++;
break;
case WARNING:
executionResults.utilities.warningCount++;
break;
case ERROR:
executionResults.utilities.errorCount++;
break;
default :
logger.error("String_Node_Str",result.getType());
break;
}
}
}
}
Program: 39590
Project: 39590
Buggy source:
@Override protected ExecutionResult execution(File transformedAppFolder,TransformationContext transformationContext){
  executed=true;
  try {
    attributeValue=(VT)transformationContext.get(attributeName);
    return TUExecutionResult.nullResult(this);
  }
 catch (  IllegalArgumentException|ClassCastException ex) {
    return TUExecutionResult.error(this,ex);
  }
}

Fixed version (ground truth):
@Override protected ExecutionResult execution(File transformedAppFolder,TransformationContext transformationContext){
  executed=true;
  try {
    attributeValue=(T)transformationContext.get(attributeName);
    return TUExecutionResult.nullResult(this);
  }
 catch (  IllegalArgumentException|ClassCastException ex) {
    return TUExecutionResult.error(this,ex);
  }
}
Program: 39591
Project: 39591
Buggy source:
/** 
 * Returns the value of the transformation context attribute specified earlier. If the attribute value is null, null is returned. If this method is called prior to the execution of this transformation utility, an   {@link IllegalStateException} is thrown.
 * @return the value of the transformation context attribute specified earlier
 */
public VT getAttributeValue(){
  if (!executed) {
    throw new IllegalStateException(getName() + "String_Node_Str");
  }
  return attributeValue;
}

Fixed version (ground truth):
/** 
 * Returns the value of the transformation context attribute specified earlier. If the attribute value is null, null is returned. If this method is called prior to the execution of this transformation utility, an   {@link IllegalStateException} is thrown.
 * @return the value of the transformation context attribute specified earlier
 */
public T getAttributeValue(){
  if (!executed) {
    throw new IllegalStateException(getName() + "String_Node_Str");
  }
  return attributeValue;
}
Program: 39592
Project: 39592
Buggy source:
/** 
 * Set the name of the transformation context attribute that refers to the file to be compared against the baseline file, which is set by regular   {@link com.paypal.butterfly.extensions.api.TransformationUtility}methods, like   {@link #relative(String)} or {@link #absolute(String)}
 * @param attribute the name of the transformation context attributethat refers to the file to be compared against the baseline file
 * @return this utility condition instance
 */
public DUC setAttribute(String attribute){
  checkForBlankString("String_Node_Str",attribute);
  this.attribute=attribute;
  return (DUC)this;
}

Fixed version (ground truth):
/** 
 * Set the name of the transformation context attribute that refers to the file to be compared against the baseline file, which is set by regular   {@link com.paypal.butterfly.extensions.api.TransformationUtility}methods, like   {@link #relative(String)} or {@link #absolute(String)}
 * @param attribute the name of the transformation context attributethat refers to the file to be compared against the baseline file
 * @return this utility condition instance
 */
public T setAttribute(String attribute){
  checkForBlankString("String_Node_Str",attribute);
  this.attribute=attribute;
  return (T)this;
}
Program: 39593
Project: 39593
Buggy source:
private RT setSource(S source){
  if (source == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.source=source;
  return (RT)this;
}

Fixed version (ground truth):
private R setSource(S source){
  if (source == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.source=source;
  return (R)this;
}
Program: 39594
Project: 39594
Buggy source:
protected RT setType(T type){
  if (type == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.type=type;
  return (RT)this;
}

Fixed version (ground truth):
protected R setType(T type){
  if (type == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.type=type;
  return (R)this;
}
Program: 39595
Project: 39595
Buggy source:
public RT setDetails(String details){
  this.details=details;
  return (RT)this;
}

Fixed version (ground truth):
public R setDetails(String details){
  this.details=details;
  return (R)this;
}
Program: 39596
Project: 39596
Buggy source:
/** 
 * Add a new warning associated with this result. Warnings never imply the result is non-successful, only errors do
 * @param warning the warning to be added
 * @return this object
 */
public RT addWarning(Exception warning){
  warnings.add(warning);
  changeTypeOnWarning();
  return (RT)this;
}

Fixed version (ground truth):
/** 
 * Add a new warning associated with this result. Warnings never imply the result is non-successful, only errors do
 * @param warning the warning to be added
 * @return this object
 */
public R addWarning(Exception warning){
  warnings.add(warning);
  changeTypeOnWarning();
  return (R)this;
}
Program: 39597
Project: 39597
Buggy source:
/** 
 * Set the exception associated with this result. This exception can only be set if the result type allows it. If that is not the case, an   {@link IllegalArgumentException}will be thrown
 * @param exception associated with the execution result
 * @return this object
 */
protected RT setException(Exception exception){
  if (exception == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (!isExceptionType()) {
    throw new IllegalArgumentException("String_Node_Str" + type);
  }
  this.exception=exception;
  return (RT)this;
}

Fixed version (ground truth):
/** 
 * Set the exception associated with this result. This exception can only be set if the result type allows it. If that is not the case, an   {@link IllegalArgumentException}will be thrown
 * @param exception associated with the execution result
 * @return this object
 */
protected R setException(Exception exception){
  if (exception == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (!isExceptionType()) {
    throw new IllegalArgumentException("String_Node_Str" + type);
  }
  this.exception=exception;
  return (R)this;
}
Program: 39598
Project: 39598
Buggy source:
/** 
 * To Test Transformation with -s options
 * @throws IOException
 * @throws ButterflyException
 */
@Test public void testTransformationWithShortcut() throws IOException, ButterflyException {
  Mockito.when(facade.getRegisteredExtension()).thenReturn(new SampleExtension());
  String arguments[]={sampleAppFolder.getAbsolutePath(),"String_Node_Str","String_Node_Str"};
  butterflyCli.setOptionSet(arguments);
  int status=butterflyCli.run().getExitStatus();
  Assert.assertEquals(status,0);
  verify(facade,times(1)).transform(eq(sampleAppFolder),eq(SampleTransformationTemplate.class),eq(new Configuration(null,false)));
}

Fixed version (ground truth):
/** 
 * To Test Transformation with -s options
 * @throws IOException
 * @throws ButterflyException
 */
@Test public void testTransformationWithShortcut() throws IOException, ButterflyException {
  when(facade.getRegisteredExtension()).thenReturn(new SampleExtension());
  String arguments[]={sampleAppFolder.getAbsolutePath(),"String_Node_Str","String_Node_Str"};
  butterflyCli.setOptionSet(arguments);
  int status=butterflyCli.run().getExitStatus();
  Assert.assertEquals(status,0);
  verify(facade,times(1)).transform(eq(sampleAppFolder),eq(SampleTransformationTemplate.class),eq(new Configuration(null,false)));
}
Program: 39599
Project: 39599
Buggy source:
@Test public void testAutomaticResolution() throws IOException, ButterflyException {
  Mockito.doReturn(SampleTransformationTemplate.class).when(facade).automaticResolution(Mockito.any(File.class));
  String arguments[]={sampleAppFolder.getAbsolutePath()};
  butterflyCli.setOptionSet(arguments);
  int status=butterflyCli.run().getExitStatus();
  verify(facade,times(1)).automaticResolution(eq(sampleAppFolder));
  verify(facade,times(1)).transform(eq(sampleAppFolder),eq(SampleTransformationTemplate.class),eq(new Configuration(null,false)));
  Assert.assertEquals(status,0);
}

Fixed version (ground truth):
@Test public void testAutomaticResolution() throws IOException, ButterflyException {
  doReturn(SampleTransformationTemplate.class).when(facade).automaticResolution(any(File.class));
  String arguments[]={sampleAppFolder.getAbsolutePath()};
  butterflyCli.setOptionSet(arguments);
  int status=butterflyCli.run().getExitStatus();
  verify(facade,times(1)).automaticResolution(eq(sampleAppFolder));
  verify(facade,times(1)).transform(eq(sampleAppFolder),eq(SampleTransformationTemplate.class),eq(new Configuration(null,false)));
  Assert.assertEquals(status,0);
}
Program: 39600
Project: 39600
Buggy source:
/** 
 * To Test Transformation with -t and -s options. Option -s should be ignored, since -t was also provided
 * @throws IOException
 * @throws ButterflyException
 */
@Test public void testTransformationWithShortcutButIgnoringIt() throws IOException, ButterflyException {
  Mockito.when(facade.getRegisteredExtension()).thenReturn(new SampleExtension());
  String arguments[]={sampleAppFolder.getAbsolutePath(),"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  butterflyCli.setOptionSet(arguments);
  int status=butterflyCli.run().getExitStatus();
  Assert.assertEquals(status,0);
  verify(facade,times(1)).transform(eq(sampleAppFolder),eq(SampleTransformationTemplate.class),eq(new Configuration(null,true)));
  verify(facade,times(0)).getRegisteredExtension();
}

Fixed version (ground truth):
/** 
 * To Test Transformation with -t and -s options. Option -s should be ignored, since -t was also provided
 * @throws IOException
 * @throws ButterflyException
 */
@Test public void testTransformationWithShortcutButIgnoringIt() throws IOException, ButterflyException {
  when(facade.getRegisteredExtension()).thenReturn(new SampleExtension());
  String arguments[]={sampleAppFolder.getAbsolutePath(),"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  butterflyCli.setOptionSet(arguments);
  int status=butterflyCli.run().getExitStatus();
  Assert.assertEquals(status,0);
  verify(facade,times(1)).transform(eq(sampleAppFolder),eq(SampleTransformationTemplate.class),eq(new Configuration(null,true)));
  verify(facade,times(0)).getRegisteredExtension();
}
Program: 39601
Project: 39601
Buggy source:
@BeforeMethod public void beforeTest() throws ButterflyException {
  TransformationResult mockResult=Mockito.mock(TransformationResult.class);
  Mockito.when(facade.transform(Mockito.any(File.class),Mockito.any(String.class))).thenReturn(mockResult);
  Mockito.when(facade.transform(Mockito.any(File.class),Mockito.any(String.class),Mockito.any(Configuration.class))).thenReturn(mockResult);
  Mockito.when(facade.transform(Mockito.any(File.class),Mockito.any(Class.class))).thenReturn(mockResult);
  Mockito.when(facade.transform(Mockito.any(File.class),Mockito.any(Class.class),Mockito.any(Configuration.class))).thenReturn(mockResult);
  Mockito.when(facade.transform(Mockito.any(File.class),Mockito.any(UpgradePath.class))).thenReturn(mockResult);
  Mockito.when(facade.transform(Mockito.any(File.class),Mockito.any(UpgradePath.class),Mockito.any(Configuration.class))).thenReturn(mockResult);
  File file=new File("String_Node_Str");
  Mockito.when(mockResult.getTransformedApplicationLocation()).thenReturn(file);
  Mockito.when(mockResult.getManualInstructionsFile()).thenReturn(file);
  sampleAppFolder=new File(this.getClass().getResource("String_Node_Str").getFile());
}

Fixed version (ground truth):
@BeforeMethod public void beforeTest() throws ButterflyException {
  TransformationResult mockResult=mock(TransformationResult.class);
  when(facade.transform(any(File.class),any(String.class))).thenReturn(mockResult);
  when(facade.transform(any(File.class),any(String.class),any(Configuration.class))).thenReturn(mockResult);
  when(facade.transform(any(File.class),any(Class.class))).thenReturn(mockResult);
  when(facade.transform(any(File.class),any(Class.class),any(Configuration.class))).thenReturn(mockResult);
  when(facade.transform(any(File.class),any(UpgradePath.class))).thenReturn(mockResult);
  when(facade.transform(any(File.class),any(UpgradePath.class),any(Configuration.class))).thenReturn(mockResult);
  File file=new File("String_Node_Str");
  when(mockResult.getTransformedApplicationLocation()).thenReturn(file);
  when(mockResult.getManualInstructionsFile()).thenReturn(file);
  sampleAppFolder=new File(this.getClass().getResource("String_Node_Str").getFile());
}
Program: 39602
Project: 39602
Buggy source:
void registerResult(PerformResult result){
  ExecutionResult executionResult=null;
switch (result.getType()) {
case ERROR:
    performResults.errorCount++;
  break;
case EXECUTION_RESULT:
performResults.executionResultCount++;
executionResult=result.getExecutionResult();
break;
case SKIPPED_CONDITION:
performResults.skippedConditionCount++;
break;
case SKIPPED_DEPENDENCY:
performResults.skippedDependencyCount++;
break;
}
TransformationUtility source=result.getSource();
if (source instanceof TransformationOperation) {
operationsCount++;
if (executionResult != null) {
TOExecutionResult toExecutionResult=(TOExecutionResult)executionResult;
switch (toExecutionResult.getType()) {
case NO_OP:
executionResults.operations.noOpCount++;
break;
case SUCCESS:
executionResults.operations.successCount++;
break;
case WARNING:
executionResults.operations.warningCount++;
break;
case ERROR:
executionResults.operations.errorCount++;
break;
}
}
}
 else {
utilitiesCount++;
if (executionResult != null) {
TUExecutionResult tuExecutionResult=(TUExecutionResult)executionResult;
switch (tuExecutionResult.getType()) {
case NULL:
executionResults.utilities.nullCount++;
break;
case VALUE:
executionResults.utilities.valueCount++;
break;
case WARNING:
executionResults.utilities.warningCount++;
break;
case ERROR:
executionResults.utilities.errorCount++;
break;
}
}
}
}

Fixed version (ground truth):
void registerResult(PerformResult result){
  ExecutionResult executionResult=null;
switch (result.getType()) {
case ERROR:
    performResults.errorCount++;
  break;
case EXECUTION_RESULT:
performResults.executionResultCount++;
executionResult=result.getExecutionResult();
break;
case SKIPPED_CONDITION:
performResults.skippedConditionCount++;
break;
case SKIPPED_DEPENDENCY:
performResults.skippedDependencyCount++;
break;
default :
logger.error("String_Node_Str",result.getType());
}
TransformationUtility source=result.getSource();
if (source instanceof TransformationOperation) {
operationsCount++;
if (executionResult != null) {
TOExecutionResult toExecutionResult=(TOExecutionResult)executionResult;
switch (toExecutionResult.getType()) {
case NO_OP:
executionResults.operations.noOpCount++;
break;
case SUCCESS:
executionResults.operations.successCount++;
break;
case WARNING:
executionResults.operations.warningCount++;
break;
case ERROR:
executionResults.operations.errorCount++;
break;
default :
logger.error("String_Node_Str",result.getType());
}
}
}
 else {
utilitiesCount++;
if (executionResult != null) {
TUExecutionResult tuExecutionResult=(TUExecutionResult)executionResult;
switch (tuExecutionResult.getType()) {
case NULL:
executionResults.utilities.nullCount++;
break;
case VALUE:
executionResults.utilities.valueCount++;
break;
case WARNING:
executionResults.utilities.warningCount++;
break;
case ERROR:
executionResults.utilities.errorCount++;
break;
default :
logger.error("String_Node_Str",result.getType());
}
}
}
}
Program: 39603
Project: 39603
Buggy source:
@Test(expectedExceptions=InternalException.class,expectedExceptionsMessageRegExp="String_Node_Str" + "String_Node_Str") public void testTransformWithAbstractTemplate() throws ButterflyException {
  butterflyFacadeImpl.transform(applicationFolder,"String_Node_Str");
}

Fixed version (ground truth):
@Test(expectedExceptions=InternalException.class,expectedExceptionsMessageRegExp="String_Node_Str") public void testTransformWithAbstractTemplate() throws ButterflyException {
  butterflyFacadeImpl.transform(applicationFolder,"String_Node_Str");
}
Program: 39604
Project: 39604
Buggy source:
@Test public void testTransformWithValidTemplate() throws ButterflyException {
  TemplateTransformation templateTransformation=new TemplateTransformation(new Application(applicationFolder),new SampleTransformationTemplate(),new Configuration());
  butterflyFacadeImpl.transform(applicationFolder,"String_Node_Str");
  verify(transformationEngine,times(1)).perform((TemplateTransformation)anyObject());
}

Fixed version (ground truth):
@Test public void testTransformWithValidTemplate() throws ButterflyException {
  butterflyFacadeImpl.transform(applicationFolder,"String_Node_Str");
  verify(transformationEngine,times(1)).perform((TemplateTransformation)anyObject());
}
Program: 39605
Project: 39605
Buggy source:
@Override protected final TO setSaveResult(boolean saveResult){
  throw new UnsupportedOperationException("String_Node_Str");
}

Fixed version (ground truth):
@Override protected final T setSaveResult(boolean saveResult){
  throw new UnsupportedOperationException("String_Node_Str");
}
Program: 39606
Project: 39606
Buggy source:
public int getOrder(){
  return order;
}

Fixed version (ground truth):
/** 
 * Returns the execution order for this utility on its parent. Value -1 means it has not been registered to any parent yet, while 1 means first.
 * @return the execution order for this utility on its parent
 */
public int getOrder(){
  return order;
}
Program: 39608
Project: 39608
Buggy source:
private Model createModel(File pomFile){
  FileInputStream fileInputStream=null;
  Exception ex=null;
  Model model=null;
  try {
    MavenXpp3Reader reader=new MavenXpp3Reader();
    fileInputStream=new FileInputStream(pomFile);
    model=reader.read(fileInputStream);
    if (model.getGroupId() == null)     model.setGroupId(model.getParent().getGroupId());
    if (model.getVersion() == null)     model.setVersion(model.getParent().getVersion());
    model.setPomFile(pomFile);
  }
 catch (  IOException|XmlPullParserException e) {
    ex=e;
    String exceptionMessage=String.format("String_Node_Str",pomFile.getAbsolutePath());
    throw new TransformationUtilityException(exceptionMessage,ex);
  }
 finally {
    if (fileInputStream != null)     try {
      fileInputStream.close();
    }
 catch (    IOException e) {
      if (ex != null)       ex.addSuppressed(e);
    }
  }
  return model;
}

Fixed version (ground truth):
private Model createModel(File pomFile){
  FileInputStream fileInputStream=null;
  Exception ex=null;
  Model model=null;
  try {
    MavenXpp3Reader reader=new MavenXpp3Reader();
    fileInputStream=new FileInputStream(pomFile);
    model=reader.read(fileInputStream);
    if (model.getGroupId() == null)     model.setGroupId(model.getParent().getGroupId());
    if (model.getVersion() == null)     model.setVersion(model.getParent().getVersion());
    model.setPomFile(pomFile);
  }
 catch (  Exception e) {
    ex=e;
    String exceptionMessage=String.format("String_Node_Str",pomFile.getAbsolutePath());
    throw new TransformationUtilityException(exceptionMessage,ex);
  }
 finally {
    if (fileInputStream != null)     try {
      fileInputStream.close();
    }
 catch (    IOException e) {
      if (ex != null)       ex.addSuppressed(e);
    }
  }
  return model;
}
Program: 39610
Project: 39610
Buggy source:
private static void printExtensionsList(ButterflyFacade butterflyFacade) throws IllegalAccessException, InstantiationException {
  Extension extension=butterflyFacade.getRegisteredExtension();
  if (extension == null) {
    logger.info("String_Node_Str");
    return;
  }
  logger.info("String_Node_Str");
  Class<? extends TransformationTemplate> template;
  int shortcut=1;
  String version=(StringUtils.isEmpty(extension.getVersion()) ? "String_Node_Str" : String.format("String_Node_Str",extension.getVersion()));
  System.out.printf("String_Node_Str",extension,extension.getDescription(),version);
  for (  Object templateObj : extension.getTemplateClasses().toArray()) {
    template=(Class<? extends TransformationTemplate>)templateObj;
    System.out.printf("String_Node_Str",shortcut++,ExtensionTypeInitial.getFromClass(template),template.getName(),template.newInstance().getDescription());
  }
}

Fixed version (ground truth):
private static void printExtensionsList(ButterflyFacade butterflyFacade) throws IllegalAccessException, InstantiationException {
  Extension extension=butterflyFacade.getRegisteredExtension();
  if (extension == null) {
    logger.info("String_Node_Str");
    return;
  }
  logger.info("String_Node_Str");
  Class<? extends TransformationTemplate> template;
  int shortcut=1;
  String version=(StringUtils.isEmpty(extension.getVersion()) ? "String_Node_Str" : String.format("String_Node_Str",extension.getVersion()));
  logger.info("String_Node_Str");
  logger.info("String_Node_Str",extension,extension.getDescription(),version);
  for (  Object templateObj : extension.getTemplateClasses().toArray()) {
    template=(Class<? extends TransformationTemplate>)templateObj;
    logger.info("String_Node_Str",shortcut++,ExtensionTypeInitial.getFromClass(template),template.getName(),template.newInstance().getDescription());
  }
}
Program: 39613
Project: 39613
Buggy source:
@Override protected int getNumberOfTypes(CompilationUnit compilationUnit){
  ClassOrInterfaceDeclaration type=(ClassOrInterfaceDeclaration)compilationUnit.getType(0);
  NodeList<ClassOrInterfaceType> extendedTypes=type.getExtendedTypes();
  return extendedTypes.size();
}

Fixed version (ground truth):
@Override protected int getNumberOfTypes(CompilationUnit compilationUnit){
  TypeDeclaration<?> typeDeclaration=compilationUnit.getType(0);
  if (typeDeclaration instanceof ClassOrInterfaceDeclaration) {
    ClassOrInterfaceDeclaration type=(ClassOrInterfaceDeclaration)compilationUnit.getType(0);
    NodeList<ClassOrInterfaceType> extendedTypes=type.getExtendedTypes();
    return extendedTypes.size();
  }
  return 0;
}
Program: 39614
Project: 39614
Buggy source:
public static void main(String... arguments) throws IOException {
  setButterflyHome();
  setLogFileName(arguments);
  setBanner();
  ConfigurableApplicationContext applicationContext=SpringApplication.run(ButterflyCliApp.class,arguments);
  ButterflyCliRunner butterflyCliRunner=applicationContext.getBean(ButterflyCliRunner.class);
  ButterflyCliRun run=butterflyCliRunner.run();
  if (optionSet != null && optionSet.has(CLI_OPTION_RESULT_FILE)) {
    run.setInputArguments(arguments);
    writeResultFile(run);
  }
  System.exit(run.getExitStatus());
}

Fixed version (ground truth):
public static void main(String... arguments) throws IOException {
  setButterflyHome();
  setLogFileName(arguments);
  logger=LoggerFactory.getLogger(ButterflyCliApp.class);
  setBanner();
  ConfigurableApplicationContext applicationContext=SpringApplication.run(ButterflyCliApp.class,arguments);
  ButterflyCliRunner butterflyCliRunner=applicationContext.getBean(ButterflyCliRunner.class);
  ButterflyCliRun run=butterflyCliRunner.run();
  if (optionSet != null && optionSet.has(CLI_OPTION_RESULT_FILE)) {
    run.setInputArguments(arguments);
    writeResultFile(run);
  }
  System.exit(run.getExitStatus());
}
Program: 39615
Project: 39615
Buggy source:
/** 
 * Sets one or more transformation context attributes that hold list of Files which the condition should perform against. If more than one attribute is specified, all list of files will be combined into a single one.</br>
 * @param filesAttributes one or more transformation context attributes that hold listof Files which the condition should perform against
 * @return this transformation utility object
 */
public MultipleConditions setFiles(String... filesAttributes){
  this.filesAttributes=filesAttributes;
  return this;
}

Fixed version (ground truth):
/** 
 * Sets one or more transformation context attributes that hold list of Files which the condition should perform against. If more than one attribute is specified, all list of files will be combined into a single one.<br>
 * @param filesAttributes one or more transformation context attributes that hold listof Files which the condition should perform against
 * @return this transformation utility object
 */
public MultipleConditions setFiles(String... filesAttributes){
  this.filesAttributes=filesAttributes;
  return this;
}
Program: 39616
Project: 39616
Buggy source:
/** 
 * This means the utility has not been executed because one or more of its dependencies "failed". See   {@link TransformationUtility#dependsOn(String)}for the dependency failure criteria definition
 * @see {@link TransformationUtility#dependsOn(String)}
 */
public static PerformResult skippedDependency(TransformationUtility transformationUtility,String details){
  PerformResult result=new PerformResult(transformationUtility,Type.SKIPPED_DEPENDENCY,details);
  return result;
}

Fixed version (ground truth):
/** 
 * This means the utility has not been executed because one or more of its dependencies "failed". See   {@link TransformationUtility#dependsOn(String)}for the dependency failure criteria definition
 */
public static PerformResult skippedDependency(TransformationUtility transformationUtility,String details){
  PerformResult result=new PerformResult(transformationUtility,Type.SKIPPED_DEPENDENCY,details);
  return result;
}
Program: 39617
Project: 39617
Buggy source:
/** 
 * This method is used to notify subclasses that the result type might have to change due to the addition of a warning. </br> Usually it should change from a successful type to a warning type. In case the result is an error kind of type, then it should remain as is.
 */
protected abstract void changeTypeOnWarning();

Fixed version (ground truth):
/** 
 * This method is used to notify subclasses that the result type might have to change due to the addition of a warning. <br> Usually it should change from a successful type to a warning type. In case the result is an error kind of type, then it should remain as is.
 */
protected abstract void changeTypeOnWarning();
Program: 39618
Project: 39618
Buggy source:
/** 
 * Set this transformation utility instance name. If not set, a default name will be assigned at the time it is added to a parent.
 * @param name
 * @return this transformation utility
 */
protected TU setName(String name){
  if (StringUtils.isBlank(name)) {
    throw new TransformationDefinitionException(name + "String_Node_Str");
  }
  this.name=name;
  return (TU)this;
}

Fixed version (ground truth):
/** 
 * Set this transformation utility instance name. If not set, a default name will be assigned at the time it is added to a parent.
 * @param name transformation utility instance name
 * @return this transformation utility
 */
protected TU setName(String name){
  if (StringUtils.isBlank(name)) {
    throw new TransformationDefinitionException(name + "String_Node_Str");
  }
  this.name=name;
  return (TU)this;
}
Program: 39620
Project: 39620
Buggy source:
/** 
 * Check if value is a blank String, if it is, then a  {@link TransformationDefinitionException) is thown.<br> This check is used for mandatory properties where value cannot be null neither an empty string.}
 * @param name the name of the property
 * @param value the value to be verified
 * @throws TransformationDefinitionException if check fails
 */
protected static void checkForBlankString(String name,String value) throws TransformationDefinitionException {
  if (StringUtils.isBlank(value)) {
    throw new TransformationDefinitionException(name + "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Check if value is a blank String, if it is, then a  {@link TransformationDefinitionException} is thrown.<br> This check is used for mandatory properties where value cannot be null neither an empty string.
 * @param name the name of the property
 * @param value the value to be verified
 * @throws TransformationDefinitionException if check fails
 */
protected static void checkForBlankString(String name,String value) throws TransformationDefinitionException {
  if (StringUtils.isBlank(value)) {
    throw new TransformationDefinitionException(name + "String_Node_Str");
  }
}
Program: 39621
Project: 39621
Buggy source:
/** 
 * Returns an absolute path to the file or folder the transformation utility is suppose to perform against
 * @param transformedAppFolder
 * @return an absolute path to the file or folder the transformationutility is suppose to perform against
 */
protected final File getAbsoluteFile(File transformedAppFolder,TransformationContext transformationContext) throws TransformationUtilityException {
  if (absoluteFile == null) {
    setAbsoluteFile(transformedAppFolder,transformationContext);
  }
  return absoluteFile;
}

Fixed version (ground truth):
/** 
 * Returns an absolute path to the file or folder the transformation utility is supposed to perform against
 * @param transformedAppFolder
 * @param transformationContext
 * @return an absolute path to the file or folder the transformationutility is suppose to perform against
 */
protected final File getAbsoluteFile(File transformedAppFolder,TransformationContext transformationContext) throws TransformationUtilityException {
  if (absoluteFile == null) {
    setAbsoluteFile(transformedAppFolder,transformationContext);
  }
  return absoluteFile;
}
Program: 39622
Project: 39622
Buggy source:
/** 
 * @see {@link #isSaveResult()}
 * @param saveResult
 */
protected TU setSaveResult(boolean saveResult){
  this.saveResult=saveResult;
  return (TU)this;
}

Fixed version (ground truth):
/** 
 * Sets whether or not the value produced by the transformation utility execution, and also its result object as a whole, should both be saved in the transformation context object. See also   {@link #isSaveResult()}.
 * @param saveResult if the value produced by the transformation utility execution,and also its result object as a whole, should both be saved in the transformation context object
 */
protected TU setSaveResult(boolean saveResult){
  this.saveResult=saveResult;
  return (TU)this;
}
Program: 39624
Project: 39624
Buggy source:
/** 
 * Returns dependencies
 * @see {@link #dependsOn(String)}
 * @return
 */
protected final List<String> getDependencies(){
  if (dependencies != null) {
    return Collections.unmodifiableList(Arrays.asList(dependencies));
  }
  return Collections.emptyList();
}

Fixed version (ground truth):
/** 
 * Returns an unmodifiable list of names of utilities this utility instance depends on. See also   {@link #dependsOn(String)}.
 * @return an unmodifiable list of names of utilities this utility instance depends on
 */
protected final List<String> getDependencies(){
  if (dependencies != null) {
    return Collections.unmodifiableList(Arrays.asList(dependencies));
  }
  return Collections.emptyList();
}
Program: 39625
Project: 39625
Buggy source:
/** 
 * Return true only if a file has been set explicitly either via   {@link #relative(String)} or {@link #absolute(String).}If set via   {@link #relative(String)} it will only return true if set to anything other than "", which would mean the root of the application.
 * @return
 */
public final boolean wasFileExplicitlySet(){
  return !(StringUtils.isBlank(getRelativePath()) && getAbsoluteFileFromContextAttribute() == null);
}

Fixed version (ground truth):
/** 
 * Return true only if a file has been set explicitly either via   {@link #relative(String)} or {@link #absolute(String)}. If set via   {@link #relative(String)} it will only return true if set to anything other than "", which would mean the root of the application.
 * @return
 */
public final boolean wasFileExplicitlySet(){
  return !(StringUtils.isBlank(getRelativePath()) && getAbsoluteFileFromContextAttribute() == null);
}
Program: 39626
Project: 39626
Buggy source:
/** 
 * Same as   {@link #absolute(String,String)}, however, the absolute file is set with an additional relative path, which is defined via parameter  {@code additionalRelativePath}. This method is powerful because it allows setting the absolute file using a portion of the location (absolute) that is only known during transformation time, plus also a second portion of the location (relative) that is already known during definition time
 * @see {@link #absolute(String,String)}
 * @param contextAttributeName the name of the transformation context attribute whosevalue will be set as the absolute file right before execution
 * @param additionalRelativePath an additional relative path to be added to the absolutefile coming from the transformation context. The path separator will be normalized, similar to what happens in  {@link #relative(String)}
 * @return this transformation utility
 * @see {@link #getAbsoluteFile(File,TransformationContext)}
 * @see {@link #relative(String)}
 * @see {@link #getRelativePath()}
 */
public TU absolute(String contextAttributeName,String additionalRelativePath){
  absoluteFileFromContextAttribute=contextAttributeName;
  this.additionalRelativePath=normalizeRelativePathSeparator(additionalRelativePath);
  return (TU)this;
}

Fixed version (ground truth):
/** 
 * Same as   {@link #absolute(String,String)}, however, the absolute file is set with an additional relative path, which is defined via parameter  {@code additionalRelativePath}. This method is powerful because it allows setting the absolute file using a portion of the location (absolute) that is only known during transformation time, plus also a second portion of the location (relative) that is already known during definition time <br> See also   {@link #getAbsoluteFile(File,TransformationContext)},   {@link #relative(String)}and   {@link #getRelativePath()}
 * @param contextAttributeName the name of the transformation context attribute whosevalue will be set as the absolute file right before execution
 * @param additionalRelativePath an additional relative path to be added to the absolutefile coming from the transformation context. The path separator will be normalized, similar to what happens in  {@link #relative(String)}
 * @return this transformation utility
 */
public TU absolute(String contextAttributeName,String additionalRelativePath){
  absoluteFileFromContextAttribute=contextAttributeName;
  this.additionalRelativePath=normalizeRelativePathSeparator(additionalRelativePath);
  return (TU)this;
}