use of org.entando.entando.web.group.model.GroupRequest in project entando-core by entando.
the class GroupControllerIntegrationTest method testUpdateInvalidGroup.
@Test
public void testUpdateInvalidGroup() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
GroupRequest groupRequest = new GroupRequest();
groupRequest.setCode("invalid");
groupRequest.setName("invalid");
ObjectMapper mapper = new ObjectMapper();
String payload = mapper.writeValueAsString(groupRequest);
ResultActions result = mockMvc.perform(put("/groups/{code}", groupRequest.getCode()).content(payload).contentType(MediaType.APPLICATION_JSON_VALUE).header("Authorization", "Bearer " + accessToken));
// System.out.println(result.andReturn().getResponse().getContentAsString());
result.andExpect(status().isNotFound());
result.andExpect(jsonPath("$.errors[0].code", is(GroupValidator.ERRCODE_GROUP_NOT_FOUND)));
}
use of org.entando.entando.web.group.model.GroupRequest in project entando-core by entando.
the class GroupControllerUnitTest method testValidateOnUpdateWithInvalidPathAndPayload.
@Test
public void testValidateOnUpdateWithInvalidPathAndPayload() throws ApsSystemException, Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
ObjectMapper mapper = new ObjectMapper();
GroupRequest group = new GroupRequest();
group.setCode("__helpdesk_");
group.setName("Helpdesk");
String payload = mapper.writeValueAsString(group);
this.controller.setGroupValidator(new GroupValidator());
ResultActions result = mockMvc.perform(put("/groups/{groupCode}", "helpdesk").content(payload).contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isBadRequest());
}
Aggregations