Program: 186114
Project: 186114
Buggy source:
@Override public Statement apply(final Statement base,final FrameworkMethod method,final Object testObject){
  return new Statement(){
    @Override public void evaluate() throws Throwable {
      target=testObject;
      defaultDataSetLocationResolver=new DefaultDataSetLocationResolver(testObject.getClass());
      UsingDataSet usingDataSet=getUsingDataSetAnnotation();
      if (isTestAnnotatedWithDataSet(usingDataSet)) {
        loadDataSet(usingDataSet,method);
      }
      injectAnnotationProcessor.processInjectAnnotation(testObject.getClass(),target,getDatabaseOperation().connectionManager());
      base.evaluate();
      ShouldMatchDataSet shouldMatchDataSet=getShouldMatchDataSetAnnotation();
      if (isTestAnnotatedWithExpectedDataSet(shouldMatchDataSet)) {
        assertExpectation(shouldMatchDataSet);
      }
    }
    private ShouldMatchDataSet getShouldMatchDataSetAnnotation(){
      ShouldMatchDataSet shouldMatchDataSet=method.getAnnotation(ShouldMatchDataSet.class);
      if (!isTestAnnotatedWithExpectedDataSet(shouldMatchDataSet)) {
        Class<?> testClass=target.getClass();
        shouldMatchDataSet=testClass.getAnnotation(ShouldMatchDataSet.class);
      }
      return shouldMatchDataSet;
    }
    private UsingDataSet getUsingDataSetAnnotation(){
      UsingDataSet usingDataSet=method.getAnnotation(UsingDataSet.class);
      if (!isTestAnnotatedWithDataSet(usingDataSet)) {
        Class<?> testClass=target.getClass();
        usingDataSet=testClass.getAnnotation(UsingDataSet.class);
      }
      return usingDataSet;
    }
    private void assertExpectation(    ShouldMatchDataSet shouldMatchDataSet) throws IOException {
      InputStream scriptContent=loadExpectedContentScript(method,shouldMatchDataSet);
      if (isNotEmptyStream(scriptContent)) {
        getDatabaseOperation().databaseIs(scriptContent);
      }
 else {
        final String suffix=EXPECTED_RESERVED_WORD + "String_Node_Str" + getWorkingExtension();
        final String defaultClassLocation=DefaultClasspathLocationBuilder.defaultClassAnnotatedClasspathLocation(method);
        final String defaultMethodLocation=DefaultClasspathLocationBuilder.defaultMethodAnnotatedClasspathLocation(method,defaultClassLocation,suffix);
        throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + defaultClassLocation + suffix+ "String_Node_Str"+ defaultMethodLocation);
      }
    }
    private InputStream loadExpectedContentScript(    final FrameworkMethod method,    ShouldMatchDataSet shouldMatchDataSet) throws IOException {
      String location=shouldMatchDataSet.location();
      InputStream scriptContent=null;
      if (isNotEmptyString(location)) {
        scriptContent=loadExpectedResultFromLocationAttribute(location);
      }
 else {
        SelectiveMatcher[] selectiveMatchers=shouldMatchDataSet.withSelectiveMatcher();
        SelectiveMatcher requiredSelectiveMatcher=findSelectiveMatcherByConnectionIdentifier(selectiveMatchers);
        if (isSelectiveMatchersDefined(requiredSelectiveMatcher)) {
          scriptContent=loadExpectedResultFromLocationAttribute(requiredSelectiveMatcher.location());
        }
 else {
          scriptContent=loadExpectedResultFromDefaultLocation(method,shouldMatchDataSet);
        }
      }
      return scriptContent;
    }
    private boolean isSelectiveMatchersDefined(    SelectiveMatcher requiredSelectiveMatcher){
      return requiredSelectiveMatcher != null;
    }
    private SelectiveMatcher findSelectiveMatcherByConnectionIdentifier(    SelectiveMatcher[] selectiveMatchers){
      return selectFirst(selectiveMatchers,having(on(SelectiveMatcher.class).identifier(),equalTo(identifier)).and(having(on(SelectiveMatcher.class).location(),notNullValue())));
    }
    private InputStream loadExpectedResultFromDefaultLocation(    final FrameworkMethod method,    ShouldMatchDataSet shouldMatchDataSet) throws IOException {
      InputStream scriptContent=null;
      String defaultLocation=defaultDataSetLocationResolver.resolveDefaultDataSetLocation(shouldMatchDataSet,method,EXPECTED_RESERVED_WORD + "String_Node_Str" + getWorkingExtension());
      if (defaultLocation != null) {
        scriptContent=loadExpectedResultFromLocationAttribute(defaultLocation);
      }
      return scriptContent;
    }
    private InputStream loadExpectedResultFromLocationAttribute(    String location) throws IOException {
      InputStream scriptContent;
      scriptContent=IOUtils.getStreamFromClasspathBaseResource(defaultDataSetLocationResolver.getResourceBase(),location);
      return scriptContent;
    }
    private void loadDataSet(    UsingDataSet usingDataSet,    FrameworkMethod method) throws IOException {
      List<InputStream> scriptContent=loadDatasets(usingDataSet,method);
      LoadStrategyEnum loadStrategyEnum=usingDataSet.loadStrategy();
      if (areDatasetsRequired(loadStrategyEnum) && emptyDataset(scriptContent) && notSelectiveAnnotation(usingDataSet.withSelectiveLocations())) {
        final String suffix="String_Node_Str" + getWorkingExtension();
        final String defaultClassLocation=DefaultClasspathLocationBuilder.defaultClassAnnotatedClasspathLocation(method);
        final String defaultMethodLocation=DefaultClasspathLocationBuilder.defaultMethodAnnotatedClasspathLocation(method,defaultClassLocation,suffix);
        throw new IllegalArgumentException("String_Node_Str" + defaultClassLocation + suffix+ "String_Node_Str"+ defaultMethodLocation);
      }
      LoadStrategyOperation loadStrategyOperation=loadStrategyFactory.getLoadStrategyInstance(loadStrategyEnum,getDatabaseOperation());
      loadStrategyOperation.executeScripts(scriptContent.toArray(new InputStream[scriptContent.size()]));
    }
    private boolean notSelectiveAnnotation(    Selective[] withSelectiveLocations){
      return withSelectiveLocations.length == 0;
    }
    private boolean emptyDataset(    List<InputStream> scriptContent){
      return scriptContent.size() == 0;
    }
    private boolean areDatasetsRequired(    LoadStrategyEnum loadStrategyEnum){
      return LoadStrategyEnum.DELETE_ALL != loadStrategyEnum;
    }
    private List<InputStream> loadDatasets(    UsingDataSet usingDataSet,    FrameworkMethod method) throws IOException {
      String[] locations=usingDataSet.locations();
      List<InputStream> scriptContent=new ArrayList<InputStream>();
      scriptContent.addAll(loadGlobalDataSets(usingDataSet,method,locations));
      scriptContent.addAll(loadSelectiveDataSets(usingDataSet));
      return scriptContent;
    }
    private List<InputStream> loadSelectiveDataSets(    UsingDataSet usingDataSet) throws IOException {
      List<InputStream> scriptContent=new ArrayList<InputStream>();
      if (isSelectiveLocationsAttributeSpecified(usingDataSet)) {
        Selective[] selectiveLocations=usingDataSet.withSelectiveLocations();
        if (selectiveLocations != null && selectiveLocations.length > 0) {
          for (          Selective selective : selectiveLocations) {
            if (identifier.equals(selective.identifier().trim()) && isLocationsAttributeSpecified(selective.locations())) {
              scriptContent.addAll(IOUtils.getAllStreamsFromClasspathBaseResource(defaultDataSetLocationResolver.getResourceBase(),selective.locations()));
            }
          }
        }
      }
      return scriptContent;
    }
    private List<InputStream> loadGlobalDataSets(    UsingDataSet usingDataSet,    FrameworkMethod method,    String[] locations) throws IOException {
      List<InputStream> scriptContent=new ArrayList<InputStream>();
      if (isLocationsAttributeSpecified(locations)) {
        scriptContent.addAll(IOUtils.getAllStreamsFromClasspathBaseResource(defaultDataSetLocationResolver.getResourceBase(),locations));
      }
 else {
        String location=defaultDataSetLocationResolver.resolveDefaultDataSetLocation(usingDataSet,method,"String_Node_Str" + getWorkingExtension());
        if (location != null) {
          scriptContent.add(IOUtils.getStreamFromClasspathBaseResource(defaultDataSetLocationResolver.getResourceBase(),location));
        }
      }
      return scriptContent;
    }
    private boolean isSelectiveLocationsAttributeSpecified(    UsingDataSet usingDataSet){
      Selective[] selectiveLocations=usingDataSet.withSelectiveLocations();
      if (selectiveLocations != null && selectiveLocations.length > 0) {
        for (        Selective selective : selectiveLocations) {
          if (identifier.equals(selective.identifier().trim()) && isLocationsAttributeSpecified(selective.locations())) {
            return true;
          }
        }
      }
      return false;
    }
    private boolean isNotEmptyStream(    InputStream inputStream){
      return inputStream != null;
    }
    private boolean isNotEmptyString(    String location){
      return location != null && !"String_Node_Str".equals(location.trim());
    }
    private boolean isLocationsAttributeSpecified(    String[] locations){
      return locations != null && locations.length > 0;
    }
    private boolean isTestAnnotatedWithExpectedDataSet(    ShouldMatchDataSet shouldMatchDataSet){
      return shouldMatchDataSet != null;
    }
    private boolean isTestAnnotatedWithDataSet(    UsingDataSet usingDataSet){
      return usingDataSet != null;
    }
  }
