Skip to content

Commit

Permalink
Merge pull request #94 from UdL-EPS-SoftArch/Feature-View-pet-catalogue
Browse files Browse the repository at this point in the history
Feature view pet catalogue
  • Loading branch information
rogargon authored Apr 8, 2024
2 parents 3e84312 + 9d39365 commit abbd973
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package cat.udl.eps.softarch.demo.steps;

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 PetRepository petRepository;

@When("I request the Catalogue")
public void viewCatalogue() throws Exception {
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 {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());
}

@When("I request the Catalogue with breed {string}")
public void viewCataloguewithBreed(String breed) throws Exception{
stepDefs.result = stepDefs.mockMvc.perform(get("/pets/search/findByBreed?breed={breed}", breed)
.accept(MediaType.APPLICATION_JSON))
.andDo(print());
}
}

28 changes: 28 additions & 0 deletions src/test/resources/features/ViewCatalogue.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Created by globox97 at 11/03/2024
Feature: View Pets Catalogue
In order to choose a pet to adopt from those available
As a User
I want to view the pet catalogue


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 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

#Scenario: View Pets Catalogue as a Shelter Volunteer
#Given There is a registered shelter volunteer with username "volunteer" and password "password" and email "[email protected]"
#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

0 comments on commit abbd973

Please sign in to comment.