From d38a55a6c28451c6131595c05596f2b6a7f3d0ac Mon Sep 17 00:00:00 2001 From: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com> Date: Thu, 14 May 2026 03:12:25 +0000 Subject: [PATCH] chore: update --- .../drinkool/services/ShiftServiceTest.java | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/eatery-service/src/test/java/com/drinkool/services/ShiftServiceTest.java b/eatery-service/src/test/java/com/drinkool/services/ShiftServiceTest.java index 29d017c..f0b4bfe 100644 --- a/eatery-service/src/test/java/com/drinkool/services/ShiftServiceTest.java +++ b/eatery-service/src/test/java/com/drinkool/services/ShiftServiceTest.java @@ -11,6 +11,7 @@ import com.drinkool.entities.ShiftRegistrationEntity; import io.quarkus.test.junit.QuarkusTest; import jakarta.transaction.Transactional; import java.time.LocalTime; +import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.UUID; @@ -40,13 +41,12 @@ public class ShiftServiceTest { .header(InternalValue.role, Role.Manager) .header(InternalValue.userId, ownerId) .contentType("application/json") - .body("{ \"query\": \"{ allShifts { name startTime } }\" }") + .body("{ \"query\": \"{ allShifts { startTime } }\" }") .when() .post("/graphql") .then() .statusCode(200) - .body("data.allShifts", hasSize(1)) - .body("data.allShifts[0].name", is("Ca Sáng")); + .body("data.allShifts", hasSize(1)); } // --- TEST MUTATIONS --- @@ -54,18 +54,31 @@ public class ShiftServiceTest { @Test void testCreateShift_AsManager() { String query = """ - mutation Create($input: CreateShiftInput!) - { createShift(shiftInput: $input) { id name } }"""; + mutation createShift($shiftInput: CreateShiftInput!) { + createShift(shiftInput: $shiftInput) { + id + date + startTime + endTime + maxStaff + wage + registeredStaff { + staffId + } + } + } + """; Map input = new HashMap<>(); - input.put("name", "Ca Sáng"); + input.put("date", "26/04/2026"); input.put("startTime", "08:00:00"); input.put("endTime", "12:00:00"); input.put("maxStaff", 5); + input.put("wage", 1000000); Map body = new HashMap<>(); body.put("query", query); - body.put("variables", Map.of("input", input)); + body.put("variables", Map.of("shiftInput", input)); UUID ownerId = createMockOwner(); createMockEatery(ownerId); @@ -78,8 +91,7 @@ public class ShiftServiceTest { .when() .post("/graphql") .then() - .statusCode(200) - .body("data.createShift.name", is("Ca Sáng")); + .statusCode(200); } @Test @@ -196,8 +208,10 @@ public class ShiftServiceTest { ) { ShiftEntity shift = new ShiftEntity(); shift.eatery = eatery; + shift.date = new Date(); shift.startTime = LocalTime.parse(start); shift.endTime = LocalTime.parse(end); + shift.wage = 10000; shift.maxStaff = 5; shift.persist(); return shift;