Skip to content

Commit d04f2fe

Browse files
committed
tidy: reformat unit tests
1 parent 7179673 commit d04f2fe

1 file changed

Lines changed: 144 additions & 144 deletions

File tree

Lines changed: 144 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -1,153 +1,153 @@
11
package io.snyk.eclipse.plugin.views.snyktoolview;
22

3-
import static org.junit.jupiter.api.Assertions.*;
4-
import static org.mockito.Mockito.*;
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.junit.jupiter.api.Assertions.assertNotNull;
5+
import static org.junit.jupiter.api.Assertions.assertNull;
6+
import static org.mockito.Mockito.mock;
57

68
import java.util.Arrays;
7-
import org.junit.jupiter.api.BeforeEach;
8-
import org.junit.jupiter.api.Test;
9+
910
import org.eclipse.jface.resource.ImageDescriptor;
1011
import org.eclipse.jface.viewers.TreeNode;
12+
import org.junit.jupiter.api.BeforeEach;
13+
import org.junit.jupiter.api.Test;
1114

1215
class BaseTreeNodeTest {
13-
private BaseTreeNode node;
14-
private ImageDescriptor mockImageDescriptor;
15-
16-
@BeforeEach
17-
void setUp() {
18-
node = new BaseTreeNode("root");
19-
mockImageDescriptor = mock(ImageDescriptor.class);
20-
}
21-
22-
@Test
23-
void testConstructorWithString() {
24-
assertEquals("root", node.getText());
25-
assertEquals("root", node.getValue());
26-
}
27-
28-
@Test
29-
void testConstructorWithNonString() {
30-
Integer value = 42;
31-
BaseTreeNode intNode = new BaseTreeNode(value);
32-
assertEquals("", intNode.getText());
33-
assertEquals(value, intNode.getValue());
34-
}
35-
36-
@Test
37-
void testSetValue() {
38-
String newValue = "newValue";
39-
node.setValue(newValue);
40-
assertEquals(newValue, node.getValue());
41-
}
42-
43-
@Test
44-
void testAddChildToEmptyNode() {
45-
BaseTreeNode child = new BaseTreeNode("child1");
46-
node.addChild(child);
47-
48-
TreeNode[] children = node.getChildren();
49-
assertNotNull(children);
50-
assertEquals(1, children.length);
51-
assertEquals(child, children[0]);
52-
}
53-
54-
@Test
55-
void testAddChildToNodeWithExistingChildren() {
56-
BaseTreeNode child1 = new BaseTreeNode("child1");
57-
BaseTreeNode child2 = new BaseTreeNode("child2");
58-
59-
node.addChild(child1);
60-
node.addChild(child2);
61-
62-
TreeNode[] children = node.getChildren();
63-
assertNotNull(children);
64-
assertEquals(2, children.length);
65-
assertEquals(child1, children[0]);
66-
assertEquals(child2, children[1]);
67-
}
68-
69-
@Test
70-
void testRemoveChildren() {
71-
BaseTreeNode child = new BaseTreeNode("child");
72-
node.addChild(child);
73-
74-
node.removeChildren();
75-
76-
TreeNode[] children = node.getChildren();
77-
assertNotNull(children);
78-
assertEquals(0, children.length);
79-
}
80-
81-
@Test
82-
void testSetAndGetImageDescriptor() {
83-
node.setImageDescriptor(mockImageDescriptor);
84-
assertEquals(mockImageDescriptor, node.getImageDescriptor());
85-
}
86-
87-
@Test
88-
void testSetAndGetText() {
89-
String newText = "newText";
90-
node.setText(newText);
91-
assertEquals(newText, node.getText());
92-
}
93-
94-
@Test
95-
void testToString() {
96-
assertEquals("root", node.toString());
97-
98-
Integer value = 42;
99-
BaseTreeNode intNode = new BaseTreeNode(value);
100-
assertEquals("42", intNode.toString());
101-
}
102-
103-
@Test
104-
void testReset() {
105-
// Setup initial state
106-
node.setText("someText");
107-
node.setImageDescriptor(mockImageDescriptor);
108-
node.addChild(new BaseTreeNode("child"));
109-
110-
// Reset the node
111-
node.reset();
112-
113-
// Verify all fields are reset
114-
assertNull(node.getValue());
115-
assertEquals("", node.getText());
116-
assertNull(node.getImageDescriptor());
117-
assertEquals(0, node.getChildren().length);
118-
}
119-
120-
@Test
121-
void testAddMultipleChildren() {
122-
BaseTreeNode[] children = new BaseTreeNode[] {
123-
new BaseTreeNode("child1"),
124-
new BaseTreeNode("child2"),
125-
new BaseTreeNode("child3")
126-
};
127-
128-
Arrays.stream(children).forEach(node::addChild);
129-
130-
TreeNode[] resultChildren = node.getChildren();
131-
assertNotNull(resultChildren);
132-
assertEquals(children.length, resultChildren.length);
133-
134-
for (int i = 0; i < children.length; i++) {
135-
assertEquals(children[i], resultChildren[i]);
136-
}
137-
}
138-
139-
@Test
140-
void testAddChildAfterRemovingChildren() {
141-
BaseTreeNode child1 = new BaseTreeNode("child1");
142-
node.addChild(child1);
143-
node.removeChildren();
144-
145-
BaseTreeNode child2 = new BaseTreeNode("child2");
146-
node.addChild(child2);
147-
148-
TreeNode[] children = node.getChildren();
149-
assertNotNull(children);
150-
assertEquals(1, children.length);
151-
assertEquals(child2, children[0]);
152-
}
16+
private BaseTreeNode node;
17+
private ImageDescriptor mockImageDescriptor;
18+
19+
@BeforeEach
20+
void setUp() {
21+
node = new BaseTreeNode("root");
22+
mockImageDescriptor = mock(ImageDescriptor.class);
23+
}
24+
25+
@Test
26+
void testConstructorWithString() {
27+
assertEquals("root", node.getText());
28+
assertEquals("root", node.getValue());
29+
}
30+
31+
@Test
32+
void testConstructorWithNonString() {
33+
Integer value = 42;
34+
BaseTreeNode intNode = new BaseTreeNode(value);
35+
assertEquals("", intNode.getText());
36+
assertEquals(value, intNode.getValue());
37+
}
38+
39+
@Test
40+
void testSetValue() {
41+
String newValue = "newValue";
42+
node.setValue(newValue);
43+
assertEquals(newValue, node.getValue());
44+
}
45+
46+
@Test
47+
void testAddChildToEmptyNode() {
48+
BaseTreeNode child = new BaseTreeNode("child1");
49+
node.addChild(child);
50+
51+
TreeNode[] children = node.getChildren();
52+
assertNotNull(children);
53+
assertEquals(1, children.length);
54+
assertEquals(child, children[0]);
55+
}
56+
57+
@Test
58+
void testAddChildToNodeWithExistingChildren() {
59+
BaseTreeNode child1 = new BaseTreeNode("child1");
60+
BaseTreeNode child2 = new BaseTreeNode("child2");
61+
62+
node.addChild(child1);
63+
node.addChild(child2);
64+
65+
TreeNode[] children = node.getChildren();
66+
assertNotNull(children);
67+
assertEquals(2, children.length);
68+
assertEquals(child1, children[0]);
69+
assertEquals(child2, children[1]);
70+
}
71+
72+
@Test
73+
void testRemoveChildren() {
74+
BaseTreeNode child = new BaseTreeNode("child");
75+
node.addChild(child);
76+
77+
node.removeChildren();
78+
79+
TreeNode[] children = node.getChildren();
80+
assertNotNull(children);
81+
assertEquals(0, children.length);
82+
}
83+
84+
@Test
85+
void testSetAndGetImageDescriptor() {
86+
node.setImageDescriptor(mockImageDescriptor);
87+
assertEquals(mockImageDescriptor, node.getImageDescriptor());
88+
}
89+
90+
@Test
91+
void testSetAndGetText() {
92+
String newText = "newText";
93+
node.setText(newText);
94+
assertEquals(newText, node.getText());
95+
}
96+
97+
@Test
98+
void testToString() {
99+
assertEquals("root", node.toString());
100+
101+
Integer value = 42;
102+
BaseTreeNode intNode = new BaseTreeNode(value);
103+
assertEquals("42", intNode.toString());
104+
}
105+
106+
@Test
107+
void testReset() {
108+
// Setup initial state
109+
node.setText("someText");
110+
node.setImageDescriptor(mockImageDescriptor);
111+
node.addChild(new BaseTreeNode("child"));
112+
113+
// Reset the node
114+
node.reset();
115+
116+
// Verify all fields are reset
117+
assertNull(node.getValue());
118+
assertEquals("", node.getText());
119+
assertNull(node.getImageDescriptor());
120+
assertEquals(0, node.getChildren().length);
121+
}
122+
123+
@Test
124+
void testAddMultipleChildren() {
125+
BaseTreeNode[] children = new BaseTreeNode[] { new BaseTreeNode("child1"), new BaseTreeNode("child2"),
126+
new BaseTreeNode("child3") };
127+
128+
Arrays.stream(children).forEach(node::addChild);
129+
130+
TreeNode[] resultChildren = node.getChildren();
131+
assertNotNull(resultChildren);
132+
assertEquals(children.length, resultChildren.length);
133+
134+
for (int i = 0; i < children.length; i++) {
135+
assertEquals(children[i], resultChildren[i]);
136+
}
137+
}
138+
139+
@Test
140+
void testAddChildAfterRemovingChildren() {
141+
BaseTreeNode child1 = new BaseTreeNode("child1");
142+
node.addChild(child1);
143+
node.removeChildren();
144+
145+
BaseTreeNode child2 = new BaseTreeNode("child2");
146+
node.addChild(child2);
147+
148+
TreeNode[] children = node.getChildren();
149+
assertNotNull(children);
150+
assertEquals(1, children.length);
151+
assertEquals(child2, children[0]);
152+
}
153153
}

0 commit comments

Comments
 (0)