use of org.entando.entando.web.widget.validator.WidgetValidator in project entando-core by entando.
the class WidgetControllerTest method testUpdateWidget.
@Test
public void testUpdateWidget() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
when(widgetService.updateWidget(any(), any())).thenReturn(new WidgetDto());
this.controller.setWidgetValidator(new WidgetValidator());
// @formatter:off
ResultActions result = mockMvc.perform(put("/widgets/test").contentType(MediaType.APPLICATION_JSON).content(convertObjectToJsonBytes(createMockRequest())).header("Authorization", "Bearer " + accessToken));
String response = result.andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
assertNotNull(response);
}
use of org.entando.entando.web.widget.validator.WidgetValidator in project entando-core by entando.
the class WidgetControllerTest method testAddWidget.
@Test
public void testAddWidget() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
this.controller.setWidgetValidator(new WidgetValidator());
// @formatter:off
ResultActions result = mockMvc.perform(post("/widgets").contentType(MediaType.APPLICATION_JSON).content(convertObjectToJsonBytes(createMockRequest())).header("Authorization", "Bearer " + accessToken));
String response = result.andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
assertNotNull(response);
}
Aggregations