From 74a51cfcf681f8acd804eef2b24dc341e61e419b Mon Sep 17 00:00:00 2001 From: "julius.lautz" Date: Wed, 10 Nov 2021 11:03:57 +0000 Subject: [PATCH] changed deadline to timestamp and the logic to schedule an auction --- .../application/port/in/LaunchAuctionCommand.java | 5 +++-- .../application/service/StartAuctionService.java | 3 ++- .../java/ch/unisg/tapas/auctionhouse/domain/Auction.java | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tapas-auction-house/src/main/java/ch/unisg/tapas/auctionhouse/application/port/in/LaunchAuctionCommand.java b/tapas-auction-house/src/main/java/ch/unisg/tapas/auctionhouse/application/port/in/LaunchAuctionCommand.java index 626fa49..37eb5db 100644 --- a/tapas-auction-house/src/main/java/ch/unisg/tapas/auctionhouse/application/port/in/LaunchAuctionCommand.java +++ b/tapas-auction-house/src/main/java/ch/unisg/tapas/auctionhouse/application/port/in/LaunchAuctionCommand.java @@ -1,10 +1,11 @@ package ch.unisg.tapas.auctionhouse.application.port.in; import ch.unisg.tapas.auctionhouse.domain.Auction; -import ch.unisg.tapas.common.SelfValidating; +import ch.unisg.common.SelfValidating; +import lombok.NonNull; import lombok.Value; -import javax.validation.constraints.NotNull; +import javax.validation.constraint.NotNull; /** * Command for launching an auction in this auction house. diff --git a/tapas-auction-house/src/main/java/ch/unisg/tapas/auctionhouse/application/service/StartAuctionService.java b/tapas-auction-house/src/main/java/ch/unisg/tapas/auctionhouse/application/service/StartAuctionService.java index 42c6e37..b9d9d3d 100644 --- a/tapas-auction-house/src/main/java/ch/unisg/tapas/auctionhouse/application/service/StartAuctionService.java +++ b/tapas-auction-house/src/main/java/ch/unisg/tapas/auctionhouse/application/service/StartAuctionService.java @@ -2,6 +2,7 @@ package ch.unisg.tapas.auctionhouse.application.service; import ch.unisg.tapas.auctionhouse.application.port.in.LaunchAuctionCommand; import ch.unisg.tapas.auctionhouse.application.port.in.LaunchAuctionUseCase; +import ch.unisg.tapas.auctionhouse.application.port.in.LaunchAuctionUseCase; import ch.unisg.tapas.auctionhouse.application.port.out.AuctionWonEventPort; import ch.unisg.tapas.auctionhouse.application.port.out.AuctionStartedEventPort; import ch.unisg.tapas.auctionhouse.domain.*; @@ -63,7 +64,7 @@ public class StartAuctionService implements LaunchAuctionUseCase { auctions.addAuction(auction); // Schedule the closing of the auction at the deadline - service.schedule(new CloseAuctionTask(auction.getAuctionId()), deadline.getValue(), + service.schedule(new CloseAuctionTask(auction.getAuctionId()), deadline.getValue().getTime() - System.currentTimeMillis(), TimeUnit.MILLISECONDS); // Publish an auction started event diff --git a/tapas-auction-house/src/main/java/ch/unisg/tapas/auctionhouse/domain/Auction.java b/tapas-auction-house/src/main/java/ch/unisg/tapas/auctionhouse/domain/Auction.java index 3e51ef7..c6d9333 100644 --- a/tapas-auction-house/src/main/java/ch/unisg/tapas/auctionhouse/domain/Auction.java +++ b/tapas-auction-house/src/main/java/ch/unisg/tapas/auctionhouse/domain/Auction.java @@ -4,6 +4,7 @@ import lombok.Getter; import lombok.Value; import java.net.URI; +import java.sql.Timestamp; import java.util.*; /** @@ -166,6 +167,6 @@ public class Auction { @Value public static class AuctionDeadline { - int value; + Timestamp value; } }