diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml
new file mode 100644
index 00000000..386837b4
--- /dev/null
+++ b/.github/workflows/maven-publish.yml
@@ -0,0 +1,37 @@
+# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
+# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
+
+name: Maven Package
+
+on:
+ push:
+ brabranches: [master]
+
+ release:
+ types: [created]
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ packages: write
+
+ steps:
+ - uses: actions/checkout@v4
+ - name: Set up JDK 11
+ uses: actions/setup-java@v3
+ with:
+ java-version: '11'
+ distribution: 'temurin'
+ server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
+ settings-path: ${{ github.workspace }} # location for the settings.xml file
+
+ - name: Build with Maven
+ run: mvn -B package --file pom.xml
+
+ - name: Publish to GitHub Packages Apache Maven
+ run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
+ env:
+ GITHUB_TOKEN: ${{ github.token }}
diff --git a/.gitignore b/.gitignore
index 12d2e159..a823f531 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
# Created by .ignore support plugin (hsz.mobi)
### Maven template
target/
+test-output/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
diff --git a/RunTestSuite.bat b/RunTestSuite.bat
new file mode 100644
index 00000000..b2aac085
--- /dev/null
+++ b/RunTestSuite.bat
@@ -0,0 +1 @@
+mvn clean test
\ No newline at end of file
diff --git a/RunTestSuite.sh b/RunTestSuite.sh
new file mode 100644
index 00000000..b2aac085
--- /dev/null
+++ b/RunTestSuite.sh
@@ -0,0 +1 @@
+mvn clean test
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 8e537898..add5d89b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,56 +1,124 @@
-
- 4.0.0
+
+ 4.0.0
- com.wakaleo.tutorials
- vet-clinic
- 1.0.0-SNAPSHOT
- jar
+ com.wakaleo.tutorials
+ vet-clinic
+ 1.0.1-SNAPSHOT
+ jar
+ tutorials
+ http://maven.apache.org
- tutorials
- http://maven.apache.org
+
+
+ github
+ GitHub abhinay5993 Apache Maven Packages
+ https://maven.pkg.github.com/abhinay5993/vet-clinic
+
+
-
- UTF-8
-
+
+
+ abhinay5993
+ abhinaylunawat5993@gmail.com
+ https://github.com/abhinay5993/vet-clinic
+
+
-
-
- junit
- junit
- 4.12
- test
-
-
- org.assertj
- assertj-core
- 3.1.0
- test
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.2
-
- 1.8
- 1.8
-
-
-
+
+ scm:git:git://github.com/abhinay5993/vet-clinic.git
+ scm:git:https://github.com/abhinay5993/vet-clinic.git
+ https://github.com/abhinay5993/vet-clinic
+ vet-clinic-autodeployed-v
+
+
+
+ UTF-8
+ 11
+ 11
+
+
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+ org.testng
+ testng
+ 7.8.0
+
+
+ org.assertj
+ assertj-core
+ 3.1.0
+ test
+
+
+ org.hamcrest
+ hamcrest-all
+ 1.3
+
+
+ com.google.guava
+ guava
+ 19.0
+
+
+ pl.pragmatists
+ JUnitParams
+ 1.0.5
+ test
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-plugin-plugin
+ 3.6.0
+
+ true
+
+
+
+ org.apache.maven.plugins
+ maven-site-plugin
+ 3.9.1
+
+
+
+
+
+ maven-compiler-plugin
+ 3.8.1
+
+ 11
+ 11
+ 11
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.18.1
+
+
+ src/test/resources/testSuites/TestNgTCs_Executions_TestSuite.xml
+
+ **/When*.java
+ **/*Tests.java
+ **/*TestSuite.java
+
+
+
+
org.apache.maven.plugins
- maven-surefire-plugin
- 2.18.1
-
-
- **/When*.java
- **/*Test.java
- **/*TestSuite.java
-
-
+ maven-release-plugin
+ 3.0.0-M1
-
-
-
+
+
+
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/BookingAcknowledgement.java b/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/BookingAcknowledgement.java
new file mode 100644
index 00000000..8645adac
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/BookingAcknowledgement.java
@@ -0,0 +1,9 @@
+package serenitylabs.tutorials.vetclinic.collections.exercises;
+
+public interface BookingAcknowledgement {
+
+ boolean isConfirmed();
+
+ boolean isOnWaitingList();
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/BookingConfirmation.java b/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/BookingConfirmation.java
new file mode 100644
index 00000000..be030664
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/BookingConfirmation.java
@@ -0,0 +1,20 @@
+package serenitylabs.tutorials.vetclinic.collections.exercises;
+import serenitylabs.tutorials.vetclinic.katas.PetEntity;
+
+public class BookingConfirmation extends BookingResponse{
+
+ public BookingConfirmation(int number, PetEntity pet) {
+ super(number, pet);
+ }
+
+ @Override
+ public boolean isConfirmed() {
+ return true;
+ }
+
+ @Override
+ public boolean isOnWaitingList() {
+ return false;
+ }
+
+}
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/BookingResponse.java b/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/BookingResponse.java
new file mode 100644
index 00000000..3de126e6
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/BookingResponse.java
@@ -0,0 +1,38 @@
+package serenitylabs.tutorials.vetclinic.collections.exercises;
+import java.util.concurrent.atomic.AtomicInteger;
+import serenitylabs.tutorials.vetclinic.katas.PetEntity;
+
+public abstract class BookingResponse implements BookingAcknowledgement {
+
+ private static AtomicInteger bookingNumberCounter = new AtomicInteger();
+ private final int number;
+ private final PetEntity pet;
+
+ public BookingResponse(int number, PetEntity pet) {
+ this.number = number;
+ this.pet = pet;
+ }
+
+ public static BookingResponse confirmedFor(PetEntity pet) {
+ return new BookingConfirmation(bookingNumberCounter.incrementAndGet(), pet);
+ }
+
+ public static BookingResponse waitingListFor(PetEntity pet) {
+ return new PlacedOnWaitingList(bookingNumberCounter.incrementAndGet(), pet);
+ }
+
+ /**
+ * @return the number
+ */
+ public int getNumber() {
+ return number;
+ }
+
+ /**
+ * @return the pet
+ */
+ public PetEntity getPet() {
+ return pet;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/Calculator.java b/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/Calculator.java
new file mode 100644
index 00000000..bc970080
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/Calculator.java
@@ -0,0 +1,11 @@
+package serenitylabs.tutorials.vetclinic.collections.exercises;
+
+public class Calculator {
+
+ protected int field;
+
+ public Integer calculate(String expression) {
+ return 0;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/CheckInStrategy.java b/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/CheckInStrategy.java
new file mode 100644
index 00000000..bdb09880
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/CheckInStrategy.java
@@ -0,0 +1,8 @@
+package serenitylabs.tutorials.vetclinic.collections.exercises;
+import serenitylabs.tutorials.vetclinic.katas.PetEntity;
+
+public interface CheckInStrategy {
+
+ BookingResponse attemptToCheckIn(PetEntity pet);
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/ConfirmBookingStrategy.java b/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/ConfirmBookingStrategy.java
new file mode 100644
index 00000000..be979e1a
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/ConfirmBookingStrategy.java
@@ -0,0 +1,19 @@
+package serenitylabs.tutorials.vetclinic.collections.exercises;
+import java.util.Collection;
+import serenitylabs.tutorials.vetclinic.katas.PetEntity;
+
+public class ConfirmBookingStrategy implements CheckInStrategy {
+
+ private final Collection pets;
+
+ public ConfirmBookingStrategy(Collection pets) {
+ this.pets = pets;
+ }
+
+ @Override
+ public BookingResponse attemptToCheckIn(PetEntity pet) {
+ pets.add(pet);
+ return BookingResponse.confirmedFor(pet);
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/HotelAvailability.java b/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/HotelAvailability.java
new file mode 100644
index 00000000..f06a1b0e
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/HotelAvailability.java
@@ -0,0 +1,7 @@
+package serenitylabs.tutorials.vetclinic.collections.exercises;
+
+public enum HotelAvailability {
+
+ Available, Full;
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/PlacedOnWaitingList.java b/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/PlacedOnWaitingList.java
new file mode 100644
index 00000000..cc2c9aeb
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/PlacedOnWaitingList.java
@@ -0,0 +1,20 @@
+package serenitylabs.tutorials.vetclinic.collections.exercises;
+import serenitylabs.tutorials.vetclinic.katas.PetEntity;
+
+public class PlacedOnWaitingList extends BookingResponse {
+
+ public PlacedOnWaitingList(int number, PetEntity pet) {
+ super(number, pet);
+ }
+
+ @Override
+ public boolean isConfirmed() {
+ return false;
+ }
+
+ @Override
+ public boolean isOnWaitingList() {
+ return true;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/SpecialisedPetHotel.java b/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/SpecialisedPetHotel.java
new file mode 100644
index 00000000..c4263120
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/SpecialisedPetHotel.java
@@ -0,0 +1,22 @@
+package serenitylabs.tutorials.vetclinic.collections.exercises;
+import java.util.ArrayList;
+import java.util.List;
+
+public class SpecialisedPetHotel {
+
+ List pets = new ArrayList<>();
+
+ /**
+ * @return the pets
+ */
+ public List getPets() {
+ return new ArrayList<>(pets);
+ }
+
+ /**
+ * @param pets the pets to set
+ */
+ public void checkIn(T pets) {
+ this.pets.add(pets);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/WaitingListStrategy.java b/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/WaitingListStrategy.java
new file mode 100644
index 00000000..415f7b0d
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/collections/exercises/WaitingListStrategy.java
@@ -0,0 +1,19 @@
+package serenitylabs.tutorials.vetclinic.collections.exercises;
+import java.util.Collection;
+import serenitylabs.tutorials.vetclinic.katas.PetEntity;
+
+public class WaitingListStrategy implements CheckInStrategy {
+
+ private final Collection relevantPets;
+
+ public WaitingListStrategy(Collection relevantPets) {
+ this.relevantPets = relevantPets;
+ }
+
+ @Override
+ public BookingResponse attemptToCheckIn(PetEntity pet) {
+ relevantPets.add(pet);
+ return BookingResponse.waitingListFor(pet);
+ }
+
+}
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/collections/katas/APetHotelEntity.java b/src/main/java/serenitylabs/tutorials/vetclinic/collections/katas/APetHotelEntity.java
new file mode 100644
index 00000000..4a0774a4
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/collections/katas/APetHotelEntity.java
@@ -0,0 +1,14 @@
+package serenitylabs.tutorials.vetclinic.collections.katas;
+
+/**
+ * A utility class to generate pet hotels with pets already booked
+ *
+ */
+
+public class APetHotelEntity {
+
+ public static PetAdderEntityBuilder with(int petCount) {
+ return new PetAdderEntityBuilder(petCount);
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/collections/katas/PetAdderEntityBuilder.java b/src/main/java/serenitylabs/tutorials/vetclinic/collections/katas/PetAdderEntityBuilder.java
new file mode 100644
index 00000000..19949a3f
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/collections/katas/PetAdderEntityBuilder.java
@@ -0,0 +1,37 @@
+package serenitylabs.tutorials.vetclinic.collections.katas;
+import java.util.List;
+import java.util.Random;
+import com.google.common.collect.ImmutableList;
+import serenitylabs.tutorials.vetclinic.enumerations.exercises.BreedEnum;
+import serenitylabs.tutorials.vetclinic.katas.PetEntity;
+
+public class PetAdderEntityBuilder {
+
+ private final int petCount;
+ private final static Random random = new Random();
+ private final static List PET_NAMES = ImmutableList.of("Fido","Felix","Rover","Spot");
+
+ public PetAdderEntityBuilder(int petCount) {
+ this.petCount = petCount;
+ }
+
+ private PetEntity somePet(int petCount) {
+ return new PetEntity(someName(petCount), someBreed());
+ }
+
+ private BreedEnum someBreed() {
+ return BreedEnum.values()[ random.nextInt(BreedEnum.values().length) ];
+ }
+
+ private String someName(int petCount) {
+ return PET_NAMES.get(random.nextInt(PET_NAMES.size())) + " " + petCount;
+ }
+
+ public PetHotel petsCheckedIn() {
+ PetHotel hotel = new PetHotel();
+ for(int count = 0; count < petCount; count++) {
+ hotel.checkIn(somePet(count));
+ }
+ return hotel;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/collections/katas/PetHotel.java b/src/main/java/serenitylabs/tutorials/vetclinic/collections/katas/PetHotel.java
new file mode 100644
index 00000000..bdadd25a
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/collections/katas/PetHotel.java
@@ -0,0 +1,55 @@
+package serenitylabs.tutorials.vetclinic.collections.katas;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+import java.util.TreeSet;
+
+import serenitylabs.tutorials.vetclinic.collections.exercises.BookingResponse;
+import serenitylabs.tutorials.vetclinic.collections.exercises.CheckInStrategy;
+import serenitylabs.tutorials.vetclinic.collections.exercises.ConfirmBookingStrategy;
+import serenitylabs.tutorials.vetclinic.collections.exercises.HotelAvailability;
+import serenitylabs.tutorials.vetclinic.collections.exercises.WaitingListStrategy;
+import serenitylabs.tutorials.vetclinic.katas.PetEntity;
+
+public class PetHotel {
+
+ public static final int MAXIMUM_PETS = 20;
+ private Collection pets = new TreeSet<>(Comparator.comparing(PetEntity::getName));
+ private Queue waitingList = new LinkedList<>();
+ private static final Map CHECK_IN_STRATEGY = new HashMap<>();
+
+ {
+ CHECK_IN_STRATEGY.put(HotelAvailability.Available, new ConfirmBookingStrategy(pets));
+ CHECK_IN_STRATEGY.put(HotelAvailability.Full, new WaitingListStrategy(waitingList));
+ }
+
+ public List getPets() {
+ return new ArrayList<>(pets);
+ }
+
+ private HotelAvailability currentAvailability() {
+ return (pets.size() >= MAXIMUM_PETS) ? HotelAvailability.Full : HotelAvailability.Available;
+ }
+
+ public BookingResponse checkIn(PetEntity pet) {
+ CheckInStrategy checkInStrategy = CHECK_IN_STRATEGY.get(currentAvailability());
+ return checkInStrategy.attemptToCheckIn(pet);
+ }
+
+ public Collection getWaitingList() {
+ return new ArrayList<>(waitingList);
+ }
+
+ public void checkOut(PetEntity pet) {
+ pets.remove(pet);
+ if (!waitingList.isEmpty()) {
+ checkIn(waitingList.poll());
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/domain/AppointmentBookerBuilderEntity.java b/src/main/java/serenitylabs/tutorials/vetclinic/domain/AppointmentBookerBuilderEntity.java
new file mode 100644
index 00000000..e8a2f163
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/domain/AppointmentBookerBuilderEntity.java
@@ -0,0 +1,28 @@
+package serenitylabs.tutorials.vetclinic.domain;
+import java.time.LocalDateTime;
+
+public class AppointmentBookerBuilderEntity {
+
+ private final String petName;
+ private String owner;
+ private String reason;
+
+ public AppointmentBookerBuilderEntity(String petName) {
+ this.petName = petName;
+ }
+
+ public AppointmentBookerBuilderEntity ownedBy(String owner) {
+ this.owner = owner;
+ return this;
+ }
+
+ public AppointmentBookerBuilderEntity because(String reason) {
+ this.reason = reason;
+ return this;
+ }
+
+ public AppointmentEntity at(LocalDateTime appointmentTime) {
+ return new AppointmentEntity(petName, owner, appointmentTime, reason);
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/domain/AppointmentEntity.java b/src/main/java/serenitylabs/tutorials/vetclinic/domain/AppointmentEntity.java
new file mode 100644
index 00000000..baedf58c
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/domain/AppointmentEntity.java
@@ -0,0 +1,55 @@
+package serenitylabs.tutorials.vetclinic.domain;
+import java.time.LocalDateTime;
+import java.util.Optional;
+
+public class AppointmentEntity {
+
+ private final String petName;
+ private final String owner;
+ private final LocalDateTime appointmentTime;
+ private final Optional reason;
+
+ public AppointmentEntity(String petName, String owner, LocalDateTime appointmentTime,String reason) {
+ this.petName = petName;
+ this.owner = owner;
+ this.appointmentTime = appointmentTime;
+ this.reason = Optional.ofNullable(reason);
+ }
+
+ public AppointmentEntity(String petName, String owner, LocalDateTime appointmentTime) {
+ this(petName, owner, appointmentTime, null);
+ }
+
+ public String getPetName() {
+ return petName;
+ }
+
+ public String getOwner() {
+ return owner;
+ }
+
+ public LocalDateTime getAppointmentTime() {
+ return appointmentTime;
+ }
+
+ public Optional getReason() {
+ return reason;
+ }
+
+ public boolean isBefore(LocalDateTime isBeforeLocatDt)
+ {
+ return true;
+ }
+
+ public boolean isAfter(LocalDateTime isAfterLocatDt)
+ {
+ return true;
+ }
+
+
+ public static AppointmentBookerBuilderEntity forPetCalled(String petName) {
+ return new AppointmentBookerBuilderEntity(petName);
+
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/domain/DogBreederEntityBuilder.java b/src/main/java/serenitylabs/tutorials/vetclinic/domain/DogBreederEntityBuilder.java
new file mode 100644
index 00000000..67a7197b
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/domain/DogBreederEntityBuilder.java
@@ -0,0 +1,57 @@
+package serenitylabs.tutorials.vetclinic.domain;
+import java.time.LocalDate;
+
+public class DogBreederEntityBuilder implements WithIBreedable,IwithColourable {
+
+ private String name;
+ private String breed;
+ private String favouriteColour;
+ private String optFldFavouriteFood;
+ private String optFldFavouriteToy;
+
+ public DogBreederEntityBuilder(String name) {
+ this.name=name;
+ System.out.println("DogBreederEntityBuilder - builders object initialized.");
+ }
+
+ public DogBreederEntityBuilder ofDogBreed(String breed) {
+ this.breed=breed;
+ return this;
+ }
+
+ public DogEntityImmutableType bornOn(LocalDate localDate) {
+ return new DogEntityImmutableType(name, breed, localDate,favouriteColour,optFldFavouriteFood,optFldFavouriteToy);
+ }
+
+
+ public DogEntity dgEntityBornOn(LocalDate localDate) {
+ return new DogEntity(name, breed, localDate,favouriteColour,optFldFavouriteFood,optFldFavouriteToy);
+ }
+
+ @Override
+ public IwithColourable ofBreed(String breed) {
+ return new DogBreederEntityBuilder(breed);
+ }
+
+ public DogBreederEntityBuilder ofDogColour(String strFavColour) {
+ this.favouriteColour=strFavColour;
+ return this;
+ }
+
+
+ public DogEntityImmutableType ofColour(String favColour) {
+ return new DogEntityImmutableType(favColour);
+ }
+
+ public DogBreederEntityBuilder setOptFldFavouriteFood(String strOptFavFood) {
+ this.optFldFavouriteFood=strOptFavFood;
+ return this;
+ }
+
+ public DogBreederEntityBuilder setOptFldFavouriteToy(String strOptFavToy) {
+ this.optFldFavouriteToy=strOptFavToy;
+ return this;
+ }
+
+
+}
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/domain/DogEntity.java b/src/main/java/serenitylabs/tutorials/vetclinic/domain/DogEntity.java
new file mode 100644
index 00000000..e64dc1d1
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/domain/DogEntity.java
@@ -0,0 +1,75 @@
+package serenitylabs.tutorials.vetclinic.domain;
+import java.time.LocalDate;
+
+/**
+ * Mutable DogEntity class as its fields values state can be modifyed with the
+ * help of setter methods.
+ *
+ */
+
+public class DogEntity {
+
+ private String dogName;
+ private String dogBreed;
+ private LocalDate birthDateTime;
+ private String favouriteColour;
+ private String optFldFavouriteFood;
+ private String optFldFavouriteToy;
+
+ DogEntity(String dogName, String dogBreed, LocalDate birthDateTime,String favColour,String strFavFood,String strFavToy) {
+ this.dogName = dogName;
+ this.dogBreed = dogBreed;
+ this.birthDateTime = birthDateTime;
+ this.favouriteColour=favColour;
+ this.optFldFavouriteFood=strFavFood;
+ this.optFldFavouriteToy=strFavToy;
+ }
+
+ public DogEntity(){
+ System.out.println("Default constructor of Mutable DogEntity class called.");
+ }
+
+ public String getDogName() {
+ return dogName;
+ }
+ public String getDogBreed() {
+ return dogBreed;
+ }
+ public LocalDate getBirthDateTime() {
+ return birthDateTime;
+ }
+
+ public String getFavouriteColour() {
+ return favouriteColour;
+ }
+
+ public String getOptFldFavouriteFood() {
+ return optFldFavouriteFood;
+ }
+
+ public String getOptFldFavouriteToy() {
+ return optFldFavouriteToy;
+ }
+
+ public static WithIBreedable called(String name)
+ {
+ return new DogBreederEntityBuilder(name);
+ }
+
+ public DogEntity dgEntityBornOn(LocalDate localDate) {
+ return new DogEntity(dogName, dogBreed, localDate,favouriteColour,optFldFavouriteFood,optFldFavouriteToy);
+ }
+
+ public void setDogName(String strDgName) {
+ this.dogName=strDgName;
+ }
+
+ public void setDogBreed(String strDgBreed) {
+ this.dogBreed=strDgBreed;
+ }
+
+ public void setBirthDateTime(LocalDate locDateTimeObj) {
+ this.birthDateTime=locDateTimeObj;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/domain/DogEntityImmutableType.java b/src/main/java/serenitylabs/tutorials/vetclinic/domain/DogEntityImmutableType.java
new file mode 100644
index 00000000..614b9167
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/domain/DogEntityImmutableType.java
@@ -0,0 +1,145 @@
+package serenitylabs.tutorials.vetclinic.domain;
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Immutable DogEntityImmutableType class as its fields values state can not be
+ * modified.
+ *
+ */
+
+public class DogEntityImmutableType {
+
+ //marking fields with final soo that its state can not be change.
+ private String dogName;
+ private String dogBreed;
+ private LocalDate dateOfBirth;
+ private String favouriteColor;
+ private String optFldFavouriteFood;
+ private String optFldFavouriteToy;
+ private List strListOfColours;
+
+ public static DogEntityImmutableType getImmutableInstance() {
+ return new DogEntityImmutableType();
+ }
+
+ public DogEntityImmutableType(String dogName, String dogBreed, LocalDate birthDateTime) {
+ this(dogName, dogBreed, birthDateTime,null,null,null);
+ System.out.println("Parameterized constructor of Immutable DogEntityImmutableType class called.");
+ }
+
+ public DogEntityImmutableType(String dogName, String dogBreed,List localLstColorStr) {
+ this.dogName=dogName;
+ this.dogBreed=dogBreed;
+ this.strListOfColours=localLstColorStr;
+ System.out.println("Parameterized constructor of Immutable DogEntityImmutableType class called.");
+ }
+
+ public DogEntityImmutableType(String dogName, String dogBreed, LocalDate birthDateTime, String favColour,String favFood,String favToys) {
+ this.dogName = dogName;
+ this.dogBreed = dogBreed;
+ this.dateOfBirth = birthDateTime;
+ this.favouriteColor = favColour;
+ this.optFldFavouriteFood=favFood;
+ this.optFldFavouriteToy=favToys;
+ System.out.println("Parameterized constructor with new field added.");
+ }
+
+ public DogEntityImmutableType() {
+
+ }
+
+ public DogEntityImmutableType(String name) {
+ this.dogName=name;
+ }
+
+ public String getDogName() {
+ return dogName;
+ }
+ public String getDogBreed() {
+ return dogBreed;
+ }
+ public LocalDate getBirthDate() {
+ return dateOfBirth;
+ }
+
+ public String getFavouriteColor() {
+ return favouriteColor;
+ }
+
+ public String getOptFldFavouriteFood() {
+ return optFldFavouriteFood;
+ }
+
+ public String getOptFldFavouriteToy() {
+ return optFldFavouriteToy;
+ }
+
+
+ public DogEntityImmutableType called(String name) {
+ this.dogName=name;
+ System.out.println("\nThis methode call is mandatory. called()");
+ return this;
+ }
+
+ public DogEntityImmutableType ofBreed(String breed) {
+ System.out.println("\nThis methode call is mandatory. ofBreed()");
+ this.dogBreed=breed;
+ return this;
+ }
+
+ public DogEntityImmutableType ofColour(String favColour) {
+ this.favouriteColor=favColour;
+ System.out.println("\nThis methode called. ofColour()");
+ return this;
+ }
+
+
+ public DogEntityImmutableType bornOn(LocalDate theFourthOfJuly) {
+ System.out.println("\nThis methode call is mandatory. bornOn()");
+ return new DogEntityImmutableType(dogName, dogBreed, theFourthOfJuly,favouriteColor,optFldFavouriteFood,optFldFavouriteToy);
+ }
+
+
+ public DogEntityImmutableType setOptFldFavouriteFood(String optFldFavouriteFood) {
+ this.optFldFavouriteFood = optFldFavouriteFood;
+ System.out.println("\nThis methode call is optional setOptFldFavouriteFood() ");
+ return this;
+ }
+
+ public DogEntityImmutableType setOptFldFavouriteToy(String optFldFavouriteToy) {
+ this.optFldFavouriteToy = optFldFavouriteToy;
+ System.out.println("\nThis methode call is optional setOptFldFavouriteToy() ");
+ return this;
+ }
+
+ public static DogEntityImmutableType aLargeDog() {
+ return getImmutableInstance().ofBreed("Labrador");
+ }
+
+ public static DogEntityImmutableType aSmallDog() {
+ return getImmutableInstance().ofBreed("Lasa");
+ }
+
+ public static DogEntityImmutableType aGuardDog() {
+ return getImmutableInstance().ofBreed("German Shepherd");
+ }
+
+ public DogEntityImmutableType andOfColour(String... favColour) {
+ System.out.println("\nThis methode called. andOfColour()");
+ return new DogEntityImmutableType(dogName, dogBreed, ImmutableList.copyOf(favColour));
+ }
+
+ @Override
+ public String toString() {
+ return ""+dogName+" the "+favouriteColor+" "+dogBreed+"";
+ }
+
+ public List getStrListOfColours() {
+ return new ArrayList(strListOfColours);
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/domain/IwithColourable.java b/src/main/java/serenitylabs/tutorials/vetclinic/domain/IwithColourable.java
new file mode 100644
index 00000000..c0ff2088
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/domain/IwithColourable.java
@@ -0,0 +1,8 @@
+package serenitylabs.tutorials.vetclinic.domain;
+
+public interface IwithColourable {
+
+ DogEntityImmutableType ofColour(String favColour);
+
+ DogBreederEntityBuilder ofDogColour(String strFavColour);
+}
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/domain/TotalConsultationPrice.java b/src/main/java/serenitylabs/tutorials/vetclinic/domain/TotalConsultationPrice.java
new file mode 100644
index 00000000..e99b277c
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/domain/TotalConsultationPrice.java
@@ -0,0 +1,13 @@
+package serenitylabs.tutorials.vetclinic.domain;
+
+public class TotalConsultationPrice {
+
+ public static TotalConsultationPrice includingTax() {
+ return new TotalConsultationPrice();
+ }
+
+ public int forANetPriceOf(double netPrice) {
+ return (int) (netPrice * 1.20);
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/domain/WithIBreedable.java b/src/main/java/serenitylabs/tutorials/vetclinic/domain/WithIBreedable.java
new file mode 100644
index 00000000..d14908ed
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/domain/WithIBreedable.java
@@ -0,0 +1,9 @@
+package serenitylabs.tutorials.vetclinic.domain;
+
+public interface WithIBreedable {
+
+ IwithColourable ofBreed(String breed);
+
+ IwithColourable ofDogBreed(String breed);
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/enumerations/colours/ColourEnum.java b/src/main/java/serenitylabs/tutorials/vetclinic/enumerations/colours/ColourEnum.java
new file mode 100644
index 00000000..58a7d6e4
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/enumerations/colours/ColourEnum.java
@@ -0,0 +1,35 @@
+package serenitylabs.tutorials.vetclinic.enumerations.colours;
+import java.util.Map;
+import com.google.common.collect.Maps;
+
+public enum ColourEnum {
+
+ Red(true), Orange(false), Yellow(true), Green(false), Blue(true), Violet(false), Black(false), White(false);
+
+ private final boolean isPrimary;
+ private static final Map OPPOSITES = Maps.newHashMap();
+
+ ColourEnum(boolean isPrimary) {
+ this.isPrimary = isPrimary;
+ }
+
+ public boolean isPrimary() {
+ return isPrimary;
+ }
+
+ public ColourEnum opposite() {
+ return OPPOSITES.get(this);
+ }
+
+ static {
+ OPPOSITES.put(Red, Green);
+ OPPOSITES.put(Green, Red);
+ OPPOSITES.put(Blue, Orange);
+ OPPOSITES.put(Orange, Blue);
+ OPPOSITES.put(Violet, Yellow);
+ OPPOSITES.put(Yellow, Violet);
+ OPPOSITES.put(Black, White);
+ OPPOSITES.put(White, Black);
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/enumerations/exercises/BreedEnum.java b/src/main/java/serenitylabs/tutorials/vetclinic/enumerations/exercises/BreedEnum.java
new file mode 100644
index 00000000..2f527719
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/enumerations/exercises/BreedEnum.java
@@ -0,0 +1,21 @@
+package serenitylabs.tutorials.vetclinic.enumerations.exercises;
+
+public enum BreedEnum {
+
+ Cat("Felis catus"),
+ Dog("Canis lupus familiaris"),
+ Rabbit("Oryctolagus cuniculus"),
+ Fish("Carassius auratus"),
+ Parrot("Psittaciformes");
+
+ private final String scientificName;
+
+ BreedEnum(String scientificName) {
+ this.scientificName = scientificName;
+ }
+
+ public String getScientificName() {
+ return scientificName;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/enumerations/exercises/GenderEnum.java b/src/main/java/serenitylabs/tutorials/vetclinic/enumerations/exercises/GenderEnum.java
new file mode 100644
index 00000000..dbbb2bf2
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/enumerations/exercises/GenderEnum.java
@@ -0,0 +1,5 @@
+package serenitylabs.tutorials.vetclinic.enumerations.exercises;
+
+public enum GenderEnum {
+ Male, Female, Unknown;
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/katas/PetEntity.java b/src/main/java/serenitylabs/tutorials/vetclinic/katas/PetEntity.java
new file mode 100644
index 00000000..cf9cf51b
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/katas/PetEntity.java
@@ -0,0 +1,76 @@
+package serenitylabs.tutorials.vetclinic.katas;
+import java.util.Objects;
+import serenitylabs.tutorials.vetclinic.enumerations.exercises.BreedEnum;
+import serenitylabs.tutorials.vetclinic.enumerations.exercises.GenderEnum;
+
+public class PetEntity {
+
+ private final String name;
+ private final BreedEnum breed;
+ private final GenderEnum gender;
+
+ public PetEntity(String name, BreedEnum breed, GenderEnum gender) {
+ this.name = name;
+ this.breed = breed;
+ this.gender = gender;
+ }
+
+ public PetEntity(String name, BreedEnum breed) {
+ this(name, breed, GenderEnum.Unknown);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public BreedEnum getBreed() {
+ return breed;
+ }
+
+ public GenderEnum getGender() {
+ return gender;
+ }
+
+ @Override
+ public String toString() {
+ return "a " + breed + " called " + name;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(breed, name);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof PetEntity)) {
+ return false;
+ }
+ PetEntity other = (PetEntity) obj;
+ return breed == other.breed && Objects.equals(name, other.name);
+ }
+
+ public static PetEntityBuilder dog() {
+ return new PetEntityBuilder(BreedEnum.Dog);
+ }
+
+ public static PetEntityBuilder cat() {
+ return new PetEntityBuilder(BreedEnum.Cat);
+ }
+
+ public static PetEntityBuilder rabbit() {
+ return new PetEntityBuilder(BreedEnum.Rabbit);
+ }
+
+ public static PetEntityBuilder parrot() {
+ return new PetEntityBuilder(BreedEnum.Parrot);
+ }
+
+ public static PetEntityBuilder fish() {
+ return new PetEntityBuilder(BreedEnum.Fish);
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/katas/PetEntityBuilder.java b/src/main/java/serenitylabs/tutorials/vetclinic/katas/PetEntityBuilder.java
new file mode 100644
index 00000000..238b8f3d
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/katas/PetEntityBuilder.java
@@ -0,0 +1,23 @@
+package serenitylabs.tutorials.vetclinic.katas;
+import serenitylabs.tutorials.vetclinic.enumerations.exercises.BreedEnum;
+import serenitylabs.tutorials.vetclinic.enumerations.exercises.GenderEnum;
+
+public class PetEntityBuilder {
+
+ private final BreedEnum breed;
+ private GenderEnum gender = GenderEnum.Unknown;
+
+ public PetEntityBuilder(BreedEnum breed) {
+ this.breed = breed;
+ }
+
+ public PetEntity named(String name) {
+ return new PetEntity(name, breed, gender);
+ }
+
+ public PetEntityBuilder ofGender(GenderEnum gender) {
+ this.gender = gender;
+ return this;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/package-info.java b/src/main/java/serenitylabs/tutorials/vetclinic/package-info.java
deleted file mode 100644
index cf2e5f53..00000000
--- a/src/main/java/serenitylabs/tutorials/vetclinic/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Our fantastic Vet Clinic app starts here
- **/
- package serenitylabs.tutorials.vetclinic;
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/ChildEntity.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/ChildEntity.java
new file mode 100644
index 00000000..4c5423e4
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/ChildEntity.java
@@ -0,0 +1,36 @@
+package serenitylabs.tutorials.vetclinic.playingball.model;
+import java.time.LocalDate;
+
+public class ChildEntity {
+
+ public static ChildEntity childEntity;
+ private final SportsSchedule sportsSchedule;
+
+ private ChildEntity() {
+ this.sportsSchedule = new SportsSchedule();
+ }
+
+ /**
+ * @param childEntity the childEntity to set
+ */
+ public static synchronized ChildEntity getChildEntity() {
+ if (childEntity == null) {
+ childEntity = new ChildEntity();
+ }
+ return childEntity;
+ }
+
+ public ChildEntity(SportsSchedule sportsSchedule) {
+ this.sportsSchedule = sportsSchedule;
+ }
+
+ public void goPlay(GameEnum game) {
+ IPlayer gameToPlay = PlayerForGame.called(game);
+ gameToPlay.play();
+ }
+
+ public GameEnum goPlayBallOn(LocalDate someDay) {
+ return sportsSchedule.forDate(someDay).letEnumToPlay();
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/DontKnowThatGameException.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/DontKnowThatGameException.java
new file mode 100644
index 00000000..d8f46f60
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/DontKnowThatGameException.java
@@ -0,0 +1,11 @@
+package serenitylabs.tutorials.vetclinic.playingball.model;
+
+public class DontKnowThatGameException extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public DontKnowThatGameException(String strMsg) {
+ super(strMsg);
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/GameEnum.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/GameEnum.java
new file mode 100644
index 00000000..66235fe8
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/GameEnum.java
@@ -0,0 +1,7 @@
+package serenitylabs.tutorials.vetclinic.playingball.model;
+
+public enum GameEnum {
+
+ Football, Tennis, Cricket, Handball, Hockey;
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/IGameSchedule.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/IGameSchedule.java
new file mode 100644
index 00000000..8680dfee
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/IGameSchedule.java
@@ -0,0 +1,8 @@
+package serenitylabs.tutorials.vetclinic.playingball.model;
+import java.time.LocalDate;
+
+public interface IGameSchedule {
+
+ IPlayBall forGameOn(LocalDate someDay);
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/IPlayBall.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/IPlayBall.java
new file mode 100644
index 00000000..cb27edd9
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/IPlayBall.java
@@ -0,0 +1,7 @@
+package serenitylabs.tutorials.vetclinic.playingball.model;
+
+public interface IPlayBall {
+
+ GameEnum letEnumToPlay();
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/IPlayer.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/IPlayer.java
new file mode 100644
index 00000000..e7299b37
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/IPlayer.java
@@ -0,0 +1,5 @@
+package serenitylabs.tutorials.vetclinic.playingball.model;
+
+public interface IPlayer {
+ void play();
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/PlayCricket.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/PlayCricket.java
new file mode 100644
index 00000000..da32d023
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/PlayCricket.java
@@ -0,0 +1,13 @@
+package serenitylabs.tutorials.vetclinic.playingball.model;
+
+public class PlayCricket implements IPlayer, IPlayBall {
+
+ public void play() {
+ System.out.print("Hit the wicket");
+ }
+
+ public GameEnum letEnumToPlay() {
+ return GameEnum.Cricket;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/PlayFootball.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/PlayFootball.java
new file mode 100644
index 00000000..66c558f6
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/PlayFootball.java
@@ -0,0 +1,14 @@
+package serenitylabs.tutorials.vetclinic.playingball.model;
+
+public class PlayFootball implements IPlayer,IPlayBall {
+
+ @Override
+ public void play() {
+ System.out.print("Kick the ball");
+ }
+
+ public GameEnum letEnumToPlay() {
+ return GameEnum.Football;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/PlayHandball.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/PlayHandball.java
new file mode 100644
index 00000000..a22e764a
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/PlayHandball.java
@@ -0,0 +1,15 @@
+package serenitylabs.tutorials.vetclinic.playingball.model;
+
+public class PlayHandball implements IPlayer,IPlayBall {
+
+ @Override
+ public void play() {
+ System.out.print("Throw the ball");
+ }
+
+ @Override
+ public GameEnum letEnumToPlay() {
+ return GameEnum.Handball;
+ }
+
+}
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/PlayHockey.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/PlayHockey.java
new file mode 100644
index 00000000..34c7a92f
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/PlayHockey.java
@@ -0,0 +1,15 @@
+package serenitylabs.tutorials.vetclinic.playingball.model;
+
+public class PlayHockey implements IPlayer,IPlayBall {
+
+ @Override
+ public void play() {
+ System.out.print("Hit the ball with the stick");
+ }
+
+ @Override
+ public GameEnum letEnumToPlay() {
+ return GameEnum.Hockey;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/PlayTennis.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/PlayTennis.java
new file mode 100644
index 00000000..f3380fa9
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/PlayTennis.java
@@ -0,0 +1,15 @@
+package serenitylabs.tutorials.vetclinic.playingball.model;
+
+public class PlayTennis implements IPlayer,IPlayBall {
+
+ @Override
+ public void play() {
+ System.out.print("Serve the ball");
+ }
+
+ @Override
+ public GameEnum letEnumToPlay() {
+ return GameEnum.Tennis;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/PlayerForGame.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/PlayerForGame.java
new file mode 100644
index 00000000..ad8fb27b
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/PlayerForGame.java
@@ -0,0 +1,22 @@
+package serenitylabs.tutorials.vetclinic.playingball.model;
+
+public class PlayerForGame {
+
+ public static IPlayer called(GameEnum game) {
+ switch (game) {
+ case Football:
+ return new PlayFootball();
+ case Tennis:
+ return new PlayTennis();
+ case Cricket:
+ return new PlayCricket();
+ case Handball:
+ return new PlayHandball();
+ case Hockey:
+ return new PlayHockey();
+ default:
+ throw new DontKnowThatGameException("Wrong!! choice..");
+ }
+ }
+
+}
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/RecreationalSportsSchedule.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/RecreationalSportsSchedule.java
new file mode 100644
index 00000000..41d969d0
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/RecreationalSportsSchedule.java
@@ -0,0 +1,15 @@
+package serenitylabs.tutorials.vetclinic.playingball.model;
+import java.time.LocalDate;
+import static java.time.DayOfWeek.*;
+
+public class RecreationalSportsSchedule implements IGameSchedule {
+
+ @Override
+ public IPlayBall forGameOn(LocalDate someDay) {
+ if ((someDay.getDayOfWeek() == SATURDAY) || (someDay.getDayOfWeek() == SUNDAY)) {
+ return new PlayFootball();
+ }
+ return new PlayHandball();
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/SampleDates.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/SampleDates.java
new file mode 100644
index 00000000..d5101667
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/SampleDates.java
@@ -0,0 +1,24 @@
+package serenitylabs.tutorials.vetclinic.playingball.model;
+import java.time.LocalDate;
+import java.time.Month;
+
+public class SampleDates {
+
+ public static final LocalDate A_SATURDAY = LocalDate.of(2016, Month.AUGUST, 27);
+ public static final LocalDate A_SUNDAY = LocalDate.of(2016, Month.AUGUST, 28);
+ public static final LocalDate A_MONDAY = LocalDate.of(2016, Month.AUGUST, 29);
+ public static final LocalDate A_TUESDAY = LocalDate.of(2016, Month.AUGUST, 30);
+ public static final LocalDate A_WEDNESDAY = LocalDate.of(2016, Month.AUGUST, 31);
+ public static final LocalDate A_THURSDAY = LocalDate.of(2016, Month.SEPTEMBER, 1);
+ public static final LocalDate A_FRIDAY = LocalDate.of(2016, Month.SEPTEMBER, 2);
+
+ public static final LocalDate A_DATE_IN_JANUARY = LocalDate.of(2016, Month.JANUARY, 1);
+ public static final LocalDate A_DATE_IN_MAY = LocalDate.of(2016, Month.MAY, 31);
+ public static final LocalDate A_DATE_IN_JUNE = LocalDate.of(2016, Month.JUNE, 1);
+ public static final LocalDate A_DATE_IN_JULY = LocalDate.of(2016, Month.JULY, 15);
+ public static final LocalDate A_DATE_IN_AUGUST = LocalDate.of(2016, Month.AUGUST, 15);
+ public static final LocalDate A_DATE_IN_SEPTEMBER = LocalDate.of(2016, Month.SEPTEMBER, 30);
+ public static final LocalDate A_DATE_IN_OCTOBER = LocalDate.of(2016, Month.OCTOBER, 1);
+ public static final LocalDate A_DATE_IN_NOVEMBER = LocalDate.of(2016, Month.NOVEMBER, 1);
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/SchoolSportsSchedule.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/SchoolSportsSchedule.java
new file mode 100644
index 00000000..c6aa0a6f
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/SchoolSportsSchedule.java
@@ -0,0 +1,17 @@
+package serenitylabs.tutorials.vetclinic.playingball.model;
+import java.time.LocalDate;
+import java.time.Month;
+
+public class SchoolSportsSchedule implements IGameSchedule {
+
+ @Override
+ public IPlayBall forGameOn(LocalDate someDay) {
+ if ((someDay.getMonth() == Month.JUNE) || (someDay.getMonth() == Month.JULY) ||
+ (someDay.getMonth() == Month.AUGUST) || (someDay.getMonth() == Month.SEPTEMBER))
+ {
+ return new PlayCricket();
+ }
+ return new PlayTennis();
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/SportsSchedule.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/SportsSchedule.java
new file mode 100644
index 00000000..b48ab3e0
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/model/SportsSchedule.java
@@ -0,0 +1,18 @@
+package serenitylabs.tutorials.vetclinic.playingball.model;
+import java.time.LocalDate;
+import static java.time.DayOfWeek.WEDNESDAY;
+
+public class SportsSchedule {
+
+ IGameSchedule schoolSportScheduled = new SchoolSportsSchedule();
+ IGameSchedule recreationalSportScheduled = new RecreationalSportsSchedule();
+
+ public IPlayBall forDate(LocalDate currentDay) {
+ if (currentDay.getDayOfWeek() == WEDNESDAY) {
+ return schoolSportScheduled.forGameOn(currentDay);
+ } else {
+ return recreationalSportScheduled.forGameOn(currentDay);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/SalesTaxService.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/SalesTaxService.java
new file mode 100644
index 00000000..abf0933d
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/SalesTaxService.java
@@ -0,0 +1,39 @@
+package serenitylabs.tutorials.vetclinic.playingball.sales;
+import java.util.HashMap;
+import java.util.Map;
+import serenitylabs.tutorials.vetclinic.playingball.sales.model.LineItemEntity;
+import serenitylabs.tutorials.vetclinic.playingball.sales.model.ProductCategoryEnum;
+import static serenitylabs.tutorials.vetclinic.playingball.sales.model.ProductCategoryEnum.*;
+import serenitylabs.tutorials.vetclinic.playingball.sales.model.SalesTaxEntity;
+
+public class SalesTaxService {
+
+ private static Map CALCULATOR_PER_PRODUCT = new HashMap<>();
+
+ public SalesTaxEntity salesTaxEntryFor(LineItemEntity item) {
+ TaxRate applicableTaxRate = taxRateFor(item);
+ return SalesTaxEntity.atRateOf(applicableTaxRate.getRate()).withName(applicableTaxRate.getName())
+ .forAnAmountOf(item.getTotal() * applicableTaxRate.getRate());
+ }
+
+ private TaxRate taxRateFor(LineItemEntity item) {
+ return CALCULATOR_PER_PRODUCT.getOrDefault(item.getCategory(), STANDARD_RATE).apply(item);
+ }
+
+ static TaxRateCalculator STANDARD_RATE = (item) -> new TaxRate(0.23, "Standard");
+
+ static TaxRateCalculator ZERO_RATE = (item) -> new TaxRate(0.0, "Zero");
+
+ static TaxRateCalculator REDUCED_RATE = (item) -> {
+ double rate = (item.getTotal() > 100.0) ? 0.135 : 0.09;
+ return new TaxRate(rate, "Reduced");
+ };
+
+ static {
+ CALCULATOR_PER_PRODUCT.put(Snacks, REDUCED_RATE);
+ CALCULATOR_PER_PRODUCT.put(SoftDrinks, REDUCED_RATE);
+ CALCULATOR_PER_PRODUCT.put(Books, ZERO_RATE);
+ CALCULATOR_PER_PRODUCT.put(Medicine, ZERO_RATE);
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/TaxRate.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/TaxRate.java
new file mode 100644
index 00000000..4d5db39a
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/TaxRate.java
@@ -0,0 +1,27 @@
+package serenitylabs.tutorials.vetclinic.playingball.sales;
+
+public class TaxRate {
+
+ private final double rate;
+ private final String name;
+
+ public TaxRate(double rate, String name) {
+ this.rate = rate;
+ this.name = name;
+ }
+
+ /**
+ * @return the rate
+ */
+ public double getRate() {
+ return rate;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/TaxRateCalculator.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/TaxRateCalculator.java
new file mode 100644
index 00000000..c6a0253f
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/TaxRateCalculator.java
@@ -0,0 +1,7 @@
+package serenitylabs.tutorials.vetclinic.playingball.sales;
+import java.util.function.Function;
+import serenitylabs.tutorials.vetclinic.playingball.sales.model.LineItemEntity;
+
+public interface TaxRateCalculator extends Function {
+
+}
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/model/IWithName.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/model/IWithName.java
new file mode 100644
index 00000000..b4a52997
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/model/IWithName.java
@@ -0,0 +1,7 @@
+package serenitylabs.tutorials.vetclinic.playingball.sales.model;
+
+public interface IWithName {
+
+ SalesTaxEntityBuilder withName(String name);
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/model/InICategory.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/model/InICategory.java
new file mode 100644
index 00000000..6e590b99
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/model/InICategory.java
@@ -0,0 +1,7 @@
+package serenitylabs.tutorials.vetclinic.playingball.sales.model;
+
+public interface InICategory {
+
+ LineItemEntityBuilder inCategory(ProductCategoryEnum category);
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/model/ItemICalled.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/model/ItemICalled.java
new file mode 100644
index 00000000..a5bf675e
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/model/ItemICalled.java
@@ -0,0 +1,7 @@
+package serenitylabs.tutorials.vetclinic.playingball.sales.model;
+
+public interface ItemICalled {
+
+ InICategory itemCalled(String itemName);
+
+}
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/model/LineItemEntity.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/model/LineItemEntity.java
new file mode 100644
index 00000000..0dc76bb0
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/model/LineItemEntity.java
@@ -0,0 +1,79 @@
+package serenitylabs.tutorials.vetclinic.playingball.sales.model;
+
+import java.util.Objects;
+
+public class LineItemEntity {
+
+ private final double unitCost;
+ private final int quanity;
+ private final String description;
+ private final ProductCategoryEnum category;
+
+ public LineItemEntity(double unitCost, int quanity, String description, ProductCategoryEnum category) {
+ this.unitCost = unitCost;
+ this.quanity = quanity;
+ this.description = description;
+ this.category = category;
+ }
+
+ public static ItemICalled forASaleOf(int quanity) {
+ return new LineItemEntityBuilder(quanity);
+ }
+
+ /**
+ * @return the unitCost
+ */
+ public double getUnitCost() {
+ return unitCost;
+ }
+
+ /**
+ * @return the quanity
+ */
+ public int getQuanity() {
+ return quanity;
+ }
+
+ /**
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ public double getTotal() {
+ return quanity * unitCost;
+ }
+
+ /**
+ * @return the category
+ */
+ public ProductCategoryEnum getCategory() {
+ return category;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(category, description, quanity, unitCost);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof LineItemEntity)) {
+ return false;
+ }
+ LineItemEntity other = (LineItemEntity) obj;
+ return category == other.category && Objects.equals(description, other.description) && quanity == other.quanity
+ && Double.doubleToLongBits(unitCost) == Double.doubleToLongBits(other.unitCost);
+ }
+
+ @Override
+ public String toString() {
+ return "LineItemEntity [unitCost=" + unitCost + ", quanity=" + quanity + ", description=" + description
+ + ", category=" + category + "]";
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/model/LineItemEntityBuilder.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/model/LineItemEntityBuilder.java
new file mode 100644
index 00000000..012496ce
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/model/LineItemEntityBuilder.java
@@ -0,0 +1,28 @@
+package serenitylabs.tutorials.vetclinic.playingball.sales.model;
+
+public class LineItemEntityBuilder implements ItemICalled, InICategory {
+
+ private int quanity;
+ private String itemName;
+ private ProductCategoryEnum category;
+
+ public LineItemEntityBuilder(int quanity) {
+ this.quanity = quanity;
+ }
+
+ @Override
+ public LineItemEntityBuilder inCategory(ProductCategoryEnum category) {
+ this.category = category;
+ return this;
+ }
+
+ @Override
+ public InICategory itemCalled(String itemName) {
+ this.itemName = itemName;
+ return this;
+ }
+
+ public LineItemEntity withAUnitPriceOf(double price) {
+ return new LineItemEntity(price, quanity, itemName, category);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/model/ProductCategoryEnum.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/model/ProductCategoryEnum.java
new file mode 100644
index 00000000..9402fcc6
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/model/ProductCategoryEnum.java
@@ -0,0 +1,6 @@
+package serenitylabs.tutorials.vetclinic.playingball.sales.model;
+
+public enum ProductCategoryEnum {
+
+ Medicine, Books, Snacks, SoftDrinks, Toys, PetFood;
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/model/SalesTaxEntity.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/model/SalesTaxEntity.java
new file mode 100644
index 00000000..e6a8b2be
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/model/SalesTaxEntity.java
@@ -0,0 +1,65 @@
+package serenitylabs.tutorials.vetclinic.playingball.sales.model;
+import java.util.Objects;
+
+public class SalesTaxEntity {
+
+ private final String name;
+ private final double rate;
+ private final double amount;
+
+ public SalesTaxEntity(String name, double rate, double amount) {
+ this.name = name;
+ this.rate = rate;
+ this.amount = amount;
+ }
+
+ public static IWithName atRateOf(double rate) {
+ return new SalesTaxEntityBuilder(rate);
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the rate
+ */
+ public double getRate() {
+ return rate;
+ }
+
+ /**
+ * @return the amount
+ */
+ public double getAmount() {
+ return amount;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(amount, name, rate);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof SalesTaxEntity)) {
+ return false;
+ }
+ SalesTaxEntity other = (SalesTaxEntity) obj;
+ return Double.doubleToLongBits(amount) == Double.doubleToLongBits(other.amount)
+ && Objects.equals(name, other.name)
+ && Double.doubleToLongBits(rate) == Double.doubleToLongBits(other.rate);
+ }
+
+ @Override
+ public String toString() {
+ return "SalesTaxEntity [name=" + name + ", rate=" + rate + ", amount=" + amount + "]";
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/model/SalesTaxEntityBuilder.java b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/model/SalesTaxEntityBuilder.java
new file mode 100644
index 00000000..48d5697f
--- /dev/null
+++ b/src/main/java/serenitylabs/tutorials/vetclinic/playingball/sales/model/SalesTaxEntityBuilder.java
@@ -0,0 +1,21 @@
+package serenitylabs.tutorials.vetclinic.playingball.sales.model;
+
+public class SalesTaxEntityBuilder implements IWithName {
+
+ private double rate;
+ private String name;
+
+ public SalesTaxEntityBuilder(double rate) {
+ this.rate = rate;
+ }
+
+ public SalesTaxEntityBuilder withName(String strName) {
+ this.name = strName;
+ return this;
+ }
+
+ public SalesTaxEntity forAnAmountOf(double amount) {
+ return new SalesTaxEntity(name, rate, amount);
+ }
+
+}
diff --git a/src/test/java/serenitylabs/tutorials/vetclinic/README.md b/src/test/java/README.md
similarity index 100%
rename from src/test/java/serenitylabs/tutorials/vetclinic/README.md
rename to src/test/java/README.md
diff --git a/src/test/java/serenitylabs/tutorials/vetclinic/collections/exercises/WhenWorkingWithAListOfPetNamesTests.java b/src/test/java/serenitylabs/tutorials/vetclinic/collections/exercises/WhenWorkingWithAListOfPetNamesTests.java
new file mode 100644
index 00000000..63101934
--- /dev/null
+++ b/src/test/java/serenitylabs/tutorials/vetclinic/collections/exercises/WhenWorkingWithAListOfPetNamesTests.java
@@ -0,0 +1,111 @@
+package serenitylabs.tutorials.vetclinic.collections.exercises;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import org.testng.annotations.Test;
+import com.google.common.collect.Lists;
+import static org.hamcrest.CoreMatchers.hasItems;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class WhenWorkingWithAListOfPetNamesTests {
+
+ @Test
+ public void should_add_Fido_to_the_list_of_pets() {
+ List names = Lists.newArrayList();
+ // TODO
+ names.add("Fido");
+
+ assertThat(names, contains("Fido"));
+ System.out.println("\nStep-1 - TC-01 - executing - should_add_Fido_to_the_list_of_pets() ");
+ }
+
+
+ @Test
+ public void should_remove_Fido_from_the_list_of_pets() {
+ List names = Lists.newArrayList("Felix", "Fido", "Spot");
+ // TODO
+ names.remove("Fido");
+
+ assertThat(names, contains("Felix", "Spot"));
+ System.out.println("\nStep-2 - TC-02 - executing - should_remove_Fido_from_the_list_of_pets() ");
+ }
+
+
+ @Test
+ public void should_remove_the_first_pet_from_the_list_of_pets() {
+ List names = Lists.newArrayList("Felix", "Fido", "Spot");
+
+ // TODO
+ names.remove(0);
+
+ assertThat(names, contains("Fido", "Spot"));
+ System.out.println("\nStep-3 - TC-03 - executing - should_remove_the_first_pet_from_the_list_of_pets() ");
+ }
+
+
+ @Test
+ public void should_make_a_list_of_cats_and_dogs() {
+ List cats = Lists.newArrayList("Felix", "Spot");
+ List dogs = Lists.newArrayList("Fido", "Rover");
+
+ // TODO
+ List catsAndDogs = new ArrayList(cats);
+ catsAndDogs.addAll(dogs);
+
+ assertThat(catsAndDogs, contains("Felix", "Spot", "Fido", "Rover"));
+ System.out.println("\nStep-4 - TC-04 - executing - should_make_a_list_of_cats_and_dogs() ");
+ }
+
+
+ @Test
+ public void should_put_the_dogs_among_the_cats() {
+ List cats = Lists.newArrayList("Felix", "Spot");
+ List dogs = Lists.newArrayList("Fido", "Rover");
+
+ // TODO
+ List catsAndDogs = new ArrayList(cats);
+ catsAndDogs.addAll(1, dogs);
+
+ assertThat(catsAndDogs, contains("Felix", "Fido", "Rover", "Spot"));
+ System.out.println("\nStep-5 - TC-05 - executing - should_put_the_dogs_among_the_cats() ");
+ }
+
+
+ @Test
+ public void should_organise_pets_in_alphabetical_order() {
+ List pets = Lists.newArrayList("Felix", "Spot", "Fido", "Rover");
+
+ // TODO
+ pets.sort(Comparator.naturalOrder());
+
+ assertThat(pets, contains("Felix", "Fido", "Rover", "Spot"));
+ System.out.println("\nStep-6 - TC-06 - executing - should_organise_pets_in_alphabetical_order() ");
+ }
+
+
+ @Test
+ public void should_organise_pets_in_reverse_alphabetical_order() {
+ List pets = Lists.newArrayList("Felix", "Spot", "Fido", "Rover");
+
+ // TODO
+ pets.sort(Comparator.reverseOrder());
+
+ assertThat(pets, hasItems("Spot", "Rover", "Fido", "Felix"));
+ System.out.println("\nStep-7 - TC-07 - executing - should_organise_pets_in_reverse_alphabetical_order() ");
+ }
+
+
+ @Test
+ public void should_organise_pets_by_name_length() {
+ List pets = Lists.newArrayList("Felix", "Alfred", "Spot");
+
+ // TODO
+ pets.sort(Comparator.comparing(String::length));
+
+ assertThat(pets, contains("Spot", "Felix", "Alfred"));
+ System.out.println("\nStep-8 - TC-08 - executing - should_organise_pets_by_name_length() ");
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/test/java/serenitylabs/tutorials/vetclinic/collections/exercises/WhenWorkingWithAListOfPetsTests.java b/src/test/java/serenitylabs/tutorials/vetclinic/collections/exercises/WhenWorkingWithAListOfPetsTests.java
new file mode 100644
index 00000000..63ee6f58
--- /dev/null
+++ b/src/test/java/serenitylabs/tutorials/vetclinic/collections/exercises/WhenWorkingWithAListOfPetsTests.java
@@ -0,0 +1,25 @@
+package serenitylabs.tutorials.vetclinic.collections.exercises;
+import java.util.ArrayList;
+import java.util.List;
+import org.testng.annotations.Test;
+import serenitylabs.tutorials.vetclinic.katas.PetEntity;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class WhenWorkingWithAListOfPetsTests {
+
+ @Test
+ public void should_store_a_list_of_pets() {
+
+ List pets = new ArrayList<>();
+
+ pets.add(PetEntity.cat().named("Felix"));
+ pets.add(PetEntity.dog().named("Fido"));
+
+ // TODO: Implement the equals and hashcode methods in the Pet class to make this
+ // work
+ assertThat(pets, hasItem(PetEntity.dog().named("Fido")));
+ System.out.println("\nStep-1 - TC-01 - Executing should_store_a_list_of_pets()");
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/serenitylabs/tutorials/vetclinic/collections/exercises/WhenWorkingWithAPetMapTests.java b/src/test/java/serenitylabs/tutorials/vetclinic/collections/exercises/WhenWorkingWithAPetMapTests.java
new file mode 100644
index 00000000..76e7df11
--- /dev/null
+++ b/src/test/java/serenitylabs/tutorials/vetclinic/collections/exercises/WhenWorkingWithAPetMapTests.java
@@ -0,0 +1,108 @@
+package serenitylabs.tutorials.vetclinic.collections.exercises;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.NavigableMap;
+import java.util.TreeMap;
+import org.testng.annotations.Test;
+import serenitylabs.tutorials.vetclinic.enumerations.exercises.BreedEnum;
+import serenitylabs.tutorials.vetclinic.katas.PetEntity;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.contains;
+
+public class WhenWorkingWithAPetMapTests {
+
+ @Test
+ public void pets_can_be_found_by_their_name() {
+ Map pets = new HashMap<>();
+
+ PetEntity fido = PetEntity.dog().named("Fido");
+
+ pets.put("Fido", fido);
+
+ // TODO
+ assertThat(pets.get("Fido"), equalTo(fido));
+ System.out.println("\nStep-1 - TC-01 - Executing pets_can_be_found_by_their_name() ");
+ }
+
+
+ @Test
+ public void should_be_able_to_get_a_default_value_if_no_matching_key_is_present() {
+ Map pets = new HashMap<>();
+
+ PetEntity fido = PetEntity.dog().named("Fido");
+ PetEntity stray = PetEntity.dog().named("Stray");
+
+ pets.put("Fido", fido);
+ pets.put("Stray", stray);
+
+ PetEntity retrievedPet = pets.getOrDefault("Rover", stray);
+
+ // TODO
+ assertThat(retrievedPet, equalTo(stray));
+ System.out.println("\nStep-2 - TC-02 - should_be_able_to_get_a_default_value_if_no_matching_key_is_present() ");
+ }
+
+
+ @Test
+ public void the_map_keys_should_be_the_pet_names() {
+ Map pets = new HashMap<>();
+
+ PetEntity fido = PetEntity.dog().named("Fido");
+ PetEntity felix = PetEntity.cat().named("Felix");
+
+ pets.put("Fido", fido);
+ pets.put("Felix", felix);
+
+ // TODO
+ assertThat(pets.keySet(), containsInAnyOrder("Fido","Felix"));
+ System.out.println("\nStep-3 - TC-03 - the_map_keys_should_be_the_pet_names() ");
+ }
+
+
+ @Test
+ public void the_map_should_store_pets_in_alphabetical_order() {
+ // TODO: Instantiate the correct type of Map
+ NavigableMap pets = new TreeMap<>();
+
+ pets.put("Rover", PetEntity.dog().named("Rover"));
+ pets.put("Felix", PetEntity.cat().named("Felix"));
+ pets.put("Spot", PetEntity.cat().named("Spot"));
+
+ assertThat(pets.keySet(), contains("Felix","Rover","Spot"));
+ System.out.println("\nStep-4 - TC-04 - the_map_should_store_pets_in_alphabetical_order() ");
+ }
+
+
+ @Test
+ public void the_map_should_store_pets_in_the_order_they_where_added() {
+ // TODO: Instantiate the correct type of Map
+ Map pets = new LinkedHashMap<>();
+
+ pets.put("Spot", PetEntity.cat().named("Spot"));
+ pets.put("Rover", PetEntity.dog().named("Rover"));
+ pets.put("Felix", PetEntity.cat().named("Felix"));
+ pets.put("Fido", PetEntity.cat().named("Fido"));
+
+ assertThat(pets.keySet(), contains("Spot", "Rover","Felix", "Fido"));
+ System.out.println("\nStep-5 - TC-05 - the_map_should_store_pets_in_the_order_they_where_added() ");
+ }
+
+
+ @Test
+ public void the_map_should_store_pet_leaders_by_breed() {
+ // TODO: Create an EnumMap to define a pet leader for each breed
+ EnumMap petLeaders = new EnumMap<>(BreedEnum.class);
+
+ petLeaders.put(BreedEnum.Cat, PetEntity.cat().named("Felix"));
+ petLeaders.put(BreedEnum.Dog, PetEntity.dog().named("Lassie"));
+ petLeaders.put(BreedEnum.Rabbit, PetEntity.cat().named("Hazel"));
+
+ assertThat(petLeaders.get(BreedEnum.Dog).getName(), equalTo("Lassie"));
+ System.out.println("\nStep-6 - TC-06 - the_map_should_store_pet_leaders_by_breed() ");
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/serenitylabs/tutorials/vetclinic/collections/exercises/WhenWorkingWithAPetQueueTests.java b/src/test/java/serenitylabs/tutorials/vetclinic/collections/exercises/WhenWorkingWithAPetQueueTests.java
new file mode 100644
index 00000000..e5d5defe
--- /dev/null
+++ b/src/test/java/serenitylabs/tutorials/vetclinic/collections/exercises/WhenWorkingWithAPetQueueTests.java
@@ -0,0 +1,40 @@
+package serenitylabs.tutorials.vetclinic.collections.exercises;
+import java.util.LinkedList;
+import java.util.Queue;
+import org.testng.annotations.Test;
+import serenitylabs.tutorials.vetclinic.katas.PetEntity;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class WhenWorkingWithAPetQueueTests {
+
+ @Test
+ public void should_add_Fido_to_the_end_of_the_queue() {
+ Queue waitingList = new LinkedList<>();
+
+ waitingList.add(PetEntity.cat().named("Felix"));
+ waitingList.add(PetEntity.dog().named("Fido"));
+
+ PetEntity nextInLine = waitingList.poll();
+
+ // TODO
+ assertThat(nextInLine.getName(), equalTo("Felix"));
+ System.out.println("\nStep-1 - TC-01 - Executing - should_add_Fido_to_the_end_of_the_queue()");
+ }
+
+
+ @Test
+ public void should_see_who_is_at_the_top_of_the_queue_without_removing_it() {
+ Queue waitingList = new LinkedList<>();
+
+ waitingList.add(PetEntity.cat().named("Felix"));
+ waitingList.add(PetEntity.dog().named("Fido"));
+
+ PetEntity nextInLine = waitingList.peek();
+
+ // TODO
+ assertThat(nextInLine.getName(), equalTo("Felix"));
+ System.out.println("\nStep-2 - TC-02 - Executing - should_see_who_is_at_the_top_of_the_queue_without_removing_it()");
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/serenitylabs/tutorials/vetclinic/collections/exercises/WhenWorkingWithASetOfPetsTests.java b/src/test/java/serenitylabs/tutorials/vetclinic/collections/exercises/WhenWorkingWithASetOfPetsTests.java
new file mode 100644
index 00000000..6fae5528
--- /dev/null
+++ b/src/test/java/serenitylabs/tutorials/vetclinic/collections/exercises/WhenWorkingWithASetOfPetsTests.java
@@ -0,0 +1,45 @@
+package serenitylabs.tutorials.vetclinic.collections.exercises;
+import java.util.Set;
+import org.testng.annotations.Test;
+import com.google.common.collect.Sets;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+
+public class WhenWorkingWithASetOfPetsTests {
+
+ @Test
+ public void should_add_Fido_to_the_set_of_pets() {
+ Set names = Sets.newHashSet();
+ // TODO
+ names.add("Fido");
+
+ assertThat(names, contains("Fido"));
+ System.out.println("\nStep-1 - TC-01 - Executing should_add_Fido_to_the_set_of_pets()");
+ }
+
+
+ @Test
+ public void a_set_of_pets_should_not_contain_duplicates() {
+ Set names = Sets.newHashSet();
+ names.add("Fido");
+ names.add("Felix");
+ names.add("Fido");
+
+ // TODO
+ assertThat(names, containsInAnyOrder("Fido", "Felix"));
+ System.out.println("\nStep-2 - TC-02 - Executing a_set_of_pets_should_not_contain_duplicates()");
+ }
+
+
+ @Test
+ public void adding_several_pets() {
+ Set names = Sets.newHashSet("Fido", "Felix");
+ names.addAll(Sets.newHashSet("Felix", "Spot"));
+
+ // TODO
+ assertThat(names, containsInAnyOrder("Fido", "Felix", "Spot"));
+ System.out.println("\nStep-3 - TC-03 - Executing adding_several_pets()");
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/serenitylabs/tutorials/vetclinic/collections/exercises/WhenWorkingWithAStackOfPetsTests.java b/src/test/java/serenitylabs/tutorials/vetclinic/collections/exercises/WhenWorkingWithAStackOfPetsTests.java
new file mode 100644
index 00000000..4f8bf8d2
--- /dev/null
+++ b/src/test/java/serenitylabs/tutorials/vetclinic/collections/exercises/WhenWorkingWithAStackOfPetsTests.java
@@ -0,0 +1,44 @@
+package serenitylabs.tutorials.vetclinic.collections.exercises;
+import static org.hamcrest.Matchers.equalTo;
+import java.util.Deque;
+import java.util.LinkedList;
+import org.testng.annotations.Test;
+import serenitylabs.tutorials.vetclinic.katas.PetEntity;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class WhenWorkingWithAStackOfPetsTests {
+
+ @Test
+ public void should_store_pets_in_a_stack() {
+
+ Deque pets = new LinkedList<>();
+
+ pets.push(PetEntity.cat().named("Felix"));
+ pets.push(PetEntity.dog().named("Fido"));
+
+ // TODO: Retrieve the last pet put on the list
+ PetEntity lastPet = pets.pop();
+
+ assertThat(lastPet.getName(), equalTo("Fido"));
+ assertThat(pets.size(), equalTo(1));
+ System.out.println("\nStep-1 - TC-01 - Executing should_store_pets_in_a_stack()");
+ }
+
+
+ @Test
+ public void should_see_the_next_item_in_a_stack() {
+
+ Deque pets = new LinkedList<>();
+
+ pets.push(PetEntity.cat().named("Felix"));
+ pets.push(PetEntity.dog().named("Fido"));
+
+ // TODO: Retrieve the last pet put on the list
+ PetEntity lastPet = pets.peek();
+
+ assertThat(lastPet.getName(), equalTo("Fido"));
+ assertThat(pets.size(), equalTo(2));
+ System.out.println("\nStep-2 - TC-02 - Executing should_see_the_next_item_in_a_stack()");
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/serenitylabs/tutorials/vetclinic/collections/katas/WhenBookingPetsIntoAPetHotelTests.java b/src/test/java/serenitylabs/tutorials/vetclinic/collections/katas/WhenBookingPetsIntoAPetHotelTests.java
new file mode 100644
index 00000000..1cfbe3cf
--- /dev/null
+++ b/src/test/java/serenitylabs/tutorials/vetclinic/collections/katas/WhenBookingPetsIntoAPetHotelTests.java
@@ -0,0 +1,209 @@
+package serenitylabs.tutorials.vetclinic.collections.katas;
+import org.testng.annotations.Test;
+import serenitylabs.tutorials.vetclinic.collections.exercises.BookingResponse;
+import serenitylabs.tutorials.vetclinic.katas.PetEntity;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.CoreMatchers.hasItems;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+
+public class WhenBookingPetsIntoAPetHotelTests {
+
+ @Test
+ public void the_hotel_should_initially_have_no_pets_booked() {
+ // GIVEN
+ PetHotel hotel = new PetHotel();
+ // THEN
+ assertThat(hotel.getPets(), hasSize(0));
+ System.out.println("\nStep-1 - part 1 - Execution completed.");
+ }
+
+
+ @Test
+ public void should_be_able_to_check_a_pet_into_the_hotel() {
+ // GIVEN
+ PetHotel hotel = new PetHotel();
+ PetEntity fido = PetEntity.dog().named("Fido");
+
+ // WHEN
+ hotel.checkIn(fido);
+
+ // THEN
+ assertThat(hotel.getPets(), hasItem(fido));
+ System.out.println("\nStep-2 - part 2 - Execution completed.");
+ }
+
+
+ @Test
+ public void should_be_able_to_check_in_several_pets() {
+ // GIVEN
+ PetHotel hotel = new PetHotel();
+ PetEntity fido = PetEntity.dog().named("Fido");
+ PetEntity felix = PetEntity.cat().named("Felix");
+
+ // WHEN
+ hotel.checkIn(fido);
+ hotel.checkIn(felix);
+
+ // THEN
+ assertThat(hotel.getPets(), hasItems(fido, felix));
+ System.out.println("\nStep-3 - part 3 - Execution completed.");
+ }
+
+
+ @Test
+ public void should_not_be_able_to_check_in_the_same_pet_twice() {
+ // GIVEN
+ PetHotel hotel = new PetHotel();
+ PetEntity fido = PetEntity.dog().named("Fido");
+ PetEntity felix = PetEntity.cat().named("Felix");
+
+ // AND
+ hotel.checkIn(fido);
+ hotel.checkIn(felix);
+
+ // WHEN
+ hotel.checkIn(fido);
+
+ // THEN
+ assertThat(hotel.getPets(),containsInAnyOrder(fido, felix));
+ System.out.println("\nStep-4 - part 4 - Execution completed.");
+ }
+
+
+ @Test
+ public void should_be_able_to_retrieve_checked_in_pets_in_alphabetical_order() {
+ // GIVEN
+ PetHotel hotel = new PetHotel();
+ PetEntity hazel = PetEntity.rabbit().named("Hazel");
+ PetEntity rover = PetEntity.dog().named("Rover");
+ PetEntity felix = PetEntity.cat().named("Felix");
+
+ // WHEN
+ hotel.checkIn(hazel);
+ hotel.checkIn(rover);
+ hotel.checkIn(felix);
+
+ // THEN
+ assertThat(hotel.getPets(),contains(felix, hazel, rover));
+
+ System.out.println("\nStep-5 - part 4 - Execution completed.");
+ }
+
+
+ @Test
+ public void should_be_able_to_obtain_a_booking_confirmation_when_we_check_in_a_pet() {
+ // GIVEN
+ PetHotel hotel = new PetHotel();
+ PetEntity fido = PetEntity.dog().named("Fido");
+
+ // WHEN
+ BookingResponse confirmation = hotel.checkIn(fido);
+
+ // THEN
+ assertThat(confirmation.getNumber(), greaterThan(0));
+ assertThat(confirmation.getPet(), equalTo(fido));
+ assertThat(confirmation.isConfirmed(), equalTo(true));
+ System.out.println("\nStep-6 - part 4 - Execution completed.");
+ }
+
+
+ @Test
+ public void should_not_be_able_to_check_in_pets_beyond_hotel_capacity() {
+ // GIVEN
+ PetHotel hotel = APetHotelEntity.with(PetHotel.MAXIMUM_PETS).petsCheckedIn();
+
+ // WHEN
+ hotel.checkIn(PetEntity.dog().named("Lassie"));
+
+ assertThat(hotel.getPets(), hasSize(20));
+ System.out.println("\nStep-7 - part 4 - Execution completed.");
+ }
+
+
+ /*
+ *
+ * Refactor checkIn method to return a BookingAcknowledgement interface, which
+ * has two methods: isConfirmed() and isOnWaitingList(). You will need to
+ * complete the APetHotel helper class used in the Given.
+ *
+ */
+ @Test
+ public void should_notify_owner_that_the_hotel_is_full() {
+ // GIVEN
+ PetHotel hotel = APetHotelEntity.with(20).petsCheckedIn();
+
+ // WHEN
+ BookingResponse response = hotel.checkIn(PetEntity.dog().named("Lassie"));
+
+ // THEN
+ assertThat(response.isConfirmed(),is(false));
+ assertThat(response.isOnWaitingList(),is(true));
+ System.out.println("\nStep-8 - part 4 - Execution completed.");
+ }
+
+
+ @Test
+ public void should_place_pets_on_a_waiting_list_when_the_hotel_is_full() {
+ // GIVEN
+ PetHotel hotel = APetHotelEntity.with(20).petsCheckedIn();
+ PetEntity lassie = PetEntity.dog().named("Lassie");
+
+ // WHEN
+ hotel.checkIn(lassie);
+
+ // THEN
+ assertThat(hotel.getWaitingList(), hasItem(lassie));
+ System.out.println("\nStep-9 - part 4 - Execution completed.");
+ }
+
+
+ @Test
+ public void pets_on_the_waiting_list_should_be_added_to_the_hotel_when_a_place_is_freed() {
+ // GIVEN
+ PetHotel hotel = APetHotelEntity.with(19).petsCheckedIn();
+ PetEntity fido = PetEntity.dog().named("Fido");
+ PetEntity lassie = PetEntity.dog().named("Lassie");
+
+ hotel.checkIn(fido);
+
+ // WHEN
+ hotel.checkIn(lassie);
+ // AND
+ hotel.checkOut(fido);
+
+ // THEN
+ assertThat(hotel.getPets(), hasItem(lassie));
+ System.out.println("\nStep-10 - part 4 - Execution completed.");
+ }
+
+
+ @Test
+ public void pets_on_the_waiting_list_should_be_admitted_on_a_first_come_first_served_basis() {
+ // GIVEN
+ PetHotel hotel = APetHotelEntity.with(19).petsCheckedIn();
+ PetEntity felix = PetEntity.cat().named("Felix");
+
+ PetEntity fido = PetEntity.dog().named("Fido");
+ PetEntity lassie = PetEntity.dog().named("Lassie");
+ hotel.checkIn(felix);
+
+ // WHEN
+ hotel.checkIn(fido);
+ hotel.checkIn(lassie);
+ // AND
+ hotel.checkOut(felix);
+
+ // THEN
+ assertThat(hotel.getPets(), hasItem(fido));
+ assertThat(hotel.getPets(), not(hasItem(lassie)));
+ System.out.println("\nStep-11 - part 4 - Execution completed.");
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/serenitylabs/tutorials/vetclinic/domain/NewDogCreationTests.java b/src/test/java/serenitylabs/tutorials/vetclinic/domain/NewDogCreationTests.java
new file mode 100644
index 00000000..013ea6d7
--- /dev/null
+++ b/src/test/java/serenitylabs/tutorials/vetclinic/domain/NewDogCreationTests.java
@@ -0,0 +1,287 @@
+package serenitylabs.tutorials.vetclinic.domain;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.endsWith;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.startsWith;
+import static org.hamcrest.Matchers.contains;
+import static org.junit.Assert.assertThat;
+import java.time.LocalDate;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * Limitations of Default constructor and over come through Builder pattern.
+ *
+ */
+
+public class NewDogCreationTests {
+
+ private static final LocalDate THE_FOURTH_OF_JULY=LocalDate.of(2024,07,04);
+
+
+ /*
+ * This TestNg test is representing test validation with builder pattern
+ * implementation.
+ *
+ * see : Exercises-1
+ * Step 1 - Creating a Dog with a name.
+ * Step 2 - Adding a date of birth.
+ * Step 3 - Adding a breed.
+ *
+ */
+ @Test
+ public void a_new_dog_should_have_a_name()
+ {
+ DogEntityImmutableType dogObj=DogEntityImmutableType.getImmutableInstance()
+ .called("Fido")
+ .ofBreed("Labrador")
+ .bornOn(THE_FOURTH_OF_JULY);
+
+ Assert.assertEquals("Fido",dogObj.getDogName());
+ Assert.assertEquals("Labrador",dogObj.getDogBreed());
+ Assert.assertEquals(THE_FOURTH_OF_JULY,dogObj.getBirthDate());
+ System.out.println("\nThis is 4th Test methode.");
+ }
+
+
+
+ /*
+ * This TestNg test is representing test validation for colour should be a
+ * mandatory field, and optional fields for Favourite Food with builder pattern
+ * implementation.
+ *
+ * see : Exercises-2 Step 5
+ *
+ */
+ @Test
+ public void a_dog_can_have_an_optional_favourite_food() {
+ DogEntity dogObj = DogEntity.called("Fido") // mandatory
+ .ofDogBreed("Labrador") // mandatory
+ .ofDogColour("black") //ofColour is mandatory.
+ .setOptFldFavouriteFood("Pizza") //setOptFldFavouriteFood is optional
+ .dgEntityBornOn(THE_FOURTH_OF_JULY); // mandatory
+
+ Assert.assertEquals("Fido", dogObj.getDogName());
+ Assert.assertEquals("Labrador", dogObj.getDogBreed());
+ Assert.assertEquals("black", dogObj.getFavouriteColour());
+ Assert.assertEquals("Pizza", dogObj.getOptFldFavouriteFood());
+ Assert.assertEquals(THE_FOURTH_OF_JULY, dogObj.getBirthDateTime());
+ System.out.println("\nThis is 6th Test methode.");
+ }
+
+
+
+ /*
+ * This TestNg test is representing test validation for colour should be a
+ * mandatory field, and optional fields for Favourite Toy with builder pattern
+ * implementation.
+ *
+ * see : Exercises-2 Step 5
+ *
+ */
+ @Test
+ public void a_dog_can_have_an_optional_favourite_toy() {
+ DogEntity dogObj=DogEntity.called("Fido") // mandatory
+ .ofDogBreed("Labrador") // mandatory
+ .ofDogColour("black") //ofColour is mandatory.
+ .setOptFldFavouriteToy("PingPong") // setOptFldFavouriteToy optional
+ .dgEntityBornOn(THE_FOURTH_OF_JULY); // mandatory
+
+ Assert.assertEquals("Fido", dogObj.getDogName());
+ Assert.assertEquals("Labrador", dogObj.getDogBreed());
+ Assert.assertEquals("black", dogObj.getFavouriteColour());
+ Assert.assertEquals("PingPong", dogObj.getOptFldFavouriteToy());
+ Assert.assertEquals(THE_FOURTH_OF_JULY, dogObj.getBirthDateTime());
+ System.out.println("\nThis is 7th Test methode.");
+ }
+
+
+
+ /*
+ * This TestNg test is implementation for external entity builder class w.r.t
+ * builder prototype method for aLargeDog
+ *
+ * see : Exercises-3
+ *
+ */
+ @Test
+ public void a_aLargeDog_can_have_an_optional_favourite_toy() {
+ DogEntityImmutableType dogObj=DogEntityImmutableType.aLargeDog()
+ .called("Fido") // mandatory
+ .ofColour("black") //ofColour is mandatory.
+ .setOptFldFavouriteToy("PingPong") // setOptFldFavouriteToy optional
+ .bornOn(THE_FOURTH_OF_JULY); // mandatory
+
+ Assert.assertEquals("Fido", dogObj.getDogName());
+ Assert.assertEquals("Labrador", dogObj.getDogBreed());
+ Assert.assertEquals("black", dogObj.getFavouriteColor());
+ Assert.assertEquals("PingPong", dogObj.getOptFldFavouriteToy());
+ Assert.assertEquals(THE_FOURTH_OF_JULY, dogObj.getBirthDate());
+ System.out.println("\nThis is 8th Test methode with prototype method aLargeDog().");
+ }
+
+
+ /*
+ * This TestNg test is implementation for external entity builder class w.r.t
+ * builder prototype method for aSmallDog
+ *
+ * see : Exercises-3
+ *
+ */
+ @Test
+ public void a_aSmallDog_can_have_an_optional_favourite_food() {
+ DogEntityImmutableType dogObj = DogEntityImmutableType.aSmallDog()
+ .called("Spot") // mandatory
+ .ofColour("white") // ofColour is mandatory.
+ .setOptFldFavouriteFood("Pizza") // setOptFldFavouriteFood is optional
+ .bornOn(THE_FOURTH_OF_JULY); // mandatory
+
+ Assert.assertEquals("Spot", dogObj.getDogName());
+ Assert.assertEquals("Lasa", dogObj.getDogBreed());
+ Assert.assertEquals("white", dogObj.getFavouriteColor());
+ Assert.assertEquals("Pizza", dogObj.getOptFldFavouriteFood());
+ Assert.assertEquals(THE_FOURTH_OF_JULY, dogObj.getBirthDate());
+ System.out.println("\nThis is 9th Test methode with prototype method aSmallDog().");
+ }
+
+
+
+ /*
+ * This TestNg test is implementation for external entity builder class w.r.t
+ * builder prototype method for aGuardDog
+ *
+ * see : Exercises-3
+ *
+ */
+ @Test
+ public void a_aGuardDog_can_have_an_optional_favourite_food() {
+ DogEntityImmutableType dogObj = DogEntityImmutableType.aGuardDog()
+ .called("Jimmy") // mandatory
+ .ofColour("browny-blackish") // ofColour is mandatory.
+ .setOptFldFavouriteFood("hot dog") // setOptFldFavouriteFood is optional
+ .bornOn(THE_FOURTH_OF_JULY); // mandatory
+
+ Assert.assertEquals("Jimmy", dogObj.getDogName());
+ Assert.assertEquals("German Shepherd", dogObj.getDogBreed());
+ Assert.assertEquals("browny-blackish", dogObj.getFavouriteColor());
+ Assert.assertEquals("hot dog", dogObj.getOptFldFavouriteFood());
+ Assert.assertEquals(THE_FOURTH_OF_JULY, dogObj.getBirthDate());
+ System.out.println("\nThis is 10th Test methode with prototype method aGuardDog().");
+ }
+
+
+
+ /*
+ * This TestNg test is representing test validation for mandatory & optional
+ * field/data member implementation with builder pattern implementation.
+ *
+ * see : Exercises-2 Step 4 - Colour is an optional field.Use an interface
+ * called WithIBreedable to allow the builder to cater for the mandatory fields
+ * (name, breed and date of birth) and the optional one (colour).
+ *
+ * This will be deleted once Exercises-2 'Step 5' will be implemented.
+ *
+ */
+ @Test
+ public void a_dog_can_have_an_optional_colour() {
+ DogEntity dogObj = DogEntity.called("Fido") // mandatory
+ .ofDogBreed("Labrador") // mandatory
+ .ofDogColour("black") //ofColour is optional.
+ .dgEntityBornOn(THE_FOURTH_OF_JULY); // mandatory
+
+ Assert.assertEquals("Fido", dogObj.getDogName());
+ Assert.assertEquals("Labrador", dogObj.getDogBreed());
+ Assert.assertEquals("black", dogObj.getFavouriteColour());
+ System.out.println("\nThis is 5th Test methode.");
+ }
+
+
+ /*
+ * This TestNg test is representing test validation for 'Vet Clinic Tutorial 2 -
+ * Hamcrest Matchers' modules Exercise - 'Step 4 - Hamcrest collection matchers'
+ * implementation
+ *
+ */
+ @Test
+ public void a_dog_can_have_several_colours() {
+ System.out.println("\nThis is 'Step 4 - Hamcrest collection matchers' Test methode-12th implementation");
+ DogEntityImmutableType dogObj=DogEntityImmutableType.getImmutableInstance()
+ .called("Fido")
+ .ofBreed("labrador")
+ .andOfColour("Red","black","green","blue");//ofColour is mandatory.
+
+ assertThat(dogObj.getStrListOfColours(),contains("Red","black","green","blue"));
+ assertThat(dogObj.getStrListOfColours(),hasItem("green"));
+ assertThat(dogObj.getStrListOfColours(),not(hasItem("yellow")));
+ }
+
+
+ /*
+ * This TestNg test is representing test validation for 'Vet Clinic Tutorial 2 -
+ * Hamcrest Matchers' modules Exercise - 'Step 3 - Hamcrest String matchers'
+ * implementation
+ *
+ */
+ @Test
+ public void a_new_dog_should_be_printed_in_a_readable_form() {
+ System.out.println("\nThis is 'Step 3 - Hamcrest String matchers' Test methode-11th implementation");
+ DogEntityImmutableType dogObj=DogEntityImmutableType.getImmutableInstance()
+ .called("Fido")
+ .ofBreed("labrador")
+ .ofColour("black");//ofColour is mandatory.
+
+ assertThat(dogObj.toString(),is(equalTo("Fido the black labrador")));
+ assertThat(dogObj.toString(),startsWith("Fido"));
+ assertThat(dogObj.toString(),endsWith("labrador"));
+ assertThat(dogObj.toString(),containsString("black"));
+ }
+
+
+
+ @Test
+ public void isNameOfDogExits()
+ {
+ DogEntity dogObj=new DogEntity();
+ dogObj.setDogName("Touchi");
+ dogObj.setDogBreed("Lasa");
+ LocalDate locDateTimeObj=LocalDate.now();
+ dogObj.setBirthDateTime(locDateTimeObj);
+
+ Assert.assertEquals("Touchi",dogObj.getDogName());
+ Assert.assertEquals("Lasa",dogObj.getDogBreed());
+ Assert.assertEquals(locDateTimeObj,dogObj.getBirthDateTime());
+ System.out.println("\nThis is 1st Test methode.");
+ }
+
+
+ @Test
+ public void isDogsArrtibuteExits()
+ {
+ LocalDate locDateTimeObj=LocalDate.now();
+ DogEntityImmutableType dogObj=new DogEntityImmutableType("Touchi","Lasa",locDateTimeObj);
+
+ Assert.assertEquals("Touchi",dogObj.getDogName());
+ Assert.assertEquals("Lasa",dogObj.getDogBreed());
+ Assert.assertEquals(locDateTimeObj,dogObj.getBirthDate());
+ System.out.println("\nThis is 2nd Test methode.");
+ }
+
+
+ @Test
+ public void isOptionalFavouriteFoodFieldExists()
+ {
+ LocalDate locDateTimeObj=LocalDate.now();
+ DogEntityImmutableType dogObj=new DogEntityImmutableType("Touchi","Lasa",locDateTimeObj,"Rasgulla",null,null);
+
+ Assert.assertEquals("Touchi",dogObj.getDogName());
+ Assert.assertEquals("Rasgulla",dogObj.getFavouriteColor());
+ System.out.println("\nThis is 3rd Test methode.");
+ }
+
+
+
+
+}
\ No newline at end of file
diff --git a/src/test/java/serenitylabs/tutorials/vetclinic/domain/WhenCalculatingTotalPricesTests.java b/src/test/java/serenitylabs/tutorials/vetclinic/domain/WhenCalculatingTotalPricesTests.java
new file mode 100644
index 00000000..4d8a3226
--- /dev/null
+++ b/src/test/java/serenitylabs/tutorials/vetclinic/domain/WhenCalculatingTotalPricesTests.java
@@ -0,0 +1,30 @@
+package serenitylabs.tutorials.vetclinic.domain;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.junit.Assert.assertThat;
+import org.testng.annotations.Test;
+
+public class WhenCalculatingTotalPricesTests {
+
+ /*
+ * This TestNg test is representing test validation for 'Vet Clinic Tutorial 2 -
+ * Hamcrest Matchers' modules Exercise - 'Step 1 - Replace JUnit asserts with
+ * Hamcrest asserts' and 'Step 2 - Hamcrest comparison assertions'
+ * implementation
+ *
+ */
+ @Test
+ public void total_consultation_price_should_include_20_percent_tax() {
+ System.out.println("\nThis is 'Step 1 & Step 2 - simple Hamcrest asserts' Test methode-13th implementation");
+ // Arrange - GIVEN
+ int netPrice = 250;
+
+ // Act - WHEN
+ int totalPrice = TotalConsultationPrice.includingTax().forANetPriceOf(netPrice);
+ System.out.println("\nCalculated Total Net price : " + totalPrice);
+
+ // Assert - THEN
+ assertThat(totalPrice,greaterThan(150));
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/test/java/serenitylabs/tutorials/vetclinic/domain/WhenWeBookAnAppointmentTests.java b/src/test/java/serenitylabs/tutorials/vetclinic/domain/WhenWeBookAnAppointmentTests.java
new file mode 100644
index 00000000..ca755cd6
--- /dev/null
+++ b/src/test/java/serenitylabs/tutorials/vetclinic/domain/WhenWeBookAnAppointmentTests.java
@@ -0,0 +1,50 @@
+package serenitylabs.tutorials.vetclinic.domain;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import java.time.LocalDateTime;
+import org.testng.annotations.Test;
+
+public class WhenWeBookAnAppointmentTests {
+
+ private static final LocalDateTime TODAY_AT_2_PM = LocalDateTime.now().withHour(2).withMinute(0);
+
+ /*
+ * This TestNg test is representing test validation for 'Vet Clinic Tutorial 2 -
+ * Hamcrest Matchers' modules Exercise - 'Step 5 - Updating the
+ * WhenWeBookAnAppointmentTests test' implementation
+ *
+ */
+ @Test
+ public void an_appointment_has_a_patient_name_an_owner_and_a_date() {
+ AppointmentEntity appointObj = AppointmentEntity.forPetCalled("Fido")
+ .ownedBy("Fred")
+ .at(TODAY_AT_2_PM);
+
+ assertThat(appointObj.getPetName(),is(equalTo("Fido")));
+ assertThat(appointObj.getOwner(),is(equalTo("Fred")));
+ assertThat(appointObj.getAppointmentTime(),is(equalTo(TODAY_AT_2_PM)));
+ System.out.println("Execution of - 'Step 5 - Updating the WhenWeBookAnAppointment tests' completed.");
+ }
+
+
+ /*
+ * This TestNg test is representing test validation for 'Vet Clinic Tutorial 2 -
+ * Hamcrest Matchers' modules Exercise - 'Step 6 - comparing appointments'
+ * implementation
+ *
+ */
+ @Test
+ public void an_appointment_can_have_an_optional_reason() {
+ AppointmentEntity appointObj = AppointmentEntity.forPetCalled("Fido")
+ .ownedBy("Fred")
+ .because("He is sick")
+ .at(TODAY_AT_2_PM);
+
+ assertThat(appointObj.getReason().isPresent(),is(true));
+ assertThat(appointObj.getReason().get(),is(equalTo("He is sick")));
+ System.out.println("Execution of - 'Step 6 - comparing appointments' tests completed.");
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/test/java/serenitylabs/tutorials/vetclinic/enumerations/exercises/WhenCreatingAComplexEnumTests.java b/src/test/java/serenitylabs/tutorials/vetclinic/enumerations/exercises/WhenCreatingAComplexEnumTests.java
new file mode 100644
index 00000000..7a1b818e
--- /dev/null
+++ b/src/test/java/serenitylabs/tutorials/vetclinic/enumerations/exercises/WhenCreatingAComplexEnumTests.java
@@ -0,0 +1,26 @@
+package serenitylabs.tutorials.vetclinic.enumerations.exercises;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import org.testng.annotations.Test;
+
+public class WhenCreatingAComplexEnumTests {
+
+ /**
+ * Add the scientific name to the animal breeds.
+ * Cat = "Felis catus"
+ * Dog = "Canis lupus familiaris"
+ * Rabbit = "Oryctolagus cuniculus"
+ * Fish = "Carassius auratus"
+ * Parrot = "Psittaciformes"
+ */
+ @Test
+ public void should_be_able_to_find_the_scientific_names_of_an_animal_breed() {
+
+ // TODO: Refactor the Breed enum so that it also stores the scientific name (see comment above).
+ assertThat(BreedEnum.Cat.getScientificName(), equalTo("Felis catus"));
+ assertThat(BreedEnum.Dog.getScientificName(), equalTo("Canis lupus familiaris"));
+ assertThat(BreedEnum.Rabbit.getScientificName(), equalTo("Oryctolagus cuniculus"));
+ System.out.println("\nThis is - TC-01 - should_be_able_to_find_the_scientific_names_of_an_animal_breed");
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/serenitylabs/tutorials/vetclinic/enumerations/exercises/WhenCreatingASimpleEnumTests.java b/src/test/java/serenitylabs/tutorials/vetclinic/enumerations/exercises/WhenCreatingASimpleEnumTests.java
new file mode 100644
index 00000000..709bcbec
--- /dev/null
+++ b/src/test/java/serenitylabs/tutorials/vetclinic/enumerations/exercises/WhenCreatingASimpleEnumTests.java
@@ -0,0 +1,34 @@
+package serenitylabs.tutorials.vetclinic.enumerations.exercises;
+import org.testng.annotations.Test;
+import serenitylabs.tutorials.vetclinic.katas.PetEntity;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+
+public class WhenCreatingASimpleEnumTests {
+
+ @Test
+ public void the_gender_of_a_pet_should_be_considered_unknown_by_default() {
+
+ // TODO: Add a gender field to the Pet class that takes two possible values:
+ // Male, Female and Unknown
+
+ PetEntity unidentifiedTabby = PetEntity.cat().named("Spot");
+
+ assertThat(unidentifiedTabby.getGender(), equalTo(GenderEnum.Unknown));
+ System.out.println("\nThis is - TC-01 - the_gender_of_a_pet_should_be_considered_unknown_by_default");
+ }
+
+
+ @Test
+ public void the_gender_of_a_pet_can_be_provided() {
+
+ // TODO: Refactor the Pet builder method to allow the following construct:
+
+ PetEntity lassie = PetEntity.cat().ofGender(GenderEnum.Male).named("Lassie");
+
+ assertThat(lassie.getGender(), equalTo(GenderEnum.Male));
+ System.out.println("\nThis is - TC-02 - the_gender_of_a_pet_can_be_provided");
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/test/java/serenitylabs/tutorials/vetclinic/enumerations/exercises/WhenWorkingWithASimpleEnumerationTests.java b/src/test/java/serenitylabs/tutorials/vetclinic/enumerations/exercises/WhenWorkingWithASimpleEnumerationTests.java
new file mode 100644
index 00000000..8ccd109c
--- /dev/null
+++ b/src/test/java/serenitylabs/tutorials/vetclinic/enumerations/exercises/WhenWorkingWithASimpleEnumerationTests.java
@@ -0,0 +1,44 @@
+package serenitylabs.tutorials.vetclinic.enumerations.exercises;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+import org.testng.annotations.Test;
+import com.google.common.collect.ImmutableList;
+import serenitylabs.tutorials.vetclinic.katas.PetEntity;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.contains;
+
+public class WhenWorkingWithASimpleEnumerationTests {
+
+ @Test
+ public void finding_dogs()
+ {
+ List pets = ImmutableList.of(PetEntity.cat().named("Felix"),
+ PetEntity.dog().named("Rover"),
+ PetEntity.dog().named("Lassie"),
+ PetEntity.rabbit().named("Fiver"));
+
+ // TODO: Extract all the dogs from the pets list
+
+ List dogs = pets.stream()
+ .filter(pet -> pet.getBreed() == BreedEnum.Dog)
+ .collect(Collectors.toList());
+
+ assertThat(dogs,containsInAnyOrder(PetEntity.dog().named("Rover"), PetEntity.dog().named("Lassie")));
+ System.out.println("\nThis is TC-01 - finding_dogs ");
+ }
+
+
+ @Test
+ public void list_all_known_breeds()
+ {
+ // TODO: List the names of all the known breeds
+ List breeds = Arrays.asList(BreedEnum.values()).stream().map(BreedEnum::toString)
+ .collect(Collectors.toList());
+
+ assertThat(breeds, contains("Cat", "Dog", "Rabbit", "Fish", "Parrot"));
+ System.out.println("\nThis is TC-02 - list_all_known_breeds ");
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/serenitylabs/tutorials/vetclinic/enumerations/katas/WhenCalculatingWithColoursTests.java b/src/test/java/serenitylabs/tutorials/vetclinic/enumerations/katas/WhenCalculatingWithColoursTests.java
new file mode 100644
index 00000000..350aa45b
--- /dev/null
+++ b/src/test/java/serenitylabs/tutorials/vetclinic/enumerations/katas/WhenCalculatingWithColoursTests.java
@@ -0,0 +1,121 @@
+package serenitylabs.tutorials.vetclinic.enumerations.katas;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.contains;
+import static org.junit.Assert.assertThat;
+import static com.google.common.collect.Lists.newArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+import org.junit.runner.RunWith;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+import com.google.common.collect.ImmutableList;
+import junitparams.JUnitParamsRunner;
+import serenitylabs.tutorials.vetclinic.enumerations.colours.ColourEnum;
+
+/*
+ * This Test class contains and runs test cases based on both TestNg and Junit Tests
+ *
+ */
+@RunWith(JUnitParamsRunner.class)
+public class WhenCalculatingWithColoursTests {
+
+ @Test
+ public void should_know_about_all_the_main_colours() {
+ List colours = newArrayList(ColourEnum.values()).stream()
+ .map(ColourEnum::toString)
+ .collect(Collectors.toList());
+ assertThat(colours, contains("Red", "Orange", "Yellow", "Green", "Blue", "Violet", "Black", "White"));
+ System.out.println("\nTC-01 Executed - should_know_about_all_the_main_colours");
+ }
+
+
+ @Test
+ public void should_identify_primary_colours() {
+ List expectedPrimaries = ImmutableList.of(ColourEnum.Red, ColourEnum.Yellow, ColourEnum.Blue);
+
+ expectedPrimaries.forEach(
+ colour -> {
+ assertThat(colour.isPrimary(), is(true));
+ }
+ );
+ System.out.println("\nTC-02 Executed - should_identify_primary_colours");
+ }
+
+
+ @Test
+ public void should_identify_non_primary_colours() {
+ List expectedPrimaries = ImmutableList.of(ColourEnum.Green, ColourEnum.Orange, ColourEnum.Violet);
+
+ expectedPrimaries.forEach(
+ colour -> {
+ assertThat(colour.isPrimary(), is(false));
+ }
+ );
+ System.out.println("\nTC-03 Executed - should_identify_non_primary_colours");
+ }
+
+
+ @Test
+ public void black_and_white_are_not_considered_primary() {
+
+ assertThat(ColourEnum.Black.isPrimary(), is(false));
+ assertThat(ColourEnum.White.isPrimary(), is(false));
+ System.out.println("\nTC-04 Executed - black_and_white_are_not_considered_primary");
+ }
+
+
+ @Test
+ public void red_is_the_opposite_of_green() {
+ assertThat(ColourEnum.Red.opposite(), is(ColourEnum.Green));
+ System.out.println("\nTC-05 Executed - red_is_the_opposite_of_green");
+ }
+
+
+ @Test
+ public void blue_is_the_opposite_of_orange() {
+ assertThat(ColourEnum.Blue.opposite(), is(ColourEnum.Orange));
+ System.out.println("\nTC-06 Executed - blue_is_the_opposite_of_orange");
+ }
+
+
+ @Test
+ public void yellow_is_the_opposite_of_violet() {
+ assertThat(ColourEnum.Yellow.opposite(), is(ColourEnum.Violet));
+ System.out.println("\nTC-07 Executed - yellow_is_the_opposite_of_violet");
+ }
+
+
+ @Test
+ public void black_is_the_opposite_of_white() {
+ assertThat(ColourEnum.Black.opposite(), is(ColourEnum.White));
+ System.out.println("\nTC-08 Executed - black_is_the_opposite_of_white");
+ }
+
+
+ /*
+ * This is junits parameterized test
+ */
+ @Parameters({"Red,Green",
+ "Blue,Orange",
+ "Violet,Yellow",
+ "Black,White"})
+ @org.junit.Test
+ public void should_identify_opposite_colours(ColourEnum colour, ColourEnum expectedOpposite) throws Exception {
+ assertThat(colour.opposite(),is(expectedOpposite));
+ System.out.println("\nTC-09 Executed - should_identify_opposite_colours");
+ }
+
+
+ @Test
+ public void opposite_colours_are_symmetric() {
+ newArrayList(ColourEnum.values()).stream()
+ .forEach(
+ colour -> {
+ assertThat(colour.opposite().opposite(),is(colour));
+ }
+ );
+ System.out.println("\nTC-10 Executed - opposite_colours_are_symmetric");
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/test/java/serenitylabs/tutorials/vetclinic/playingball/WhenPlayingBallTests.java b/src/test/java/serenitylabs/tutorials/vetclinic/playingball/WhenPlayingBallTests.java
new file mode 100644
index 00000000..44ab651c
--- /dev/null
+++ b/src/test/java/serenitylabs/tutorials/vetclinic/playingball/WhenPlayingBallTests.java
@@ -0,0 +1,65 @@
+package serenitylabs.tutorials.vetclinic.playingball;
+import static java.time.Month.AUGUST;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+import java.time.LocalDate;
+import org.testng.annotations.Test;
+import serenitylabs.tutorials.vetclinic.playingball.model.ChildEntity;
+import serenitylabs.tutorials.vetclinic.playingball.model.GameEnum;
+import serenitylabs.tutorials.vetclinic.playingball.model.SportsSchedule;
+
+public class WhenPlayingBallTests {
+
+ static final LocalDate A_SATURDAY = LocalDate.of(2016, AUGUST, 27);
+ static final LocalDate A_SUNDAY = LocalDate.of(2016, AUGUST, 28);
+ static final LocalDate A_MONDAY = LocalDate.of(2016, AUGUST, 29);
+
+ @Test
+ public void should_play_football_on_sundays() {
+
+ SportsSchedule sportsSchedule = new SportsSchedule();
+ ChildEntity bill = new ChildEntity(sportsSchedule);
+
+ GameEnum gamePlayed = bill.goPlayBallOn(A_SUNDAY);
+
+ assertThat(gamePlayed, equalTo(GameEnum.Football));
+ System.out.println("\nTC-01 - Executing - should_play_football_on_sundays()");
+ }
+
+
+ @Test
+ public void should_play_football_on_saturdays() {
+ SportsSchedule sportsSchedule = new SportsSchedule();
+ ChildEntity bill = new ChildEntity(sportsSchedule);
+
+ GameEnum gamePlayed = bill.goPlayBallOn(A_SATURDAY);
+
+ assertThat(gamePlayed, equalTo(GameEnum.Football));
+ System.out.println("\nTC-02 - Executing - should_play_football_on_saturdays()");
+ }
+
+
+ @Test
+ public void should_play_handball_on_weekdays() {
+ SportsSchedule sportsSchedule = new SportsSchedule();
+ ChildEntity bill = new ChildEntity(sportsSchedule);
+
+ GameEnum gamePlayed = bill.goPlayBallOn(A_MONDAY);
+
+ assertThat(gamePlayed, equalTo(GameEnum.Handball));
+ System.out.println("\nTC-03 - Executing - should_play_handball_on_weekdays()");
+ }
+
+
+ @Test
+ public void should_play_tennis_on_wednesdays() {
+ SportsSchedule sportsSchedule = new SportsSchedule();
+ ChildEntity bill = new ChildEntity(sportsSchedule);
+
+ GameEnum gamePlayed = bill.goPlayBallOn(A_MONDAY);
+
+ assertThat(gamePlayed, equalTo(GameEnum.Handball));
+ System.out.println("\nTC-04 - Executing - should_play_tennis_on_wednesdays()");
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/serenitylabs/tutorials/vetclinic/playingball/WhenSchedulingRecreationalSportTests.java b/src/test/java/serenitylabs/tutorials/vetclinic/playingball/WhenSchedulingRecreationalSportTests.java
new file mode 100644
index 00000000..9321913d
--- /dev/null
+++ b/src/test/java/serenitylabs/tutorials/vetclinic/playingball/WhenSchedulingRecreationalSportTests.java
@@ -0,0 +1,46 @@
+package serenitylabs.tutorials.vetclinic.playingball;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static serenitylabs.tutorials.vetclinic.playingball.model.SampleDates.A_FRIDAY;
+import static serenitylabs.tutorials.vetclinic.playingball.model.SampleDates.A_MONDAY;
+import static serenitylabs.tutorials.vetclinic.playingball.model.SampleDates.A_SATURDAY;
+import static serenitylabs.tutorials.vetclinic.playingball.model.SampleDates.A_SUNDAY;
+import static serenitylabs.tutorials.vetclinic.playingball.model.SampleDates.A_THURSDAY;
+import static serenitylabs.tutorials.vetclinic.playingball.model.SampleDates.A_TUESDAY;
+import static serenitylabs.tutorials.vetclinic.playingball.model.SampleDates.A_WEDNESDAY;
+import java.time.LocalDate;
+import java.util.List;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+import com.google.common.collect.Lists;
+import serenitylabs.tutorials.vetclinic.playingball.model.GameEnum;
+import serenitylabs.tutorials.vetclinic.playingball.model.IGameSchedule;
+import serenitylabs.tutorials.vetclinic.playingball.model.RecreationalSportsSchedule;
+
+public class WhenSchedulingRecreationalSportTests {
+
+ IGameSchedule scheduler;
+ static final List WEEKEND_DAYS = Lists.newArrayList(A_SATURDAY, A_SUNDAY);
+ static final List WEEK_DAYS = Lists.newArrayList(A_MONDAY, A_TUESDAY, A_WEDNESDAY, A_THURSDAY, A_FRIDAY);
+
+ @BeforeTest
+ public void setup() {
+ scheduler = new RecreationalSportsSchedule();
+ System.out.println("\nExecuting TC-01 - setup()");
+ }
+
+
+ @Test
+ public void should_play_football_on_the_weekends() {
+ WEEKEND_DAYS.forEach(day -> assertThat(scheduler.forGameOn(day).letEnumToPlay(), equalTo(GameEnum.Football)));
+ System.out.println("\nExecuting TC-02 - should_play_football_on_the_weekends() ");
+ }
+
+
+ @Test
+ public void should_play_handball_during_the_week() {
+ WEEK_DAYS.forEach(day -> assertThat(scheduler.forGameOn(day).letEnumToPlay(), equalTo(GameEnum.Handball)));
+ System.out.println("\nExecuting TC-03 - should_play_handball_during_the_week() ");
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/serenitylabs/tutorials/vetclinic/playingball/WhenSchedulingSchoolSportTests.java b/src/test/java/serenitylabs/tutorials/vetclinic/playingball/WhenSchedulingSchoolSportTests.java
new file mode 100644
index 00000000..f17b145c
--- /dev/null
+++ b/src/test/java/serenitylabs/tutorials/vetclinic/playingball/WhenSchedulingSchoolSportTests.java
@@ -0,0 +1,55 @@
+package serenitylabs.tutorials.vetclinic.playingball;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static serenitylabs.tutorials.vetclinic.playingball.model.SampleDates.A_DATE_IN_AUGUST;
+import static serenitylabs.tutorials.vetclinic.playingball.model.SampleDates.A_DATE_IN_JANUARY;
+import static serenitylabs.tutorials.vetclinic.playingball.model.SampleDates.A_DATE_IN_JULY;
+import static serenitylabs.tutorials.vetclinic.playingball.model.SampleDates.A_DATE_IN_JUNE;
+import static serenitylabs.tutorials.vetclinic.playingball.model.SampleDates.A_DATE_IN_MAY;
+import static serenitylabs.tutorials.vetclinic.playingball.model.SampleDates.A_DATE_IN_NOVEMBER;
+import static serenitylabs.tutorials.vetclinic.playingball.model.SampleDates.A_DATE_IN_OCTOBER;
+import static serenitylabs.tutorials.vetclinic.playingball.model.SampleDates.A_DATE_IN_SEPTEMBER;
+import java.time.LocalDate;
+import java.util.Arrays;
+import java.util.Collection;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import serenitylabs.tutorials.vetclinic.playingball.model.GameEnum;
+import serenitylabs.tutorials.vetclinic.playingball.model.IGameSchedule;
+import serenitylabs.tutorials.vetclinic.playingball.model.SchoolSportsSchedule;
+
+@RunWith(Parameterized.class)
+public class WhenSchedulingSchoolSportTests {
+
+ private final LocalDate someDate;
+ private final GameEnum expectedGame;
+
+ @Parameterized.Parameters
+ public static Collection