Skip to content

Commit e31a413

Browse files
committed
Update ManageProjectStepDefs.java
1 parent 85dba70 commit e31a413

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,25 @@ public void iUpdateTheProjectNamed(String oldName, String newName) throws Except
103103
.andDo(print());
104104
}
105105

106+
// ➕ NOU
107+
@When("I update the project named {string} setting visibility to {string}")
108+
public void iUpdateTheProjectVisibility(String name, String visibility) throws Exception {
109+
Project found = projectRepository.findByNameContaining(name)
110+
.stream().filter(p -> p.getName().equals(name))
111+
.findFirst().orElseThrow();
112+
113+
found.setVisibility(Visibility.valueOf(visibility));
114+
115+
stepDefs.result = stepDefs.mockMvc.perform(
116+
put("/projects/{id}", found.getId())
117+
.contentType(MediaType.APPLICATION_JSON)
118+
.content(stepDefs.mapper.writeValueAsString(found))
119+
.characterEncoding(StandardCharsets.UTF_8)
120+
.accept(MediaType.APPLICATION_JSON)
121+
.with(AuthenticationStepDefs.authenticate()))
122+
.andDo(print());
123+
}
124+
106125
@When("I delete the project named {string}")
107126
public void iDeleteTheProjectNamed(String name) throws Exception {
108127
Project found = projectRepository.findByNameContaining(name)
@@ -135,6 +154,12 @@ public void theProjectCreationDateShouldBeSet() throws Exception {
135154
stepDefs.result.andExpect(jsonPath("$.created", notNullValue()));
136155
}
137156

157+
// ➕ NOU
158+
@Then("The project modification date should be set")
159+
public void theProjectModificationDateShouldBeSet() throws Exception {
160+
stepDefs.result.andExpect(jsonPath("$.modified", notNullValue()));
161+
}
162+
138163
@Then("The project visibility should be {string}")
139164
public void theProjectVisibilityShouldBe(String visibility) throws Exception {
140165
stepDefs.result.andExpect(jsonPath("$.visibility", is(visibility)));

0 commit comments

Comments
 (0)