package net.zephyrizing.http_server_test;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.stream.Stream;

import net.zephyrizing.http_server.HttpProtocol;
import net.zephyrizing.http_server.HttpRequest;

import org.junit.Ignore;
import org.junit.Test;

import static java.util.Arrays.asList;

import static net.zephyrizing.http_server.HttpRequest.Method.*;

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

public class HttpRequestTest {

    @Test
    public void canCreateGETRequest() {
        HttpRequest request = new HttpRequest(GET, "/");

        assertEquals(GET, request.method());
        assertEquals(Paths.get("/"), request.path());
    }

    @Test
    public void canCreatePOSTRequest() {
        HttpRequest request = new HttpRequest(POST, "/root");

        assertEquals(POST, request.method());
        assertEquals(Paths.get("/root"), request.path());
    }

    @Test
    public void canResolveTheRootPath() {
        HttpRequest request = new HttpRequest(POST, "/");

        Path root = Paths.get("/root/path");

        Path requested = request.getResolvedPath(root);
        assertEquals(Paths.get("/root/path"), requested);
    }

    @Test
    public void canResolvePaths() {
        HttpRequest request = new HttpRequest(POST, "/branch");

        Path root = Paths.get("/root/path");

        Path requested = request.getResolvedPath(root);
        assertEquals(Paths.get("/root/path/branch"), requested);
    }

    @Test
    public void canAddRequestParams() {
        HttpRequest request = new HttpRequest(GET, "/");

        String key = "key";
        String value = "value";
        request.addUrlParam(key, value);

        assertThat(request.getUrlParam(key), equalTo(value));
        assertThat(request.getUrlParam("not-there"), nullValue());
    }
}

@@ -405,53 +405,8 @@
 *;%0A%0A
-import static org.junit.Assert.assertEquals;%0A
 impo
@@ -444,16 +444,16 @@
 rtThat;%0A
+
 import s
@@ -646,20 +646,13 @@
 sert
-Equals(GET, 
+That(
 requ
@@ -655,32 +655,46 @@
 request.method()
+, equalTo(GET)
 );%0A        asser
@@ -686,38 +686,60 @@
 ;%0A        assert
-E
+That(request.path(), e
 qual
-s
+To
 (Paths.get(%22/%22),
@@ -737,31 +737,16 @@
 get(%22/%22)
-, request.path(
 ));%0A    
@@ -880,21 +880,13 @@
 sert
-Equals(POST, 
+That(
 requ
@@ -897,16 +897,31 @@
 method()
+, equalTo(POST)
 );%0A     
@@ -921,38 +921,60 @@
 ;%0A        assert
-E
+That(request.path(), e
 qual
-s
+To
 (Paths.get(%22/roo
@@ -980,23 +980,8 @@
 ot%22)
-, request.path(
 ));%0A
@@ -1206,38 +1206,55 @@
 ;%0A        assert
-E
+That(requested, e
 qual
-s
+To
 (Paths.get(%22/roo
@@ -1261,27 +1261,17 @@
 t/path%22)
-, requested
+)
 );%0A    %7D
@@ -1503,14 +1503,31 @@
 sert
-E
+That(requested, e
 qual
-s
+To
 (Pat
@@ -1557,19 +1557,9 @@
 ch%22)
-, requested
+)
 );%0A 

Change Request test to Hamcrest matcher assertions