;
}

Fixed version (ground truth):
@Override public Statement apply(final Statement base,final FrameworkMethod method,final Object testObject){
  return new Statement(){
    @Override public void evaluate() throws Throwable {
      target=testObject;
      defaultDataSetLocationResolver=new DefaultDataSetLocationResolver(testObject.getClass());
      UsingDataSet usingDataSet=getUsingDataSetAnnotation();
      if (isTestAnnotatedWithDataSet(usingDataSet)) {
        createCustomInsertationStrategyIfPresent();
        loadDataSet(usingDataSet,method);
      }
      injectAnnotationProcessor.processInjectAnnotation(testObject.getClass(),target,getDatabaseOperation().connectionManager());
      base.evaluate();
      ShouldMatchDataSet shouldMatchDataSet=getShouldMatchDataSetAnnotation();
      if (isTestAnnotatedWithExpectedDataSet(shouldMatchDataSet)) {
        createCustomComparisionStrategyIfPresent();
        assertExpectation(shouldMatchDataSet);
      }
    }
    private void createCustomComparisionStrategyIfPresent(){
      CustomComparisionStrategy customComparisionStrategy=getCustomComparisionStrategy();
      if (isTestAnnotatedWithCustomComparisionStrategy(customComparisionStrategy)) {
        DatabaseOperation<?> databaseOperation=getDatabaseOperation();
        if (isDatabaseOperationCustomizable(databaseOperation)) {
          Class<? extends ComparisionStrategy<?>> comparisionStrategy=customComparisionStrategy.comparisionStrategy();
          ComparisionStrategy<?> comparisionStrategyObject=org.joor.Reflect.on(comparisionStrategy).create().get();
          overrideComparisionStrategy(databaseOperation,comparisionStrategyObject);
        }
 else {
          throw new IllegalArgumentException("String_Node_Str");
        }
      }
    }
    private void createCustomInsertationStrategyIfPresent(){
      CustomInsertationStrategy customInsertationStrategy=getCustomInsertationStrategy();
      if (isTestAnnotatedWithCustomInsertationStrategy(customInsertationStrategy)) {
        DatabaseOperation<?> databaseOperation=getDatabaseOperation();
        if (isDatabaseOperationCustomizable(databaseOperation)) {
          Class<? extends InsertationStrategy<?>> insertationStrategy=customInsertationStrategy.insertationStrategy();
          InsertationStrategy<?> insertationStrategyObject=org.joor.Reflect.on(insertationStrategy).create().get();
          overrideInsertationStrategy(databaseOperation,insertationStrategyObject);
        }
 else {
          throw new IllegalArgumentException("String_Node_Str");
        }
      }
    }
    private void overrideComparisionStrategy(    DatabaseOperation<?> databaseOperation,    ComparisionStrategy<?> comparisionStrategyObject){
      AbstractCustomizableDatabaseOperation customizableDatabaseOperation=(AbstractCustomizableDatabaseOperation)databaseOperation;
      customizableDatabaseOperation.setComparisionStrategy(comparisionStrategyObject);
    }
    private void overrideInsertationStrategy(    DatabaseOperation<?> databaseOperation,    InsertationStrategy<?> insertationStrategyObject){
      AbstractCustomizableDatabaseOperation customizableDatabaseOperation=(AbstractCustomizableDatabaseOperation)databaseOperation;
      customizableDatabaseOperation.setInsertationStrategy(insertationStrategyObject);
    }
    private boolean isDatabaseOperationCustomizable(    DatabaseOperation databaseOperation){
      return databaseOperation instanceof AbstractCustomizableDatabaseOperation;
    }
    private ShouldMatchDataSet getShouldMatchDataSetAnnotation(){
      ShouldMatchDataSet shouldMatchDataSet=method.getAnnotation(ShouldMatchDataSet.class);
      if (!isTestAnnotatedWithExpectedDataSet(shouldMatchDataSet)) {
        Class<?> testClass=target.getClass();
        shouldMatchDataSet=testClass.getAnnotation(ShouldMatchDataSet.class);
      }
      return shouldMatchDataSet;
    }
    private UsingDataSet getUsingDataSetAnnotation(){
      UsingDataSet usingDataSet=method.getAnnotation(UsingDataSet.class);
      if (!isTestAnnotatedWithDataSet(usingDataSet)) {
        Class<?> testClass=target.getClass();
        usingDataSet=testClass.getAnnotation(UsingDataSet.class);
      }
      return usingDataSet;
    }
    private CustomComparisionStrategy getCustomComparisionStrategy(){
      Class<?> testClass=target.getClass();
      return testClass.getAnnotation(com.lordofthejars.nosqlunit.annotation.CustomComparisionStrategy.class);
    }
    private com.lordofthejars.nosqlunit.annotation.CustomInsertationStrategy getCustomInsertationStrategy(){
      Class<?> testClass=target.getClass();
      return testClass.getAnnotation(com.lordofthejars.nosqlunit.annotation.CustomInsertationStrategy.class);
    }
    private void assertExpectation(    ShouldMatchDataSet shouldMatchDataSet) throws IOException {
      InputStream scriptContent=loadExpectedContentScript(method,shouldMatchDataSet);
      if (isNotEmptyStream(scriptContent)) {
        getDatabaseOperation().databaseIs(scriptContent);
      }
 else {
        final String suffix=EXPECTED_RESERVED_WORD + "String_Node_Str" + getWorkingExtension();
        final String defaultClassLocation=DefaultClasspathLocationBuilder.defaultClassAnnotatedClasspathLocation(method);
        final String defaultMethodLocation=DefaultClasspathLocationBuilder.defaultMethodAnnotatedClasspathLocation(method,defaultClassLocation,suffix);
        throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + defaultClassLocation + suffix+ "String_Node_Str"+ defaultMethodLocation);
      }
    }
    private InputStream loadExpectedContentScript(    final FrameworkMethod method,    ShouldMatchDataSet shouldMatchDataSet) throws IOException {
      String location=shouldMatchDataSet.location();
      InputStream scriptContent=null;
      if (isNotEmptyString(location)) {
        scriptContent=loadExpectedResultFromLocationAttribute(location);
      }
 else {
        SelectiveMatcher[] selectiveMatchers=shouldMatchDataSet.withSelectiveMatcher();
        SelectiveMatcher requiredSelectiveMatcher=findSelectiveMatcherByConnectionIdentifier(selectiveMatchers);
        if (isSelectiveMatchersDefined(requiredSelectiveMatcher)) {
          scriptContent=loadExpectedResultFromLocationAttribute(requiredSelectiveMatcher.location());
        }
 else {
          scriptContent=loadExpectedResultFromDefaultLocation(method,shouldMatchDataSet);
        }
      }
      return scriptContent;
    }
    private boolean isSelectiveMatchersDefined(    SelectiveMatcher requiredSelectiveMatcher){
      return requiredSelectiveMatcher != null;
    }
    private SelectiveMatcher findSelectiveMatcherByConnectionIdentifier(    SelectiveMatcher[] selectiveMatchers){
      return selectFirst(selectiveMatchers,having(on(SelectiveMatcher.class).identifier(),equalTo(identifier)).and(having(on(SelectiveMatcher.class).location(),notNullValue())));
    }
    private InputStream loadExpectedResultFromDefaultLocation(    final FrameworkMethod method,    ShouldMatchDataSet shouldMatchDataSet) throws IOException {
      InputStream scriptContent=null;
      String defaultLocation=defaultDataSetLocationResolver.resolveDefaultDataSetLocation(shouldMatchDataSet,method,EXPECTED_RESERVED_WORD + "String_Node_Str" + getWorkingExtension());
      if (defaultLocation != null) {
        scriptContent=loadExpectedResultFromLocationAttribute(defaultLocation);
      }
      return scriptContent;
    }
    private InputStream loadExpectedResultFromLocationAttribute(    String location) throws IOException {
      InputStream scriptContent;
      scriptContent=IOUtils.getStreamFromClasspathBaseResource(defaultDataSetLocationResolver.getResourceBase(),location);
      return scriptContent;
    }
    private void loadDataSet(    UsingDataSet usingDataSet,    FrameworkMethod method) throws IOException {
      List<InputStream> scriptContent=loadDatasets(usingDataSet,method);
      LoadStrategyEnum loadStrategyEnum=usingDataSet.loadStrategy();
      if (areDatasetsRequired(loadStrategyEnum) && emptyDataset(scriptContent) && notSelectiveAnnotation(usingDataSet.withSelectiveLocations())) {
        final String suffix="String_Node_Str" + getWorkingExtension();
        final String defaultClassLocation=DefaultClasspathLocationBuilder.defaultClassAnnotatedClasspathLocation(method);
        final String defaultMethodLocation=DefaultClasspathLocationBuilder.defaultMethodAnnotatedClasspathLocation(method,defaultClassLocation,suffix);
        throw new IllegalArgumentException("String_Node_Str" + defaultClassLocation + suffix+ "String_Node_Str"+ defaultMethodLocation);
      }
      LoadStrategyOperation loadStrategyOperation=loadStrategyFactory.getLoadStrategyInstance(loadStrategyEnum,getDatabaseOperation());
      loadStrategyOperation.executeScripts(scriptContent.toArray(new InputStream[scriptContent.size()]));
    }
    private boolean notSelectiveAnnotation(    Selective[] withSelectiveLocations){
      return withSelectiveLocations.length == 0;
    }
    private boolean emptyDataset(    List<InputStream> scriptContent){
      return scriptContent.size() == 0;
    }
    private boolean areDatasetsRequired(    LoadStrategyEnum loadStrategyEnum){
      return LoadStrategyEnum.DELETE_ALL != loadStrategyEnum;
    }
    private List<InputStream> loadDatasets(    UsingDataSet usingDataSet,    FrameworkMethod method) throws IOException {
      String[] locations=usingDataSet.locations();
      List<InputStream> scriptContent=new ArrayList<InputStream>();
      scriptContent.addAll(loadGlobalDataSets(usingDataSet,method,locations));
      scriptContent.addAll(loadSelectiveDataSets(usingDataSet));
      return scriptContent;
    }
    private List<InputStream> loadSelectiveDataSets(    UsingDataSet usingDataSet) throws IOException {
      List<InputStream> scriptContent=new ArrayList<InputStream>();
      if (isSelectiveLocationsAttributeSpecified(usingDataSet)) {
        Selective[] selectiveLocations=usingDataSet.withSelectiveLocations();
        if (selectiveLocations != null && selectiveLocations.length > 0) {
          for (          Selective selective : selectiveLocations) {
            if (identifier.equals(selective.identifier().trim()) && isLocationsAttributeSpecified(selective.locations())) {
              scriptContent.addAll(IOUtils.getAllStreamsFromClasspathBaseResource(defaultDataSetLocationResolver.getResourceBase(),selective.locations()));
            }
          }
        }
      }
      return scriptContent;
    }
    private List<InputStream> loadGlobalDataSets(    UsingDataSet usingDataSet,    FrameworkMethod method,    String[] locations) throws IOException {
      List<InputStream> scriptContent=new ArrayList<InputStream>();
      if (isLocationsAttributeSpecified(locations)) {
        scriptContent.addAll(IOUtils.getAllStreamsFromClasspathBaseResource(defaultDataSetLocationResolver.getResourceBase(),locations));
      }
 else {
        String location=defaultDataSetLocationResolver.resolveDefaultDataSetLocation(usingDataSet,method,"String_Node_Str" + getWorkingExtension());
        if (location != null) {
          scriptContent.add(IOUtils.getStreamFromClasspathBaseResource(defaultDataSetLocationResolver.getResourceBase(),location));
        }
      }
      return scriptContent;
    }
    private boolean isSelectiveLocationsAttributeSpecified(    UsingDataSet usingDataSet){
      Selective[] selectiveLocations=usingDataSet.withSelectiveLocations();
      if (selectiveLocations != null && selectiveLocations.length > 0) {
        for (        Selective selective : selectiveLocations) {
          if (identifier.equals(selective.identifier().trim()) && isLocationsAttributeSpecified(selective.locations())) {
            return true;
          }
        }
      }
      return false;
    }
    private boolean isNotEmptyStream(    InputStream inputStream){
      return inputStream != null;
    }
    private boolean isNotEmptyString(    String location){
      return location != null && !"String_Node_Str".equals(location.trim());
    }
    private boolean isLocationsAttributeSpecified(    String[] locations){
      return locations != null && locations.length > 0;
    }
    private boolean isTestAnnotatedWithCustomComparisionStrategy(    CustomComparisionStrategy customComparisionStrategy){
      return customComparisionStrategy != null;
    }
    private boolean isTestAnnotatedWithCustomInsertationStrategy(    CustomInsertationStrategy customInsertationStrategy){
      return customInsertationStrategy != null;
    }
    private boolean isTestAnnotatedWithExpectedDataSet(    ShouldMatchDataSet shouldMatchDataSet){
      return shouldMatchDataSet != null;
    }
    private boolean isTestAnnotatedWithDataSet(    UsingDataSet usingDataSet){
      return usingDataSet != null;
    }
  }
;
}