33 */
44package io .github .kubesys .client .core ;
55
6- import static org .junit .Assert .assertEquals ;
6+ import static org .junit .jupiter .api .Assertions .assertEquals ;
7+ import static org .junit .jupiter .api .Assertions .assertThrows ;
78
89import java .util .Arrays ;
910
10- import org .junit .Test ;
11+ import org .junit .jupiter . api . Test ;
1112
1213import com .fasterxml .jackson .databind .ObjectMapper ;
1314import com .fasterxml .jackson .databind .node .ObjectNode ;
@@ -86,80 +87,99 @@ public static void main(String[] args) {
8687 System .out .println (convertor .createUrl (podJson ));
8788 }
8889
89- @ Test (expected = NullPointerException .class )
90- public void testNullCreateURL () {
91- convertor .createUrl (null );
90+ @ Test
91+ void testNullCreateURL () {
92+ assertThrows (NullPointerException .class , () -> {
93+ convertor .createUrl (null );
94+ });
95+
9296 }
9397
94- @ Test (expected = NullPointerException .class )
95- public void testInvalidJsonCreateURL () {
96- convertor .createUrl (new ObjectMapper ().createObjectNode ());
98+ @ Test
99+ void testInvalidJsonCreateURL () {
100+ assertThrows (NullPointerException .class , () -> {
101+ convertor .createUrl (new ObjectMapper ().createObjectNode ());
102+ });
97103 }
98104
99- @ Test (expected = NullPointerException .class )
100- public void testNullBindingURL () {
101- convertor .bindingUrl (null );
105+ @ Test
106+ void testNullBindingURL () {
107+ assertThrows (NullPointerException .class , () -> {
108+ convertor .bindingUrl (null );
109+ });
102110 }
103111
104- @ Test (expected = NullPointerException .class )
105- public void testInvalidJsonBindingURL () {
106- convertor .bindingUrl (new ObjectMapper ().createObjectNode ());
112+ @ Test
113+ void testInvalidJsonBindingURL () {
114+ assertThrows (NullPointerException .class , () -> {
115+ convertor .bindingUrl (new ObjectMapper ().createObjectNode ());
116+ });
107117 }
108118
109- @ Test (expected = NullPointerException .class )
110- public void testNullDeleteKindURL () {
111- convertor .deleteUrl (null , "abc" , "abc" );
119+ @ Test
120+ void testNullDeleteKindURL () {
121+ assertThrows (NullPointerException .class , () -> {
122+ convertor .deleteUrl (null , "abc" , "abc" );
123+ });
112124 }
113125
114- @ Test (expected = NullPointerException .class )
115- public void testNullDeleteNameURL1 () {
116- convertor .deleteUrl ("abc" , "abc" , null );
126+ @ Test
127+ void testNullDeleteNameURL1 () {
128+ assertThrows (NullPointerException .class , () -> {
129+ convertor .deleteUrl ("abc" , "abc" , null );
130+ });
117131 }
118132
119- @ Test (expected = NullPointerException .class )
120- public void testNullDeleteNameURL2 () {
121- convertor .deleteUrl ("abc" , "abc" , "" );
133+ @ Test
134+ void testNullDeleteNameURL2 () {
135+ assertThrows (NullPointerException .class , () -> {
136+ convertor .deleteUrl ("abc" , "abc" , "" );
137+ });
138+
122139 }
123140
124- @ Test (expected = NullPointerException .class )
125- public void testNullListKindURL () {
126- convertor .listUrl (null , "abc" );
141+ @ Test
142+ void testNullListKindURL () {
143+ assertThrows (NullPointerException .class , () -> {
144+ convertor .listUrl (null , "abc" );
145+ });
146+
127147 }
128148
129149 @ Test
130- public void testValidCreateURL () {
150+ void testValidCreateURL () {
131151 assertEquals ("https://39.100.71.73:6443/api/v1/namespaces/kube-system/pods" , convertor .createUrl (podJson ));
132152 assertEquals ("https://39.100.71.73:6443/apis/apps/v1/namespaces/kube-system/deployments" , convertor .createUrl (deployJson ));
133153 assertEquals ("https://39.100.71.73:6443/api/v1/nodes" , convertor .createUrl (nodeJson ));
134154 assertEquals ("https://39.100.71.73:6443/apis/networking.k8s.io/v1/ingressclasses" , convertor .createUrl (igrsJson ));
135155 }
136156
137157 @ Test
138- public void testValidDeleteURL () {
158+ void testValidDeleteURL () {
139159 assertEquals ("https://39.100.71.73:6443/api/v1/namespaces/kube-system/pods/testPod" , convertor .deleteUrl ("Pod" , "kube-system" , "testPod" ));
140160 assertEquals ("https://39.100.71.73:6443/apis/apps/v1/namespaces/kube-system/deployments/testDeploy" , convertor .deleteUrl ("apps.Deployment" , "kube-system" , "testDeploy" ));
141161 assertEquals ("https://39.100.71.73:6443/api/v1/nodes/testNode" , convertor .deleteUrl ("Node" , "" , "testNode" ));
142162 assertEquals ("https://39.100.71.73:6443/apis/networking.k8s.io/v1/ingressclasses/testIngress" , convertor .deleteUrl ("networking.k8s.io.IngressClass" , "" , "testIngress" ));
143163 }
144164
145165 @ Test
146- public void testValidUpdateURL () {
166+ void testValidUpdateURL () {
147167 assertEquals ("https://39.100.71.73:6443/api/v1/namespaces/kube-system/pods/testPod" , convertor .updateUrl ("Pod" , "kube-system" , "testPod" ));
148168 assertEquals ("https://39.100.71.73:6443/apis/apps/v1/namespaces/kube-system/deployments/testDeploy" , convertor .updateUrl ("apps.Deployment" , "kube-system" , "testDeploy" ));
149169 assertEquals ("https://39.100.71.73:6443/api/v1/nodes/testNode" , convertor .updateUrl ("Node" , "" , "testNode" ));
150170 assertEquals ("https://39.100.71.73:6443/apis/networking.k8s.io/v1/ingressclasses/testIngress" , convertor .updateUrl ("networking.k8s.io.IngressClass" , "" , "testIngress" ));
151171 }
152172
153173 @ Test
154- public void testValidGetURL () {
174+ void testValidGetURL () {
155175 assertEquals ("https://39.100.71.73:6443/api/v1/namespaces/kube-system/pods/testPod" , convertor .getUrl ("Pod" , "kube-system" , "testPod" ));
156176 assertEquals ("https://39.100.71.73:6443/apis/apps/v1/namespaces/kube-system/deployments/testDeploy" , convertor .getUrl ("apps.Deployment" , "kube-system" , "testDeploy" ));
157177 assertEquals ("https://39.100.71.73:6443/api/v1/nodes/testNode" , convertor .getUrl ("Node" , "" , "testNode" ));
158178 assertEquals ("https://39.100.71.73:6443/apis/networking.k8s.io/v1/ingressclasses/testIngress" , convertor .getUrl ("networking.k8s.io.IngressClass" , "" , "testIngress" ));
159179 }
160180
161181 @ Test
162- public void testValidListURL () {
182+ void testValidListURL () {
163183 assertEquals ("https://39.100.71.73:6443/api/v1/namespaces/kube-system/pods" , convertor .listUrl ("Pod" , "kube-system" ));
164184 assertEquals ("https://39.100.71.73:6443/api/v1/pods" , convertor .listUrl ("Pod" , "" ));
165185 assertEquals ("https://39.100.71.73:6443/apis/apps/v1/namespaces/kube-system/deployments" , convertor .listUrl ("apps.Deployment" , "kube-system" ));
@@ -169,23 +189,23 @@ public void testValidListURL() {
169189 }
170190
171191 @ Test
172- public void testValidUpdateStatusUrlURL () {
192+ void testValidUpdateStatusUrlURL () {
173193 assertEquals ("https://39.100.71.73:6443/api/v1/namespaces/kube-system/pods/testPod/status" , convertor .updateStatusUrl ("Pod" , "kube-system" , "testPod" ));
174194 assertEquals ("https://39.100.71.73:6443/apis/apps/v1/namespaces/kube-system/deployments/testDeploy/status" , convertor .updateStatusUrl ("apps.Deployment" , "kube-system" , "testDeploy" ));
175195 assertEquals ("https://39.100.71.73:6443/api/v1/nodes/testNode/status" , convertor .updateStatusUrl ("Node" , "" , "testNode" ));
176196 assertEquals ("https://39.100.71.73:6443/apis/networking.k8s.io/v1/ingressclasses/testIngress/status" , convertor .updateStatusUrl ("networking.k8s.io.IngressClass" , "" , "testIngress" ));
177197 }
178198
179199 @ Test
180- public void testValidWatchOneUrlURL () {
200+ void testValidWatchOneUrlURL () {
181201 assertEquals ("https://39.100.71.73:6443/api/v1/watch/namespaces/kube-system/pods/testPod?watch=true&timeoutSeconds=315360000" , convertor .watchOneUrl ("Pod" , "kube-system" , "testPod" ));
182202 assertEquals ("https://39.100.71.73:6443/apis/apps/v1/watch/namespaces/kube-system/deployments/testDeploy?watch=true&timeoutSeconds=315360000" , convertor .watchOneUrl ("apps.Deployment" , "kube-system" , "testDeploy" ));
183203 assertEquals ("https://39.100.71.73:6443/api/v1/watch/nodes/testNode?watch=true&timeoutSeconds=315360000" , convertor .watchOneUrl ("Node" , "" , "testNode" ));
184204 assertEquals ("https://39.100.71.73:6443/apis/networking.k8s.io/v1/watch/ingressclasses/testIngress?watch=true&timeoutSeconds=315360000" , convertor .watchOneUrl ("networking.k8s.io.IngressClass" , "" , "testIngress" ));
185205 }
186206
187207 @ Test
188- public void testValidWatchAllUrlURL () {
208+ void testValidWatchAllUrlURL () {
189209 assertEquals ("https://39.100.71.73:6443/api/v1/watch/namespaces/kube-system/pods?watch=true&timeoutSeconds=315360000" , convertor .watchAllUrl ("Pod" , "kube-system" ));
190210 assertEquals ("https://39.100.71.73:6443/api/v1/watch/pods?watch=true&timeoutSeconds=315360000" , convertor .watchAllUrl ("Pod" , "" ));
191211 assertEquals ("https://39.100.71.73:6443/apis/apps/v1/watch/namespaces/kube-system/deployments?watch=true&timeoutSeconds=315360000" , convertor .watchAllUrl ("apps.Deployment" , "kube-system" ));
0 commit comments