chore: update
Java CI with Maven / build-and-test (pull_request) Successful in 17m8s

This commit is contained in:
TakahashiNg
2026-04-12 05:30:31 +00:00
parent 01538034ea
commit baf218a208
4 changed files with 33 additions and 32 deletions
@@ -1,8 +1,6 @@
package com.drinkool.services;
import com.drinkool.InternalValue;
import com.drinkool.Role;
import com.drinkool.Url;
import com.drinkool.*;
import com.drinkool.dtos.*;
import com.drinkool.entities.CustomerEntity;
import jakarta.inject.Inject;
@@ -87,24 +85,4 @@ public class CustomerService {
.header(InternalValue.role, Role.Customer)
.build();
}
@POST
@Path(Url.SmsOtp)
public Response smsOtp(SmsOtp input) {
CustomerEntity customer = CustomerEntity.find(
"phone",
input.phone
).firstResult();
if (customer == null) return Response.status(Response.Status.BAD_REQUEST)
.entity("InvalidPhoneNumber")
.build();
String otp = otpService.generateAndSaveOtp(input.phone);
// Ở đây bạn sẽ gọi Kafka để gửi SMS thực tế
System.out.println("OTP cho " + input.phone + " là: " + otp);
return Response.accepted().build();
}
}
@@ -2,7 +2,9 @@ package com.drinkool.services;
import com.drinkool.InternalValue;
import com.drinkool.Url;
import com.drinkool.dtos.SmsOtp;
import com.drinkool.models.UserModel;
import jakarta.inject.Inject;
import jakarta.transaction.Transactional;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.Response;
@@ -11,6 +13,9 @@ import java.util.UUID;
@Path("")
public class UserService {
@Inject
OtpService otpService;
@POST
@Path(Url.Me)
@Transactional
@@ -21,4 +26,21 @@ public class UserService {
return Response.ok(UserModel.find("id", id).firstResult()).build();
}
@POST
@Path(Url.SmsOtp)
public Response smsOtp(SmsOtp input) {
UserModel customer = UserModel.find("phone", input.phone).firstResult();
if (customer == null) return Response.status(Response.Status.BAD_REQUEST)
.entity("InvalidPhoneNumber")
.build();
String otp = otpService.generateAndSaveOtp(input.phone);
// Ở đây bạn sẽ gọi Kafka để gửi SMS thực tế
System.out.println("OTP cho " + input.phone + " là: " + otp);
return Response.accepted().build();
}
}
@@ -35,7 +35,7 @@ public class AuthenticationServiceTest {
.contentType(ContentType.JSON)
.body(input)
.when()
.post(Url.Signup)
.post(Role.Customer + Url.Signup)
.then()
.statusCode(201);
@@ -53,7 +53,7 @@ public class AuthenticationServiceTest {
.contentType(ContentType.JSON)
.body(input)
.when()
.post(Url.QuickSignup)
.post(Role.Customer + Url.QuickSignup)
.then()
.header(InternalValue.userId, notNullValue())
.header(InternalValue.role, is(Role.Customer))
@@ -74,7 +74,7 @@ public class AuthenticationServiceTest {
given()
.contentType(ContentType.JSON)
.body(signupData)
.post(Url.Signup)
.post(Role.Customer + Url.Signup)
.then()
.statusCode(201);
@@ -87,7 +87,7 @@ public class AuthenticationServiceTest {
.contentType(ContentType.JSON)
.body(loginInput)
.when()
.post(Url.Login)
.post(Role.Customer + Url.Login)
.then()
.statusCode(202);
}
@@ -103,7 +103,7 @@ public class AuthenticationServiceTest {
given()
.contentType(ContentType.JSON)
.body(signupData)
.post(Url.Signup)
.post(Role.Customer + Url.Signup)
.then()
.statusCode(201);
@@ -115,7 +115,7 @@ public class AuthenticationServiceTest {
.contentType(ContentType.JSON)
.body(loginInput)
.when()
.post(Url.Login)
.post(Role.Customer + Url.Login)
.then()
.statusCode(400); // BadRequestException
}
@@ -135,7 +135,7 @@ public class AuthenticationServiceTest {
.contentType(ContentType.JSON)
.body(signup)
.when()
.post(Url.Signup)
.post(Role.Customer + Url.Signup)
.then();
given()
@@ -158,7 +158,7 @@ public class AuthenticationServiceTest {
.contentType(ContentType.JSON)
.body(input)
.when()
.post(Url.QuickLogin)
.post(Role.Customer + Url.QuickLogin)
.then()
.statusCode(401);
}
@@ -4,6 +4,7 @@ import static io.restassured.RestAssured.*;
import static org.hamcrest.CoreMatchers.*;
import com.drinkool.InternalValue;
import com.drinkool.Role;
import com.drinkool.Url;
import com.drinkool.dtos.QuickSignup;
import io.quarkus.test.junit.QuarkusTest;
@@ -23,7 +24,7 @@ public class UserServiceTest {
.contentType(ContentType.JSON)
.body(input)
.when()
.post(Url.QuickSignup)
.post(Role.Customer + Url.QuickSignup)
.then()
.extract()
.header(InternalValue.userId);