package ro.isdc.wro.model.resource.locator.factory;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import org.junit.Before;
import org.junit.Test;

import ro.isdc.wro.extensions.locator.WebjarUriLocator;
import ro.isdc.wro.model.resource.locator.UriLocator;


/**
 * @author Alex Objelean
 */
public class TestDefaultUriLocatorFactory {
  private DefaultUriLocatorFactory victim;

  @Before
  public void setUp() {
    victim = new DefaultUriLocatorFactory();
  }

  @Test
  public void shouldHaveSeveralDefaultLocators() {
    assertEquals(7, victim.getUriLocators().size());
  }

  @Test
  public void shouldContainWebjarLocator() {
    boolean hasWebjarLocator = false;
    for (final UriLocator locator : victim.getUriLocators()) {
      if (locator instanceof WebjarUriLocator) {
        hasWebjarLocator = true;
      }
    }
    assertTrue(hasWebjarLocator);
  }
}

@@ -135,16 +135,40 @@
 tTrue;%0A%0A
+import java.util.List;%0A%0A
 import o
@@ -219,45 +219,186 @@
 ort 
-ro.isdc.wro.extensions.locator.Webjar
+com.google.common.base.Predicate;%0Aimport com.google.common.base.Predicates;%0A%0Aimport ro.isdc.wro.extensions.locator.WebjarUriLocator;%0Aimport ro.isdc.wro.extensions.locator.Webjars
 UriL
@@ -746,9 +746,9 @@
 als(
-7
+8
 , vi
@@ -844,32 +844,323 @@
     
-boolean has
+assertTrue(contains(victim.getUriLocators(), Predicates.instanceOf(WebjarUriLocator.class)));%0A    assertTrue(contains(victim.getUriLocators(), Predicates.instanceOf(
 Webjar
+sUri
 Locator
+.class)));%0A  %7D%0A%0A  private boolean contains(final List%3CUriLocator%3E collection, final Predicate%3CObject%3E predicate) %7B%0A    boolean hasAny
  = f
@@ -1242,44 +1242,33 @@
 if (
-locator instanceof WebjarUriL
+predicate.apply(l
 ocator)
+)
  %7B%0A 
@@ -1277,29 +1277,19 @@
      has
-WebjarLocator
+Any
  = true;
@@ -1299,48 +1299,48 @@
     
-%7D%0A    %7D%0A    assertTrue(hasWebjarLocator)
+  break;%0A      %7D%0A    %7D%0A    return hasAny
 ;%0A  

fix failing test