|
@@ -155,7 +155,7 @@ public class PromiseTest {
|
155
|
155
|
}
|
156
|
156
|
|
157
|
157
|
@Test
|
158
|
|
- public void mapTest()
|
|
158
|
+ public void mapTestResolve()
|
159
|
159
|
{
|
160
|
160
|
LuPromise<Integer> promise = new LuPromise<>();
|
161
|
161
|
final int[] result = new int[1];
|
|
@@ -176,6 +176,31 @@ public class PromiseTest {
|
176
|
176
|
}
|
177
|
177
|
});
|
178
|
178
|
promise.resolve(42);
|
179
|
|
- assertEquals(result[0], 4242);
|
|
179
|
+ assertEquals(4242, result[0]);
|
|
180
|
+ }
|
|
181
|
+
|
|
182
|
+ @Test
|
|
183
|
+ public void mapTestReject()
|
|
184
|
+ {
|
|
185
|
+ LuPromise<Integer> promise = new LuPromise<>();
|
|
186
|
+ final int[] result = new int[1];
|
|
187
|
+ promise.map(new LuConverter<Integer, Boolean>() {
|
|
188
|
+ @Override
|
|
189
|
+ public Boolean convert(Integer data) {
|
|
190
|
+ return data == 42;
|
|
191
|
+ }
|
|
192
|
+ }).then(new LuConsumer<Boolean>() {
|
|
193
|
+ @Override
|
|
194
|
+ public void execute(Boolean data) {
|
|
195
|
+ result[0] = data ? 4242 : 2424;
|
|
196
|
+ }
|
|
197
|
+ }, new LuConsumer<LuPromiseError>() {
|
|
198
|
+ @Override
|
|
199
|
+ public void execute(LuPromiseError data) {
|
|
200
|
+ result[0] = 2442;
|
|
201
|
+ }
|
|
202
|
+ });
|
|
203
|
+ promise.reject(null);
|
|
204
|
+ assertEquals(2442, result[0]);
|
180
|
205
|
}
|
181
|
206
|
}
|