Package mate00.parafia.ui

Source Code of mate00.parafia.ui.DatePickerTest

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));
    }
}
TOP

Related Classes of mate00.parafia.ui.DatePickerTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.