/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package database.service.test;

import com.cimpapps.construction.pm.service.UserService;
import construction.pm.lib.dto.UserDTO;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author catalin.cimpoeru
 */
public class UserRegisterTest {
    
    public UserRegisterTest() {
    }

    @Test
    public void testRegisterUser(){
        UserDTO u = new UserDTO();
        
        u.setUsername("Catalin");
        u.setPassword("Cimpoeru");
        
        UserService service = UserService.getInstance();
        
        boolean register = service.register(u);
        assertTrue(register);
        
        
        UserDTO userDto = service.logIn(u);
        assertNotNull(userDto);
        
        userDto = service.logIn(new UserDTO());
        assertNull(userDto);
        
        register = service.register(u);
        assertFalse(register);
        
        service.removeUser(u);
    }
}

@@ -561,24 +561,78 @@
 sterTest %7B%0D%0A
+    UserService service = UserService.getInstance();%0D%0A
     %0D%0A    pu
@@ -747,34 +747,24 @@
 UserDTO();%0D%0A
-        %0D%0A
         u.se
@@ -826,86 +826,8 @@
 );%0D%0A
-        %0D%0A        UserService service = UserService.getInstance();%0D%0A        %0D%0A
     
@@ -900,34 +900,32 @@
 gister);%0D%0A      
-  
 %0D%0A        %0D%0A    
@@ -922,33 +922,16 @@
     
-%0D%0A        UserDTO userDto
+register
  = s
@@ -937,21 +937,24 @@
 service.
-logIn
+register
 (u);%0D%0A  
@@ -969,23 +969,22 @@
 sert
-NotNull(userDto
+False(register
 );%0D%0A
@@ -1005,32 +1005,84 @@
     
-userDto = service.logIn(
+%0D%0A    %7D%0D%0A    %0D%0A    @Test%0D%0A    public void logInTest()%7B%0D%0A        UserDTO u = 
 new 
@@ -1090,17 +1090,16 @@
 serDTO()
-)
 ;%0D%0A     
@@ -1105,26 +1105,67 @@
     
-assertNull(userDto
+u.setUsername(%22Catalin%22);%0D%0A        u.setPassword(%22Cimpoeru%22
 );%0D%0A
@@ -1178,32 +1178,25 @@
   %0D%0A        
-register
+u
  = service.r
@@ -1190,32 +1190,29 @@
 u = service.
-register
+logIn
 (u);%0D%0A      
@@ -1215,38 +1215,33 @@
       assert
-False(register
+NotNull(u
 );%0D%0A        
@@ -1278,14 +1278,89 @@
 );%0D%0A    
-%7D
+    u = service.logIn(u);%0D%0A        assertNull(u);%0D%0A        %0D%0A    %7D%0D%0A    %0D%0A  
 %0D%0A%7D%0D%0A

refactor Register login test