-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
481 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/cat/udl/eps/softarch/demo/repository/RoleRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package cat.udl.eps.softarch.demo.repository; | ||
|
||
import cat.udl.eps.softarch.demo.domain.Pet; | ||
import cat.udl.eps.softarch.demo.domain.Role; | ||
import org.springframework.data.repository.CrudRepository; | ||
import org.springframework.data.repository.PagingAndSortingRepository; | ||
import org.springframework.data.rest.core.annotation.RepositoryRestResource; | ||
|
||
@RepositoryRestResource | ||
public interface RoleRepository extends CrudRepository<Role, Long>, PagingAndSortingRepository<Role, Long> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/java/cat/udl/eps/softarch/demo/repository/ShelterRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package cat.udl.eps.softarch.demo.repository; | ||
|
||
import cat.udl.eps.softarch.demo.domain.Shelter; | ||
import org.springframework.data.repository.CrudRepository; | ||
import org.springframework.data.repository.PagingAndSortingRepository; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.data.rest.core.annotation.RepositoryRestResource; | ||
|
||
@RepositoryRestResource | ||
public interface ShelterRepository extends CrudRepository<Shelter, Long>, PagingAndSortingRepository<Shelter, Long> { | ||
Shelter findByName(@Param("name") String name); | ||
} |
49 changes: 49 additions & 0 deletions
49
src/test/java/cat/udl/eps/softarch/demo/steps/DeleteShelterStepDefs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package cat.udl.eps.softarch.demo.steps; | ||
|
||
import cat.udl.eps.softarch.demo.domain.Shelter; | ||
import cat.udl.eps.softarch.demo.repository.ShelterRepository; | ||
import io.cucumber.java.en.And; | ||
import io.cucumber.java.en.When; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.MediaType; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
|
||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
|
||
public class DeleteShelterStepDefs { | ||
@Autowired | ||
private StepDefs stepDefs; | ||
|
||
@Autowired | ||
private ShelterRepository shelterRepository; | ||
|
||
@When("^I delete the shelter with name \"([^\"]*)\"$") | ||
public void iDeleteAShelterWithName(String name) throws Exception { | ||
Shelter shelter = shelterRepository.findByName(name); | ||
|
||
stepDefs.result = stepDefs.mockMvc.perform( | ||
delete("/shelters/{id}", (shelter != null) ? shelter.getId() : "999") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.content(stepDefs.mapper.writeValueAsString(shelter)) | ||
.characterEncoding(StandardCharsets.UTF_8) | ||
.accept(MediaType.APPLICATION_JSON) | ||
.with(AuthenticationStepDefs.authenticate())) | ||
.andDo(print()); | ||
} | ||
|
||
@And("^The shelter with name \"([^\"]*)\" has been deleted$") | ||
public void theShelterWithNameHasBeenDeleted(String name) { | ||
Shelter shelter = shelterRepository.findByName(name); | ||
assertThat(shelter).isNull(); | ||
} | ||
|
||
@And("^The shelter with name \"([^\"]*)\" has not been deleted$") | ||
public void theShelterWithNameHasNotBeenDeleted(String name) { | ||
Shelter shelter = shelterRepository.findByName(name); | ||
assertThat(shelter).isNotNull(); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/test/java/cat/udl/eps/softarch/demo/steps/GetShelterStepDefs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cat.udl.eps.softarch.demo.steps; | ||
|
||
import cat.udl.eps.softarch.demo.domain.Shelter; | ||
import cat.udl.eps.softarch.demo.repository.ShelterRepository; | ||
import io.cucumber.java.en.When; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.MediaType; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
|
||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; | ||
|
||
public class GetShelterStepDefs { | ||
@Autowired | ||
private StepDefs stepDefs; | ||
|
||
@Autowired | ||
private ShelterRepository shelterRepository; | ||
|
||
@When("^I retrieve the shelter with name \"([^\"]*)\"$") | ||
public void iRetrieveShelterWithName(String name) throws Exception { | ||
Shelter shelter = shelterRepository.findByName(name); | ||
|
||
stepDefs.result = stepDefs.mockMvc.perform( | ||
get("/shelters/{id}", (shelter != null) ? shelter.getId() : "999") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.content(stepDefs.mapper.writeValueAsString(shelter)) | ||
.characterEncoding(StandardCharsets.UTF_8) | ||
.accept(MediaType.APPLICATION_JSON) | ||
.with(AuthenticationStepDefs.authenticate())) | ||
.andDo(print()); | ||
} | ||
} |
Oops, something went wrong.