|
1 | 1 | /*
|
2 |
| - * Copyright 2020-2021 the original author or authors. |
| 2 | + * Copyright 2020-2022 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -33,18 +33,38 @@ class CloseableIteratorUnitTests {
|
33 | 33 | @Test // DATACMNS-1637
|
34 | 34 | void shouldCreateStream() {
|
35 | 35 |
|
36 |
| - var iterator = new CloseableIteratorImpl<String>(Arrays.asList("1", "2", "3").iterator()); |
| 36 | + var iterator = new CloseableIteratorImpl<>(Arrays.asList("1", "2", "3").iterator()); |
37 | 37 |
|
38 | 38 | var collection = iterator.stream().map(it -> "hello " + it).collect(Collectors.toList());
|
39 | 39 |
|
40 | 40 | assertThat(collection).contains("hello 1", "hello 2", "hello 3");
|
41 | 41 | assertThat(iterator.closed).isFalse();
|
42 | 42 | }
|
43 | 43 |
|
| 44 | + @Test // GH-2519 |
| 45 | + void shouldCount() { |
| 46 | + |
| 47 | + var iterator = new CloseableIteratorImpl<>(Arrays.asList("1", "2", "3").iterator()); |
| 48 | + |
| 49 | + var count = iterator.stream().count(); |
| 50 | + |
| 51 | + assertThat(count).isEqualTo(3); |
| 52 | + } |
| 53 | + |
| 54 | + @Test // GH-2519 |
| 55 | + void shouldApplyToList() { |
| 56 | + |
| 57 | + var iterator = new CloseableIteratorImpl<>(Arrays.asList("1", "2", "3").iterator()); |
| 58 | + |
| 59 | + var list = iterator.stream().toList(); |
| 60 | + |
| 61 | + assertThat(list).isEqualTo(Arrays.asList("1", "2", "3")); |
| 62 | + } |
| 63 | + |
44 | 64 | @Test // DATACMNS-1637
|
45 | 65 | void closeStreamShouldCloseIterator() {
|
46 | 66 |
|
47 |
| - var iterator = new CloseableIteratorImpl<String>(Arrays.asList("1", "2", "3").iterator()); |
| 67 | + var iterator = new CloseableIteratorImpl<>(Arrays.asList("1", "2", "3").iterator()); |
48 | 68 |
|
49 | 69 | try (var stream = iterator.stream()) {
|
50 | 70 | assertThat(stream.findFirst()).hasValue("1");
|
|
0 commit comments