added shouldNotCreateProjectWithSameName test
This commit is contained in:
parent
beb293753b
commit
3e92e2747c
1 changed files with 34 additions and 0 deletions
|
@ -41,4 +41,38 @@ public class CreateTest extends IntegrationTest {
|
||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andExpect(jsonPath("$.id").exists());
|
.andExpect(jsonPath("$.id").exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldNotCreateProjectWithSameName() throws Exception {
|
||||||
|
|
||||||
|
CreateProjectDTO createDTO = new CreateProjectDTO();
|
||||||
|
createDTO.setName("Test");
|
||||||
|
createDTO.setGoal("A Test Goal");
|
||||||
|
createDTO.setCustomerId(10L);
|
||||||
|
createDTO.setAdministratorId(10L);
|
||||||
|
createDTO.setStart(LocalDateTime.of(2000, 1, 13, 12, 51));
|
||||||
|
createDTO.setPlannedEnd(LocalDateTime.of(2002, 3, 21, 11, 42));
|
||||||
|
|
||||||
|
RequestBuilder firstProjectRequestBuilder = createProjectRequestBuilder(createDTO);
|
||||||
|
|
||||||
|
this.mvc
|
||||||
|
.perform(firstProjectRequestBuilder)
|
||||||
|
.andExpect(status().isCreated())
|
||||||
|
.andExpect(jsonPath("$.id").exists());
|
||||||
|
|
||||||
|
RequestBuilder secondProjectRequestBuilder = createProjectRequestBuilder(createDTO);
|
||||||
|
|
||||||
|
this.mvc
|
||||||
|
.perform(secondProjectRequestBuilder)
|
||||||
|
.andExpect(status().isConflict());
|
||||||
|
}
|
||||||
|
|
||||||
|
private RequestBuilder createProjectRequestBuilder(CreateProjectDTO createDTO) throws Exception {
|
||||||
|
|
||||||
|
return MockMvcRequestBuilders
|
||||||
|
.post(baseUri + "/project")
|
||||||
|
.accept(MediaType.APPLICATION_JSON)
|
||||||
|
.content(this.objectMapper.writeValueAsString(createDTO))
|
||||||
|
.contentType(MediaType.APPLICATION_JSON);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue