15
15
import com .ibm .cloud .sdk .core .http .RequestBuilder ;
16
16
import com .ibm .cloud .sdk .core .http .Response ;
17
17
import com .ibm .cloud .sdk .core .http .ServiceCall ;
18
- import com .ibm .cloud .sdk .core .http .ServiceCallbackWithDetails ;
18
+ import com .ibm .cloud .sdk .core .http .ServiceCallback ;
19
19
import com .ibm .cloud .sdk .core .service .BaseService ;
20
20
import com .ibm .cloud .sdk .core .service .model .GenericModel ;
21
21
import com .ibm .cloud .sdk .core .test .BaseServiceUnitTest ;
@@ -84,30 +84,30 @@ public void setUp() throws Exception {
84
84
}
85
85
86
86
/**
87
- * Test that all fields are populated when calling executeWithDetails ().
87
+ * Test that all fields are populated when calling execute ().
88
88
*
89
89
* @throws InterruptedException the interrupted exception
90
90
*/
91
91
@ Test
92
- public void testExecuteWithDetails () throws InterruptedException {
92
+ public void testExecute () throws InterruptedException {
93
93
server .enqueue (new MockResponse ().setBody (testResponseBody ));
94
94
95
- Response <TestModel > response = service .testMethod ().executeWithDetails ();
95
+ Response <TestModel > response = service .testMethod ().execute ();
96
96
assertNotNull (response .getResult ());
97
97
assertEquals (testResponseValue , response .getResult ().getKey ());
98
98
assertNotNull (response .getHeaders ());
99
99
}
100
100
101
101
/**
102
- * Test that all fields are populated when calling enqueueWithDetails ().
102
+ * Test that all fields are populated when calling enqueue ().
103
103
*
104
104
* @throws InterruptedException the interrupted exception
105
105
*/
106
106
@ Test
107
- public void testEnqueueWithDetails () throws InterruptedException {
107
+ public void testEnqueue () throws InterruptedException {
108
108
server .enqueue (new MockResponse ().setBody (testResponseBody ));
109
109
110
- service .testMethod ().enqueueWithDetails (new ServiceCallbackWithDetails <TestModel >() {
110
+ service .testMethod ().enqueue (new ServiceCallback <TestModel >() {
111
111
@ Override
112
112
public void onResponse (Response <TestModel > response ) {
113
113
assertNotNull (response .getResult ());
@@ -126,37 +126,14 @@ public void onFailure(Exception e) { }
126
126
public void testReactiveRequest () throws InterruptedException {
127
127
server .enqueue (new MockResponse ().setBody (testResponseBody ));
128
128
129
- final TestModel [] responseValue = new TestModel [1 ];
130
- Single <TestModel > observableRequest = service .testMethod ().reactiveRequest ();
131
-
132
- observableRequest
133
- .subscribeOn (Schedulers .single ())
134
- .subscribe (new Consumer <TestModel >() {
135
- @ Override
136
- public void accept (TestModel testModel ) throws Exception {
137
- responseValue [0 ] = testModel ;
138
- }
139
- });
140
-
141
- // asynchronous, so test that we continued without a value yet
142
- assertNull (responseValue [0 ]);
143
- Thread .sleep (2000 );
144
- assertNotNull (responseValue [0 ]);
145
- assertEquals (testResponseValue , responseValue [0 ].getKey ());
146
- }
147
-
148
- @ Test
149
- public void testReactiveRequestWithDetails () throws InterruptedException {
150
- server .enqueue (new MockResponse ().setBody (testResponseBody ));
151
-
152
- Single <Response <TestModel >> observableRequest = service .testMethod ().reactiveRequestWithDetails ();
129
+ Single <Response <TestModel >> observableRequest = service .testMethod ().reactiveRequest ();
153
130
154
131
observableRequest
155
132
.subscribeOn (Schedulers .single ())
156
133
.subscribe (new Consumer <Response <TestModel >>() {
157
134
@ Override
158
- public void accept (Response <TestModel > testModel ) throws Exception {
159
- testResponseModel = testModel ;
135
+ public void accept (Response <TestModel > response ) throws Exception {
136
+ testResponseModel = response ;
160
137
}
161
138
});
162
139
@@ -169,19 +146,19 @@ public void accept(Response<TestModel> testModel) throws Exception {
169
146
}
170
147
171
148
/**
172
- * Test that headers are accessible from a HEAD method call using executeWithDetails ().
149
+ * Test that headers are accessible from a HEAD method call using execute ().
173
150
*
174
151
* @throws InterruptedException the interrupted exception
175
152
*/
176
153
@ Test
177
- public void testExecuteWithDetailsForHead () throws InterruptedException {
154
+ public void testExecuteForHead () throws InterruptedException {
178
155
Headers rawHeaders = Headers .of ("Content-Length" , "472" , "Content-Type" , "application/json"
179
156
, "Server" , "Mock" );
180
157
com .ibm .cloud .sdk .core .http .Headers expectedHeaders =
181
158
new com .ibm .cloud .sdk .core .http .Headers (rawHeaders );
182
159
server .enqueue (new MockResponse ().setHeaders (rawHeaders ));
183
160
184
- Response <Void > response = service .testHeadMethod ().executeWithDetails ();
161
+ Response <Void > response = service .testHeadMethod ().execute ();
185
162
com .ibm .cloud .sdk .core .http .Headers actualHeaders = response .getHeaders ();
186
163
System .out .print (actualHeaders .equals (expectedHeaders ));
187
164
assertNull (response .getResult ());
0 commit comments