source: domaineditor/src/test/java/geniusweb/panels/ComboBoxTest.java@ 53

Last change on this file since 53 was 53, checked in by ruud, 4 days ago

All TimeDependent parties now support the nonlinear SumOfGroupsUtilitySpace. Example Nonlinear space in the computer domain

File size: 3.5 KB
Line 
1package geniusweb.panels;
2
3import static org.mockito.Mockito.mock;
4
5import java.awt.BorderLayout;
6import java.util.Arrays;
7import java.util.Collections;
8import java.util.Map;
9
10import javax.swing.JFrame;
11import javax.swing.JPanel;
12import javax.swing.JSeparator;
13
14import org.junit.Test;
15
16import geniusweb.domaineditor.ProfileEditor;
17import geniusweb.domaineditor.model.DiscreteValueSetModel;
18import geniusweb.domaineditor.model.DomainModel;
19import geniusweb.domaineditor.model.ValueSetModel;
20import tudelft.utilities.logging.Reporter;
21import tudelft.utilities.mvc.model.DefaultListModel;
22import tudelft.utilities.mvc.model.DefaultMapModel;
23import tudelft.utilities.mvc.model.DefaultSelectionModel;
24import tudelft.utilities.mvc.model.MapModel;
25import tudelft.utilities.mvc.model.SelectionModel;
26import tudelft.utilities.mvc.model.StringModel;
27import tudelft.utilities.mvc.panels.ComboBox;
28
29public class ComboBoxTest {
30 private Reporter log = mock(Reporter.class);
31
32 @Test
33 public void GuiTest() throws InterruptedException {
34
35 StringModel a = new StringModel("apples", log, ProfileEditor.TIME);
36 StringModel b = new StringModel("bears", log, ProfileEditor.TIME);
37 StringModel c = new StringModel("carrots", log, ProfileEditor.TIME);
38
39 JFrame f = new JFrame();
40 JPanel panel = new JPanel(new BorderLayout());
41 f.getContentPane().add(panel);
42 DefaultListModel<StringModel> model = new DefaultListModel(
43 Arrays.asList(a, b, c), log, ProfileEditor.TIME);
44 DefaultSelectionModel<StringModel> selectionmodel1 = new DefaultSelectionModel(
45 model, log, true);
46 panel.add(new ComboBox<StringModel>(selectionmodel1),
47 BorderLayout.NORTH);
48 panel.add(new JSeparator(), BorderLayout.CENTER);
49 panel.add(new ComboBox<StringModel>(selectionmodel1),
50 BorderLayout.SOUTH);
51 f.pack();
52 f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
53 f.setVisible(true);
54 Thread.sleep(10000);
55 f.setVisible(false);
56 }
57
58 @Test
59 public void testEqualsDeep() {
60
61 StringModel redvalue = new StringModel("red", log, ProfileEditor.TIME);
62 StringModel greenvalue = new StringModel("green", log,
63 ProfileEditor.TIME);
64 DiscreteValueSetModel issue1values = new DiscreteValueSetModel(
65 Arrays.asList(redvalue, greenvalue), log);
66
67 StringModel issue1 = new StringModel("issue", log, ProfileEditor.TIME);
68
69 SelectionModel issue1valuessel = new DefaultSelectionModel(issue1values,
70 log, true);
71 Map<StringModel, SelectionModel> a = Collections.singletonMap(issue1,
72 issue1valuessel);
73 DefaultMapModel<StringModel, SelectionModel> issuevalues = new DefaultMapModel<StringModel, SelectionModel>(
74 a, log, ProfileEditor.TIME) {
75
76 @Override
77 public String getColumnName(int n) {
78 return n == 0 ? "issue" : "value";
79 }
80
81 @Override
82 public SelectionModel create(StringModel key) {
83 throw new UnsupportedOperationException();
84 }
85
86 @Override
87 public int getMinimumSize() {
88 return 1;
89 }
90
91 };
92
93 MapModel<StringModel, ValueSetModel> issuevaluesmodel = new DefaultMapModel<StringModel, ValueSetModel>(
94 Collections.singletonMap(issue1, issue1values), log,
95 ProfileEditor.TIME) {
96
97 @Override
98 public String getColumnName(int n) {
99 return n == 0 ? "issue" : "value";
100 }
101
102 @Override
103 public int getMinimumSize() {
104 return 1;
105 }
106
107 @Override
108 public ValueSetModel create(StringModel key) {
109 throw new UnsupportedOperationException();
110 }
111
112 };
113 DomainModel domain = new DomainModel(
114 new StringModel("testdomain", log, ProfileEditor.TIME),
115 issuevaluesmodel, log);
116
117 // TODO test equals functions in ComboBoxModel
118 }
119}
Note: See TracBrowser for help on using the repository browser.