use of org.springframework.test.web.servlet.ResultActions in project entando-core by entando.
the class ProfileTypeControllerIntegrationTest method testRefreshUserProfileTypes.
@Test
public void testRefreshUserProfileTypes() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
ResultActions result = mockMvc.perform(post("/profileTypesStatus").content("{\"profileTypeCodes\":[\"AAA\",\"BBB\"]}").contentType(MediaType.APPLICATION_JSON_VALUE).header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isNotFound());
result.andExpect(jsonPath("$.errors", Matchers.hasSize(1)));
result = mockMvc.perform(post("/profileTypesStatus").content("{\"profileTypeCodes\":[\"PFL\"]}").contentType(MediaType.APPLICATION_JSON_VALUE).header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isOk());
result.andExpect(jsonPath("$.payload.size()", is(2)));
result.andExpect(jsonPath("$.payload.result", is("success")));
result.andExpect(jsonPath("$.payload.profileTypeCodes.size()", is(1)));
result.andExpect(jsonPath("$.errors", Matchers.hasSize(0)));
result.andExpect(jsonPath("$.metaData.size()", is(0)));
}
use of org.springframework.test.web.servlet.ResultActions in project entando-core by entando.
the class ProfileTypeControllerIntegrationTest method testGetInvalidUserProfileType.
@Test
public void testGetInvalidUserProfileType() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
ResultActions result = mockMvc.perform(get("/profileTypes/{profileTypeCode}", new Object[] { "XXX" }).header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isNotFound());
}
use of org.springframework.test.web.servlet.ResultActions in project entando-core by entando.
the class ProfileTypeControllerIntegrationTest method testGetUserProfileAttributeType_2.
@Test
public void testGetUserProfileAttributeType_2() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
ResultActions result = mockMvc.perform(get("/profileTypeAttributes/{attributeTypeCode}", new Object[] { "WrongTypeCode" }).header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isNotFound());
result.andExpect(jsonPath("$.payload", Matchers.hasSize(0)));
result.andExpect(jsonPath("$.errors", Matchers.hasSize(1)));
result.andExpect(jsonPath("$.metaData.size()", is(0)));
}
use of org.springframework.test.web.servlet.ResultActions in project entando-core by entando.
the class ProfileTypeControllerIntegrationTest method testAddGetUserProfileType_1.
@Test
public void testAddGetUserProfileType_1() throws Exception {
try {
Assert.assertNull(this.userProfileManager.getEntityPrototype("TST"));
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
this.executeProfileTypePost("2_POST_valid.json", accessToken, status().isOk());
UserProfile addedType = (UserProfile) this.userProfileManager.getEntityPrototype("TST");
Assert.assertNotNull(addedType);
Assert.assertEquals("Profile Type TST", addedType.getTypeDescription());
Assert.assertEquals(3, addedType.getAttributeList().size());
ResultActions result = mockMvc.perform(get("/profileTypes/{profileTypeCode}", new Object[] { "TST" }).header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isOk());
result.andExpect(jsonPath("$.payload.code", is("TST")));
result.andExpect(jsonPath("$.payload.attributes.size()", is(3)));
result.andExpect(jsonPath("$.errors", Matchers.hasSize(0)));
} finally {
if (null != this.userProfileManager.getEntityPrototype("TST")) {
((IEntityTypesConfigurer) this.userProfileManager).removeEntityPrototype("TST");
}
}
}
use of org.springframework.test.web.servlet.ResultActions in project entando-core by entando.
the class ProfileTypeControllerIntegrationTest method testGetUserProfileTypesWithAdminPermission.
@Test
public void testGetUserProfileTypesWithAdminPermission() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
ResultActions result = mockMvc.perform(get("/profileTypes").header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isOk());
}
Aggregations