Projects >> wro4j >>5bb471eb982072da70af52e8cffada4c44942da5

Chunk
Conflicting content
   */
  @Inject
  private transient PreProcessorExecutor preProcessorExecutor;
<<<<<<< HEAD
  
=======
>>>>>>> cc0eeedcef34f6327e2141f7cfb6c96360c55f1f

  /**
   * While processing the resources, if any exception occurs - it is wrapped in a RuntimeException.
Solution content
   */
  @Inject
  private transient PreProcessorExecutor preProcessorExecutor;


  /**
   * While processing the resources, if any exception occurs - it is wrapped in a RuntimeException.
File
GroupsProcessor.java
Developer's decision
Version 1
Kind of conflict
Blank
Chunk
Conflicting content
    if (allPostProcessors.isEmpty() && processorsFactory.getPreProcessors().isEmpty()) {
      LOG.warn("No processors defined. Please, check if your configuration is correct.");
    }
<<<<<<< HEAD
    Collection processors = ProcessorsUtils.getProcessorsByType(resourceType, allPostProcessors);
    processors.addAll(ProcessorsUtils.getProcessorsByType(null, allPostProcessors));
    if (!minimize) {
      processors = ProcessorsUtils.getMinimizeFreeProcessors(processors);
    }

    final String resourceName = group.getName() + "." + resourceType.name().toLowerCase();
    final Resource mergedResource = Resource.create(resourceName, resourceType);
    mergedResource.setMinimize(false);
    mergedResource.setType(resourceType);

    LOG.debug("postProcessors: {}", processors);
    final String output = applyPostProcessors(mergedResource, processors, content);
=======
    final Collection processors = ProcessorsUtils.filterProcessorsToApply(minimize, resourceType, allPostProcessors);
    final String output = applyPostProcessors(processors, content);
>>>>>>> cc0eeedcef34f6327e2141f7cfb6c96360c55f1f
    return output;
  }
Solution content
    if (allPostProcessors.isEmpty() && processorsFactory.getPreProcessors().isEmpty()) {
      LOG.warn("No processors defined. Please, check if your configuration is correct.");
    }
    final Collection processors = ProcessorsUtils.filterProcessorsToApply(minimize, resourceType, allPostProcessors);
    final String output = applyPostProcessors(mergedResource, processors, content);
    return output;
  }
File
GroupsProcessor.java
Developer's decision
Combination
Kind of conflict
If statement
Method invocation
Variable
Chunk
Conflicting content
    for (final ResourceProcessor processor : processors) {
      stopWatch.start("Using " + processor.getClass().getSimpleName());
      output = new StringWriter();
<<<<<<< HEAD
      
      decorateWithPostProcessCallback(processor).process(mergedResource, input, output);
  
=======

      decorateWithPostProcessCallback(processor).process(input, output);
>>>>>>> cc0eeedcef34f6327e2141f7cfb6c96360c55f1f

      input = new StringReader(output.toString());
      stopWatch.stop();
Solution content
    for (final ResourceProcessor processor : processors) {
      stopWatch.start("Using " + processor.getClass().getSimpleName());
      output = new StringWriter();

      decorateWithPostProcessCallback(processor).process(mergedResource, input, output);
  

      input = new StringReader(output.toString());
      stopWatch.stop();
File
GroupsProcessor.java
Developer's decision
Version 1
Kind of conflict
Method invocation
Chunk
Conflicting content
  /**
<<<<<<< HEAD
  }
  
   * Execute all the preProcessors on the provided resource.
   * 
   * @param resource
   *          {@link Resource} to preProcess.
   * @param resources
   *          the list of all resources to be processed in this context.
   * @param minimize
   *          whether the minimize aware preProcessor must be applied.
   * @return the result of preProcessing as string content.
   */
  private String processSingleResource(final Resource resource, final List resources, final boolean minimize)
      throws IOException {
    LOG.debug("processingSingleResource: {}", resource);
    // TODO: hold a list of processed resources in order to avoid duplicates
    // merge preProcessorsBy type and anyPreProcessors
    Collection processors = ProcessorsUtils.getProcessorsByType(resource.getType(),
        processorsFactory.getPreProcessors());
    if (!minimize) {
      processors = ProcessorsUtils.getMinimizeFreeProcessors(processors);
    }
    return applyPreProcessors(resource, resources, processors);
  }
  
  /**
   * Apply a list of preprocessors on a resource.
   * 
   * @param resource
   *          the {@link Resource} on which processors will be applied
   * @param resources
   *          the list of all resources to be processed in this context.
   * @param processors
   *          the list of processor to apply on the resource.
   */
  private String applyPreProcessors(final Resource resource, final List resources,
      final Collection processors)
      throws IOException {
=======
   * Apply a list of preprocessors on a resource.
   *
   * @param resource the {@link Resource} on which processors will be applied
   * @param processors the list of processor to apply on the resource.
   */
  private String applyPreProcessors(final Resource resource, final boolean minimize)
    throws IOException {
    // merge preProcessorsBy type and anyPreProcessors
    final Collection processors = ProcessorsUtils.filterProcessorsToApply(minimize,
      resource.getType(), processorsFactory.getPreProcessors());
>>>>>>> cc0eeedcef34f6327e2141f7cfb6c96360c55f1f
    LOG.debug("applying preProcessors: {}", processors);
    String resourceContent = getResourceContent(resource);
    if (processors.isEmpty()) {
Solution content
  }
  
  /**
   * Apply a list of preprocessors on a resource.
   *
   * @param resource the {@link Resource} on which processors will be applied
   * @param processors the list of processor to apply on the resource.
   */
  private String applyPreProcessors(final Resource resource, final boolean minimize)
    throws IOException {
    // merge preProcessorsBy type and anyPreProcessors
    final Collection processors = ProcessorsUtils.filterProcessorsToApply(minimize,
      resource.getType(), processorsFactory.getPreProcessors());
    LOG.debug("applying preProcessors: {}", processors);
    String resourceContent = getResourceContent(resource);
    if (processors.isEmpty()) {
File
PreProcessorExecutor.java
Developer's decision
Version 2
Kind of conflict
Comment
Method declaration
Method invocation
Method signature
Variable
Chunk
Conflicting content
   * @param resources
   *          the list of all resources processed in this context, used for duplicate resource detection.
   */
<<<<<<< HEAD
  private String getResourceContent(final Resource resource, final List resources)
      throws IOException {
=======
  private String getResourceContent(final Resource resource)
    throws IOException {
>>>>>>> cc0eeedcef34f6327e2141f7cfb6c96360c55f1f
    final WroConfiguration config = Context.get().getConfig();
    try {
      final InputStream is = new BOMInputStream(resourceLocatorFactory.locate(resource.getUri()).getInputStream());
Solution content
   * @param resources
   *          the list of all resources processed in this context, used for duplicate resource detection.
   */
  private String getResourceContent(final Resource resource)
      throws IOException {
    final WroConfiguration config = Context.get().getConfig();
    try {
      final InputStream is = new BOMInputStream(resourceLocatorFactory.locate(resource.getUri()).getInputStream());
File
PreProcessorExecutor.java
Developer's decision
Version 2
Kind of conflict
Method signature
Chunk
Conflicting content
  }

  /**
<<<<<<< HEAD
   * @param  processor type. Can be {@link ResourceProcessor}, {@link ResourcePostProcessor} or null (any).
=======
   * This method is visible for testing only.
   * @param  processor type. Can be {@link ResourcePreProcessor}, {@link ResourcePostProcessor} or null (any).
>>>>>>> cc0eeedcef34f6327e2141f7cfb6c96360c55f1f
   * @param type {@link ResourceType} to apply for searching on available processors.
   * @param availableProcessors a list where to perform the search.
   * @return a list of found processors which satisfy the search criteria. There are 3 possibilities:
Solution content
  }

  /**
   * This method is visible for testing only.
   * @param  processor type. Can be {@link ResourcePreProcessor}, {@link ResourcePostProcessor} or null (any).
   * @param type {@link ResourceType} to apply for searching on available processors.
   * @param availableProcessors a list where to perform the search.
   * @return a list of found processors which satisfy the search criteria. There are 3 possibilities:
File
ProcessorsUtils.java
Developer's decision
Version 2
Kind of conflict
Comment
Chunk
Conflicting content
    return found;
  }

<<<<<<< HEAD
=======
  /**
   * Transforms a preProcessor into a postProcessor.
   *
   * @param preProcessor {@link ResourcePreProcessor} to transform.
   */
  public static ResourcePostProcessor toPostProcessor(final ResourcePreProcessor preProcessor) {
    return new ResourcePostProcessor() {
      public void process(final Reader reader, final Writer writer)
        throws IOException {
        preProcessor.process(null, reader, writer);
      }
    };
  }

  /**
   * Transforms a postProcessor into a preProcessor.
   *
   * @param postProcessor {@link ResourcePostProcessor} to transform.
   */
  public static ResourcePreProcessor toPreProcessor(final ResourcePostProcessor postProcessor) {
    return new ResourcePreProcessor() {
      public void process(final Resource resource, final Reader reader, final Writer writer)
        throws IOException {
        postProcessor.process(reader, writer);
      }
    };
  }

>>>>>>> cc0eeedcef34f6327e2141f7cfb6c96360c55f1f
  /**
   * @return preProcessor of type processorClass if any found or null otherwise.
   */
Solution content
    return found;
  }

  /**
   * @return preProcessor of type processorClass if any found or null otherwise.
   */
File
ProcessorsUtils.java
Developer's decision
Version 1
Kind of conflict
Comment
Method declaration
Chunk
Conflicting content
public class TestProcessorsUtils {

  private static class AnyTypeProcessor
<<<<<<< HEAD
    implements ResourceProcessor {
=======
    implements ResourcePreProcessor, ResourcePostProcessor {
>>>>>>> cc0eeedcef34f6327e2141f7cfb6c96360c55f1f
    public void process(final Resource resource, final Reader reader, final Writer writer)
      throws IOException {}
    public void process(final Reader reader, final Writer writer)
Solution content
public class TestProcessorsUtils {

  private static class AnyTypeProcessor
    implements ResourceProcessor {
    public void process(final Resource resource, final Reader reader, final Writer writer)
      throws IOException {}
    public void process(final Reader reader, final Writer writer)
File
TestProcessorsUtils.java
Developer's decision
Version 1
Kind of conflict
Other
Chunk
Conflicting content
  @SuppressWarnings("unchecked")
  @Test
  public void testGetProcessorsByTypeWithEmptyCollection() {
<<<<<<< HEAD
    final Collection input = Collections.EMPTY_LIST;
    final Collection output = ProcessorsUtils.getProcessorsByType(ResourceType.CSS, input);
=======
    final Collection input = Collections.EMPTY_LIST;
    final Collection output = ProcessorsUtils.filterProcessorsToApply(true, ResourceType.CSS,
      input);
>>>>>>> cc0eeedcef34f6327e2141f7cfb6c96360c55f1f
    Assert.assertEquals(0, output.size());
  }
Solution content
  @SuppressWarnings("unchecked")
  @Test
  public void testGetProcessorsByTypeWithEmptyCollection() {
    final Collection input = Collections.EMPTY_LIST;
    final Collection output = ProcessorsUtils.filterProcessorsToApply(true, ResourceType.CSS,
      input);
    Assert.assertEquals(0, output.size());
  }
File
TestProcessorsUtils.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
    final Collection input = Arrays.asList(new ResourceProcessor[] {
      new JSMinProcessor(), new CssMinProcessor()
    });
<<<<<<< HEAD
    Collection output = ProcessorsUtils.getProcessorsByType(ResourceType.CSS, input);
=======
    Collection output = ProcessorsUtils.filterProcessorsToApply(true, ResourceType.CSS, input);
>>>>>>> cc0eeedcef34f6327e2141f7cfb6c96360c55f1f
    Assert.assertEquals(1, output.size());
    output = ProcessorsUtils.filterProcessorsToApply(true, ResourceType.JS, input);
    Assert.assertEquals(1, output.size());
Solution content
    final Collection input = Arrays.asList(new ResourceProcessor[] {
      new JSMinProcessor(), new CssMinProcessor()
    });
    Collection output = ProcessorsUtils.filterProcessorsToApply(true, ResourceType.CSS, input);
    Assert.assertEquals(1, output.size());
    output = ProcessorsUtils.filterProcessorsToApply(true, ResourceType.JS, input);
    Assert.assertEquals(1, output.size());
File
TestProcessorsUtils.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
    final Collection input = Arrays.asList(new ResourceProcessor[] {
      new CssMinProcessor(), new AnyTypeProcessor()
    });
<<<<<<< HEAD
    Collection output = ProcessorsUtils.getProcessorsByType(ResourceType.CSS, input);
=======
    Collection output = ProcessorsUtils.filterProcessorsToApply(true, ResourceType.CSS, input);
>>>>>>> cc0eeedcef34f6327e2141f7cfb6c96360c55f1f
    Assert.assertEquals(2, output.size());
    output = ProcessorsUtils.filterProcessorsToApply(true, ResourceType.JS, input);
    Assert.assertEquals(1, output.size());
Solution content
    final Collection input = Arrays.asList(new ResourceProcessor[] {
      new CssMinProcessor(), new AnyTypeProcessor()
    });
    Collection output = ProcessorsUtils.filterProcessorsToApply(true, ResourceType.CSS, input);
    Assert.assertEquals(2, output.size());
    output = ProcessorsUtils.filterProcessorsToApply(true, ResourceType.JS, input);
    Assert.assertEquals(1, output.size());
File
TestProcessorsUtils.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
    final Collection input = Arrays.asList(new ResourceProcessor[] {
      CopyrightKeeperProcessorDecorator.decorate(new JSMinProcessor())
    });
<<<<<<< HEAD
    Collection output = ProcessorsUtils.getProcessorsByType(ResourceType.CSS, input);
=======
    Collection output = ProcessorsUtils.filterProcessorsToApply(true, ResourceType.CSS, input);
>>>>>>> cc0eeedcef34f6327e2141f7cfb6c96360c55f1f
    Assert.assertEquals(0, output.size());
    output = ProcessorsUtils.filterProcessorsToApply(true, ResourceType.JS, input);
    Assert.assertEquals(1, output.size());
Solution content
    final Collection input = Arrays.asList(new ResourceProcessor[] {
      CopyrightKeeperProcessorDecorator.decorate(new JSMinProcessor())
    });
    Collection output = ProcessorsUtils.filterProcessorsToApply(true, ResourceType.CSS, input);
    Assert.assertEquals(0, output.size());
    output = ProcessorsUtils.filterProcessorsToApply(true, ResourceType.JS, input);
    Assert.assertEquals(1, output.size());
File
TestProcessorsUtils.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
    final Collection input = Arrays.asList(new ResourceProcessor[] {
      CopyrightKeeperProcessorDecorator.decorate(new CssMinProcessor())
    });
<<<<<<< HEAD
    Collection output = ProcessorsUtils.getProcessorsByType(ResourceType.CSS, input);
=======
    Collection output = ProcessorsUtils.filterProcessorsToApply(true, ResourceType.CSS, input);
>>>>>>> cc0eeedcef34f6327e2141f7cfb6c96360c55f1f
    Assert.assertEquals(1, output.size());
    output = ProcessorsUtils.filterProcessorsToApply(true, ResourceType.JS, input);
    Assert.assertEquals(0, output.size());
Solution content
    final Collection input = Arrays.asList(new ResourceProcessor[] {
      CopyrightKeeperProcessorDecorator.decorate(new CssMinProcessor())
    });
    Collection output = ProcessorsUtils.filterProcessorsToApply(true, ResourceType.CSS, input);
    Assert.assertEquals(1, output.size());
    output = ProcessorsUtils.filterProcessorsToApply(true, ResourceType.JS, input);
    Assert.assertEquals(0, output.size());
File
TestProcessorsUtils.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
    Assert.assertEquals(2, output.size());
      CopyrightKeeperProcessorDecorator.decorate(new AnyTypeProcessor()),
      CopyrightKeeperProcessorDecorator.decorate(new JSMinProcessor())
    });
<<<<<<< HEAD
    Collection output = ProcessorsUtils.getProcessorsByType(ResourceType.CSS, input);
=======
    Collection output = ProcessorsUtils.filterProcessorsToApply(true, ResourceType.CSS, input);
>>>>>>> cc0eeedcef34f6327e2141f7cfb6c96360c55f1f
    Assert.assertEquals(1, output.size());
    output = ProcessorsUtils.filterProcessorsToApply(true, ResourceType.JS, input);
Solution content
      CopyrightKeeperProcessorDecorator.decorate(new AnyTypeProcessor()),
      CopyrightKeeperProcessorDecorator.decorate(new JSMinProcessor())
    });
    Collection output = ProcessorsUtils.filterProcessorsToApply(true, ResourceType.CSS, input);
    Assert.assertEquals(1, output.size());
    output = ProcessorsUtils.filterProcessorsToApply(true, ResourceType.JS, input);
    Assert.assertEquals(2, output.size());
File
TestProcessorsUtils.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Variable