chore: update
This commit is contained in:
@@ -9,10 +9,15 @@ import jakarta.transaction.Transactional;
|
||||
import jakarta.ws.rs.BadRequestException;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.text.StyledEditorKit.BoldAction;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.drinkool.entities.CustomerEntity;
|
||||
|
||||
import groovyjarjarantlr4.v4.parse.ANTLRParser.labeledAlt_return;
|
||||
|
||||
@Entity
|
||||
@Table
|
||||
class TestUserEntity extends UserModel {}
|
||||
@@ -71,4 +76,43 @@ public class UserModelTest {
|
||||
|
||||
assertEquals("InvalidPhoneNumber", exception.getMessage());
|
||||
}
|
||||
@Test
|
||||
@Transactional
|
||||
public void testLoginSuccess() {
|
||||
//dang nhap thanh cong
|
||||
TestUserEntity user = new TestUserEntity();
|
||||
String phone =
|
||||
"+8477" + String.format("%07d", (new Random()).nextInt(10000000));
|
||||
String password = "02092006Danh";
|
||||
user.signup("Tran Huu Danh", phone, password);
|
||||
|
||||
Boolean loginResult = user.login(password);
|
||||
|
||||
assertTrue(loginResult);
|
||||
}
|
||||
@Test
|
||||
@Transactional
|
||||
public void testLoginFailWrongPassword() {
|
||||
//dang nhap that bai
|
||||
TestUserEntity user = new TestUserEntity();
|
||||
String phone =
|
||||
"+8477" + String.format("%07d", (new Random()).nextInt(10000000));
|
||||
String truePassword = "02092006Danh";
|
||||
String wrongPassword = "02092006danhh";
|
||||
|
||||
user.signup("Tran Huu Danh", phone, truePassword);
|
||||
Boolean wrongTest = user.login(wrongPassword);
|
||||
|
||||
assertFalse(wrongTest);
|
||||
}
|
||||
@Test
|
||||
@Transactional
|
||||
public void testLoginFailNullHashedPassword(){
|
||||
TestUserEntity user = new TestUserEntity();
|
||||
String phone = "+84372548260";
|
||||
user.hashedPassword = null;
|
||||
|
||||
boolean loginResult = user.login("anhdomixi");
|
||||
assertFalse(loginResult);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.drinkool.services;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.http.ContentType;
|
||||
|
||||
@QuarkusTest
|
||||
public class AuthenticationServiceTest {
|
||||
public void signupTestAPI(){
|
||||
Map<String, String> newUser = new HashMap<>();
|
||||
newUser.put("name","Tran Huu Danh");
|
||||
newUser.put("phone","+8477" + String.format("%07d", (new Random()).nextInt(10000000)));
|
||||
newUser.put("password","trandanh020906@");
|
||||
|
||||
given()
|
||||
.contentType(ContentType.JSON)
|
||||
.body(newUser)
|
||||
.when()
|
||||
.post("/api/signup")
|
||||
.then()
|
||||
.statusCode(201);
|
||||
assertEquals(1, InventoryItemEntity.find("newUser", newUser).count());
|
||||
|
||||
}
|
||||
@Test
|
||||
public void loginTestAPI(){
|
||||
Map<String, String> newUser = new HashMap<>();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.drinkool.services;
|
||||
|
||||
public interface InventoryItemEntity {
|
||||
|
||||
}
|
||||
@@ -1,12 +1,16 @@
|
||||
package com.drinkool.services;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static io.restassured.RestAssured.when;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import com.drinkool.dtos.AddInventory;
|
||||
import com.drinkool.entities.InventoryItemEntity;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.http.ContentType;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -33,4 +37,6 @@ public class InventoryServiceTest {
|
||||
|
||||
assertEquals(1, InventoryItemEntity.find("name", name).count());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user