2
2
3
3
import java .net .HttpURLConnection ;
4
4
import java .util .ArrayList ;
5
+ import java .util .Arrays ;
5
6
import java .util .Collection ;
6
7
import java .util .List ;
7
8
@@ -41,23 +42,23 @@ public void tearDown() throws Exception {
41
42
42
43
@ Test
43
44
public void whenCollectionEmpty_makeNoCalls () throws Exception {
44
- runStep ();
45
+ runDeleteStep ();
45
46
}
46
47
47
- private void runStep () {
48
- testSupport .runStep (new DeleteIngressListStep (ingresses , terminalStep ));
48
+ private void runDeleteStep (V1beta1Ingress ... ingresses ) {
49
+ this .ingresses .addAll (Arrays .asList (ingresses ));
50
+ testSupport .runStep (new DeleteIngressListStep (this .ingresses , terminalStep ));
49
51
}
50
52
51
53
@ Test
52
54
public void whenCollectionContainsItems_invokeDeleteCalls () throws Exception {
53
55
defineResponse ("namespace1" , "name1" ).returning (new V1Status ());
54
56
defineResponse ("namespace2" , "name2" ).returning (new V1Status ());
55
- ingresses .add (new V1beta1Ingress ().metadata (new V1ObjectMeta ().namespace ("namespace1" ).name ("name1" )));
56
- ingresses .add (new V1beta1Ingress ().metadata (new V1ObjectMeta ().namespace ("namespace2" ).name ("name2" )));
57
57
58
- runStep ();
58
+ runDeleteStep (new V1beta1Ingress ().metadata (new V1ObjectMeta ().namespace ("namespace1" ).name ("name1" )),
59
+ new V1beta1Ingress ().metadata (new V1ObjectMeta ().namespace ("namespace2" ).name ("name2" )));
59
60
60
- testSupport .verify ();
61
+ testSupport .verifyAllDefinedResponsesInvoked ();
61
62
}
62
63
63
64
@ SuppressWarnings ("unchecked" )
@@ -68,18 +69,16 @@ private <T> AsyncCallTestSupport.CannedResponse<T> defineResponse(String namespa
68
69
@ Test
69
70
public void onFailureResponse_reportError () throws Exception {
70
71
defineResponse ("namespace1" , "name1" ).failingWithStatus (HttpURLConnection .HTTP_FORBIDDEN );
71
- ingresses .add (new V1beta1Ingress ().metadata (new V1ObjectMeta ().namespace ("namespace1" ).name ("name1" )));
72
72
73
- runStep ( );
73
+ runDeleteStep ( new V1beta1Ingress (). metadata ( new V1ObjectMeta (). namespace ( "namespace1" ). name ( "name1" )) );
74
74
75
75
testSupport .verifyCompletionThrowable (ApiException .class );
76
76
}
77
77
78
78
@ Test
79
79
public void onNotFoundResponse_dontReportError () throws Exception {
80
80
defineResponse ("namespace1" , "name1" ).failingWithStatus (HttpURLConnection .HTTP_NOT_FOUND );
81
- ingresses .add (new V1beta1Ingress ().metadata (new V1ObjectMeta ().namespace ("namespace1" ).name ("name1" )));
82
81
83
- runStep ( );
82
+ runDeleteStep ( new V1beta1Ingress (). metadata ( new V1ObjectMeta (). namespace ( "namespace1" ). name ( "name1" )) );
84
83
}
85
84
}
0 commit comments