package bjohnson.ResponseHandlers;

import bjohnson.Request;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.*;

public class HTMLDirectoryResponseBuilderTest {
    private String filePath;
    private Request request;

    @Before
    public void setUp(){
        filePath = System.getProperty("user.dir") + "/src/test/java/bjohnson/testResource";
        request = new Request();
        request.setURL("/");
        request.setMethod("GET");
    }
    @Test
    public void testReturns200Ok() throws Exception {
        Response response = new HTMLDirectoryResponseBuilder(filePath).getResponse(request);
        assertEquals("200 OK", response.getStatus());
    }

    @Test
    public void testBodyContainsTestHtml() throws Exception {
        HTMLDirectoryResponseBuilder htmlDirectoryResponseBuilder = new HTMLDirectoryResponseBuilder(filePath);
        Response response = htmlDirectoryResponseBuilder.getResponse(request);
        String testHtml = "<Body>\n<ol>\n" +
                "<li><a href=\"/image.png\">image.png</a></li>\n" +
                "<li><a href=\"/partial_content.txt\">partial_content.txt</a></li>\n" +
                "<li><a href=\"/patch-content.txt\">patch-content.txt</a></li>\n" +
                "<li><a href=\"/readerFile.txt\">readerFile.txt</a></li>\n" +
                "</ol>\n</Body>\n";
        assertArrayEquals(testHtml.getBytes(), response.getBody());
    }
}
@@ -54,16 +54,50 @@
 equest;%0A
+import org.hamcrest.CoreMatchers;%0A
 import o
@@ -1003,61 +1003,79 @@
     
-String testHtml = %22%3CBody%3E%5Cn%3Col%3E%5Cn%22 +%0A                
+assertThat(new String(response.getBody()), CoreMatchers.containsString(
 %22%3Cli
@@ -1111,34 +1111,35 @@
 .png%3C/a%3E%3C/li%3E%5Cn%22
- +
+));
 %0A               
@@ -1127,32 +1127,95 @@
 ));%0A        
-        
+assertThat(new String(response.getBody()), CoreMatchers.containsString(
 %22%3Cli%3E%3Ca href
@@ -1263,34 +1263,35 @@
 .txt%3C/a%3E%3C/li%3E%5Cn%22
- +
+));
 %0A               
@@ -1279,32 +1279,95 @@
 ));%0A        
-        
+assertThat(new String(response.getBody()), CoreMatchers.containsString(
 %22%3Cli%3E%3Ca href
@@ -1411,34 +1411,35 @@
 .txt%3C/a%3E%3C/li%3E%5Cn%22
- +
+));
 %0A               
@@ -1435,178 +1435,138 @@
     
-        %22%3Cli%3E%3Ca href=%5C%22/readerFile.txt%5C%22%3EreaderFile.txt%3C/a%3E%3C/li%3E%5Cn%22 +%0A                %22%3C/ol%3E%5Cn%3C/Body%3E%5Cn%22;%0A        assertArrayEquals(testHtml.getBytes(), response.getBody(
+assertThat(new String(response.getBody()), CoreMatchers.containsString(%22%3Cli%3E%3Ca href=%5C%22/readerFile.txt%5C%22%3EreaderFile.txt%3C/a%3E%3C/li%3E%5Cn%22
 ));%0A

Change test to check for contents instead of full string