File tree Expand file tree Collapse file tree 3 files changed +26
-3
lines changed
main/java/org/gridsuite/studyconfig/server
test/java/org/gridsuite/studyconfig/server Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -46,4 +46,13 @@ public ResponseEntity<StudyLayout> getStudyLayout(
4646 @ PathVariable ("id" ) UUID studyLayoutUuid ) {
4747 return ResponseEntity .ok ().contentType (MediaType .APPLICATION_JSON ).body (studyLayoutService .getByStudyLayoutUuid (studyLayoutUuid ));
4848 }
49+
50+ @ DeleteMapping (value = "/{id}" )
51+ @ Operation (summary = "Delete study layout" )
52+ @ ApiResponses (value = {@ ApiResponse (responseCode = "200" , description = "The study layout is deleted" )})
53+ public ResponseEntity <StudyLayout > deleteStudyLayout (
54+ @ PathVariable ("id" ) UUID studyLayoutUuid ) {
55+ studyLayoutService .deleteStudyLayout (studyLayoutUuid );
56+ return ResponseEntity .ok ().build ();
57+ }
4958}
Original file line number Diff line number Diff line change @@ -26,6 +26,11 @@ public StudyLayout getByStudyLayoutUuid(UUID studyLayoutUuid) {
2626 .toDto ();
2727 }
2828
29+ @ Transactional
30+ public void deleteStudyLayout (UUID studyLayoutUuid ) {
31+ studyLayoutRepository .deleteById (studyLayoutUuid );
32+ }
33+
2934 @ Transactional
3035 public UUID saveStudyLayout (StudyLayout studyLayout ) {
3136 StudyLayoutEntity studyLayoutEntity = studyLayoutRepository .save (studyLayout .toEntity ());
Original file line number Diff line number Diff line change 2222import java .util .Map ;
2323import java .util .UUID ;
2424
25- import static org .springframework . test . web . servlet . request . MockMvcRequestBuilders . get ;
26- import static org .springframework . test . web . servlet . request . MockMvcRequestBuilders . post ;
27- import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .put ;
25+ import static org .junit . jupiter . api . Assertions . assertEquals ;
26+ import static org .junit . jupiter . api . Assertions . assertTrue ;
27+ import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .* ;
2828import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .status ;
2929import static org .assertj .core .api .Assertions .assertThat ;
3030
@@ -52,6 +52,15 @@ void testGetStudyLayout() throws Exception {
5252 assertThat (result ).usingRecursiveComparison ().isEqualTo (expectedResult .toDto ());
5353 }
5454
55+ @ Test
56+ void testDeleteStudyLayout () throws Exception {
57+ StudyLayoutEntity expectedResult = studyLayoutRepository .save (createStudyLayout ().toEntity ());
58+ mockMvc .perform (delete ("/v1/study-layout/{studyLayoutUuid}" , expectedResult .getUuid ()))
59+ .andExpect (status ().isOk ());
60+
61+ assertTrue (studyLayoutRepository .findById (expectedResult .getUuid ()).isEmpty ());
62+ }
63+
5564 @ Test
5665 void testSaveStudyLayout () throws Exception {
5766 StudyLayout studyLayoutToSave = createStudyLayout ();
You can’t perform that action at this time.
0 commit comments