Projects >> wro4j >>11e9c64137ba7d28150b1b635c9f0023c85c29aa

Chunk
Conflicting content
      future.get();
    }
  }
<<<<<<< HEAD
  
=======

  public static void runConcurrently(final Callable... tasks) throws Exception {
    final ExecutorService service = Executors.newFixedThreadPool(5);
    final List> futures = new ArrayList>();
    for (final Callable task : tasks) {
      futures.add(service.submit(task));
    }
    for (final Future future : futures) {
      future.get();
    }
  }

>>>>>>> dd3c1fb6b14b0016acf873390f423cd3a386fb59
  /**
   * Run the task concurrently 50 times.
   */
Solution content
      future.get();
    }
  }
  
  public static void runConcurrently(final Callable... tasks) throws Exception {
    final ExecutorService service = Executors.newFixedThreadPool(5);
    final List> futures = new ArrayList>();
    for (final Callable task : tasks) {
      futures.add(service.submit(task));
    }
    for (final Future future : futures) {
      future.get();
    }
  }

  /**
   * Run the task concurrently 50 times.
   */
File
WroTestUtils.java
Developer's decision
Version 2
Kind of conflict
Method declaration
Chunk
Conflicting content
      throws Exception {
    initMocks(this);
    Context.set(Context.webContext(request, response, filterConfig));
<<<<<<< HEAD
    victim = new ResourceWatcher();
    when(mockLocatorFactory.getLocator(Mockito.anyString())).thenReturn(mockLocator);
    when(mockLocatorFactory.locate(Mockito.anyString())).thenReturn(WroUtil.EMPTY_STREAM);
=======
    // spy the interface instead of WroTestUtils.createResourceMockingLocator() because of mockito bug which was
    // reported on their mailing list.
    mockLocator = Mockito.spy(new UriLocator() {
      public InputStream locate(final String uri)
          throws IOException {
        return new ByteArrayInputStream(uri.getBytes());
      }

      public boolean accept(final String uri) {
        return true;
      }
    });
    // Add explicity the filter which makes the request allowed for async check
    when(request.getAttribute(Mockito.eq(WroFilter.ATTRIBUTE_PASSED_THROUGH_FILTER))).thenReturn(true);
>>>>>>> dd3c1fb6b14b0016acf873390f423cd3a386fb59

    victim = new ResourceWatcher();
    createDefaultInjector().inject(victim);
Solution content
      throws Exception {
    initMocks(this);
    Context.set(Context.webContext(request, response, filterConfig));
    victim = new ResourceWatcher();
    when(mockLocatorFactory.getLocator(Mockito.anyString())).thenReturn(mockLocator);
    when(mockLocatorFactory.locate(Mockito.anyString())).thenReturn(WroUtil.EMPTY_STREAM);
    // Add explicity the filter which makes the request allowed for async check
    when(request.getAttribute(Mockito.eq(WroFilter.ATTRIBUTE_PASSED_THROUGH_FILTER))).thenReturn(true);

    victim = new ResourceWatcher();
    createDefaultInjector().inject(victim);
File
TestResourceWatcher.java
Developer's decision
Combination
Kind of conflict
Attribute
Comment
Method invocation
Chunk
Conflicting content
  }

  public Injector createDefaultInjector() {
<<<<<<< HEAD
    final WroModel model = new WroModel().addGroup(new Group(GROUP_NAME).addResource(Resource.create(RESOURCE_URI)));
    model.addGroup(new Group(GROUP_2).addResource(Resource.create(RESOURCE_FIRST)).addResource(
=======
    final UriLocatorFactory locatorFactory = new AbstractUriLocatorFactory() {
      public UriLocator getInstance(final String uri) {
        return mockLocator;
      }
    };

    final WroModel model = new WroModel().addGroup(new Group(GROUP_NAME).addResource(Resource.create(RESOURCE_CSS_URI)));
    model.addGroup(new Group(GROUP_2).addResource(Resource.create(RESOURCE_JS_URI)).addResource(
>>>>>>> dd3c1fb6b14b0016acf873390f423cd3a386fb59
        Resource.create("/path/2.js")));
    model.addGroup(new Group(MIXED_GROUP_NAME).addResource(Resource.create(RESOURCE_CSS_URI)).addResource(
        Resource.create(RESOURCE_JS_URI)));
Solution content
  }

  public Injector createDefaultInjector() {
    final WroModel model = new WroModel().addGroup(new Group(GROUP_NAME).addResource(Resource.create(RESOURCE_CSS_URI)));
    model.addGroup(new Group(GROUP_2).addResource(Resource.create(RESOURCE_JS_URI)).addResource(
        Resource.create("/path/2.js")));
    model.addGroup(new Group(MIXED_GROUP_NAME).addResource(Resource.create(RESOURCE_CSS_URI)).addResource(
        Resource.create(RESOURCE_JS_URI)));
File
TestResourceWatcher.java
Developer's decision
Combination
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
    final CacheKey cacheEntry = new CacheKey(GROUP_NAME, ResourceType.CSS, true);
    victim = new ResourceWatcher();
    createDefaultInjector().inject(victim);
<<<<<<< HEAD
    when(mockLocator.getInputStream()).then(answerWithContent(String.format("@import url(%s)", importResourceUri)));
=======
    when(mockLocator.locate(Mockito.anyString())).thenAnswer(answerWithContent("initial"));
    when(mockLocator.locate("/" + Mockito.eq(RESOURCE_CSS_URI))).thenAnswer(
        answerWithContent(String.format("@import url(%s)", importResourceUri)));
>>>>>>> dd3c1fb6b14b0016acf873390f423cd3a386fb59

    final ResourceLocator mockImportedResourceLocator = mock(ResourceLocator.class);
    when(mockImportedResourceLocator.getInputStream()).then(answerWithContent("initial"));
Solution content
    final CacheKey cacheEntry = new CacheKey(GROUP_NAME, ResourceType.CSS, true);
    victim = new ResourceWatcher();
    createDefaultInjector().inject(victim);
    when(mockLocator.getInputStream()).then(answerWithContent(String.format("@import url(%s)", importResourceUri)));

    final ResourceLocator mockImportedResourceLocator = mock(ResourceLocator.class);
    when(mockImportedResourceLocator.getInputStream()).then(answerWithContent("initial"));
File
TestResourceWatcher.java
Developer's decision
Version 1
Kind of conflict
Method invocation
Chunk
Conflicting content
    victim.check(cacheEntry);

<<<<<<< HEAD
    when(mockImportedResourceLocator.getInputStream()).then(answerWithContent("changed"));
=======
    when(mockLocator.locate(Mockito.anyString())).thenAnswer(answerWithContent("changed"));
    when(mockLocator.locate("/" + Mockito.eq(RESOURCE_CSS_URI))).thenAnswer(
        answerWithContent(String.format("@import url(%s)", importResourceUri)));
>>>>>>> dd3c1fb6b14b0016acf873390f423cd3a386fb59

    victim.check(cacheEntry);
Solution content
    victim.check(cacheEntry);

    when(mockImportedResourceLocator.getInputStream()).then(answerWithContent("changed"));

    victim.check(cacheEntry);
File
TestResourceWatcher.java
Developer's decision
Version 1
Kind of conflict
Method invocation
Chunk
Conflicting content
    // first check will always detect changes.
    victim.check(cacheKey2, resourceWatcherCallback);

<<<<<<< HEAD
    Mockito.when(mockLocatorFactory.locate(RESOURCE_FIRST)).then(answerWithContent("changed"));
=======
    when(mockLocator.locate(RESOURCE_JS_URI)).thenAnswer(answerWithContent("changed"));
>>>>>>> dd3c1fb6b14b0016acf873390f423cd3a386fb59

    victim.check(cacheKey2, resourceWatcherCallback);
    verify(resourceWatcherCallback, Mockito.atLeastOnce()).onGroupChanged(Mockito.any(CacheKey.class));
Solution content
    Mockito.when(mockLocatorFactory.locate(RESOURCE_JS_URI)).then(answerWithContent("changed"));
    // first check will always detect changes.
    victim.check(cacheKey2, resourceWatcherCallback);


    victim.check(cacheKey2, resourceWatcherCallback);
    verify(resourceWatcherCallback, Mockito.atLeastOnce()).onGroupChanged(Mockito.any(CacheKey.class));
File
TestResourceWatcher.java
Developer's decision
Manual
Kind of conflict
Method invocation