package de.matrixweb.smaller.resource;

import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.junit.Test;

/**
 * @author rongae
 */
public class SourceMergerTest {

  /**
   * @throws IOException
   */
  @Test
  public void testUniqueFileResolving() throws IOException {
    final String tempFolder = "/tmp";
    final ResourceResolver resolver = new FileResourceResolver(tempFolder);
    final SourceMerger merger = new SourceMerger(Boolean.TRUE);
    final List<String> resourcesFiles = new ArrayList<String>();
    resourcesFiles.add("basic.json");
    final List<Resource> resources = merger.getResources(resolver,
        resourcesFiles);
    assertThat(resources.size(), is(2));
    assertThat(resources.get(0).getURL().getPath(), is(tempFolder
        + "/extensions/js/ext/json2.js"));
    assertThat(resources.get(1).getURL().getPath(), is(tempFolder
        + "/extensions/js/ext/modernizr.custom.js"));
  }
}

@@ -278,53 +278,16 @@
  %7B%0A%0A
-  /**%0A   * @throws IOException%0A   */%0A
   @Test%0A
   pu
@@ -282,16 +282,16 @@
   @Test%0A
+
   public
@@ -924,32 +924,32 @@
 , is(tempFolder%0A
-
         + %22/exte
@@ -989,11 +989,1516 @@
 %22));%0A  %7D
+%0A%0A  @Test%0A  public void testMutlipleFileResolving() throws IOException %7B%0A    final String tempFolder = %22/tmp%22;%0A    final ResourceResolver resolver = new FileResourceResolver(tempFolder);%0A    final SourceMerger merger = new SourceMerger();%0A    final List%3CString%3E resourcesFiles = new ArrayList%3CString%3E();%0A    resourcesFiles.add(%22basic.json%22);%0A    final List%3CResource%3E resources = merger.getResources(resolver,%0A        resourcesFiles);%0A%0A    assertThat(resources.size(), is(9));%0A%0A    assertThat(resources.get(0).getURL().getPath(), is(tempFolder%0A        + %22/extensions/js/ext/json2.js%22));%0A    assertThat(resources.get(1).getURL().getPath(), is(tempFolder%0A        + %22/extensions/js/ext/modernizr.custom.js%22));%0A    assertThat(resources.get(2).getURL().getPath(), is(tempFolder%0A        + %22/extensions/js/ext/modernizr.custom.js%22));%0A    assertThat(resources.get(3).getURL().getPath(), is(tempFolder%0A        + %22/extensions/js/ext/json2.js%22));%0A    assertThat(resources.get(4).getURL().getPath(), is(tempFolder%0A        + %22/extensions/js/ext/modernizr.custom.js%22));%0A    assertThat(resources.get(5).getURL().getPath(), is(tempFolder%0A        + %22/extensions/js/ext/json2.js%22));%0A    assertThat(resources.get(6).getURL().getPath(), is(tempFolder%0A        + %22/extensions/js/ext/json2.js%22));%0A    assertThat(resources.get(7).getURL().getPath(), is(tempFolder%0A        + %22/extensions/js/ext/modernizr.custom.js%22));%0A    assertThat(resources.get(8).getURL().getPath(), is(tempFolder%0A        + %22/extensions/js/ext/json2.js%22));%0A  %7D
 %0A%7D%0A

add test for multiple source file resolving (default behaviour)