Merge branch 'features1.4/testing' into develop-1.4

This commit is contained in:
GME 2019-04-03 17:32:54 +02:00
commit 48c0b2a340
21 changed files with 240 additions and 74 deletions

View file

@ -1,8 +1,8 @@
-- SEQUENCE: public."T_SESSION_session_id_seq" -- SEQUENCE: public."session_id_seq"
-- DROP SEQUENCE public."T_SESSION_session_id_seq"; -- DROP SEQUENCE public."session_id_seq";
CREATE SEQUENCE public."t_session_id_seq"; CREATE SEQUENCE public."t_session_id_seq";
ALTER SEQUENCE public."t_session_id_seq" ALTER SEQUENCE public."t_session_id_seq"
OWNER TO postgres; OWNER TO monnethicadmin;

View file

@ -1,8 +1,8 @@
-- SEQUENCE: public."T_WALLET_wallet_id_seq" -- SEQUENCE: public."t_wallet_id_seq"
-- DROP SEQUENCE public."T_WALLET_wallet_id_seq"; -- DROP SEQUENCE public."t_wallet_id_seq";
CREATE SEQUENCE public."t_wallet_id_seq"; CREATE SEQUENCE public."t_wallet_id_seq";
ALTER SEQUENCE public."t__wallet_id_seq" ALTER SEQUENCE public."t_wallet_id_seq"
OWNER TO monnethicadmin; OWNER TO monnethicadmin;

View file

