153 lines
4.5 KiB
Java
153 lines
4.5 KiB
Java
package restImplementation;
|
|
|
|
import database.user.User;
|
|
import org.apache.log4j.BasicConfigurator;
|
|
import org.apache.log4j.Logger;
|
|
import org.junit.Ignore;
|
|
import org.junit.Test;
|
|
|
|
import java.util.Map;
|
|
|
|
@Ignore
|
|
public class UserImplementationTest {
|
|
private static Logger logger = Logger.getLogger(UserImplementationTest.class);
|
|
|
|
/*
|
|
@Test
|
|
public void ApproveUser(){
|
|
BasicConfigurator.configure();
|
|
String email = "sarah.huet@mail.fr";
|
|
String user_hash = "$2a$10$ZZNA5dPX/OpR327If/ShluJtJwm6tr7WLjp8CyWLsQQvJ0QUZlzkG";
|
|
|
|
User u = new User(email,user_hash);
|
|
|
|
UserImplementation userImplementation = new UserImplementation();
|
|
try{
|
|
userImplementation.approveUser(u);
|
|
}catch (Exception e){
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
*/
|
|
|
|
/*
|
|
@Test
|
|
public void getUserApproval(){
|
|
BasicConfigurator.configure();
|
|
String email = "sarah.huet@mail.fr";
|
|
String user_hash = "$2a$10$ZZNA5dPX/OpR327If/ShluJtJwm6tr7WLjp8CyWLsQQvJ0QUZlzkG";
|
|
|
|
User u = new User(email,user_hash);
|
|
|
|
UserImplementation userImplementation = new UserImplementation();
|
|
try{
|
|
logger.info(userImplementation.getUserApproval(email));
|
|
}catch (Exception e){
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
@Test
|
|
public void RegisterUserWithoutPhone() { //OK
|
|
BasicConfigurator.configure();
|
|
User userTest = new User("TotoName","TotoFirstName","TotoEmail@gmail.com","totoPassword1234$","gonette");
|
|
UserImplementation userImplementation = new UserImplementation();
|
|
|
|
try{
|
|
Map<String,String> response = userImplementation.registerUser(userTest);
|
|
logger.info("response is: "+response.get("response"));
|
|
if(Boolean.parseBoolean(response.get("response"))){
|
|
logger.info("User hash: "+response.get("user_hash"));
|
|
}
|
|
} catch (Exception e){
|
|
logger.warn("Error: "+e);
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void RegisterUserWithPhone() { //OK
|
|
BasicConfigurator.configure();
|
|
User userTest = new User("TataName","TataFirstName","TataEmail@gmail.com","tataPassword1234$","0607080900","gonette");
|
|
UserImplementation userImplementation = new UserImplementation();
|
|
|
|
try{
|
|
Map<String,String> responseTest = userImplementation.registerUser(userTest);
|
|
logger.info("response is: "+responseTest.get("response"));
|
|
if(Boolean.parseBoolean(responseTest.get("response"))){
|
|
logger.info("User hash: "+responseTest.get("user_hash"));
|
|
}
|
|
}catch (Exception e){
|
|
logger.warn("Error: "+e);
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void approveUser1Test() { //ok
|
|
BasicConfigurator.configure();
|
|
User userTest = new User("TotoEmail@gmail.com","");
|
|
UserImplementation userImplementation = new UserImplementation();
|
|
try {
|
|
userImplementation.approveUser(userTest);
|
|
}catch (Exception e){
|
|
logger.warn("Error: "+e);
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void approveUser2Test() { //ok
|
|
BasicConfigurator.configure();
|
|
User userTest = new User("TataEmail@gmail.com","");
|
|
UserImplementation userImplementation = new UserImplementation();
|
|
try {
|
|
userImplementation.approveUser(userTest);
|
|
}catch (Exception e){
|
|
logger.warn("Error: "+e);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
public void userLoggerTest(){ //OK
|
|
BasicConfigurator.configure();
|
|
User userTest = new User("TataName","TataFirstName","TataEmail@gmail.com","tataPassword1234$","0607080900","gonette");
|
|
UserImplementation userImplementation = new UserImplementation();
|
|
try{
|
|
Map<String,String> responseTest = userImplementation.userLogger(userTest);
|
|
if(Boolean.parseBoolean(responseTest.get("response"))){
|
|
logger.info("User hash: "+responseTest.get("user_hash"));
|
|
}
|
|
} catch (Exception e){
|
|
logger.warn("Error: "+e);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
public void deleteUserTest(){ //OK
|
|
BasicConfigurator.configure();
|
|
User userTest = new User("TotoEmail@gmail.com","$2a$10$AFlLoL3MpyILTmI4CAnVce8XYagrqkqQ9Be8pVAzadNDvexbBXZHm");
|
|
UserImplementation userImplementation = new UserImplementation();
|
|
try{
|
|
userImplementation.deleteUser(userTest);
|
|
} catch (Exception e){
|
|
logger.warn("Error: "+e);
|
|
}
|
|
}
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|