commit ded2936a33d3af536dc4d4f09dff4367d0665389
Author: Petr Urban <urbanp@gapps.zcu.cz>
Date:   Thu Apr 6 21:30:59 2023 +0200

    new: #10245 ReactJS routing, přihlašovací formulář
    desc: zprovozněn registrační formulář uživatele včetně poupravení user modulu

diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/controller/UserController.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/controller/UserController.java
index 448811f..e443e0e 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/controller/UserController.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/controller/UserController.java
@@ -3,10 +3,14 @@ package cz.zcu.fav.kiv.antipatterndetectionapp.v2.controller;
 import cz.zcu.fav.kiv.antipatterndetectionapp.v2.dials.UserModelStatusCodes;
 import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.User;
 import cz.zcu.fav.kiv.antipatterndetectionapp.v2.service.UserService;
+import cz.zcu.fav.kiv.antipatterndetectionapp.v2.utils.JSONBuilder;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.HashMap;
+
 /**
  * Controller for providing basic support for user management
  * @version 1.0
diff --git a/src/test/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/controller/UserControllerTest.java b/src/test/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/controller/UserControllerTest.java
index a802c4e..2f9a22f 100644
--- a/src/test/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/controller/UserControllerTest.java
+++ b/src/test/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/controller/UserControllerTest.java
@@ -9,6 +9,9 @@ import org.mockito.Mockito;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
 import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.mock.web.MockHttpServletResponse;
 import org.springframework.security.test.context.support.WithMockUser;
 import org.springframework.test.context.junit.jupiter.SpringExtension;
 import org.springframework.test.web.servlet.MockMvc;
diff --git a/src/test/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/UserServiceImpTest.java b/src/test/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/UserServiceImpTest.java
index 618648b..daedfcc 100644
--- a/src/test/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/UserServiceImpTest.java
+++ b/src/test/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/UserServiceImpTest.java
@@ -1,5 +1,6 @@
 package cz.zcu.fav.kiv.antipatterndetectionapp.v2.service;
 
+import cz.zcu.fav.kiv.antipatterndetectionapp.v2.dials.UserModelStatusCodes;
 import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.User;
 import cz.zcu.fav.kiv.antipatterndetectionapp.v2.repository.UserRepository;
 import org.junit.jupiter.api.BeforeAll;
@@ -52,7 +53,7 @@ public class UserServiceImpTest {
     /**
      * Mocked User
      */
