11package de .westemeyer .plugins .multiselect ;
22
3- import org .junit .jupiter .api .Assertions ;
43import org .junit .jupiter .api .Test ;
54
5+ import java .util .ArrayDeque ;
6+ import java .util .Collections ;
7+ import java .util .Queue ;
8+
9+ import static org .junit .jupiter .api .Assertions .*;
10+ import static org .mockito .ArgumentMatchers .any ;
11+ import static org .mockito .Mockito .*;
12+
613class MultiselectDecisionItemTest {
714 /** Input to be used in tests. */
815 private static final MultiselectDecisionTree INPUT = MultiselectDecisionTree .parse ("H,Type,Sport,Country,Team\n V,SELECTED_TYPE,SELECTED_SPORT,SELECTED_COUNTRY,SELECTED_TEAM\n C,Water,Wakeboarding,Germany,WSC Duisburg Rheinhausen\n C,Water,Wakeboarding,Germany,WSC Paderborn\n C,Water,Wakeboarding,Austria,WSC Wien\n T,,,,Alternative team name\n C,Water,Waterball,Germany,Waterball Team\n C,Water,Surfing,England,Bristol Surf Team\n C,Ball,Football,France,Paris St. Germain\n T,,,,Alternative team name\n C,Ball,Handball,Germany,THW Kiel\n " );
@@ -17,71 +24,90 @@ class MultiselectDecisionItemTest {
1724 private static final String NEW_VALUE = "New value" ;
1825
1926 @ Test
20- void getDisplayLabel () throws Exception {
27+ void getDisplayLabel () {
2128 MultiselectDecisionItem item = INPUT .getItemByCoordinates (0 , 1 , 0 , 0 );
22- Assertions . assertEquals (ALTERNATIVE_TEAM_NAME , item .getDisplayLabel ());
29+ assertEquals (ALTERNATIVE_TEAM_NAME , item .getDisplayLabel ());
2330 item = INPUT .getItemByCoordinates (0 , 0 , 0 , 0 );
24- Assertions .assertEquals (WSC_DUISBURG_RHEINHAUSEN , item .getDisplayLabel ());
31+ assertEquals (WSC_DUISBURG_RHEINHAUSEN , item .getDisplayLabel ());
32+ item = new MultiselectDecisionItem (null , null , null );
33+ assertNull (item .getDisplayLabel ());
2534 }
2635
2736 @ Test
28- void getParent () throws Exception {
37+ void getParent () {
2938 MultiselectDecisionItem item = INPUT .getItemByCoordinates (0 , 0 );
3039 item = item .getParent ();
31- Assertions .assertNotNull (item );
32- Assertions .assertNull (item .getParent ());
40+ assertNotNull (item );
41+ assertNull (item .getParent ());
42+ }
43+
44+ @ Test
45+ void nvl () {
46+ assertEquals ("MultiselectDecisionItem{label='', value='null', children=[]}" , new MultiselectDecisionItem (null , null , null ).toString ());
47+ assertEquals ("MultiselectDecisionItem{label='label', value='null', children=[]}" , new MultiselectDecisionItem (null , "label" , null ).toString ());
3348 }
3449
3550 @ Test
36- void isRoot () throws Exception {
51+ void isRoot () {
3752 MultiselectDecisionItem item = INPUT .getItemByCoordinates (0 , 0 );
38- Assertions . assertFalse (item .isRoot ());
53+ assertFalse (item .isRoot ());
3954 item = item .getParent ();
40- Assertions . assertTrue (item .isRoot ());
55+ assertTrue (item .isRoot ());
4156 }
4257
4358 @ Test
44- void getChildren () throws Exception {
59+ void getChildren () {
4560 MultiselectDecisionItem item = INPUT .getItemByCoordinates (0 , 0 , 0 );
4661 item = item .getChildren ().get (0 );
47- Assertions . assertEquals (0 , item .getChildren ().size ());
62+ assertEquals (0 , item .getChildren ().size ());
4863 }
4964
5065 @ Test
51- void isLeaf () throws Exception {
66+ void isLeaf () {
5267 MultiselectDecisionItem item = INPUT .getItemByCoordinates (0 , 0 , 0 );
53- Assertions . assertFalse (item .isLeaf ());
68+ assertFalse (item .isLeaf ());
5469 item = item .getChildren ().get (0 );
55- Assertions . assertTrue (item .isLeaf ());
70+ assertTrue (item .isLeaf ());
5671 }
5772
5873 @ Test
59- void getLabel () throws Exception {
74+ void getLabel () {
6075 MultiselectDecisionItem item = INPUT .getItemByCoordinates (0 , 0 , 0 , 0 );
61- Assertions . assertEquals ("" , item .getLabel ());
76+ assertEquals ("" , item .getLabel ());
6277 item = INPUT .getItemByCoordinates (0 , 1 , 0 , 0 );
63- Assertions . assertEquals (ALTERNATIVE_TEAM_NAME , item .getLabel ());
78+ assertEquals (ALTERNATIVE_TEAM_NAME , item .getLabel ());
6479 }
6580
6681 @ Test
67- void value () throws Exception {
82+ void value () {
6883 MultiselectDecisionItem item = INPUT .getItemByCoordinates (0 , 0 , 0 , 0 );
69- Assertions . assertEquals (WSC_DUISBURG_RHEINHAUSEN , item .getValue ());
84+ assertEquals (WSC_DUISBURG_RHEINHAUSEN , item .getValue ());
7085 item .setValue (NEW_VALUE );
71- Assertions . assertEquals (NEW_VALUE , item .getValue ());
86+ assertEquals (NEW_VALUE , item .getValue ());
7287 }
7388
7489 @ Test
75- void testToString () throws Exception {
90+ void testToString () {
7691 MultiselectDecisionItem item = INPUT .getItemByCoordinates (0 , 0 , 0 , 0 );
77- Assertions . assertEquals ("MultiselectDecisionItem{label='', value='WSC Duisburg Rheinhausen', children=[]}" , item .toString ());
92+ assertEquals ("MultiselectDecisionItem{label='', value='WSC Duisburg Rheinhausen', children=[]}" , item .toString ());
7893 }
7994
8095 @ Test
8196 void testSetter () {
8297 MultiselectDecisionItem item = new MultiselectDecisionItem (null , "Hello" , "Value" );
83- Assertions . assertEquals ("Hello" , item .getLabel ());
98+ assertEquals ("Hello" , item .getLabel ());
8499 item .setLabel ("Hullo" );
85- Assertions .assertEquals ("Hullo" , item .getLabel ());
100+ assertEquals ("Hullo" , item .getLabel ());
101+ }
102+
103+ @ Test
104+ void visitSubTree () throws Exception {
105+ MultiselectDecisionItemVisitor visitor = (item , column ) -> false ;
106+ MultiselectVariableDescriptor descriptor = new MultiselectVariableDescriptor ("" , "" , 0 );
107+ Queue <MultiselectVariableDescriptor > descriptors = new ArrayDeque <>();
108+ descriptors .add (descriptor );
109+ MultiselectDecisionItem item = mock (MultiselectDecisionItem .class );
110+ MultiselectDecisionItem .visitSubTree (visitor , Collections .singletonList (item ), descriptors );
111+ verify (item , times (0 )).visitSubTree (any (), any ());
86112 }
87113}
0 commit comments