package mate00.parafia.ui;
import static org.mockito.Mockito.*;
import javax.swing.JSlider;
import javax.swing.event.ChangeListener;
import javax.swing.event.ChangeEvent;
import mate00.parafia.net.ExpeditionDetails;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
/**
*
* @author mate00
*/
public class DatePickerTest {
private ExpeditionDetails details;
private ChangeListener listener;
@Mock
private JSlider daysSlider = mock(JSlider.class);
@Mock
private JSlider hourSlider = mock(JSlider.class);
@Mock
private ChangeEvent event;
@Mock
private SliderUpdateListener sliderMock;
@Before
public void setUp() {
details = new ExpeditionDetails();
sliderMock = mock(SliderUpdateListener.class);
listener = new ExpeditionTimeSliderListener(daysSlider, hourSlider, sliderMock);
event = mock(ChangeEvent.class);
}
@Test
public void test() {
when(event.getSource()).thenReturn(daysSlider);
when(daysSlider.getValue()).thenReturn(4);
listener.stateChanged(event);
ExpeditionDetails expected = new ExpeditionDetails();
expected.setDays(4);
verify(sliderMock).updateWithDetails(Mockito.eq(expected));
}
}