diff --git a/src/integration-test/groovy/io/pillopl/library/lending/patronprofile/infrastructure/FindingPatronProfileInDatabaseIT.groovy b/src/integration-test/groovy/io/pillopl/library/lending/patronprofile/infrastructure/FindingPatronProfileInDatabaseIT.groovy index 13b2411..2c237cd 100644 --- a/src/integration-test/groovy/io/pillopl/library/lending/patronprofile/infrastructure/FindingPatronProfileInDatabaseIT.groovy +++ b/src/integration-test/groovy/io/pillopl/library/lending/patronprofile/infrastructure/FindingPatronProfileInDatabaseIT.groovy @@ -8,6 +8,8 @@ import io.pillopl.library.lending.librarybranch.model.LibraryBranchId import io.pillopl.library.lending.patron.model.PatronEvent import io.pillopl.library.lending.patron.model.PatronId import io.pillopl.library.lending.patron.model.PatronType +import io.pillopl.library.lending.patronprofile.model.Checkout +import io.pillopl.library.lending.patronprofile.model.Hold import io.pillopl.library.lending.patronprofile.model.PatronProfile import io.pillopl.library.lending.patronprofile.model.PatronProfiles import org.springframework.beans.factory.annotation.Autowired @@ -23,7 +25,6 @@ import static io.pillopl.library.catalogue.BookType.Restricted import static io.pillopl.library.lending.book.model.BookFixture.anyBookId import static io.pillopl.library.lending.librarybranch.model.LibraryBranchFixture.anyBranch import static io.pillopl.library.lending.patron.model.PatronFixture.anyPatronId -import static io.vavr.Tuple.of import static java.time.Instant.now @SpringBootTest(classes = LendingTestContext.class) @@ -83,14 +84,14 @@ class FindingPatronProfileInDatabaseIT extends Specification { void thereIsOnlyOneHold(PatronProfile profile) { assert profile.holdsView.currentHolds.size() == 1 - assert profile.holdsView.currentHolds.get(0).equals(of(bookId, TOMORROW)) + assert profile.holdsView.currentHolds.get(0) == new Hold(bookId, TOMORROW) assert profile.currentCheckouts.currentCheckouts.size() == 0 } void thereIsOnlyOneCheckout(PatronProfile profile) { assert profile.holdsView.currentHolds.size() == 0 assert profile.currentCheckouts.currentCheckouts.size() == 1 - assert profile.currentCheckouts.currentCheckouts.get(0).equals(of(bookId, TOMORROW)) + assert profile.currentCheckouts.currentCheckouts.get(0) == new Checkout(bookId, TOMORROW) } void thereIsZeroHoldsAndZeroCheckouts(PatronProfile profile) { @@ -99,7 +100,7 @@ class FindingPatronProfileInDatabaseIT extends Specification { } - PatronEvent.BookCheckedOut bookCheckedOutTill(Instant till) { + PatronEvent.BookCheckedOut bookCheckedOutTill(Instant till) { return new PatronEvent.BookCheckedOut( now(), patronId.getPatronId(), diff --git a/src/integration-test/groovy/io/pillopl/library/lending/patronprofile/web/PatronProfileControllerIT.java b/src/integration-test/groovy/io/pillopl/library/lending/patronprofile/web/PatronProfileControllerIT.java index a1924b0..7b64829 100644 --- a/src/integration-test/groovy/io/pillopl/library/lending/patronprofile/web/PatronProfileControllerIT.java +++ b/src/integration-test/groovy/io/pillopl/library/lending/patronprofile/web/PatronProfileControllerIT.java @@ -6,11 +6,12 @@ import io.pillopl.library.lending.patron.application.hold.CancelingHold; import io.pillopl.library.lending.patron.model.PatronFixture; import io.pillopl.library.lending.patron.model.PatronId; +import io.pillopl.library.lending.patronprofile.model.Checkout; import io.pillopl.library.lending.patronprofile.model.CheckoutsView; +import io.pillopl.library.lending.patronprofile.model.Hold; import io.pillopl.library.lending.patronprofile.model.HoldsView; import io.pillopl.library.lending.patronprofile.model.PatronProfile; import io.pillopl.library.lending.patronprofile.model.PatronProfiles; -import io.vavr.Tuple; import io.vavr.control.Try; import org.junit.Test; import org.junit.runner.RunWith; @@ -191,7 +192,7 @@ public void shouldReturn500IfSomethingFailedWhileCanceling() throws Exception { PatronProfile profiles() { return new PatronProfile( - new HoldsView(of(Tuple.of(bookId, anyDate))), - new CheckoutsView(of(Tuple.of(anotherBook, anotherDate)))); + new HoldsView(of(new Hold(bookId, anyDate))), + new CheckoutsView(of(new Checkout(anotherBook, anotherDate)))); } } \ No newline at end of file diff --git a/src/main/java/io/pillopl/library/lending/dailysheet/infrastructure/SheetsReadModel.java b/src/main/java/io/pillopl/library/lending/dailysheet/infrastructure/SheetsReadModel.java index 563c9a9..8966017 100644 --- a/src/main/java/io/pillopl/library/lending/dailysheet/infrastructure/SheetsReadModel.java +++ b/src/main/java/io/pillopl/library/lending/dailysheet/infrastructure/SheetsReadModel.java @@ -3,11 +3,16 @@ import io.pillopl.library.catalogue.BookId; import io.pillopl.library.lending.dailysheet.model.CheckoutsToOverdueSheet; import io.pillopl.library.lending.dailysheet.model.DailySheet; +import io.pillopl.library.lending.dailysheet.model.ExpiredHold; import io.pillopl.library.lending.dailysheet.model.HoldsToExpireSheet; +import io.pillopl.library.lending.dailysheet.model.OverdueCheckout; import io.pillopl.library.lending.librarybranch.model.LibraryBranchId; -import io.pillopl.library.lending.patron.model.PatronEvent.*; +import io.pillopl.library.lending.patron.model.PatronEvent.BookCheckedOut; +import io.pillopl.library.lending.patron.model.PatronEvent.BookHoldCanceled; +import io.pillopl.library.lending.patron.model.PatronEvent.BookHoldExpired; +import io.pillopl.library.lending.patron.model.PatronEvent.BookPlacedOnHold; +import io.pillopl.library.lending.patron.model.PatronEvent.BookReturned; import io.pillopl.library.lending.patron.model.PatronId; -import io.vavr.Tuple3; import io.vavr.control.Option; import lombok.AllArgsConstructor; import org.springframework.context.event.EventListener; @@ -23,7 +28,6 @@ import java.util.Map; import java.util.UUID; -import static io.vavr.Tuple.of; import static io.vavr.collection.List.ofAll; import static java.sql.Timestamp.from; import static java.util.stream.Collectors.toList; @@ -39,7 +43,7 @@ public HoldsToExpireSheet queryForHoldsToExpireSheet() { return new HoldsToExpireSheet(ofAll( findHoldsToExpire() .stream() - .map(this::toExpiredHoldsTuple) + .map(this::toExpiredHold) .collect(toList()))); } @@ -50,8 +54,8 @@ private List> findHoldsToExpire() { new ColumnMapRowMapper()); } - private Tuple3 toExpiredHoldsTuple(Map map) { - return of( + private ExpiredHold toExpiredHold(Map map) { + return new ExpiredHold( new BookId((UUID) map.get("BOOK_ID")), new PatronId((UUID) map.get("HOLD_BY_PATRON_ID")), new LibraryBranchId((UUID) map.get("HOLD_AT_BRANCH"))); @@ -62,7 +66,7 @@ public CheckoutsToOverdueSheet queryForCheckoutsToOverdue() { return new CheckoutsToOverdueSheet(ofAll( findCheckoutsToOverdue() .stream() - .map(this::toOverdueCheckoutsTuple) + .map(this::toOverdueCheckout) .collect(toList()))); } @@ -73,8 +77,8 @@ private List> findCheckoutsToOverdue() { new ColumnMapRowMapper()); } - private Tuple3 toOverdueCheckoutsTuple(Map map) { - return of( + private OverdueCheckout toOverdueCheckout(Map map) { + return new OverdueCheckout( new BookId((UUID) map.get("BOOK_ID")), new PatronId((UUID) map.get("CHECKED_OUT_BY_PATRON_ID")), new LibraryBranchId((UUID) map.get("CHECKED_OUT_AT_BRANCH"))); diff --git a/src/main/java/io/pillopl/library/lending/dailysheet/model/CheckoutsToOverdueSheet.java b/src/main/java/io/pillopl/library/lending/dailysheet/model/CheckoutsToOverdueSheet.java index 70f0396..b055f09 100644 --- a/src/main/java/io/pillopl/library/lending/dailysheet/model/CheckoutsToOverdueSheet.java +++ b/src/main/java/io/pillopl/library/lending/dailysheet/model/CheckoutsToOverdueSheet.java @@ -1,10 +1,6 @@ package io.pillopl.library.lending.dailysheet.model; -import io.pillopl.library.catalogue.BookId; -import io.pillopl.library.lending.librarybranch.model.LibraryBranchId; import io.pillopl.library.lending.patron.model.PatronEvent.OverdueCheckoutRegistered; -import io.pillopl.library.lending.patron.model.PatronId; -import io.vavr.Tuple3; import io.vavr.collection.List; import io.vavr.collection.Stream; import lombok.NonNull; @@ -14,21 +10,15 @@ public class CheckoutsToOverdueSheet { @NonNull - List> checkouts; + List checkouts; public Stream toStreamOfEvents() { - return checkouts - .toStream() - .map(this::tupleToEvent); + return checkouts.toStream() + .map(OverdueCheckout::toEvent); } public int count() { return checkouts.size(); } - private OverdueCheckoutRegistered tupleToEvent(Tuple3 overdueCheckouts) { - return OverdueCheckoutRegistered.now(overdueCheckouts._2, overdueCheckouts._1, overdueCheckouts._3); - } - - } diff --git a/src/main/java/io/pillopl/library/lending/dailysheet/model/ExpiredHold.java b/src/main/java/io/pillopl/library/lending/dailysheet/model/ExpiredHold.java new file mode 100644 index 0000000..728253f --- /dev/null +++ b/src/main/java/io/pillopl/library/lending/dailysheet/model/ExpiredHold.java @@ -0,0 +1,18 @@ +package io.pillopl.library.lending.dailysheet.model; + +import io.pillopl.library.catalogue.BookId; +import io.pillopl.library.lending.librarybranch.model.LibraryBranchId; +import io.pillopl.library.lending.patron.model.PatronEvent.BookHoldExpired; +import io.pillopl.library.lending.patron.model.PatronId; +import lombok.Value; + +@Value +public class ExpiredHold { + private final BookId heldBook; + private final PatronId patron; + private final LibraryBranchId library; + + BookHoldExpired toEvent() { + return BookHoldExpired.now(this.heldBook, this.patron, this.library); + } +} diff --git a/src/main/java/io/pillopl/library/lending/dailysheet/model/HoldsToExpireSheet.java b/src/main/java/io/pillopl/library/lending/dailysheet/model/HoldsToExpireSheet.java index b043753..0ac556a 100644 --- a/src/main/java/io/pillopl/library/lending/dailysheet/model/HoldsToExpireSheet.java +++ b/src/main/java/io/pillopl/library/lending/dailysheet/model/HoldsToExpireSheet.java @@ -1,10 +1,6 @@ package io.pillopl.library.lending.dailysheet.model; -import io.pillopl.library.catalogue.BookId; -import io.pillopl.library.lending.librarybranch.model.LibraryBranchId; import io.pillopl.library.lending.patron.model.PatronEvent; -import io.pillopl.library.lending.patron.model.PatronId; -import io.vavr.Tuple3; import io.vavr.collection.List; import io.vavr.collection.Stream; import lombok.NonNull; @@ -15,22 +11,17 @@ public class HoldsToExpireSheet { @NonNull - List> expiredHolds; + List expiredHolds; @EventListener public Stream toStreamOfEvents() { return expiredHolds .toStream() - .map(this::tupleToEvent); + .map(ExpiredHold::toEvent); } public int count() { return expiredHolds.size(); } - private PatronEvent.BookHoldExpired tupleToEvent(Tuple3 expiredHold) { - return PatronEvent.BookHoldExpired.now(expiredHold._1, expiredHold._2, expiredHold._3); - } - - } diff --git a/src/main/java/io/pillopl/library/lending/dailysheet/model/OverdueCheckout.java b/src/main/java/io/pillopl/library/lending/dailysheet/model/OverdueCheckout.java new file mode 100644 index 0000000..244907c --- /dev/null +++ b/src/main/java/io/pillopl/library/lending/dailysheet/model/OverdueCheckout.java @@ -0,0 +1,18 @@ +package io.pillopl.library.lending.dailysheet.model; + +import io.pillopl.library.catalogue.BookId; +import io.pillopl.library.lending.librarybranch.model.LibraryBranchId; +import io.pillopl.library.lending.patron.model.PatronEvent.OverdueCheckoutRegistered; +import io.pillopl.library.lending.patron.model.PatronId; +import lombok.Value; + +@Value +public class OverdueCheckout { + private final BookId checkedOutBook; + private final PatronId patron; + private final LibraryBranchId library; + + OverdueCheckoutRegistered toEvent() { + return OverdueCheckoutRegistered.now(this.patron, this.checkedOutBook, this.library); + } +} diff --git a/src/main/java/io/pillopl/library/lending/patronprofile/infrastructure/PatronProfileReadModel.java b/src/main/java/io/pillopl/library/lending/patronprofile/infrastructure/PatronProfileReadModel.java index d152107..03cfa42 100644 --- a/src/main/java/io/pillopl/library/lending/patronprofile/infrastructure/PatronProfileReadModel.java +++ b/src/main/java/io/pillopl/library/lending/patronprofile/infrastructure/PatronProfileReadModel.java @@ -2,18 +2,17 @@ import io.pillopl.library.catalogue.BookId; import io.pillopl.library.lending.patron.model.PatronId; +import io.pillopl.library.lending.patronprofile.model.Checkout; import io.pillopl.library.lending.patronprofile.model.CheckoutsView; +import io.pillopl.library.lending.patronprofile.model.Hold; import io.pillopl.library.lending.patronprofile.model.HoldsView; import io.pillopl.library.lending.patronprofile.model.PatronProfile; import io.pillopl.library.lending.patronprofile.model.PatronProfiles; -import io.vavr.Tuple; -import io.vavr.Tuple2; import lombok.AllArgsConstructor; import org.springframework.jdbc.core.ColumnMapRowMapper; import org.springframework.jdbc.core.JdbcTemplate; import java.sql.Timestamp; -import java.time.Instant; import java.util.List; import java.util.Map; import java.util.UUID; @@ -31,12 +30,12 @@ public PatronProfile fetchFor(PatronId patronId) { HoldsView holdsView = new HoldsView( ofAll(findCurrentHoldsFor(patronId) .stream() - .map(this::toHoldViewTuple) + .map(this::toHold) .collect(toList()))); CheckoutsView checkoutsView = new CheckoutsView( ofAll(findCurrentCheckoutsFor(patronId) .stream() - .map(this::toCheckoutsViewTuple) + .map(this::toCheckout) .collect(toList()))); return new PatronProfile(holdsView, checkoutsView); } @@ -48,8 +47,8 @@ private List> findCurrentHoldsFor(PatronId patronId) { new ColumnMapRowMapper()); } - private Tuple2 toHoldViewTuple(Map map) { - return Tuple.of(new BookId((UUID) map.get("BOOK_ID")), + private Hold toHold(Map map) { + return new Hold(new BookId((UUID) map.get("BOOK_ID")), ((Timestamp) map.get("HOLD_TILL")).toInstant()); } @@ -60,8 +59,8 @@ private List> findCurrentCheckoutsFor(PatronId patronId) { new ColumnMapRowMapper()); } - private Tuple2 toCheckoutsViewTuple(Map map) { - return Tuple.of(new BookId((UUID) map.get("BOOK_ID")), + private Checkout toCheckout(Map map) { + return new Checkout(new BookId((UUID) map.get("BOOK_ID")), ((Timestamp) map.get("CHECKOUT_TILL")).toInstant()); } } diff --git a/src/main/java/io/pillopl/library/lending/patronprofile/model/Checkout.java b/src/main/java/io/pillopl/library/lending/patronprofile/model/Checkout.java new file mode 100644 index 0000000..953d381 --- /dev/null +++ b/src/main/java/io/pillopl/library/lending/patronprofile/model/Checkout.java @@ -0,0 +1,15 @@ +package io.pillopl.library.lending.patronprofile.model; + +import io.pillopl.library.catalogue.BookId; +import lombok.Value; + +import java.time.Instant; + +@Value +public class Checkout { + + private final BookId book; + + private final Instant till; + +} diff --git a/src/main/java/io/pillopl/library/lending/patronprofile/model/CheckoutsView.java b/src/main/java/io/pillopl/library/lending/patronprofile/model/CheckoutsView.java index 813a513..6473a94 100644 --- a/src/main/java/io/pillopl/library/lending/patronprofile/model/CheckoutsView.java +++ b/src/main/java/io/pillopl/library/lending/patronprofile/model/CheckoutsView.java @@ -1,17 +1,13 @@ package io.pillopl.library.lending.patronprofile.model; -import io.pillopl.library.catalogue.BookId; -import io.vavr.Tuple2; import io.vavr.collection.List; import lombok.NonNull; import lombok.Value; -import java.time.Instant; - @Value public class CheckoutsView { @NonNull - List> currentCheckouts; + List currentCheckouts; } diff --git a/src/main/java/io/pillopl/library/lending/patronprofile/model/Hold.java b/src/main/java/io/pillopl/library/lending/patronprofile/model/Hold.java new file mode 100644 index 0000000..7f332d5 --- /dev/null +++ b/src/main/java/io/pillopl/library/lending/patronprofile/model/Hold.java @@ -0,0 +1,15 @@ +package io.pillopl.library.lending.patronprofile.model; + +import io.pillopl.library.catalogue.BookId; +import lombok.Value; + +import java.time.Instant; + +@Value +public class Hold { + + private final BookId book; + + private final Instant till; + +} diff --git a/src/main/java/io/pillopl/library/lending/patronprofile/model/HoldsView.java b/src/main/java/io/pillopl/library/lending/patronprofile/model/HoldsView.java index a508e21..c1d8e8a 100644 --- a/src/main/java/io/pillopl/library/lending/patronprofile/model/HoldsView.java +++ b/src/main/java/io/pillopl/library/lending/patronprofile/model/HoldsView.java @@ -1,17 +1,13 @@ package io.pillopl.library.lending.patronprofile.model; -import io.pillopl.library.catalogue.BookId; -import io.vavr.Tuple2; import io.vavr.collection.List; import lombok.NonNull; import lombok.Value; -import java.time.Instant; - @Value public class HoldsView { @NonNull - List> currentHolds; + List currentHolds; } diff --git a/src/main/java/io/pillopl/library/lending/patronprofile/model/PatronProfile.java b/src/main/java/io/pillopl/library/lending/patronprofile/model/PatronProfile.java index 6fffc00..bcce830 100644 --- a/src/main/java/io/pillopl/library/lending/patronprofile/model/PatronProfile.java +++ b/src/main/java/io/pillopl/library/lending/patronprofile/model/PatronProfile.java @@ -1,33 +1,30 @@ package io.pillopl.library.lending.patronprofile.model; import io.pillopl.library.catalogue.BookId; -import io.vavr.Tuple2; import io.vavr.control.Option; import lombok.NonNull; import lombok.Value; -import java.time.Instant; - @Value public class PatronProfile { @NonNull HoldsView holdsView; @NonNull CheckoutsView currentCheckouts; - public Option> findHold(BookId bookId) { + public Option findHold(BookId bookId) { return holdsView - .getCurrentHolds() - .toStream() - .find(hold -> hold._1.equals(bookId)); + .getCurrentHolds() + .toStream() + .find(hold -> hold.getBook().equals(bookId)); } - public Option> findCheckout(BookId bookId) { + public Option findCheckout(BookId bookId) { return currentCheckouts .getCurrentCheckouts() .toStream() - .find(hold -> hold._1.equals(bookId)); + .find(hold -> hold.getBook().equals(bookId)); } diff --git a/src/main/java/io/pillopl/library/lending/patronprofile/web/PatronProfileController.java b/src/main/java/io/pillopl/library/lending/patronprofile/web/PatronProfileController.java index 8406004..55a358c 100644 --- a/src/main/java/io/pillopl/library/lending/patronprofile/web/PatronProfileController.java +++ b/src/main/java/io/pillopl/library/lending/patronprofile/web/PatronProfileController.java @@ -8,7 +8,6 @@ import io.pillopl.library.lending.patron.model.PatronId; import io.pillopl.library.lending.patronprofile.model.PatronProfiles; import io.vavr.Predicates; -import io.vavr.Tuple2; import io.vavr.control.Try; import lombok.AllArgsConstructor; import lombok.Value; @@ -29,7 +28,9 @@ import static io.vavr.API.Case; import static io.vavr.API.Match; import static java.util.stream.Collectors.toList; -import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.*; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.afford; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; import static org.springframework.http.ResponseEntity.notFound; import static org.springframework.http.ResponseEntity.ok; @@ -95,20 +96,24 @@ ResponseEntity cancelHold(@PathVariable UUID patronId, @PathVariable UUID bookId .getOrElse(ResponseEntity.status(500).build()); - - } - private EntityModel resourceWithLinkToHoldSelf(UUID patronId, Tuple2 hold) { - return new EntityModel<>(new Hold(hold._1.getBookId(), hold._2), linkTo(methodOn(PatronProfileController.class).findHold(patronId, hold._1.getBookId())).withSelfRel() - .andAffordance(afford(methodOn(PatronProfileController.class).cancelHold(patronId, hold._1.getBookId())))); + private EntityModel resourceWithLinkToHoldSelf(UUID patronId, io.pillopl.library.lending.patronprofile.model.Hold hold) { + return new EntityModel<>( + new Hold(hold), + linkTo(methodOn(PatronProfileController.class).findHold(patronId, hold.getBook().getBookId())) + .withSelfRel() + .andAffordance(afford(methodOn(PatronProfileController.class) + .cancelHold(patronId, hold.getBook().getBookId())))); } - private EntityModel resourceWithLinkToCheckoutSelf(UUID patronId, Tuple2 checkout) { - return new EntityModel<>(new Checkout(checkout._1.getBookId(), checkout._2), linkTo(methodOn(PatronProfileController.class).findCheckout(patronId, checkout._1.getBookId())).withSelfRel()); + private EntityModel resourceWithLinkToCheckoutSelf(UUID patronId, io.pillopl.library.lending.patronprofile.model.Checkout checkout) { + return new EntityModel<>( + new Checkout(checkout), + linkTo(methodOn(PatronProfileController.class).findCheckout(patronId, checkout.getBook().getBookId())) + .withSelfRel()); } - } @Value @@ -132,6 +137,10 @@ class Hold { UUID bookId; Instant till; + Hold(io.pillopl.library.lending.patronprofile.model.Hold hold) { + this.bookId = hold.getBook().getBookId(); + this.till = hold.getTill(); + } } @Value @@ -140,4 +149,9 @@ class Checkout { UUID bookId; Instant till; -} \ No newline at end of file + Checkout(io.pillopl.library.lending.patronprofile.model.Checkout hold) { + this.bookId = hold.getBook().getBookId(); + this.till = hold.getTill(); + } + +} diff --git a/src/test/groovy/io/pillopl/library/lending/dailysheet/model/CheckoutsToOverdueSheetTest.groovy b/src/test/groovy/io/pillopl/library/lending/dailysheet/model/CheckoutsToOverdueSheetTest.groovy index d9ec940..0bbfa75 100644 --- a/src/test/groovy/io/pillopl/library/lending/dailysheet/model/CheckoutsToOverdueSheetTest.groovy +++ b/src/test/groovy/io/pillopl/library/lending/dailysheet/model/CheckoutsToOverdueSheetTest.groovy @@ -4,7 +4,6 @@ import io.pillopl.library.catalogue.BookId import io.pillopl.library.lending.librarybranch.model.LibraryBranchId import io.pillopl.library.lending.patron.model.PatronEvent import io.pillopl.library.lending.patron.model.PatronId -import io.vavr.Tuple import io.vavr.collection.List import spock.lang.Specification @@ -45,6 +44,8 @@ class CheckoutsToOverdueSheetTest extends Specification { } private CheckoutsToOverdueSheet sheet(PatronId patronId, PatronId anotherPatronId, BookId bookId, BookId anotherBookId, LibraryBranchId libraryBranchId, LibraryBranchId anotherBranchId) { - new CheckoutsToOverdueSheet(List.of(Tuple.of(bookId, patronId, libraryBranchId), Tuple.of(anotherBookId, anotherPatronId, anotherBranchId))) + new CheckoutsToOverdueSheet(List.of( + new OverdueCheckout(bookId, patronId, libraryBranchId), + new OverdueCheckout(anotherBookId, anotherPatronId, anotherBranchId))) } } diff --git a/src/test/groovy/io/pillopl/library/lending/dailysheet/model/HoldsToExpireSheetTest.groovy b/src/test/groovy/io/pillopl/library/lending/dailysheet/model/HoldsToExpireSheetTest.groovy index ccc8890..87ece05 100644 --- a/src/test/groovy/io/pillopl/library/lending/dailysheet/model/HoldsToExpireSheetTest.groovy +++ b/src/test/groovy/io/pillopl/library/lending/dailysheet/model/HoldsToExpireSheetTest.groovy @@ -4,7 +4,6 @@ import io.pillopl.library.catalogue.BookId import io.pillopl.library.lending.librarybranch.model.LibraryBranchId import io.pillopl.library.lending.patron.model.PatronEvent import io.pillopl.library.lending.patron.model.PatronId -import io.vavr.Tuple import io.vavr.collection.List import spock.lang.Specification @@ -45,6 +44,8 @@ class HoldsToExpireSheetTest extends Specification { } private HoldsToExpireSheet sheet(PatronId patronId, PatronId anotherPatronId, BookId bookId, BookId anotherBookId, LibraryBranchId libraryBranchId, LibraryBranchId anotherBranchId) { - new HoldsToExpireSheet(List.of(Tuple.of(bookId, patronId, libraryBranchId), Tuple.of(anotherBookId, anotherPatronId, anotherBranchId))) + new HoldsToExpireSheet(List.of( + new ExpiredHold(bookId, patronId, libraryBranchId), + new ExpiredHold(anotherBookId, anotherPatronId, anotherBranchId))) } } diff --git a/src/test/groovy/io/pillopl/library/lending/patron/application/checkout/RegisteringOverdueCheckoutsTest.groovy b/src/test/groovy/io/pillopl/library/lending/patron/application/checkout/RegisteringOverdueCheckoutsTest.groovy index c7b480a..1d1347f 100644 --- a/src/test/groovy/io/pillopl/library/lending/patron/application/checkout/RegisteringOverdueCheckoutsTest.groovy +++ b/src/test/groovy/io/pillopl/library/lending/patron/application/checkout/RegisteringOverdueCheckoutsTest.groovy @@ -3,9 +3,10 @@ package io.pillopl.library.lending.patron.application.checkout import io.pillopl.library.commons.commands.BatchResult import io.pillopl.library.lending.dailysheet.model.CheckoutsToOverdueSheet import io.pillopl.library.lending.dailysheet.model.DailySheet +import io.pillopl.library.lending.dailysheet.model.OverdueCheckout import io.pillopl.library.lending.patron.model.PatronEvent -import io.pillopl.library.lending.patron.model.Patrons import io.pillopl.library.lending.patron.model.PatronId +import io.pillopl.library.lending.patron.model.Patrons import io.vavr.control.Try import spock.lang.Specification @@ -63,8 +64,8 @@ class RegisteringOverdueCheckoutsTest extends Specification { CheckoutsToOverdueSheet overdueCheckoutsBy(PatronId patronId, PatronId anotherPatronId) { return new CheckoutsToOverdueSheet( of( - io.vavr.Tuple.of(anyBookId(), patronId, anyBranch()), - io.vavr.Tuple.of(anyBookId(), anotherPatronId, anyBranch()), + new OverdueCheckout(anyBookId(), patronId, anyBranch()), + new OverdueCheckout(anyBookId(), anotherPatronId, anyBranch()), )) } diff --git a/src/test/groovy/io/pillopl/library/lending/patron/application/hold/ExpiringHoldsTest.groovy b/src/test/groovy/io/pillopl/library/lending/patron/application/hold/ExpiringHoldsTest.groovy index 54dae59..7198b84 100644 --- a/src/test/groovy/io/pillopl/library/lending/patron/application/hold/ExpiringHoldsTest.groovy +++ b/src/test/groovy/io/pillopl/library/lending/patron/application/hold/ExpiringHoldsTest.groovy @@ -2,10 +2,11 @@ package io.pillopl.library.lending.patron.application.hold import io.pillopl.library.commons.commands.BatchResult import io.pillopl.library.lending.dailysheet.model.DailySheet +import io.pillopl.library.lending.dailysheet.model.ExpiredHold import io.pillopl.library.lending.dailysheet.model.HoldsToExpireSheet import io.pillopl.library.lending.patron.model.PatronEvent -import io.pillopl.library.lending.patron.model.Patrons import io.pillopl.library.lending.patron.model.PatronId +import io.pillopl.library.lending.patron.model.Patrons import io.vavr.control.Try import spock.lang.Specification @@ -61,9 +62,8 @@ class ExpiringHoldsTest extends Specification { HoldsToExpireSheet expiredHoldsBy(PatronId patronId, PatronId anotherPatronId) { return new HoldsToExpireSheet( of( - io.vavr.Tuple.of(anyBookId(), patronId, anyBranch()), - io.vavr.Tuple.of(anyBookId(), anotherPatronId, anyBranch()) - + new ExpiredHold(anyBookId(), patronId, anyBranch()), + new ExpiredHold(anyBookId(), anotherPatronId, anyBranch()) )) }