Search in sources :

Example 1 with Moment

use of org.uberfire.client.views.pfly.widgets.Moment in project kie-wb-common by kiegroup.

the class TimePicker method setDefaultData.

void setDefaultData() {
    final Moment now = moment();
    view.setDate(now);
}
Also used : Moment(org.uberfire.client.views.pfly.widgets.Moment)

Example 2 with Moment

use of org.uberfire.client.views.pfly.widgets.Moment in project kie-wb-common by kiegroup.

the class TimePickerTest method testRefreshDateInPopup.

@Test
public void testRefreshDateInPopup() {
    final Moment moment = mock(Moment.class);
    final String inputValue = "22:30:51";
    int expectedHours = 22;
    int expectedMinutes = 30;
    int expectedSeconds = 51;
    when(moment.isValid()).thenReturn(true);
    when(moment.hours()).thenReturn(expectedHours);
    when(moment.minutes()).thenReturn(expectedMinutes);
    when(moment.seconds()).thenReturn(expectedSeconds);
    doReturn(moment).when(picker).getDateInInput();
    input.value = inputValue;
    picker.refreshDateInPopup();
    verify(view).setDate(momentArgumentCaptor.capture());
    final Moment actual = momentArgumentCaptor.getValue();
    assertEquals(expectedHours, actual.hours());
    assertEquals(expectedMinutes, actual.minutes());
    assertEquals(expectedSeconds, actual.seconds());
}
Also used : Moment(org.uberfire.client.views.pfly.widgets.Moment) Test(org.junit.Test)

Example 3 with Moment

use of org.uberfire.client.views.pfly.widgets.Moment in project kie-wb-common by kiegroup.

the class TimePickerTest method testOnDateChanged.

@Test
public void testOnDateChanged() {
    final Consumer<Moment> consumer = mock(Consumer.class);
    picker.setOnDateChanged(consumer);
    final String expected = "14:55:01";
    final Moment moment = mock(Moment.class);
    when(moment.format("HH:mm:ss")).thenReturn(expected);
    picker.onDateChanged(moment);
    assertEquals(expected, input.value);
    verify(consumer).accept(argThat(argument -> Objects.equals(argument, moment)));
}
Also used : GwtMockitoTestRunner(com.google.gwtmockito.GwtMockitoTestRunner) HTMLInputElement(elemental2.dom.HTMLInputElement) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Mockito.spy(org.mockito.Mockito.spy) Captor(org.mockito.Captor) Moment(org.uberfire.client.views.pfly.widgets.Moment) Mockito.verify(org.mockito.Mockito.verify) Objects(java.util.Objects) Consumer(java.util.function.Consumer) ArgumentCaptor(org.mockito.ArgumentCaptor) Assert.assertFalse(org.junit.Assert.assertFalse) Mockito.doReturn(org.mockito.Mockito.doReturn) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) Mockito.mock(org.mockito.Mockito.mock) Moment(org.uberfire.client.views.pfly.widgets.Moment) Test(org.junit.Test)

Aggregations

Moment (org.uberfire.client.views.pfly.widgets.Moment)3 Test (org.junit.Test)2 GwtMockitoTestRunner (com.google.gwtmockito.GwtMockitoTestRunner)1 HTMLInputElement (elemental2.dom.HTMLInputElement)1 Objects (java.util.Objects)1 Consumer (java.util.function.Consumer)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Before (org.junit.Before)1 RunWith (org.junit.runner.RunWith)1 ArgumentCaptor (org.mockito.ArgumentCaptor)1 ArgumentMatchers.argThat (org.mockito.ArgumentMatchers.argThat)1 Captor (org.mockito.Captor)1 Mock (org.mockito.Mock)1 Mockito.doReturn (org.mockito.Mockito.doReturn)1 Mockito.mock (org.mockito.Mockito.mock)1 Mockito.spy (org.mockito.Mockito.spy)1 Mockito.verify (org.mockito.Mockito.verify)1 Mockito.when (org.mockito.Mockito.when)1