package controllers;

import org.junit.*;

import java.util.*;

import play.mvc.*;

import static play.test.Helpers.*;
import static org.fest.assertions.Assertions.*;

public class UserAppTest {
    @BeforeClass
    public static void beforeClass() {
        callAction(
                routes.ref.Application.init()
        );
    }

    public void findById_doesntExist() {
        running(fakeApplication(), new Runnable() {
            public void run() {
                //Given
                Map<String,String> data = new HashMap<String,String>();
                data.put("loginId", "nekure");

                //When
                Result result = callAction(
                        controllers.routes.ref.UserApp.isUserExist("nekure"),
                        fakeRequest().withFormUrlEncodedBody(data)
                );  // fakeRequest doesn't need here, but remains for example

                //Then
                assertThat(status(result)).isEqualTo(OK);
                assertThat(contentAsString(result)).contains("{\"isExist\":false}");
            }
        });
    }

    public void findById_alreadyExist() {
        running(fakeApplication(), new Runnable() {
            public void run() {
                //Given
                Map<String,String> data = new HashMap<String,String>();
                data.put("loginId", "hobi");

                //When
                Result result = callAction(
                        controllers.routes.ref.UserApp.isUserExist("hobi"),
                        fakeRequest().withFormUrlEncodedBody(data)
                ); // fakeRequest doesn't need here, but remains for example

                //Then
                assertThat(status(result)).isEqualTo(OK);
                assertThat(contentAsString(result)).contains("{\"isExist\":true}");
            }
        });
    }

    public void isEmailExist() {
        running(fakeApplication(), new Runnable() {
            public void run() {
                //Given
                //When
                Result result = callAction(
                        controllers.routes.ref.UserApp.isEmailExist("doortts@gmail.com")
                );

                //Then
                assertThat(status(result)).isEqualTo(OK);
                assertThat(contentAsString(result)).contains("{\"isExist\":true}");
            }
        });
    }
}

@@ -75,16 +75,42 @@
 y.mvc.*;
+%0Aimport play.test.Helpers;
 %0A%0Aimport
@@ -346,32 +346,42 @@
       );%0A    %7D%0A%0A
+    @Test%0A
     public void 
@@ -429,32 +429,58 @@
 fakeApplication(
+Helpers.inMemoryDatabase()
 ), new Runnable(
@@ -1141,32 +1141,42 @@
      %7D);%0A    %7D%0A%0A
+    @Test%0A
     public void 
@@ -1225,32 +1225,58 @@
 fakeApplication(
+Helpers.inMemoryDatabase()
 ), new Runnable(
@@ -1935,24 +1935,34 @@
  %7D);%0A    %7D%0A%0A
+    @Test%0A
     public v
@@ -1974,32 +1974,32 @@
 sEmailExist() %7B%0A
-
         running(
@@ -2014,16 +2014,42 @@
 ication(
+Helpers.inMemoryDatabase()
 ), new R

enable ignored tests