@ -7,7 +7,7 @@ CREATE TABLE public."T_SESSION"
session_id integer NOT NULL DEFAULT nextval('"t_session_id_seq"'::regclass), session_id integer NOT NULL DEFAULT nextval('"t_session_id_seq"'::regclass),
user_id bigint NOT NULL, user_id bigint NOT NULL,
start_session bigint NOT NULL, start_session bigint NOT NULL,
end_session bigint NOT NULL, end_session bigint,
CONSTRAINT "T_SESSION_pkey" PRIMARY KEY (session_id) CONSTRAINT "T_SESSION_pkey" PRIMARY KEY (session_id)
) )
WITH ( WITH (
@ -16,4 +16,4 @@ WITH (
TABLESPACE pg_default; TABLESPACE pg_default;
ALTER TABLE public."T_SESSION" ALTER TABLE public."T_SESSION"
OWNER to postgres; OWNER to monnethicadmin;

View file

@ -36,7 +36,7 @@ public class Config {
public static final String CHANNEL_NAME = "mychannel"; public static final String CHANNEL_NAME = "mychannel";
//public static final String CHAINCODE_NAME = "mycc"; //public static final String CHAINCODE_NAME = "mycc";
public static final String CHAINCODE_NAME = "monnethic"; public static final String CHAINCODE_NAME = "monnethic_2";
//public static final String CHAINCODE_NAME = "monnethic-dev-4"; //public static final String CHAINCODE_NAME = "monnethic-dev-4";
public static final String CHAINCODE_PROD = "monnethic-prod"; public static final String CHAINCODE_PROD = "monnethic-prod";

View file

@ -30,6 +30,7 @@ public class QueryWrapper {
queryByChaincodeRequest.setArgs(args); queryByChaincodeRequest.setArgs(args);
queryByChaincodeRequest.setFcn(functionName); queryByChaincodeRequest.setFcn(functionName);
queryByChaincodeRequest.setChaincodeID(chaincodeID); queryByChaincodeRequest.setChaincodeID(chaincodeID);
queryByChaincodeRequest.setProposalWaitTime(12000);
Collection<ProposalResponse> queryProposals; Collection<ProposalResponse> queryProposals;

View file

@ -4,10 +4,8 @@ import com.j256.ormlite.jdbc.JdbcConnectionSource;
import com.j256.ormlite.support.ConnectionSource; import com.j256.ormlite.support.ConnectionSource;
public class DatabaseHelper { public class DatabaseHelper {
private static final String DATABASE_NAME = "monnethic"; private static final String DATABASE_NAME = "monnethic_test";
//private static final String DATABASE_USER = "postgres";
private static final String DATABASE_USER = "monnethicadmin"; private static final String DATABASE_USER = "monnethicadmin";
//private static final String DATABASE_PWD = "L-*q~Ytaha{;u+7yJ8";
private static final String DATABASE_PWD = "vHEQszGXcJ6;/)}z!V"; private static final String DATABASE_PWD = "vHEQszGXcJ6;/)}z!V";
private final static String DATABASE_URL = "jdbc:postgresql://37.187.101.44:5432/"+DATABASE_NAME; private final static String DATABASE_URL = "jdbc:postgresql://37.187.101.44:5432/"+DATABASE_NAME;

View file

@ -6,7 +6,7 @@ import com.j256.ormlite.table.DatabaseTable;
@DatabaseTable(tableName = "T_WALLET") @DatabaseTable(tableName = "T_WALLET")
public class Wallet { public class Wallet {
@DatabaseField(canBeNull = false) @DatabaseField(generatedId = true)
private int wallet_id; private int wallet_id;
@DatabaseField(canBeNull = false) @DatabaseField(canBeNull = false)
private String wallet_hash; private String wallet_hash;
@ -80,7 +80,7 @@ public class Wallet {
public Double getBalance() { public Double getBalance() {
return balance; return balance;
} }
public void setBalance(Double sold) { public void setBalance(Double balance) {
this.balance = balance; this.balance = balance;
} }

View file

@ -69,13 +69,13 @@ public class WalletDao {
updateBuilder.update(); updateBuilder.update();
} }
public void deleteWallet(String walletHash) throws Exception{ public void deleteWallet(String walletHash, String userHash) throws Exception{
walletDao = createWalletDaoConnection(); walletDao = createWalletDaoConnection();
UpdateBuilder<Wallet, String> updateBuilder = walletDao.updateBuilder(); UpdateBuilder<Wallet, String> updateBuilder = walletDao.updateBuilder();
updateBuilder.updateColumnValue("is_active",false); updateBuilder.updateColumnValue("is_active",false);
Timestamp timestamp = new Timestamp(System.currentTimeMillis()); Timestamp timestamp = new Timestamp(System.currentTimeMillis());
updateBuilder.updateColumnValue("modification_date",timestamp.getTime()); updateBuilder.updateColumnValue("modification_date",timestamp.getTime());
updateBuilder.where().eq("walletHash",walletHash); updateBuilder.where().eq("wallet_hash",walletHash).and().eq("user_hash",userHash);
updateBuilder.update(); updateBuilder.update();
} }

View file

@ -1,7 +1,9 @@
package database.session; package database.session;
import com.j256.ormlite.field.DatabaseField; import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
@DatabaseTable(tableName = "T_SESSION")
public class Session { public class Session {
@DatabaseField(generatedId = true) @DatabaseField(generatedId = true)
private int session_id; private int session_id;
@ -9,7 +11,7 @@ public class Session {
private int user_id; private int user_id;
@DatabaseField(canBeNull = false) @DatabaseField(canBeNull = false)
private long start_session; private long start_session;
@DatabaseField(canBeNull = false) @DatabaseField
private long end_session; private long end_session;
public Session(){} public Session(){}

View file

@ -4,8 +4,7 @@ import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.dao.DaoManager; import com.j256.ormlite.dao.DaoManager;
import com.j256.ormlite.stmt.UpdateBuilder; import com.j256.ormlite.stmt.UpdateBuilder;
import database.DatabaseHelper; import database.DatabaseHelper;
import java.time.Instant;
import java.sql.Timestamp;
public class SessionDao { public class SessionDao {
private DatabaseHelper dbh = new DatabaseHelper(); private DatabaseHelper dbh = new DatabaseHelper();
@ -20,17 +19,17 @@ public class SessionDao {
} }
} }
public int setStartSession(int userId) throws Exception { public int setStartSession(Session session) throws Exception {
sessionDao = createSessionDaoConnection(); sessionDao = createSessionDaoConnection();
Timestamp timestamp = new Timestamp(System.currentTimeMillis()); sessionDao.create(session);
return sessionDao.updateRaw("INSERT INTO T_SESSION (user_id,start_session) VALUES ("+userId+","+timestamp+") RETURNING session_id"); return session.getSession_id();
} }
public void setEndSession(int session_id) throws Exception { public void setEndSession(int session_id) throws Exception {
sessionDao = createSessionDaoConnection(); sessionDao = createSessionDaoConnection();
UpdateBuilder<Session,String> updateBuilder = sessionDao.updateBuilder(); UpdateBuilder<Session,String> updateBuilder = sessionDao.updateBuilder();
Timestamp timestamp = new Timestamp(System.currentTimeMillis()); long now = Instant.now().toEpochMilli();
updateBuilder.updateColumnValue("end_session",timestamp); updateBuilder.updateColumnValue("end_session",now);
updateBuilder.where().eq("session_id",session_id); updateBuilder.where().eq("session_id",session_id);
updateBuilder.update(); updateBuilder.update();
} }

View file

@ -1,18 +1,27 @@
package restImplementation; package restImplementation;
import database.session.Session;
import database.session.SessionDao; import database.session.SessionDao;
import java.time.Instant;
public class SessionImplementation { public class SessionImplementation {
public int startSession(String userHash, String userEmail) throws Exception { public int startSession(String userHash, String userEmail) throws Exception {
SessionDao sessionDao = new SessionDao(); SessionDao sessionDao = new SessionDao();
UserImplementation userImplementation = new UserImplementation(); UserImplementation userImplementation = new UserImplementation();
int userId = userImplementation.getUserId(userHash,userEmail); int userId = userImplementation.getUserId(userHash,userEmail);
return sessionDao.setStartSession(userId);
Session session = new Session();
session.setUser_id(userId);
long now = Instant.now().toEpochMilli();
session.setStart_session(now);
return sessionDao.setStartSession(session);
} }
public void endSession(int userId) throws Exception { public void endSession(int sessionId) throws Exception {
SessionDao sessionDao = new SessionDao(); SessionDao sessionDao = new SessionDao();
sessionDao.setEndSession(userId); sessionDao.setEndSession(sessionId);
} }
} }

View file

@ -37,6 +37,7 @@ public class WalletImplementation {
wallet.setCreation_date(now); wallet.setCreation_date(now);
wallet.setModification_date(now); wallet.setModification_date(now);
walletDao.addWallet(wallet); // add wallet to replica DB walletDao.addWallet(wallet); // add wallet to replica DB
response.put("walletHash",wallet.getWallet_hash()); response.put("walletHash",wallet.getWallet_hash());
@ -77,18 +78,24 @@ public class WalletImplementation {
return wallet; return wallet;
} }
//setSold //setBalance
public void setSoldToWallet(String walletHash, double balance) throws Exception { public void setBalanceToWallet(String walletHash, double amount) throws Exception {
double newBalance = 0.0;
TransactionWrapper transactionWrapper = new TransactionWrapper(); TransactionWrapper transactionWrapper = new TransactionWrapper();
transactionWrapper.sendTransaction("setSoldOnWallet",new String[]{walletHash,String.valueOf(balance)}); transactionWrapper.sendTransaction("setSoldOnWallet",new String[]{walletHash,String.valueOf(amount)});
Wallet wallet = getWallet(walletHash);
if(wallet!=null){
newBalance=wallet.getBalance();
WalletDao walletDao = new WalletDao();
walletDao.updateWalletBalance(walletHash,newBalance);
} else {
throw new Exception("ERROR QUERY WALLET");
}
WalletDao walletDao = new WalletDao();
walletDao.updateWalletBalance(walletHash,balance);
} }
//addMoney
//TODO
//transfer //transfer
public void transferWallet(String walletHash, String newUserHash) throws Exception { public void transferWallet(String walletHash, String newUserHash) throws Exception {
TransactionWrapper transactionWrapper = new TransactionWrapper(); TransactionWrapper transactionWrapper = new TransactionWrapper();
@ -100,12 +107,12 @@ public class WalletImplementation {
//delete //delete
public void deleteWallet(String walletHash) throws Exception { public void deleteWallet(String walletHash, String userHash) throws Exception {
TransactionWrapper transactionWrapper = new TransactionWrapper(); TransactionWrapper transactionWrapper = new TransactionWrapper();
transactionWrapper.sendTransaction("deleteWallet",new String[]{walletHash}); transactionWrapper.sendTransaction("deleteWallet",new String[]{walletHash});
WalletDao walletDao = new WalletDao(); WalletDao walletDao = new WalletDao();
walletDao.deleteWallet(walletHash); walletDao.deleteWallet(walletHash,userHash);
} }

View file

@ -76,7 +76,7 @@ public class WalletResource {
public ResponseEntity setBalance(@RequestBody Wallet wallet){ public ResponseEntity setBalance(@RequestBody Wallet wallet){
WalletImplementation walletImplementation = new WalletImplementation(); WalletImplementation walletImplementation = new WalletImplementation();
try{ try{
walletImplementation.setSoldToWallet(wallet.getWallet_hash(),wallet.getBalance()); walletImplementation.setBalanceToWallet(wallet.getWallet_hash(),wallet.getBalance());
return ResponseEntity.status(HttpStatus.OK).body("{\"response\":\"ok\"}"); return ResponseEntity.status(HttpStatus.OK).body("{\"response\":\"ok\"}");
} catch (Exception e){ } catch (Exception e){
StringResponse responseS = new StringResponse(e.getMessage()); StringResponse responseS = new StringResponse(e.getMessage());
@ -99,11 +99,11 @@ public class WalletResource {
} }
@RequestMapping(value = "/delete/{walletHash}", method = RequestMethod.DELETE) @RequestMapping(value = "/{userHash}/delete/{walletHash}", method = RequestMethod.DELETE)
public ResponseEntity deleteWallet(@PathVariable("walletHash") String walletHash){ public ResponseEntity deleteWallet(@PathVariable("walletHash") String walletHash, @PathVariable("userHash") String userHash){
WalletImplementation walletImplementation = new WalletImplementation(); WalletImplementation walletImplementation = new WalletImplementation();
try{ try{
walletImplementation.deleteWallet(walletHash); walletImplementation.deleteWallet(walletHash,userHash);
return ResponseEntity.status(HttpStatus.OK).body("{\"response\":\"ok\"}"); return ResponseEntity.status(HttpStatus.OK).body("{\"response\":\"ok\"}");
}catch (Exception e){ }catch (Exception e){
StringResponse responseS = new StringResponse(e.getMessage()); StringResponse responseS = new StringResponse(e.getMessage());

View file

@ -19,7 +19,7 @@ public class DeleteUserTest {
try{ try{
TransactionWrapper transactionWrapper = new TransactionWrapper(); TransactionWrapper transactionWrapper = new TransactionWrapper();
String functionName = "deleteUser"; String functionName = "deleteUser";
String[] args = new String[]{"$2a$10$04YjBhcKPG.DD8abC/AnhOwTIbYH1x0Gr78XXVhAd6551c3Cb21i2"}; String[] args = new String[]{"$2a$10$tpC8fILKiQqyApJ8/jTPE.YX0grzZsEtmWUyJAidmHOuWGQ4FBdfy"};
BlockEvent.TransactionEvent responseEvent = transactionWrapper.sendTransaction(functionName,args); BlockEvent.TransactionEvent responseEvent = transactionWrapper.sendTransaction(functionName,args);
logger.info("Event transaction id : "+responseEvent.getTransactionID()); //print transaction id logger.info("Event transaction id : "+responseEvent.getTransactionID()); //print transaction id
}catch (Exception e){ }catch (Exception e){

View file

@ -22,7 +22,7 @@ public class ReadUserTest {
try{ try{
QueryWrapper queryWrapper = new QueryWrapper(); QueryWrapper queryWrapper = new QueryWrapper();
String functionName = "readUser"; String functionName = "readUser";
String[] args = new String[]{"$2a$10$tpC8fILKiQqyApJ8/jTPE.YX0grzZsEtmWUyJAidmHOuWGQ4FBdfy"}; String[] args = new String[]{"$2a$10$tdkMwJ7BQSOXO2uofu/fEOlncUfuX7SsjB.2N9KVsXJUQiarAQzpG"};
String response = queryWrapper.sendQuery(functionName,args); String response = queryWrapper.sendQuery(functionName,args);
if(response != null){ if(response != null){
JsonReader reader = Json.createReader(new StringReader(response)); JsonReader reader = Json.createReader(new StringReader(response));

View file

@ -24,8 +24,7 @@ public class QueryWalletByOwnerTest {
try{ try{
QueryWrapper queryWrapper = new QueryWrapper(); QueryWrapper queryWrapper = new QueryWrapper();
String functionName = "queryWalletsByOwner"; String functionName = "queryWalletsByOwner";
//String[] args = new String[]{"usera"}; String[] args = new String[]{"$2a$10$tdkMwJ7BQSOXO2uofu/fEOlncUfuX7SsjB.2N9KVsXJUQiarAQzpG"};
String[] args = new String[]{"bitman"};
String response = queryWrapper.sendQuery(functionName,args); String response = queryWrapper.sendQuery(functionName,args);
logger.info("response : "+response); logger.info("response : "+response);

View file

@ -18,7 +18,7 @@ public class QueryWalletHistory {
try{ try{
QueryWrapper queryWrapper = new QueryWrapper(); QueryWrapper queryWrapper = new QueryWrapper();
String functionName = "getHistoryForWallet"; String functionName = "getHistoryForWallet";
String[] args = new String[]{"qerh654d5f5hdsf1515"}; String[] args = new String[]{"$2a$10$X2xW3CH/q7nij8yJpQTao.vEnuV31lNSMPhTCjGNl4oFp6MXW/6w6"};
String response = queryWrapper.sendQuery(functionName,args); String response = queryWrapper.sendQuery(functionName,args);
logger.info("response : "+response); logger.info("response : "+response);
}catch (Exception e){ }catch (Exception e){

View file

@ -17,14 +17,14 @@ import java.io.StringReader;
public class ReadWalletTest { public class ReadWalletTest {
private static Logger logger = Logger.getLogger(ReadWalletTest.class); private static Logger logger = Logger.getLogger(ReadWalletTest.class);
/*
@Test @Test
public void SuccessTestReadWalletTest() { public void SuccessTestReadWalletTest() {
BasicConfigurator.configure(); BasicConfigurator.configure();
try{ try{
QueryWrapper queryWrapper = new QueryWrapper(); QueryWrapper queryWrapper = new QueryWrapper();
String functionName = "readWallet"; String functionName = "readWallet";
String[] args = new String[]{"qerh654d5f5h46q4fdh6h65fh00"}; String[] args = new String[]{"$2a$10$PuJBO70uMfzUwbQ/Qz9kTe7JYJppwetyLyP0e6JAITr3B6pQf0cbe"};
String response = queryWrapper.sendQuery(functionName,args); String response = queryWrapper.sendQuery(functionName,args);
if(response!=null){ if(response!=null){
@ -40,8 +40,9 @@ public class ReadWalletTest {
e.printStackTrace(); e.printStackTrace();
} }
} }
*/
/*
@Test @Test
public void FailTestReadWalletTest() { public void FailTestReadWalletTest() {
BasicConfigurator.configure(); BasicConfigurator.configure();
@ -66,4 +67,5 @@ public class ReadWalletTest {
e.printStackTrace(); e.printStackTrace();
} }
} }
*/
} }

View file

@ -0,0 +1,40 @@
package restImplementation;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;
import org.junit.Ignore;
import org.junit.Test;
@Ignore
public class SessionImplementationTest {
private static Logger logger = Logger.getLogger(SessionImplementationTest.class);
@Test
public void testAstartSession() { //OK
BasicConfigurator.configure();
String userHash = "$2a$10$tdkMwJ7BQSOXO2uofu/fEOlncUfuX7SsjB.2N9KVsXJUQiarAQzpG";
String userEmail = "TotoEmail@gmail.com";
SessionImplementation sessionImplementation = new SessionImplementation();
try{
int responseSessionId = sessionImplementation.startSession(userHash,userEmail);
logger.info("SESSION ID : "+responseSessionId);
} catch (Exception e){
logger.warn("Error: "+e);
}
}
@Test
public void testBendSession(){ //OK
BasicConfigurator.configure();
SessionImplementation sessionImplementation = new SessionImplementation();
try{
sessionImplementation.endSession(1);
} catch (Exception e){
logger.warn("Error: "+e);
}
}
}

View file

@ -11,11 +11,14 @@ import java.util.Map;
@Ignore @Ignore
public class UserImplementationTest { public class UserImplementationTest {
private static Logger logger = Logger.getLogger(UserImplementationTest.class); private static Logger logger = Logger.getLogger(UserImplementationTest.class);
String userHash1 = null;
String userHash2 = null;
/* /*
@Test @Test
public void RegisterUserWithoutPhone() { public void RegisterUserWithoutPhone() { //OK
BasicConfigurator.configure(); BasicConfigurator.configure();
User userTest = new User("TotoName","TotoFirstName","TotoEmail@gmail.com","totoPassword1234$","gonette"); User userTest = new User("TotoName","TotoFirstName","TotoEmail@gmail.com","totoPassword1234$","gonette");
UserImplementation userImplementation = new UserImplementation(); UserImplementation userImplementation = new UserImplementation();
@ -25,17 +28,16 @@ public class UserImplementationTest {
logger.info("response is: "+response.get("response")); logger.info("response is: "+response.get("response"));
if(Boolean.parseBoolean(response.get("response"))){ if(Boolean.parseBoolean(response.get("response"))){
StringResponse responseS = new StringResponse("Ok",response.get("userHash")); StringResponse responseS = new StringResponse("Ok",response.get("userHash"));
userHash1 = responseS.getUserHash();
logger.info("StringResponse is: "+responseS.getResponse()+". User hash: "+responseS.getUserHash()); logger.info("StringResponse is: "+responseS.getResponse()+". User hash: "+responseS.getUserHash());
} }
} catch (Exception e){ } catch (Exception e){
logger.warn("Error: "+e); logger.warn("Error: "+e);
} }
} }
*/
/*
@Test @Test
public void RegisterUserWithPhone() { public void RegisterUserWithPhone() { //OK
BasicConfigurator.configure(); BasicConfigurator.configure();
User userTest = new User("TataName","TataFirstName","TataEmail@gmail.com","tataPassword1234$","0607080900","gonette"); User userTest = new User("TataName","TataFirstName","TataEmail@gmail.com","tataPassword1234$","0607080900","gonette");
UserImplementation userImplementation = new UserImplementation(); UserImplementation userImplementation = new UserImplementation();
@ -45,6 +47,7 @@ public class UserImplementationTest {
logger.info("response is: "+responseTest.get("response")); logger.info("response is: "+responseTest.get("response"));
if(Boolean.parseBoolean(responseTest.get("response"))){ if(Boolean.parseBoolean(responseTest.get("response"))){
StringResponse responseS = new StringResponse("Ok",responseTest.get("userHash")); StringResponse responseS = new StringResponse("Ok",responseTest.get("userHash"));
userHash2 = responseS.getUserHash();
logger.info("StringResponse is: "+responseS.getResponse()+". User hash: "+responseS.getUserHash()); logger.info("StringResponse is: "+responseS.getResponse()+". User hash: "+responseS.getUserHash());
} }
}catch (Exception e){ }catch (Exception e){
@ -52,9 +55,34 @@ public class UserImplementationTest {
} }
} }
@Test
public void approveUser1Test() { //ok
BasicConfigurator.configure();
User userTest = new User("TotoEmail@gmail.com",userHash1);
UserImplementation userImplementation = new UserImplementation();
try {
userImplementation.approveUser(userTest);
}catch (Exception e){
logger.warn("Error: "+e);
}
}
@Test @Test
public void userLoggerTest(){ public void approveUser2Test() { //ok
BasicConfigurator.configure();
User userTest = new User("TataEmail@gmail.com",userHash2);
UserImplementation userImplementation = new UserImplementation();
try {
userImplementation.approveUser(userTest);
}catch (Exception e){
logger.warn("Error: "+e);
}
}
@Test
public void userLoggerTest(){ //OK
BasicConfigurator.configure(); BasicConfigurator.configure();
User userTest = new User("TataName","TataFirstName","TataEmail@gmail.com","tataPassword1234$","0607080900","gonette"); User userTest = new User("TataName","TataFirstName","TataEmail@gmail.com","tataPassword1234$","0607080900","gonette");
UserImplementation userImplementation = new UserImplementation(); UserImplementation userImplementation = new UserImplementation();
@ -69,28 +97,13 @@ public class UserImplementationTest {
} }
} }
*/
@Test @Test
public void approveUserTest() { public void deleteUserTest(){ //OK
BasicConfigurator.configure(); BasicConfigurator.configure();
User userTest = new User("TotoEmail@gmail.com","$2a$10$tpC8fILKiQqyApJ8/jTPE.YX0grzZsEtmWUyJAidmHOuWGQ4FBdfy"); User userTest = new User("TotoEmail@gmail.com","$2a$10$AFlLoL3MpyILTmI4CAnVce8XYagrqkqQ9Be8pVAzadNDvexbBXZHm");
UserImplementation userImplementation = new UserImplementation();
try {
userImplementation.approveUser(userTest);
}catch (Exception e){
logger.warn("Error: "+e);
}
}
/*
@Test
public void deleteUserTest(){
BasicConfigurator.configure();
User userTest = new User("TataEmail@gmail.com","$2a$10$N1C1lPeVMZ6oY4hSyX2cbuKBoGtJ0yWSXIgBaZ1RsI8QfaoTHCYi2");
UserImplementation userImplementation = new UserImplementation(); UserImplementation userImplementation = new UserImplementation();
try{ try{
userImplementation.deleteUser(userTest); userImplementation.deleteUser(userTest);
@ -101,4 +114,6 @@ public class UserImplementationTest {
*/ */
} }

View file

@ -12,10 +12,11 @@ import java.util.Map;
public class WalletImplementationTest { public class WalletImplementationTest {
private static Logger logger = Logger.getLogger(UserImplementationTest.class); private static Logger logger = Logger.getLogger(UserImplementationTest.class);
/*
@Test @Test
public void CreateWallet() { public void UserACreateWallet() { // OK
BasicConfigurator.configure(); BasicConfigurator.configure();
Wallet wallet = new Wallet("client","$2a$10$tpC8fILKiQqyApJ8/jTPE.YX0grzZsEtmWUyJAidmHOuWGQ4FBdfy"); Wallet wallet = new Wallet("client","$2a$10$tdkMwJ7BQSOXO2uofu/fEOlncUfuX7SsjB.2N9KVsXJUQiarAQzpG");
WalletImplementation walletImplementation = new WalletImplementation(); WalletImplementation walletImplementation = new WalletImplementation();
try{ try{
@ -31,8 +32,101 @@ public class WalletImplementationTest {
} catch (Exception e){ } catch (Exception e){
logger.warn("Error: "+e.getMessage()); logger.warn("Error: "+e.getMessage());
} }
}
*/
/*
@Test
public void UserBCreateWallet() { //OK
BasicConfigurator.configure();
Wallet wallet = new Wallet("fournisseur","$2a$10$iMk/RWukka34xhF7drB7z.mb3YWbRh0qtunTpPXLbTBaZu2TxAOAW");
WalletImplementation walletImplementation = new WalletImplementation();
try{
Map<String,String> walletResponse = walletImplementation.createWallet(wallet);
Wallet returnWallet = new Wallet();
returnWallet.setWallet_hash(walletResponse.get("walletHash"));
returnWallet.setBalance(Double.parseDouble(walletResponse.get("walletSold")));
returnWallet.setType(walletResponse.get("walletType"));
logger.info("wallet hash: "+returnWallet.getWallet_hash());
logger.info("wallet sold: "+returnWallet.getBalance());
logger.info("wallet type: "+returnWallet.getType());
} catch (Exception e){
logger.warn("Error: "+e.getMessage());
}
}
*/
/*
@Test
public void UserB2CreateWallet() { //OK
BasicConfigurator.configure();
Wallet wallet = new Wallet("client","$2a$10$iMk/RWukka34xhF7drB7z.mb3YWbRh0qtunTpPXLbTBaZu2TxAOAW");
WalletImplementation walletImplementation = new WalletImplementation();
try{
Map<String,String> walletResponse = walletImplementation.createWallet(wallet);
Wallet returnWallet = new Wallet();
returnWallet.setWallet_hash(walletResponse.get("walletHash"));
returnWallet.setBalance(Double.parseDouble(walletResponse.get("walletSold")));
returnWallet.setType(walletResponse.get("walletType"));
logger.info("wallet hash: "+returnWallet.getWallet_hash());
logger.info("wallet sold: "+returnWallet.getBalance());
logger.info("wallet type: "+returnWallet.getType());
} catch (Exception e){
logger.warn("Error: "+e.getMessage());
}
}
*/
/*
@Test
public void TestDeleteWallet() { //OK
BasicConfigurator.configure();
WalletImplementation walletImplementation = new WalletImplementation();
try{
walletImplementation.deleteWallet("$2a$10$X2xW3CH/q7nij8yJpQTao.vEnuV31lNSMPhTCjGNl4oFp6MXW/6w6","$2a$10$iMk/RWukka34xhF7drB7z.mb3YWbRh0qtunTpPXLbTBaZu2TxAOAW");
} catch (Exception e){
logger.warn("Error: "+e.getMessage());
}
}
*/
/*
@Test
public void TestGetWallet(){ //OK
BasicConfigurator.configure();
WalletImplementation walletImplementation = new WalletImplementation();
try{
Wallet wallet = walletImplementation.getWallet("$2a$10$PuJBO70uMfzUwbQ/Qz9kTe7JYJppwetyLyP0e6JAITr3B6pQf0cbe");
logger.info("Wallet hash : "+wallet.getWallet_hash());
logger.info("Wallet owner : "+wallet.getUser_hash());
logger.info("Wallet type : "+wallet.getType());
logger.info("Wallet balance : "+wallet.getBalance());
} catch (Exception e){
logger.warn("Error: "+e.getMessage());
}
}
*/
@Test
public void TestSetBalance(){ //TODO
BasicConfigurator.configure();
WalletImplementation walletImplementation = new WalletImplementation();
try{
walletImplementation.setBalanceToWallet("$2a$10$PuJBO70uMfzUwbQ/Qz9kTe7JYJppwetyLyP0e6JAITr3B6pQf0cbe",20.0);
} catch (Exception e){
logger.warn("Error: "+e.getMessage());
}
} }
} }