Search in sources :

Example 1 with VaadinService

use of com.vaadin.server.VaadinService in project SORMAS-Project by hzi-braunschweig.

the class CaseControllerTest method initUI.

@Before
public void initUI() throws Exception {
    creator.createUser(null, null, null, "ad", "min", UserRole.ADMIN, UserRole.NATIONAL_USER);
    VaadinRequest request = Mockito.mock(VaadinServletRequest.class);
    when(request.getUserPrincipal()).thenReturn((Principal) () -> "admin");
    CurrentInstance.set(VaadinRequest.class, request);
    VaadinService service = Mockito.mock(VaadinService.class);
    CurrentInstance.set(VaadinService.class, service);
    VaadinSession session = Mockito.mock(VaadinSession.class);
    ConverterFactory converterFactory = new SormasDefaultConverterFactory();
    when(session.getConverterFactory()).thenReturn(converterFactory);
    when(session.getService()).thenReturn(service);
    CurrentInstance.set(VaadinSession.class, session);
    ui = new SormasUI();
    CurrentInstance.set(UI.class, ui);
    java.lang.reflect.Field pageField = UI.class.getDeclaredField("page");
    pageField.setAccessible(true);
    pageField.set(ui, Mockito.mock(Page.class));
}
Also used : SormasDefaultConverterFactory(de.symeda.sormas.ui.utils.SormasDefaultConverterFactory) VaadinSession(com.vaadin.server.VaadinSession) SormasUI(de.symeda.sormas.ui.SormasUI) VaadinService(com.vaadin.server.VaadinService) VaadinRequest(com.vaadin.server.VaadinRequest) ConverterFactory(com.vaadin.v7.data.util.converter.ConverterFactory) SormasDefaultConverterFactory(de.symeda.sormas.ui.utils.SormasDefaultConverterFactory) Page(com.vaadin.server.Page) Before(org.junit.Before)

Aggregations

Page (com.vaadin.server.Page)1 VaadinRequest (com.vaadin.server.VaadinRequest)1 VaadinService (com.vaadin.server.VaadinService)1 VaadinSession (com.vaadin.server.VaadinSession)1 ConverterFactory (com.vaadin.v7.data.util.converter.ConverterFactory)1 SormasUI (de.symeda.sormas.ui.SormasUI)1 SormasDefaultConverterFactory (de.symeda.sormas.ui.utils.SormasDefaultConverterFactory)1 Before (org.junit.Before)1