Search in sources :

Example 1 with WidgetValidator

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);
}
Also used : WidgetValidator(org.entando.entando.web.widget.validator.WidgetValidator) UserDetails(com.agiletec.aps.system.services.user.UserDetails) ResultActions(org.springframework.test.web.servlet.ResultActions) WidgetDto(org.entando.entando.aps.system.services.widgettype.model.WidgetDto) AbstractControllerTest(org.entando.entando.web.AbstractControllerTest) Test(org.junit.Test)

Example 2 with WidgetValidator

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);
}
Also used : WidgetValidator(org.entando.entando.web.widget.validator.WidgetValidator) UserDetails(com.agiletec.aps.system.services.user.UserDetails) ResultActions(org.springframework.test.web.servlet.ResultActions) AbstractControllerTest(org.entando.entando.web.AbstractControllerTest) Test(org.junit.Test)

Aggregations

UserDetails (com.agiletec.aps.system.services.user.UserDetails)2 AbstractControllerTest (org.entando.entando.web.AbstractControllerTest)2 WidgetValidator (org.entando.entando.web.widget.validator.WidgetValidator)2 Test (org.junit.Test)2 ResultActions (org.springframework.test.web.servlet.ResultActions)2 WidgetDto (org.entando.entando.aps.system.services.widgettype.model.WidgetDto)1