Skip to content

Commit 3d1572a

Browse files
committed
adding code for steps
1 parent e31a413 commit 3d1572a

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/test/java/cat/udl/eps/softarch/demo/steps/ManageProjectStepDefs.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import java.nio.charset.StandardCharsets;
1414

15+
import static org.hamcrest.Matchers.hasItem;
1516
import static org.hamcrest.Matchers.is;
1617
import static org.hamcrest.Matchers.notNullValue;
1718
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
@@ -121,6 +122,15 @@ public void iUpdateTheProjectVisibility(String name, String visibility) throws E
121122
.with(AuthenticationStepDefs.authenticate()))
122123
.andDo(print());
123124
}
125+
126+
@When("I retrieve the list of projects")
127+
public void iRetrieveTheListOfProjects() throws Exception {
128+
stepDefs.result = stepDefs.mockMvc.perform(
129+
get("/projects")
130+
.accept(MediaType.APPLICATION_JSON)
131+
.with(AuthenticationStepDefs.authenticate()))
132+
.andDo(print());
133+
}
124134

125135
@When("I delete the project named {string}")
126136
public void iDeleteTheProjectNamed(String name) throws Exception {
@@ -160,6 +170,13 @@ public void theProjectModificationDateShouldBeSet() throws Exception {
160170
stepDefs.result.andExpect(jsonPath("$.modified", notNullValue()));
161171
}
162172

173+
@Then("The project list contains a project named {string}")
174+
public void theProjectListContainsAProjectNamed(String name) throws Exception {
175+
stepDefs.result.andExpect(
176+
jsonPath("$._embedded.projects[*].name", hasItem(is(name)))
177+
);
178+
}
179+
163180
@Then("The project visibility should be {string}")
164181
public void theProjectVisibilityShouldBe(String visibility) throws Exception {
165182
stepDefs.result.andExpect(jsonPath("$.visibility", is(visibility)));

0 commit comments

Comments
 (0)