source: src/test/java/genius/gui/boaparties/BoaComponentPanelTest.java@ 346

Last change on this file since 346 was 1, checked in by Wouter Pasman, 6 years ago

Initial import : Genius 9.0.0

File size: 1.9 KB
Line 
1package genius.gui.boaparties;
2
3import static org.mockito.Mockito.mock;
4import static org.mockito.Mockito.when;
5
6import java.awt.BorderLayout;
7import java.util.ArrayList;
8import java.util.Arrays;
9import java.util.List;
10
11import javax.swing.JFrame;
12
13import org.junit.Test;
14
15import genius.core.boaframework.BOAparameter;
16import genius.core.exceptions.InstantiateException;
17import genius.core.repository.RepItem;
18import genius.gui.panels.SingleSelectionModel;
19
20/**
21 * bit hacky test. Just opens the panel with a mocked component.
22 */
23public class BoaComponentPanelTest {
24 @SuppressWarnings("rawtypes")
25 @Test
26 public void testOpenPanel() throws InstantiateException, InterruptedException {
27 JFrame frame = new JFrame();
28 frame.setLayout(new BorderLayout());
29
30 // Mock a Boa component model to test the GUI
31 @SuppressWarnings("rawtypes")
32 BoaComponentModel model = mock(BoaComponentModel.class);
33 @SuppressWarnings("rawtypes")
34 SingleSelectionModel componentlist = mock(SingleSelectionModel.class);
35 when(model.getComponentsListModel()).thenReturn(componentlist);
36 BoaParametersModel params = mock(BoaParametersModel.class);
37 when(model.getParameters()).thenReturn(params);
38 when(params.getSetting()).thenReturn(new ArrayList<BOAparameter>());
39
40 RepItem comp1 = mock(RepItem.class);
41 when(comp1.toString()).thenReturn("comp1");
42 RepItem comp2 = mock(RepItem.class);
43 when(comp2.toString()).thenReturn("comp2");
44 RepItem comp3 = mock(RepItem.class);
45 when(comp3.toString()).thenReturn("comp3");
46
47 List<RepItem> allitems = Arrays.asList(new RepItem[] { comp1, comp2, comp3 });
48 when(componentlist.getAllItems()).thenReturn(allitems);
49 when(componentlist.getSelectedItem()).thenReturn(allitems.get(0));
50
51 frame.getContentPane().add(new BoaComponentPanel(model, "test boa component panel"), BorderLayout.CENTER);
52 frame.pack();
53 frame.setVisible(true);
54 Thread.sleep(2000);
55 frame.setVisible(false);
56 }
57
58}
Note: See TracBrowser for help on using the repository browser.