Dev #65

Merged
reynisson merged 67 commits from dev into main 2021-11-16 18:14:00 +00:00
3 changed files with 10 additions and 5 deletions
Showing only changes of commit 1d9459d8f3 - Show all commits

View File

@ -7,6 +7,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.sql.Timestamp;
/** /**
* Used to expose a representation of the state of an auction through an interface. This class is * Used to expose a representation of the state of an auction through an interface. This class is
* only meant as a starting point when defining a uniform HTTP API for the Auction House: feel free * only meant as a starting point when defining a uniform HTTP API for the Auction House: feel free
@ -28,12 +30,12 @@ public class AuctionJsonRepresentation {
private String taskType; private String taskType;
@Getter @Setter @Getter @Setter
private Integer deadline; private Timestamp deadline;
public AuctionJsonRepresentation() { } public AuctionJsonRepresentation() { }
public AuctionJsonRepresentation(String auctionId, String auctionHouseUri, String taskUri, public AuctionJsonRepresentation(String auctionId, String auctionHouseUri, String taskUri,
String taskType, Integer deadline) { String taskType, Timestamp deadline) {
this.auctionId = auctionId; this.auctionId = auctionId;
this.auctionHouseUri = auctionHouseUri; this.auctionHouseUri = auctionHouseUri;
this.taskUri = taskUri; this.taskUri = taskUri;

View File

@ -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.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.in.LaunchAuctionUseCase;
import ch.unisg.tapas.auctionhouse.application.port.out.AuctionWonEventPort; import ch.unisg.tapas.auctionhouse.application.port.out.AuctionWonEventPort;
import ch.unisg.tapas.auctionhouse.application.port.out.AuctionStartedEventPort; import ch.unisg.tapas.auctionhouse.application.port.out.AuctionStartedEventPort;
import ch.unisg.tapas.auctionhouse.domain.*; import ch.unisg.tapas.auctionhouse.domain.*;
@ -11,6 +12,7 @@ import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.sql.Timestamp;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
@ -25,7 +27,7 @@ import java.util.concurrent.TimeUnit;
public class StartAuctionService implements LaunchAuctionUseCase { public class StartAuctionService implements LaunchAuctionUseCase {
private static final Logger LOGGER = LogManager.getLogger(StartAuctionService.class); private static final Logger LOGGER = LogManager.getLogger(StartAuctionService.class);
private final static int DEFAULT_AUCTION_DEADLINE_MILLIS = 10000; private final Timestamp DEFAULT_AUCTION_DEADLINE_MILLIS = Timestamp.valueOf("1970-01-01 00:00:01");
// Event port used to publish an auction started event // Event port used to publish an auction started event
private final AuctionStartedEventPort auctionStartedEventPort; private final AuctionStartedEventPort auctionStartedEventPort;
@ -63,7 +65,7 @@ public class StartAuctionService implements LaunchAuctionUseCase {
auctions.addAuction(auction); auctions.addAuction(auction);
// Schedule the closing of the auction at the deadline // 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); TimeUnit.MILLISECONDS);
// Publish an auction started event // Publish an auction started event

View File

@ -4,6 +4,7 @@ import lombok.Getter;
import lombok.Value; import lombok.Value;
import java.net.URI; import java.net.URI;
import java.sql.Timestamp;
import java.util.*; import java.util.*;
/** /**
@ -166,6 +167,6 @@ public class Auction {
@Value @Value
public static class AuctionDeadline { public static class AuctionDeadline {
int value; Timestamp value;
} }
} }