Search in sources :

Example 1 with SormasDefaultConverterFactory

use of de.symeda.sormas.ui.utils.SormasDefaultConverterFactory 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)

Example 2 with SormasDefaultConverterFactory

use of de.symeda.sormas.ui.utils.SormasDefaultConverterFactory in project SORMAS-Project by hzi-braunschweig.

the class LoginUI method init.

@Override
public void init(VaadinRequest vaadinRequest) {
    setErrorHandler(SormasErrorHandler.get());
    setLocale(vaadinRequest.getLocale());
    Responsive.makeResponsive(this);
    VaadinSession.getCurrent().setConverterFactory(new SormasDefaultConverterFactory());
    getPage().setTitle(FacadeProvider.getConfigFacade().getSormasInstanceName());
    setContent(new LoginScreen(DefaultPasswordUIHelper.getInterceptionLoginListener((LoginListener) () -> UI.getCurrent().getPage().setLocation(VaadinServletService.getCurrentServletRequest().getContextPath() + "#" + DataHelper.toStringNullable(UI.getCurrent().getPage().getUriFragment())), UI.getCurrent())));
}
Also used : SormasDefaultConverterFactory(de.symeda.sormas.ui.utils.SormasDefaultConverterFactory)

Example 3 with SormasDefaultConverterFactory

use of de.symeda.sormas.ui.utils.SormasDefaultConverterFactory in project SORMAS-Project by hzi-braunschweig.

the class SormasUI method init.

@Override
public void init(VaadinRequest vaadinRequest) {
    setErrorHandler(SormasErrorHandler.get());
    setLocale(vaadinRequest.getLocale());
    Responsive.makeResponsive(this);
    VaadinSession.getCurrent().setConverterFactory(new SormasDefaultConverterFactory());
    getPage().setTitle(FacadeProvider.getConfigFacade().getSormasInstanceName());
    initMainScreen();
}
Also used : SormasDefaultConverterFactory(de.symeda.sormas.ui.utils.SormasDefaultConverterFactory)

Aggregations

SormasDefaultConverterFactory (de.symeda.sormas.ui.utils.SormasDefaultConverterFactory)3 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 Before (org.junit.Before)1