From 82c41039eada78d4c5a3450d42c6536d79fd8ee8 Mon Sep 17 00:00:00 2001 From: globox97 Date: Sat, 6 Apr 2024 19:28:28 +0200 Subject: [PATCH] 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