fix: final commit (#61)
Release package / release (push) Successful in 22m28s

Co-authored-by: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com>
Reviewed-on: #61
This commit was merged in pull request #61.
This commit is contained in:
2026-05-15 14:22:35 +00:00
parent 8fad38fa6c
commit aa7bfed331
60 changed files with 196 additions and 154 deletions
@@ -29,7 +29,7 @@ public class ManagerEntity extends UserModel {
}
@Transactional
public void signup(
public ManagerEntity signup(
String name,
String phone,
String bankAccount,
@@ -38,5 +38,7 @@ public class ManagerEntity extends UserModel {
this.bankAccount = bankAccount;
super.signup(name, phone, rawPassword);
return this;
}
}
@@ -13,6 +13,10 @@ import jakarta.transaction.Transactional;
@Table(name = Role.Staff)
public class StaffEntity extends UserModel {
public StaffEntity() {
super(Role.Staff);
}
@Transactional
public void signup(
String name,
@@ -1,6 +1,6 @@
package com.drinkool.filters;
import com.drinkool.lib.utils.BaseHeaderAuthentication;
import com.drinkool.BaseHeaderAuthentication;
import jakarta.enterprise.context.ApplicationScoped;
@ApplicationScoped
@@ -1,6 +1,6 @@
package com.drinkool.models;
import com.drinkool.lib.entities.BaseEntity;
import com.drinkool.entities.BaseEntity;
import com.drinkool.utils.PhoneValidator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.password4j.Password;
@@ -4,7 +4,7 @@ import com.drinkool.Role;
import com.drinkool.Url;
import com.drinkool.entities.ManagerEntity;
import com.drinkool.entities.StaffEntity;
import com.drinkool.lib.dtos.SmsOtp;
import com.drinkool.dtos.SmsOtp;
import com.drinkool.models.UserModel;
import jakarta.inject.Inject;
import jakarta.ws.rs.*;
@@ -1,12 +1,13 @@
package com.drinkool.services;
import com.drinkool.*;
import com.drinkool.dtos.*;
import com.drinkool.entities.CustomerEntity;
import com.drinkool.lib.dtos.*;
import jakarta.inject.Inject;
import jakarta.transaction.Transactional;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.*;
import java.util.UUID;
@Path(Role.Customer)
public class CustomerService extends BaseService<CustomerEntity> {
@@ -88,4 +89,10 @@ public class CustomerService extends BaseService<CustomerEntity> {
.entity(customer)
.build();
}
@GET
@Path("/{id}")
public Response findStaff(@PathParam("id") UUID staffId) {
return Response.ok(CustomerEntity.findById(staffId)).build();
}
}
@@ -1,9 +1,9 @@
package com.drinkool.services;
import com.drinkool.*;
import com.drinkool.dtos.*;
import com.drinkool.dtos.event.ManagerCreate;
import com.drinkool.entities.ManagerEntity;
import com.drinkool.lib.dtos.*;
import com.drinkool.lib.dtos.event.ManagerCreate;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.transaction.Transactional;
import jakarta.ws.rs.*;
@@ -26,6 +26,10 @@ public class ManagerService extends BaseService<ManagerEntity> {
@Path(Url.Signup)
@Transactional
public Response signup(ManagerSignup input) {
if (ManagerEntity.count() > 0) return Response.status(
Response.Status.BAD_REQUEST
).build();
ManagerEntity newManager = new ManagerEntity();
newManager.signup(
@@ -3,16 +3,18 @@ package com.drinkool.services;
import com.drinkool.InternalValue;
import com.drinkool.Role;
import com.drinkool.Url;
import com.drinkool.dtos.Login;
import com.drinkool.dtos.Signup;
import com.drinkool.entities.ManagerEntity;
import com.drinkool.entities.StaffEntity;
import com.drinkool.lib.dtos.Login;
import com.drinkool.lib.dtos.Signup;
import io.vertx.core.http.HttpServerRequest;
import jakarta.annotation.security.RolesAllowed;
import jakarta.inject.Inject;
import jakarta.transaction.Transactional;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.core.Response;
import java.util.UUID;
@@ -64,9 +66,16 @@ public class StaffService extends BaseService<StaffEntity> {
.build();
return Response.accepted()
.entity(staff)
.header(InternalValue.userId, staff.id.toString())
.header(InternalValue.managerId, staff.serve.id.toString())
.header(InternalValue.role, Role.Staff)
.build();
}
@GET
@Path("/{id}")
public Response findStaff(@PathParam("id") UUID staffId) {
return Response.ok(StaffEntity.findById(staffId)).build();
}
}
@@ -3,7 +3,7 @@ package com.drinkool.services;
import static io.restassured.RestAssured.*;
import com.drinkool.*;
import com.drinkool.lib.dtos.*;
import com.drinkool.dtos.*;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.Test;
@@ -4,7 +4,7 @@ import static io.restassured.RestAssured.*;
import static org.hamcrest.CoreMatchers.*;
import com.drinkool.*;
import com.drinkool.lib.dtos.*;
import com.drinkool.dtos.*;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.Test;
@@ -5,7 +5,7 @@ import static org.junit.jupiter.api.Assertions.*;
import com.drinkool.*;
import com.drinkool.entities.CustomerEntity;
import com.drinkool.lib.dtos.*;
import com.drinkool.dtos.*;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.http.ContentType;
import jakarta.inject.Inject;
@@ -4,15 +4,18 @@ import static io.restassured.RestAssured.*;
import static org.junit.jupiter.api.Assertions.*;
import com.drinkool.*;
import com.drinkool.lib.dtos.*;
import com.drinkool.dtos.*;
import com.drinkool.entities.ManagerEntity;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.kafka.*;
import io.restassured.http.ContentType;
import io.smallrye.reactive.messaging.kafka.companion.ConsumerTask;
import io.smallrye.reactive.messaging.kafka.companion.KafkaCompanion;
import jakarta.transaction.Transactional;
import java.time.Duration;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@QuarkusTest
@@ -25,6 +28,12 @@ public class ManagerServiceTest {
@ConfigProperty(name = "mp.messaging.outgoing.manager-out.topic")
String topicName;
@BeforeEach
@Transactional
void setup() {
ManagerEntity.deleteAll();
}
@Test
void testSignupSuccessAndKafkaMessageSent() {
ManagerSignup input = new ManagerSignup();
@@ -4,45 +4,45 @@ import static io.restassured.RestAssured.*;
import static org.junit.jupiter.api.Assertions.*;
import com.drinkool.*;
import com.drinkool.dtos.*;
import com.drinkool.entities.ManagerEntity;
import com.drinkool.entities.StaffEntity;
import com.drinkool.lib.dtos.*;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.kafka.*;
import io.restassured.http.ContentType;
import jakarta.enterprise.context.control.ActivateRequestContext;
import jakarta.transaction.Transactional;
import jakarta.ws.rs.core.Response;
import java.util.concurrent.TimeUnit;
import net.datafaker.Faker;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@QuarkusTest
@QuarkusTestResource(KafkaCompanionResource.class)
public class StaffServiceTest {
public class StaffServiceTest_ {
private final Faker faker = new Faker();
private String managerId;
private static String managerId;
@BeforeEach
void setup() {
@BeforeAll
@Transactional
@ActivateRequestContext
static void setup() throws InterruptedException {
ManagerSignup input = new ManagerSignup();
input.name = "Ho Van Quan";
input.phone = Utils.generateRandomPhone();
input.password = "strong_password";
input.eateryName = "Quan Com Ngon";
var response = given()
.contentType("application/json")
.body(input)
.when()
.post(Role.Manager + Url.Signup)
.then()
.statusCode(201)
.header(InternalValue.userId, org.hamcrest.Matchers.notNullValue())
.header(InternalValue.role, Role.Manager)
.extract();
managerId = response.header(InternalValue.userId);
managerId = (new ManagerEntity()).signup(
input.name,
input.phone,
"",
input.password
).id.toString();
}
@Test