You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2021/10/06 17:45:47 UTC

[isis-app-demo] 19/19: adds error scenario that visitAt when bookVisit must be in future

This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/isis-app-demo.git

commit cb22e049566814173ec46862037014b3c260f041
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Wed Oct 6 18:39:06 2021 +0100

    adds error scenario that visitAt when bookVisit must be in future
---
 .../integtest/tests/Pet_bookVisit_IntegTest.java      | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/module-visits/src/test/java/petclinic/modules/visits/integtest/tests/Pet_bookVisit_IntegTest.java b/module-visits/src/test/java/petclinic/modules/visits/integtest/tests/Pet_bookVisit_IntegTest.java
index 2127efa..de3508c 100644
--- a/module-visits/src/test/java/petclinic/modules/visits/integtest/tests/Pet_bookVisit_IntegTest.java
+++ b/module-visits/src/test/java/petclinic/modules/visits/integtest/tests/Pet_bookVisit_IntegTest.java
@@ -75,6 +75,25 @@ public class Pet_bookVisit_IntegTest extends VisitsModuleIntegTestAbstract {
         .hasMessage("'Reason' is mandatory");
     }
 
+    @Test
+    public void cannot_book_in_the_past() {
+
+        // given
+        Pet somePet = fakeDataService.enums().anyOf(Pet_persona.class)
+                .findUsing(serviceRegistry);
+        List<Visit> before = visitRepository.findByPetOrderByVisitAtDesc(somePet);
+
+        // when, then
+        LocalDateTime visitAt = clockService.getClock().nowAsLocalDateTime();
+        String reason = fakeDataService.strings().upper(40);
+
+        assertThatThrownBy(() ->
+                wrapMixin(Pet_bookVisit.class, somePet).act(visitAt, reason)
+        )
+                .isInstanceOf(InvalidException.class)
+                .hasMessage("Must be in the future");
+    }
+
     @Inject FakeDataService fakeDataService;
     @Inject VisitRepository visitRepository;
     @Inject ClockService clockService;