From 0ed18255c937d2b89c456b3ac406d8ac3edb5328 Mon Sep 17 00:00:00 2001 From: globox97 Date: Mon, 11 Mar 2024 13:06:18 +0100 Subject: [PATCH 1/6] Feature View Pets Catalogue --- .../resources/features/ViewCatalogue.feature | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/test/resources/features/ViewCatalogue.feature diff --git a/src/test/resources/features/ViewCatalogue.feature b/src/test/resources/features/ViewCatalogue.feature new file mode 100644 index 00000000..a890396c --- /dev/null +++ b/src/test/resources/features/ViewCatalogue.feature @@ -0,0 +1,18 @@ +# Created by globox97 at 11/03/2024 +Feature: View Pets Catalogue + In order to make an adoption + As a User + I want to view the pet catalogue + + Background: + Given there is a registered user with username "user" and password "password" and email "user@user.com" + + Scenario: View Pets Catalogue + Given I can login with username "user" and password "password" + And The response code is 200 + + Scenario: View Pets Catalogue without being logged in + Given I'm not logged in + Scenario: View Pets Catalogue from a specific Shelter + Given + Scenario: View Pets Catalogue from a specific \ No newline at end of file From ccba0494a51c6b5f6e3cd63d4bed29f87fa1073f Mon Sep 17 00:00:00 2001 From: globox97 Date: Mon, 11 Mar 2024 20:04:10 +0100 Subject: [PATCH 2/6] Feature View Pets Catalogue --- .../resources/features/ViewCatalogue.feature | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/test/resources/features/ViewCatalogue.feature b/src/test/resources/features/ViewCatalogue.feature index a890396c..8a46808b 100644 --- a/src/test/resources/features/ViewCatalogue.feature +++ b/src/test/resources/features/ViewCatalogue.feature @@ -1,18 +1,24 @@ # Created by globox97 at 11/03/2024 Feature: View Pets Catalogue - In order to make an adoption + In order to view the Pets Catalogue As a User I want to view the pet catalogue Background: - Given there is a registered user with username "user" and password "password" and email "user@user.com" + Given there is a registered client with username "client" and password "password" and email "user@domain.com" + Given there is a registered volunteer with username "volunteer" and password "password" and email "volunteer@domain.com" + Given there are pets in a shelter - Scenario: View Pets Catalogue - Given I can login with username "user" and password "password" - And The response code is 200 + + Scenario: View Pets Catalogue as a Client + Given I login as "client" with password "password" + When I + Then The response code is 200 Scenario: View Pets Catalogue without being logged in Given I'm not logged in - Scenario: View Pets Catalogue from a specific Shelter - Given + + Scenario: View Pets Catalogue as a Shelter Volunteer + Given I'm logged in as a Volunteer + Scenario: View Pets Catalogue from a specific \ No newline at end of file From 3b8b36194d21857a09b12dac9cae3665ca3dab61 Mon Sep 17 00:00:00 2001 From: globox97 Date: Tue, 12 Mar 2024 17:03:33 +0100 Subject: [PATCH 3/6] Feature View Pets Catalogue --- .../demo/steps/ViewCatalogueStepDefs.java | 18 ++++++++++++++++++ .../resources/features/ViewCatalogue.feature | 9 ++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 src/test/java/cat/udl/eps/softarch/demo/steps/ViewCatalogueStepDefs.java diff --git a/src/test/java/cat/udl/eps/softarch/demo/steps/ViewCatalogueStepDefs.java b/src/test/java/cat/udl/eps/softarch/demo/steps/ViewCatalogueStepDefs.java new file mode 100644 index 00000000..3d15430c --- /dev/null +++ b/src/test/java/cat/udl/eps/softarch/demo/steps/ViewCatalogueStepDefs.java @@ -0,0 +1,18 @@ +package cat.udl.eps.softarch.demo.steps; + +import cat.udl.eps.softarch.demo.repository.ShelterRepository; +import org.springframework.beans.factory.annotation.Autowired; +import io.cucumber.java.en.When; + +public class ViewCatalogueStepDefs { + @Autowired + private StepDefs stepDefs; + + @Autowired + private ShelterRepository shelterRepository; + + @When("I request the Catalogue") + public void viewCatalogue() throws Exception { + + } +} diff --git a/src/test/resources/features/ViewCatalogue.feature b/src/test/resources/features/ViewCatalogue.feature index 8a46808b..da8b362a 100644 --- a/src/test/resources/features/ViewCatalogue.feature +++ b/src/test/resources/features/ViewCatalogue.feature @@ -12,13 +12,16 @@ Feature: View Pets Catalogue Scenario: View Pets Catalogue as a Client Given I login as "client" with password "password" - When I + When I request the Catalogue Then The response code is 200 Scenario: View Pets Catalogue without being logged in Given I'm not logged in + When I request the Catalogue + Then The response code is 200 Scenario: View Pets Catalogue as a Shelter Volunteer Given I'm logged in as a Volunteer - - Scenario: View Pets Catalogue from a specific \ No newline at end of file + When I request the Catalogue + Then I'm shown the Catalogue from the shelter I work in + And The response code is 200 \ No newline at end of file From 3cebf6cf7c1812babf826185272d3fa8ef57bec7 Mon Sep 17 00:00:00 2001 From: globox97 Date: Wed, 13 Mar 2024 18:32:21 +0100 Subject: [PATCH 4/6] Feature View Pets Catalogue - implemented two scenarios --- .../demo/steps/ViewCatalogueStepDefs.java | 20 ++++++++++++++++--- .../resources/features/ViewCatalogue.feature | 16 ++++++++++----- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/test/java/cat/udl/eps/softarch/demo/steps/ViewCatalogueStepDefs.java b/src/test/java/cat/udl/eps/softarch/demo/steps/ViewCatalogueStepDefs.java index 3d15430c..a78c29f8 100644 --- a/src/test/java/cat/udl/eps/softarch/demo/steps/ViewCatalogueStepDefs.java +++ b/src/test/java/cat/udl/eps/softarch/demo/steps/ViewCatalogueStepDefs.java @@ -1,18 +1,32 @@ package cat.udl.eps.softarch.demo.steps; -import cat.udl.eps.softarch.demo.repository.ShelterRepository; -import org.springframework.beans.factory.annotation.Autowired; +import cat.udl.eps.softarch.demo.repository.PetRepository; import io.cucumber.java.en.When; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; public class ViewCatalogueStepDefs { + @Autowired private StepDefs stepDefs; @Autowired - private ShelterRepository shelterRepository; + private PetRepository petRepository; @When("I request the Catalogue") public void viewCatalogue() throws Exception { + stepDefs.result = stepDefs.mockMvc.perform(get("/pets/search?isAdopted=false") + .accept(MediaType.APPLICATION_JSON)) + .andDo(print()); + } + @When("I request the Catalogue with breed {string}") + public void viewCataloguewithBreed(String breed) throws Exception{ + stepDefs.result = stepDefs.mockMvc.perform(get("/pets/search?breed={breed}", breed) + .accept(MediaType.APPLICATION_JSON)) + .andDo(print()); } } + diff --git a/src/test/resources/features/ViewCatalogue.feature b/src/test/resources/features/ViewCatalogue.feature index da8b362a..16893892 100644 --- a/src/test/resources/features/ViewCatalogue.feature +++ b/src/test/resources/features/ViewCatalogue.feature @@ -7,16 +7,22 @@ Feature: View Pets Catalogue Background: Given there is a registered client with username "client" and password "password" and email "user@domain.com" Given there is a registered volunteer with username "volunteer" and password "password" and email "volunteer@domain.com" - Given there are pets in a shelter + And There is a Pet with breed "cat" + And There is a Pet with breed "dog" - Scenario: View Pets Catalogue as a Client - Given I login as "client" with password "password" + Scenario: View Pets Catalogue without being logged in + Given I'm not logged in When I request the Catalogue Then The response code is 200 - Scenario: View Pets Catalogue without being logged in - Given I'm not logged in + Scenario: View Pets Catalogue for a specific type of pet without being logged in + Given I'm not logged in + When I request the Catalogue with breed "cat" + Then The response code is 200 + + Scenario: View Pets Catalogue as a Client + Given I login as "client" with password "password" When I request the Catalogue Then The response code is 200 From 82c41039eada78d4c5a3450d42c6536d79fd8ee8 Mon Sep 17 00:00:00 2001 From: globox97 Date: Sat, 6 Apr 2024 19:28:28 +0200 Subject: [PATCH 5/6] Feature View Pets Catalogue - implemented two scenarios --- .../softarch/demo/steps/ViewCatalogueStepDefs.java | 11 +++++++++-- src/test/resources/features/ViewCatalogue.feature | 13 ++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/test/java/cat/udl/eps/softarch/demo/steps/ViewCatalogueStepDefs.java b/src/test/java/cat/udl/eps/softarch/demo/steps/ViewCatalogueStepDefs.java index a78c29f8..d71356e3 100644 --- a/src/test/java/cat/udl/eps/softarch/demo/steps/ViewCatalogueStepDefs.java +++ b/src/test/java/cat/udl/eps/softarch/demo/steps/ViewCatalogueStepDefs.java @@ -17,14 +17,21 @@ public class ViewCatalogueStepDefs { @When("I request the Catalogue") public void viewCatalogue() throws Exception { - stepDefs.result = stepDefs.mockMvc.perform(get("/pets/search?isAdopted=false") + stepDefs.result = stepDefs.mockMvc.perform(get("/pets/search/findByIsAdopted?isAdopted=false") .accept(MediaType.APPLICATION_JSON)) .andDo(print()); } + @When("I request the catalogue for the specific shelter {string}") + public void viewShelterCatalogue(String shelter) throws Exception { + stepDefs.result = stepDefs.mockMvc.perform(get("/pets/search/findByShelter?Shelter={shelter}", shelter) + .accept(MediaType.APPLICATION_JSON)) + .andDo(print()); + } + @When("I request the Catalogue with breed {string}") public void viewCataloguewithBreed(String breed) throws Exception{ - stepDefs.result = stepDefs.mockMvc.perform(get("/pets/search?breed={breed}", breed) + stepDefs.result = stepDefs.mockMvc.perform(get("/pets/search/findByBreed?breed={breed}", breed) .accept(MediaType.APPLICATION_JSON)) .andDo(print()); } diff --git a/src/test/resources/features/ViewCatalogue.feature b/src/test/resources/features/ViewCatalogue.feature index 16893892..03b15484 100644 --- a/src/test/resources/features/ViewCatalogue.feature +++ b/src/test/resources/features/ViewCatalogue.feature @@ -1,15 +1,9 @@ # Created by globox97 at 11/03/2024 Feature: View Pets Catalogue - In order to view the Pets Catalogue + In order to choose a pet to adopt from those available As a User I want to view the pet catalogue - Background: - Given there is a registered client with username "client" and password "password" and email "user@domain.com" - Given there is a registered volunteer with username "volunteer" and password "password" and email "volunteer@domain.com" - And There is a Pet with breed "cat" - And There is a Pet with breed "dog" - Scenario: View Pets Catalogue without being logged in Given I'm not logged in @@ -27,7 +21,8 @@ Feature: View Pets Catalogue Then The response code is 200 Scenario: View Pets Catalogue as a Shelter Volunteer - Given I'm logged in as a Volunteer - When I request the Catalogue + Given There is a registered shelter volunteer with username "volunteer" and password "password" and email "shelterv@sample.app" + Given I login with username "volunteer" and password "password" + When I request the Catalogue for the specific shelter Then I'm shown the Catalogue from the shelter I work in And The response code is 200 \ No newline at end of file From 9d39365d4c9af5c25c7c4380890b52e948b5d4b4 Mon Sep 17 00:00:00 2001 From: globox97 Date: Sun, 7 Apr 2024 22:27:26 +0200 Subject: [PATCH 6/6] Feature View Pets Catalogue - implemented two scenarios --- .../softarch/demo/steps/ViewCatalogueStepDefs.java | 4 ++-- src/test/resources/features/ViewCatalogue.feature | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/java/cat/udl/eps/softarch/demo/steps/ViewCatalogueStepDefs.java b/src/test/java/cat/udl/eps/softarch/demo/steps/ViewCatalogueStepDefs.java index d71356e3..5c539869 100644 --- a/src/test/java/cat/udl/eps/softarch/demo/steps/ViewCatalogueStepDefs.java +++ b/src/test/java/cat/udl/eps/softarch/demo/steps/ViewCatalogueStepDefs.java @@ -22,8 +22,8 @@ public void viewCatalogue() throws Exception { .andDo(print()); } - @When("I request the catalogue for the specific shelter {string}") - public void viewShelterCatalogue(String shelter) throws Exception { + @When("I request the Catalogue for the specific shelter {long}") + public void viewShelterCatalogue(Long shelter) throws Exception { stepDefs.result = stepDefs.mockMvc.perform(get("/pets/search/findByShelter?Shelter={shelter}", shelter) .accept(MediaType.APPLICATION_JSON)) .andDo(print()); diff --git a/src/test/resources/features/ViewCatalogue.feature b/src/test/resources/features/ViewCatalogue.feature index 03b15484..c96a5fe2 100644 --- a/src/test/resources/features/ViewCatalogue.feature +++ b/src/test/resources/features/ViewCatalogue.feature @@ -20,9 +20,9 @@ Feature: View Pets Catalogue When I request the Catalogue Then The response code is 200 - Scenario: View Pets Catalogue as a Shelter Volunteer - Given There is a registered shelter volunteer with username "volunteer" and password "password" and email "shelterv@sample.app" - Given I login with username "volunteer" and password "password" - When I request the Catalogue for the specific shelter - Then I'm shown the Catalogue from the shelter I work in - And The response code is 200 \ No newline at end of file + #Scenario: View Pets Catalogue as a Shelter Volunteer + #Given There is a registered shelter volunteer with username "volunteer" and password "password" and email "shelterv@sample.app" + #Given I login with username "volunteer" and password "password" + #When I request the Catalogue for the specific shelter "shelter" + #Then I'm shown the Catalogue from the shelter I work in + #And The response code is 200 \ No newline at end of file