-    private final User mockUser = new User("test", "test@tt.cz");
+    private final User mockUser = new User("test", "test@tt.cz", "Ahoj99");
 
     /**
      * Testing registration implementation
@@ -66,9 +67,9 @@ public class UserServiceImpTest {
                 "ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" +
                 "ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" +
                 "dddddddddddhfbsdjfhbsdjhbjckvxjhbvjhfbsjhbdjhsbvhbsckjhvbsdhfbsdjhvbjxhcbvhbjhvbxcv", "tt@aa.ct");
-        int foundCode = userService.registerUser(MUser);
+        UserModelStatusCodes foundCode = userService.registerUser(MUser);
 
-        assertEquals(foundCode, 0);
+        assertEquals(foundCode, UserModelStatusCodes.INVALID_USER_ARGUMENTS);
     }
 
     /**
@@ -82,9 +83,9 @@ public class UserServiceImpTest {
                 "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" +
                 "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" +
                 "ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddt@aa.ct");
-        int foundCode = userService.registerUser(MUser);
+        UserModelStatusCodes foundCode = userService.registerUser(MUser);
 
-        assertEquals(foundCode, 0);
+        assertEquals(foundCode, UserModelStatusCodes.INVALID_USER_ARGUMENTS);
     }
 
     /**
@@ -104,9 +105,65 @@ public class UserServiceImpTest {
                 "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" +
                 "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" +
                 "ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddt@aa.ct");
-        int foundCode = userService.registerUser(MUser);
+        UserModelStatusCodes foundCode = userService.registerUser(MUser);
 
-        assertEquals(foundCode, 0);
+        assertEquals(foundCode, UserModelStatusCodes.INVALID_USER_ARGUMENTS);
+    }
+
+    @Test
+    public void whenUserNULLName_thenReturnMSG() {
+        User MUser = new User(null, "tt@asd.cf", "Ahoj99");
+        UserModelStatusCodes foundCode = userService.registerUser(MUser);
+
+        assertEquals(foundCode, UserModelStatusCodes.INVALID_USER_ARGUMENTS);
+    }
+
+    @Test
+    public void whenUserNULLEmail_thenReturnMSG() {
+        User MUser = new User("tt", null, "Ahoj99");
+        UserModelStatusCodes foundCode = userService.registerUser(MUser);
+
+        assertEquals(foundCode, UserModelStatusCodes.INVALID_USER_ARGUMENTS);
+    }
+
+    @Test
+    public void whenUserNULLPassword_thenReturnMSG() {
+        User MUser = new User("tt", "tt@asd.cf", null);
+        UserModelStatusCodes foundCode = userService.registerUser(MUser);
+
+        assertEquals(foundCode, UserModelStatusCodes.INVALID_USER_ARGUMENTS);
+    }
+
+    @Test
+    public void whenUserNULLNameEmail_thenReturnMSG() {
+        User MUser = new User(null, null, "Ahoj99");
+        UserModelStatusCodes foundCode = userService.registerUser(MUser);
+
+        assertEquals(foundCode, UserModelStatusCodes.INVALID_USER_ARGUMENTS);
+    }
+
+    @Test
+    public void whenUserNULLNamePassword_thenReturnMSG() {
+        User MUser = new User(null, "tt@asd.cf", null);
+        UserModelStatusCodes foundCode = userService.registerUser(MUser);
+
+        assertEquals(foundCode, UserModelStatusCodes.INVALID_USER_ARGUMENTS);
+    }
+
+    @Test
+    public void whenUserNULLEmailPassword_thenReturnMSG() {
+        User MUser = new User("tt", null, null);
+        UserModelStatusCodes foundCode = userService.registerUser(MUser);
+
+        assertEquals(foundCode, UserModelStatusCodes.INVALID_USER_ARGUMENTS);
+    }
+
+    @Test
+    public void whenUserNULLNameEmailPassword_thenReturnMSG() {
+        User MUser = new User(null, null, null);
+        UserModelStatusCodes foundCode = userService.registerUser(MUser);
+
+        assertEquals(foundCode, UserModelStatusCodes.INVALID_USER_ARGUMENTS);
     }
 
     /**
@@ -115,11 +172,11 @@ public class UserServiceImpTest {
      */
     @Test
     public void whenUserIsNotRegistered_thenRegisterHim() {
-        Mockito.when(userRepository.findByName("neni_v_DB")).thenReturn(null);
+        Mockito.when(userRepository.save(any())).thenReturn(mockUser);
 
-        int foundCode = userService.registerUser(mockUser);
+        UserModelStatusCodes foundCode = userService.registerUser(mockUser);
 
-        assertEquals(foundCode, 1);
+        assertEquals(foundCode, UserModelStatusCodes.USER_CREATED);
     }
 
     /**
@@ -130,9 +187,9 @@ public class UserServiceImpTest {
     public void whenUserIsRegistered_thenSendMSG() {
         Mockito.when(userRepository.findByName(mockUser.getName())).thenReturn(mockUser);
 
-        int foundCode = userService.registerUser(mockUser);
+        UserModelStatusCodes foundCode = userService.registerUser(mockUser);
 
-        assertEquals(foundCode, -1);
+        assertEquals(foundCode, UserModelStatusCodes.USER_EXISTS);
     }
 
     /**
@@ -145,9 +202,9 @@ public class UserServiceImpTest {
         Mockito.when(userRepository.findByName(mockUser.getName())).thenReturn(mockUser);
 
         String name = "test";
-        int foundCode = userService.loginUser(new User(name, ""));
+        UserModelStatusCodes foundCode = userService.loginUser(new User(name, ""));
 
-        assertEquals(foundCode, 1);
+        assertEquals(foundCode, UserModelStatusCodes.USER_LOGGED_IN);
     }
 
     /**
@@ -160,9 +217,9 @@ public class UserServiceImpTest {
         //Mockito.when(userRepository.findByName(mockUser.getName())).thenReturn(mockUser);
 
         String name = "notest";
-        int foundCode = userService.loginUser(new User(name, ""));
+        UserModelStatusCodes foundCode = userService.loginUser(new User(name, ""));
 
-        assertEquals(foundCode, 0);
+        assertEquals(foundCode, UserModelStatusCodes.USER_LOGIN_FAILED);
     }
 
 }
