use of org.entando.entando.web.common.exceptions.ValidationConflictException in project entando-core by entando.
the class GroupControllerUnitTest method testValidateOnDeleteReservedGroups.
@Test
public void testValidateOnDeleteReservedGroups() throws ApsSystemException, Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
String groupName = Group.FREE_GROUP_NAME;
BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult("group", "group");
bindingResult.reject(GroupValidator.ERRCODE_CANNOT_DELETE_RESERVED_GROUP, new String[] { groupName }, "group.cannot.delete.reserved");
doThrow(new ValidationConflictException(bindingResult)).when(groupService).removeGroup(groupName);
this.controller.setGroupValidator(new GroupValidator());
ResultActions result = mockMvc.perform(delete("/groups/{groupName}", groupName).contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isConflict());
result.andExpect(jsonPath("$.errors[0].code", is(GroupValidator.ERRCODE_CANNOT_DELETE_RESERVED_GROUP)));
}
Aggregations