package org.wuokko.robot.restlib.mockserver;

import static java.util.concurrent.TimeUnit.SECONDS;
import static org.mockserver.matchers.Times.*;
import static org.mockserver.model.NottableString.*;
import static org.mockserver.model.StringBody.exact;
import static org.mockserver.model.HttpRequest.request;
import static org.mockserver.model.HttpResponse.response;

import org.mockserver.client.server.MockServerClient;
import org.mockserver.initialize.ExpectationInitializer;
import org.mockserver.matchers.ExactStringMatcher;
import org.mockserver.model.Delay;
import org.mockserver.model.Header;
import org.mockserver.model.HttpRequest;
import org.mockserver.model.Parameter;

public class MockserverInitialization implements ExpectationInitializer {

	@Override
	public void initializeExpectations(MockServerClient mockServer) {
		
		mockServer.when(
                request()
                        .withMethod("GET")
                        .withPath("/hello"),
                unlimited()
        )
        .respond(
                response()
                        .withStatusCode(200)
                        .withBody("{ message: 'hello world' }")
        );
		
		mockServer.when(
                request()
                        .withMethod("POST")
                        .withPath("/login")
                        .withBody(exact("{username: 'foo', password: 'bar'}")),
                unlimited()
        )
        .respond(
                response()
                        .withStatusCode(200)
                        .withBody("{ message: 'Welcome', status: 'success' }")
        );
		
		mockServer.when(
                request()
                        .withMethod("POST")
                        .withPath("/login"),
                unlimited()
        )
        .respond(
                response()
                        .withStatusCode(200)
                        .withBody("{ message: 'Access denied', status: 'failed' }")
        );
		
		mockServer.when(
                request()
                        .withMethod("PUT")
                        .withPath("/add")
                        .withBody(exact("{title: 'car', value: '1500'}")),
                unlimited()
        )
        .respond(
                response()
                        .withStatusCode(200)
                        .withBody("{ modified: '1' }")
        );
		
		mockServer.when(
                request()
                        .withMethod("DELETE")
                        .withPath("/delete")
                        .withQueryStringParameter("id", "123"),
                unlimited()
        )
        .respond(
                response()
                        .withStatusCode(200)
                        .withBody("{ deleted: '1' }")
        );
		
	}

}

@@ -57,198 +57,47 @@
 tic 
-java.util.concurrent.TimeUnit.SECONDS;%0Aimport static org.mockserver.matchers.Times.*;%0Aimport static org.mockserver.model.NottableString.*;%0Aimport static org.mockserver.model.StringBody.exact
+org.mockserver.matchers.Times.unlimited
 ;%0Aim
@@ -207,16 +207,69 @@
 esponse;
+%0Aimport static org.mockserver.model.StringBody.exact;
 %0A%0Aimport
@@ -316,16 +316,16 @@
 Client;%0A
+
 import o
@@ -376,210 +376,8 @@
 zer;
-%0Aimport org.mockserver.matchers.ExactStringMatcher;%0Aimport org.mockserver.model.Delay;%0Aimport org.mockserver.model.Header;%0Aimport org.mockserver.model.HttpRequest;%0Aimport org.mockserver.model.Parameter;
 %0A%0Apu

Remove unused imports