Commit 2c95024f authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Bugfix on delete group API

parent ea65db8f
......@@ -10,11 +10,11 @@
<b-list-group-item href="#" v-on:click="openGroup(group)">
<span class="float-left">{{group.groupName}}</span>
<span v-if="group.permission === 'ADMIN'" class="float-right">
<a href="#" v-on:click.stop="openEditGroupModal(group)" title="Edit">
<a href="#" v-on:click.stop.prevent="openEditGroupModal(group)" title="Edit">
<font-awesome-icon icon="edit"></font-awesome-icon>
</a>
&nbsp;
<a href="#" v-on:click.stop="openRemoveGroupModal(group)" class="text-danger" title="Delete">
<a href="#" v-on:click.stop.prevent="openRemoveGroupModal(group)" class="text-danger" title="Delete">
<font-awesome-icon icon="trash"></font-awesome-icon>
</a>
</span>
......
......@@ -40,7 +40,7 @@ public class GroupsController {
@Autowired
private GroupsTabResponseBuilder groupsTabResponseBuilder;
@GetMapping(value = "/groups", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@GetMapping(value = "/groups", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getGroupsTab(@Valid GroupsRequest request) {
if (request.isOnlyPanel()) {
// Only groupsPanel
......@@ -52,7 +52,7 @@ public class GroupsController {
}
}
@PostMapping(value = "/group", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@PostMapping(value = "/group", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<PaginatedData<GroupNode>> createGroup(@Valid @RequestBody AddGroupRequest request) {
GroupEntity parent = groupsManager.getGroupById(request.getParentGroupId());
......@@ -64,7 +64,7 @@ public class GroupsController {
return new ResponseEntity<>(groupsPanel, HttpStatus.CREATED);
}
@PutMapping(value = "/group/{groupId}", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@PutMapping(value = "/group/{groupId}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<PaginatedData<GroupNode>> updateGroup(@PathVariable("groupId") String groupId, @Valid @RequestBody RenameGroupRequest request) {
GroupEntity updatedGroup = groupsManager.updateGroup(groupId, request.getNewGroupName(), request.isLeaf());
......@@ -76,7 +76,7 @@ public class GroupsController {
return ResponseEntity.ok(groupsPanel);
}
@DeleteMapping(value = "/group/{groupId}", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@DeleteMapping(value = "/group/{groupId}", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> deleteGroup(@PathVariable("groupId") String groupId, DeleteGroupRequest request) {
GroupEntity parent = groupsManager.deleteGroup(groupId);
......
......@@ -20,14 +20,19 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
......@@ -103,7 +108,17 @@ public class GroupsControllerTest {
mockMvc.perform(post("/group")
.content(mapper.writeValueAsString(request))
.contentType(MediaType.APPLICATION_JSON_UTF8))
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isCreated());
}
@Test
public void testDeleteGroup() throws Exception {
mockMvc.perform(delete("/group/id?paginatorPageSize=20&paginatorPage=1&searchFilter="))
.andDo(print())
.andExpect(status().isOk());
verify(groupsManager, times(1)).deleteGroup(eq("id"));
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment