chore: update
This commit is contained in:
@@ -11,6 +11,7 @@ import com.drinkool.entities.ShiftRegistrationEntity;
|
|||||||
import io.quarkus.test.junit.QuarkusTest;
|
import io.quarkus.test.junit.QuarkusTest;
|
||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -40,13 +41,12 @@ public class ShiftServiceTest {
|
|||||||
.header(InternalValue.role, Role.Manager)
|
.header(InternalValue.role, Role.Manager)
|
||||||
.header(InternalValue.userId, ownerId)
|
.header(InternalValue.userId, ownerId)
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.body("{ \"query\": \"{ allShifts { name startTime } }\" }")
|
.body("{ \"query\": \"{ allShifts { startTime } }\" }")
|
||||||
.when()
|
.when()
|
||||||
.post("/graphql")
|
.post("/graphql")
|
||||||
.then()
|
.then()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
.body("data.allShifts", hasSize(1))
|
.body("data.allShifts", hasSize(1));
|
||||||
.body("data.allShifts[0].name", is("Ca Sáng"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- TEST MUTATIONS ---
|
// --- TEST MUTATIONS ---
|
||||||
@@ -54,18 +54,31 @@ public class ShiftServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
void testCreateShift_AsManager() {
|
void testCreateShift_AsManager() {
|
||||||
String query = """
|
String query = """
|
||||||
mutation Create($input: CreateShiftInput!)
|
mutation createShift($shiftInput: CreateShiftInput!) {
|
||||||
{ createShift(shiftInput: $input) { id name } }""";
|
createShift(shiftInput: $shiftInput) {
|
||||||
|
id
|
||||||
|
date
|
||||||
|
startTime
|
||||||
|
endTime
|
||||||
|
maxStaff
|
||||||
|
wage
|
||||||
|
registeredStaff {
|
||||||
|
staffId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
""";
|
||||||
|
|
||||||
Map<String, Object> input = new HashMap<>();
|
Map<String, Object> input = new HashMap<>();
|
||||||
input.put("name", "Ca Sáng");
|
input.put("date", "26/04/2026");
|
||||||
input.put("startTime", "08:00:00");
|
input.put("startTime", "08:00:00");
|
||||||
input.put("endTime", "12:00:00");
|
input.put("endTime", "12:00:00");
|
||||||
input.put("maxStaff", 5);
|
input.put("maxStaff", 5);
|
||||||
|
input.put("wage", 1000000);
|
||||||
|
|
||||||
Map<String, Object> body = new HashMap<>();
|
Map<String, Object> body = new HashMap<>();
|
||||||
body.put("query", query);
|
body.put("query", query);
|
||||||
body.put("variables", Map.of("input", input));
|
body.put("variables", Map.of("shiftInput", input));
|
||||||
|
|
||||||
UUID ownerId = createMockOwner();
|
UUID ownerId = createMockOwner();
|
||||||
createMockEatery(ownerId);
|
createMockEatery(ownerId);
|
||||||
@@ -78,8 +91,7 @@ public class ShiftServiceTest {
|
|||||||
.when()
|
.when()
|
||||||
.post("/graphql")
|
.post("/graphql")
|
||||||
.then()
|
.then()
|
||||||
.statusCode(200)
|
.statusCode(200);
|
||||||
.body("data.createShift.name", is("Ca Sáng"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -196,8 +208,10 @@ public class ShiftServiceTest {
|
|||||||
) {
|
) {
|
||||||
ShiftEntity shift = new ShiftEntity();
|
ShiftEntity shift = new ShiftEntity();
|
||||||
shift.eatery = eatery;
|
shift.eatery = eatery;
|
||||||
|
shift.date = new Date();
|
||||||
shift.startTime = LocalTime.parse(start);
|
shift.startTime = LocalTime.parse(start);
|
||||||
shift.endTime = LocalTime.parse(end);
|
shift.endTime = LocalTime.parse(end);
|
||||||
|
shift.wage = 10000;
|
||||||
shift.maxStaff = 5;
|
shift.maxStaff = 5;
|
||||||
shift.persist();
|
shift.persist();
|
||||||
return shift;
|
return shift;
|
||||||
|
|||||||
Reference in New Issue
Block a user