Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IA2
GMS
Commits
2c95024f
Commit
2c95024f
authored
Jul 07, 2020
by
Sonia Zorba
Browse files
Bugfix on delete group API
parent
ea65db8f
Changes
3
Hide whitespace changes
Inline
Side-by-side
gms-ui/src/components/GroupsPanel.vue
View file @
2c95024f
...
...
@@ -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>
<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>
...
...
gms/src/main/java/it/inaf/ia2/gms/controller/GroupsController.java
View file @
2c95024f
...
...
@@ -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
);
...
...
gms/src/test/java/it/inaf/ia2/gms/controller/GroupsControllerTest.java
View file @
2c95024f
...
...
@@ -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"
));
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment