Merge branch 'features1.4/user' into develop-1.4
This commit is contained in:
commit
be076b7fab
|
@ -11,7 +11,7 @@ CREATE TABLE public."T_USER"
|
||||||
password character varying(255) COLLATE pg_catalog."default" NOT NULL,
|
password character varying(255) COLLATE pg_catalog."default" NOT NULL,
|
||||||
creation_date bigint NOT NULL,
|
creation_date bigint NOT NULL,
|
||||||
modification_date bigint NOT NULL,
|
modification_date bigint NOT NULL,
|
||||||
phone bigint NOT NULL,
|
phone character varying(255) COLLATE pg_catalog."default" NOT NULL,
|
||||||
association character varying(255) COLLATE pg_catalog."default" NOT NULL,
|
association character varying(255) COLLATE pg_catalog."default" NOT NULL,
|
||||||
verified boolean NOT NULL,
|
verified boolean NOT NULL,
|
||||||
approved boolean NOT NULL,
|
approved boolean NOT NULL,
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class TransactionWrapper {
|
||||||
//try{
|
//try{
|
||||||
|
|
||||||
Collection<ProposalResponse> successful = new LinkedList<>();
|
Collection<ProposalResponse> successful = new LinkedList<>();
|
||||||
Collection<ProposalResponse> failed = new LinkedList<>();
|
//Collection<ProposalResponse> failed = new LinkedList<>();
|
||||||
FabricClientWrapper fabricClientWrapper;
|
FabricClientWrapper fabricClientWrapper;
|
||||||
|
|
||||||
if(user != null){
|
if(user != null){
|
||||||
|
@ -56,8 +56,9 @@ public class TransactionWrapper {
|
||||||
logger.info("Successful transaction proposal response Txid: "+response.getTransactionID()+" from peer "+response.getPeer().getName());
|
logger.info("Successful transaction proposal response Txid: "+response.getTransactionID()+" from peer "+response.getPeer().getName());
|
||||||
successful.add(response);
|
successful.add(response);
|
||||||
} else {
|
} else {
|
||||||
failed.add(response);
|
|
||||||
logger.info("Failed transaction proposal response Txid: "+response.getTransactionID()+" from peer "+response.getPeer().getName());
|
logger.info("Failed transaction proposal response Txid: "+response.getTransactionID()+" from peer "+response.getPeer().getName());
|
||||||
|
throw new Exception("Error during insert into Blockchain");
|
||||||
|
//failed.add(response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class User {
|
||||||
@DatabaseField(canBeNull = false)
|
@DatabaseField(canBeNull = false)
|
||||||
private long modification_date;
|
private long modification_date;
|
||||||
@DatabaseField(canBeNull = false)
|
@DatabaseField(canBeNull = false)
|
||||||
private long phone;
|
private String phone;
|
||||||
@DatabaseField(canBeNull = false)
|
@DatabaseField(canBeNull = false)
|
||||||
private String association;
|
private String association;
|
||||||
@DatabaseField(canBeNull = false)
|
@DatabaseField(canBeNull = false)
|
||||||
|
@ -36,13 +36,24 @@ public class User {
|
||||||
public User() {
|
public User() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public User(String name, String firstname, String email, String password) {
|
public User(String name, String firstname, String email, String password, String association) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.firstname = firstname;
|
this.firstname = firstname;
|
||||||
this.email = email;
|
this.email = email;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
|
this.association = association;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public User(String name, String firstname, String email, String password, String phone, String association){
|
||||||
|
this.name = name;
|
||||||
|
this.firstname = firstname;
|
||||||
|
this.email = email;
|
||||||
|
this.password = password;
|
||||||
|
this.phone = phone;
|
||||||
|
this.association = association;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public User(String name, String firstname,String user_hash, String email, String password, long creation_date, long modification_date, boolean verified, boolean approved) {
|
public User(String name, String firstname,String user_hash, String email, String password, long creation_date, long modification_date, boolean verified, boolean approved) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.firstname = firstname;
|
this.firstname = firstname;
|
||||||
|
@ -55,7 +66,7 @@ public class User {
|
||||||
this.approved = approved;
|
this.approved = approved;
|
||||||
}
|
}
|
||||||
|
|
||||||
public User(String name, String firstname,String user_hash, String email, String password, long creation_date, long modification_date, long phone, String association, boolean verified, boolean approved) {
|
public User(String name, String firstname,String user_hash, String email, String password, long creation_date, long modification_date, String phone, String association, boolean verified, boolean approved) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.firstname = firstname;
|
this.firstname = firstname;
|
||||||
this.user_hash = user_hash;
|
this.user_hash = user_hash;
|
||||||
|
@ -69,14 +80,6 @@ public class User {
|
||||||
this.approved = approved;
|
this.approved = approved;
|
||||||
}
|
}
|
||||||
|
|
||||||
public User(String name, String firstname, String user_hash, int phone, String association){
|
|
||||||
this.name = name;
|
|
||||||
this.firstname = firstname;
|
|
||||||
this.user_hash = user_hash;
|
|
||||||
this.phone = phone;
|
|
||||||
this.association = association;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Getters and Setters
|
//Getters and Setters
|
||||||
public int getUserId() {
|
public int getUserId() {
|
||||||
|
@ -130,8 +133,8 @@ public class User {
|
||||||
this.modification_date = modification_date;
|
this.modification_date = modification_date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getPhone(){return phone;}
|
public String getPhone(){return phone;}
|
||||||
public void setPhone(int phone){this.phone=phone;}
|
public void setPhone(String phone){this.phone=phone;}
|
||||||
|
|
||||||
public String getAssociation(){return association;}
|
public String getAssociation(){return association;}
|
||||||
public void setAssociation(){this.association=association;}
|
public void setAssociation(){this.association=association;}
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class BlockchainQueryImplementation {
|
||||||
return wallets;
|
return wallets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public String sendTransaction(String sourceWallet, String destinationWallet, Double amount){
|
public String sendTransaction(String sourceWallet, String destinationWallet, Double amount){
|
||||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||||
BlockEvent.TransactionEvent transactionEvent = transactionWrapper.sendTransaction("transaction",new String[]{sourceWallet,destinationWallet,amount.toString()});
|
BlockEvent.TransactionEvent transactionEvent = transactionWrapper.sendTransaction("transaction",new String[]{sourceWallet,destinationWallet,amount.toString()});
|
||||||
|
@ -91,6 +91,7 @@ public class BlockchainQueryImplementation {
|
||||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||||
transactionWrapper.sendTransaction("transferWallet", new String[]{walletHash,userHash});
|
transactionWrapper.sendTransaction("transferWallet", new String[]{walletHash,userHash});
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,10 @@ public class UserImplementation {
|
||||||
user.setUser_hash(hashPassword(user.getName()+user.getEmail()+user.getFirstname()+user.getAssociation()));
|
user.setUser_hash(hashPassword(user.getName()+user.getEmail()+user.getFirstname()+user.getAssociation()));
|
||||||
|
|
||||||
//REGISTER IN BLOCKCHAIN
|
//REGISTER IN BLOCKCHAIN
|
||||||
|
if(user.getPhone()==null){
|
||||||
|
user.setPhone("0000000000");
|
||||||
|
}
|
||||||
|
|
||||||
String[] userInfos = new String[]{user.getUser_hash(),user.getName(),user.getFirstname(),""+user.getPhone(),user.getAssociation()};
|
String[] userInfos = new String[]{user.getUser_hash(),user.getName(),user.getFirstname(),""+user.getPhone(),user.getAssociation()};
|
||||||
transactionWrapper.sendTransaction("registerUser",userInfos);
|
transactionWrapper.sendTransaction("registerUser",userInfos);
|
||||||
|
|
||||||
|
|
|
@ -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[]{"usera"};
|
String[] args = new String[]{"$2a$10$6vjtplKcFKKaE0HKGd.8VOJi0xugc5Ojbf9m5LqyZ8mzU5nfcxt5."};
|
||||||
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){
|
||||||
|
|
|
@ -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[]{"usera"};
|
String[] args = new String[]{"$2a$10$6vjtplKcFKKaE0HKGd.8VOJi0xugc5Ojbf9m5LqyZ8mzU5nfcxt5."};
|
||||||
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));
|
||||||
|
|
|
@ -7,6 +7,7 @@ import restImplementation.DatabaseUserImplementation;
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
public class DatabaseUserImplementationTest {
|
public class DatabaseUserImplementationTest {
|
||||||
|
/*
|
||||||
@Test
|
@Test
|
||||||
public void TestUser(){
|
public void TestUser(){
|
||||||
try {
|
try {
|
||||||
|
@ -20,4 +21,5 @@ public class DatabaseUserImplementationTest {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
53
src/test/java/restImplementation/UserImplementationTest.java
Normal file
53
src/test/java/restImplementation/UserImplementationTest.java
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
package restImplementation;
|
||||||
|
|
||||||
|
import database.user.User;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.junit.Ignore;
|
||||||
|
import org.junit.Test;
|
||||||
|
import restService.StringResponse;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
public class UserImplementationTest {
|
||||||
|
private static Logger logger = Logger.getLogger(UserImplementationTest.class);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void RegisterUserWithoutPhone() {
|
||||||
|
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"))){
|
||||||
|
StringResponse responseS = new StringResponse("Ok",response.get("userHash"));
|
||||||
|
logger.info("StringResponse is: "+responseS.getResponse()+". User hash: "+responseS.getUserHash());
|
||||||
|
}
|
||||||
|
} catch (Exception e){
|
||||||
|
logger.warn("Error: "+e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
@Test
|
||||||
|
public void RegisterUserWithPhone() {
|
||||||
|
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"))){
|
||||||
|
StringResponse responseS = new StringResponse("Ok",responseTest.get("userHash"));
|
||||||
|
logger.info("StringResponse is: "+responseS.getResponse()+". User hash: "+responseS.getUserHash());
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.warn("Error: "+e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
|
@ -8,6 +8,7 @@ import java.util.Map;
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
public class UserLoggerTest {
|
public class UserLoggerTest {
|
||||||
|
/*
|
||||||
@Test
|
@Test
|
||||||
public void testLoggerUser(){
|
public void testLoggerUser(){
|
||||||
try{
|
try{
|
||||||
|
@ -22,4 +23,5 @@ public class UserLoggerTest {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue