package com.atexpose.util.httpresponse;

import com.google.common.collect.ImmutableMap;
import io.schinzel.basicutils.UTF8;
import io.schinzel.basicutils.substring.SubString;
import org.junit.Test;

import java.util.Map;

import static junit.framework.TestCase.assertEquals;

public class HttpResponse404Test {


    @Test
    public void getResponse_Default_HeaderShouldContainStatusCode404() {
        String httpResponse = UTF8.getString(HttpResponse404.builder()
                .filenameMissingFile("monkey.txt")
                .build()
                .getResponse());
        String actual = SubString.create(httpResponse)
                .startDelimiter("HTTP/1.1 ")
                .endDelimiter("\r\n")
                .toString();
        String expected = HttpStatusCode.FILE_NOT_FOUND.getCode();
        assertEquals(expected, actual);
    }


    @Test
    public void getResponse_Default_BodyShouldContainFileName() {
        String httpResponse = UTF8.getString(HttpResponse404.builder()
                .filenameMissingFile("monkey.txt")
                .build()
                .getResponse());
        String actual = SubString.create(httpResponse)
                .startDelimiter("\r\n\r\n")
                .toString();
        String expected = "<html><body><center>File 'monkey.txt' not found</center><body></html>";
        assertEquals(expected, actual);
    }


    @Test
    public void getResponse_CustomHeader_HeaderShouldContainCustomHeader() {
        Map<String, String> map = ImmutableMap.<String, String>builder()
                .put("key", "val")
                .build();
        String httpResponse = UTF8.getString(HttpResponse404.builder()
                .filenameMissingFile("monkey.txt")
                .customHeaders(map)
                .build()
                .getResponse());
        String actual = SubString.create(httpResponse)
                .startDelimiter("key: ")
                .endDelimiter("\r\n")
                .toString();
        String expected = "val";
        assertEquals(expected, actual);
    }
}
@@ -233,48 +233,54 @@
 tic 
-junit.framework.TestCase
+org.assertj.core.api.Assertions
 .assert
-Equals
+That
 ;%0A%0A
+%0A
 publ
@@ -815,38 +815,54 @@
 ;%0A        assert
+That(actual).is
 Equal
-s
+To
 (expected, actua
@@ -850,32 +850,24 @@
 lTo(expected
-, actual
 );%0A    %7D%0A%0A%0A 
@@ -1354,38 +1354,54 @@
 ;%0A        assert
+That(actual).is
 Equal
-s
+To
 (expected, actua
@@ -1389,32 +1389,602 @@
 lTo(expected
-, actual
+);%0A    %7D%0A%0A%0A    @Test%0A    public void getResponse_Custom404Page_Custom404PageShould() %7B%0A        String html404Page = %22%3Chtml%3E%3Cbody%3E%3Ccenter%3EBummer! File not found :(%3C/center%3E%3Cbody%3E%3C/html%3E%22;%0A        String httpResponse = UTF8.getString(HttpResponse404.builder()%0A                .filenameMissingFile(%22monkey.txt%22)%0A                .html(html404Page)%0A                .build()%0A                .getResponse());%0A        String actual = SubString.create(httpResponse)%0A                .startDelimiter(%22%5Cr%5Cn%5Cr%5Cn%22)%0A                .toString();%0A        assertThat(actual).isEqualTo(html404Page
 );%0A    %7D%0A%0A%0A 
@@ -2633,14 +2633,30 @@
 sert
+That(actual).is
 Equal
-s
+To
 (exp
@@ -2664,16 +2664,8 @@
 cted
-, actual
 );%0A 

Test added