chore: update
Java CI with Maven / test (pull_request) Successful in 8m12s
Java CI with Maven / build (pull_request) Successful in 26m19s

This commit is contained in:
TakahashiNg
2026-05-13 08:51:07 +00:00
parent 8b2d3e7bef
commit 902d6e710d
2 changed files with 20 additions and 31 deletions
@@ -150,11 +150,11 @@ public class CartService {
}
@Mutation("addItem")
public Uni<Cart> addItem(
public Cart addItem(
@Name("cartId") UUID cartId,
@Name("menuItemId") UUID menuItemId,
@Name("quantity") long quantity
) {
) throws GraphQLException {
String key = "cart:" + cartId;
String priceKey = "cart_prices:" + cartId;
@@ -163,18 +163,18 @@ public class CartService {
UUID eateryId = UUID.fromString(eateryIdStr);
return eateryController
Response response = eateryController
.checkMenuItemExists(eateryId, menuItemId)
.onItem()
.transform(response -> {
.await()
.indefinitely();
if (response.getStatus() != Response.Status.OK.getStatusCode()) {
throw new RuntimeException("NotFoundMenuItemInEatery");
throw new GraphQLException("NotFoundMenuItemInEatery");
}
Double menuItemPrice = response.readEntity(Double.class);
hashCommands.hincrby(key, menuItemId.toString(), quantity);
hashCommands.hset(
priceKey,
menuItemId.toString(),
@@ -182,16 +182,8 @@ public class CartService {
);
hashCommands.getDataSource().key().expire(key, Duration.ofDays(30));
hashCommands
.getDataSource()
.key()
.expire(priceKey, Duration.ofDays(30));
hashCommands.getDataSource().key().expire(priceKey, Duration.ofDays(30));
try {
return getCart(cartId);
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
});
}
}
@@ -124,7 +124,7 @@ public class CartServiceTest {
}
@Test
void testAddItem_Success() {
void testAddItem_Success() throws GraphQLException {
UUID cartId = UUID.randomUUID();
UUID eateryId = UUID.randomUUID();
UUID menuItemId = UUID.randomUUID();
@@ -137,10 +137,7 @@ public class CartServiceTest {
Uni.createFrom().item(Response.ok(17.0).build())
);
Cart result = cartService
.addItem(cartId, menuItemId, 2L)
.await()
.atMost(Duration.ofSeconds(5));
Cart result = cartService.addItem(cartId, menuItemId, 2L);
assertNotNull(result);
assertEquals(cartId, result.getId());