use of org.entando.entando.web.group.model.GroupRequest in project entando-core by entando.
the class GroupControllerIntegrationTest method testParamSize.
@Test
public void testParamSize() throws ApsSystemException, Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
GroupRequest groupRequest = new GroupRequest();
groupRequest.setCode(StringUtils.repeat("a", 21));
groupRequest.setName(StringUtils.repeat("a", 51));
ObjectMapper mapper = new ObjectMapper();
String payload = mapper.writeValueAsString(groupRequest);
ResultActions result = mockMvc.perform(post("/groups").content(payload).contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + accessToken));
System.out.println(result.andReturn().getResponse().getContentAsString());
result.andExpect(status().isBadRequest());
}
use of org.entando.entando.web.group.model.GroupRequest in project entando-core by entando.
the class GroupControllerIntegrationTest method testAddExistingGroup.
@Test
public void testAddExistingGroup() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
GroupDto group = this.groupService.getGroup(Group.FREE_GROUP_NAME);
GroupRequest groupRequest = new GroupRequest();
groupRequest.setCode(group.getCode());
groupRequest.setName(group.getName());
ObjectMapper mapper = new ObjectMapper();
String payload = mapper.writeValueAsString(groupRequest);
ResultActions result = mockMvc.perform(post("/groups").content(payload).contentType(MediaType.APPLICATION_JSON_VALUE).header("Authorization", "Bearer " + accessToken));
// System.out.println(result.andReturn().getResponse().getContentAsString());
result.andExpect(status().isConflict());
}
use of org.entando.entando.web.group.model.GroupRequest in project entando-core by entando.
the class GroupControllerUnitTest method testParamSize.
@Test
public void testParamSize() throws ApsSystemException, Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
GroupRequest groupRequest = new GroupRequest();
groupRequest.setCode(StringUtils.repeat("a", 21));
groupRequest.setName(StringUtils.repeat("a", 51));
ObjectMapper mapper = new ObjectMapper();
String payload = mapper.writeValueAsString(groupRequest);
this.controller.setGroupValidator(new GroupValidator());
ResultActions result = mockMvc.perform(post("/groups").content(payload).contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + accessToken));
// System.out.println(result.andReturn().getResponse().getContentAsString());
result.andExpect(status().isBadRequest());
}
use of org.entando.entando.web.group.model.GroupRequest in project entando-core by entando.
the class GroupValidator method validate.
@Override
public void validate(Object target, Errors errors) {
GroupRequest request = (GroupRequest) target;
String groupCode = request.getCode();
if (null != groupManager.getGroup(groupCode)) {
errors.reject(ERRCODE_GROUP_ALREADY_EXISTS, new String[] { groupCode }, "group.exists");
}
}
use of org.entando.entando.web.group.model.GroupRequest in project entando-core by entando.
the class GroupControllerIntegrationTest method testGetInvalidGroup.
@Test
public void testGetInvalidGroup() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
GroupDto group = this.groupService.getGroup(Group.FREE_GROUP_NAME);
GroupRequest groupRequest = new GroupRequest();
groupRequest.setCode(group.getCode());
groupRequest.setName(group.getName());
ResultActions result = mockMvc.perform(get("/groups/{code}", "invalid_code").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)));
}
Aggregations