示例#1
0
 @Test
 public void detachNoScope() {
   // given
   prepAttach();
   ui.attach();
   // when
   ui.detach();
   // then
   // no exception
 }
示例#2
0
  @SuppressWarnings("deprecation")
  private void prepAttach() {
    when(request.getParameter("v-loc")).thenReturn(baseUri + "/#home");
    ui.getPage().init(request);
    when(session.createConnectorId(Matchers.any(ClientConnector.class)))
        .thenAnswer(new ConnectorIdAnswer());
    when(session.getLocale()).thenReturn(Locale.FRANCE);

    when(session.hasLock()).thenReturn(true);
    ui.setSession(session);
  }
示例#3
0
 @Test
 public void changeView() {
   // given
   when(toView.getRootComponent()).thenReturn(viewContent);
   when(toView.getName()).thenReturn("toView");
   // when
   ui.changeView(toView);
   // then
   verify(toView).getRootComponent();
   verify(translator).translate(toView);
   verify(viewContent).setSizeFull();
   assertThat(ui.getViewDisplayPanel().getContent()).isEqualTo(viewContent);
 }
示例#4
0
 @Test
 public void detachScopeNotNull() {
   // given
   prepAttach();
   ui.attach();
   ui.setScope(uiScope);
   ui.setInstanceKey(uiKey);
   // when
   ui.detach();
   // then
   verify(uiScope).releaseScope(ui.getInstanceKey());
   verify(broadcaster).unregister(Broadcaster.ALL_MESSAGES, ui);
 }
示例#5
0
  /** There is a much better functional test */
  @Test
  public void receiveBroadcastMessage() throws Exception {
    // given
    prepAttach();
    ui.attach();
    ui.setScope(uiScope);
    ui.setInstanceKey(uiKey);

    // when
    ui.receiveBroadcast("group", "message", uiKey, 55);
    // then
    assertThat(logMonitor.debugLogs())
        .contains("UI instance UIKey:33 receiving message id: 55 from: UIKey:33");
  }
示例#6
0
 @Test
 public void pageTitle() throws Exception {
   // given
   when(applicationTitle.getTitleKey()).thenReturn(LabelKey.Yes);
   when(translate.from(LabelKey.Yes)).thenReturn("Title");
   // when
   assertThat(ui.pageTitle()).isEqualTo("Title");
 }
示例#7
0
  @Test(expected = MethodReconfigured.class)
  public void methodReconfigured() {
    // given

    // when
    ui.setNavigator(vaadinNavigator);
    // then
  }
示例#8
0
 @Test(expected = ConfigurationException.class)
 public void changeView_RootComponentNotSet() {
   // given
   when(toView.getRootComponent()).thenReturn(null);
   when(toView.getName()).thenReturn("toView");
   // when
   ui.changeView(toView);
   // then
 }
示例#9
0
 @Test
 public void init() {
   // given
   prepAttach();
   // when
   ui.init(request);
   // then
   verify(session).setConverterFactory(converterFactory);
   InOrder inOrder = inOrder(currentLocale, navigator, translator, navigator);
   //        inOrder.verify(currentLocale)
   //               .setLocale(Locale.FRANCE, false);
   inOrder.verify(navigator).init();
   inOrder.verify(translator).translate(ui);
   inOrder.verify(navigator).navigateTo("home");
 }
示例#10
0
  @Test(expected = ConfigurationException.class)
  public void init_with_viewDisplayPanel_parent_null() {
    // given
    ui =
        new DuffUI(
            navigator,
            errorHandler,
            converterFactory,
            broadcaster,
            pushMessageRouter,
            applicationTitle,
            translate,
            currentLocale,
            translator);
    prepAttach();
    // when
    ui.init(request);
    // then

  }
示例#11
0
 @Before
 public void setup() {
   Locale.setDefault(Locale.UK);
   when(uiBusProvider.get()).thenReturn(eventBus);
   pushMessageRouter = new DefaultPushMessageRouter(uiBusProvider);
   logMonitor = new LogMonitor();
   logMonitor.addClassFilter(ScopedUI.class);
   uiKey = new UIKey(33);
   ui =
       new BasicUI(
           navigator,
           errorHandler,
           converterFactory,
           broadcaster,
           pushMessageRouter,
           applicationTitle,
           translate,
           currentLocale,
           translator,
           option);
   ui.setInstanceKey(uiKey);
 }