Skip to content

Commit 124ea3f

Browse files
committed
- fix failed tests
1 parent 8fe29e2 commit 124ea3f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+116
-151
lines changed

pom.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@
5151

5252
<dependencyManagement>
5353
<dependencies>
54+
<dependency>
55+
<groupId>org.apache.logging.log4j</groupId>
56+
<artifactId>log4j-bom</artifactId>
57+
<version>2.22.0</version>
58+
<type>pom</type>
59+
<scope>import</scope>
60+
</dependency>
5461
<dependency>
5562
<groupId>io.vertx</groupId>
5663
<artifactId>vertx-stack-depchain</artifactId>
@@ -228,8 +235,7 @@
228235
</dependency>
229236
<dependency> <!-- for testcontainers -->
230237
<groupId>org.apache.logging.log4j</groupId>
231-
<artifactId>log4j-slf4j-impl</artifactId>
232-
<version>2.22.1</version>
238+
<artifactId>log4j-slf4j2-impl</artifactId>
233239
<scope>test</scope>
234240
</dependency>
235241
</dependencies>
@@ -242,6 +248,7 @@
242248

243249
<plugins>
244250
<plugin>
251+
<groupId>org.apache.maven.plugins</groupId>
245252
<artifactId>maven-compiler-plugin</artifactId>
246253
<version>${maven-compiler-plugin.version}</version>
247254
<configuration>

src/main/java/org/folio/rest/impl/InstanceStorageBatchApi.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@
1010

1111
import com.google.common.collect.Lists;
1212
import io.vertx.core.AsyncResult;
13-
import io.vertx.core.CompositeFuture;
1413
import io.vertx.core.Context;
1514
import io.vertx.core.Future;
1615
import io.vertx.core.Handler;
1716
import java.util.ArrayList;
1817
import java.util.List;
1918
import java.util.Map;
2019
import java.util.function.Function;
21-
import java.util.stream.Collectors;
2220
import javax.ws.rs.core.Response;
2321
import org.apache.logging.log4j.LogManager;
2422
import org.apache.logging.log4j.Logger;
@@ -102,12 +100,12 @@ public void postInstanceStorageBatchInstances(Instances entity,
102100
* @return succeeded future containing the list of completed (failed and succeeded)
103101
* individual result futures, one per instance
104102
*/
105-
private Future<List<Future>> executeInBatch(List<Instance> instances,
106-
Function<List<Instance>, Future<List<Future>>> action) {
107-
List<Future> totalFutures = new ArrayList<>();
103+
private Future<List<Future<Instance>>> executeInBatch(List<Instance> instances,
104+
Function<List<Instance>, Future<List<Future<Instance>>>> action) {
105+
List<Future<Instance>> totalFutures = new ArrayList<>();
108106

109107
List<List<Instance>> batches = Lists.partition(instances, PARALLEL_DB_CONNECTIONS_LIMIT);
110-
Future<List<Future>> future = succeededFuture();
108+
Future<List<Future<Instance>>> future = succeededFuture();
111109
for (List<Instance> batch : batches) {
112110
future = future.compose(x -> action.apply(batch))
113111
.onSuccess(totalFutures::addAll);
@@ -122,12 +120,12 @@ private Future<List<Future>> executeInBatch(List<Instance> instances,
122120
* @param postgresClient Postgres Client
123121
* @return succeeded future containing the list of completed (succeeded and failed) individual result futures
124122
*/
125-
private Future<List<Future>> saveInstances(List<Instance> instances, PostgresClient postgresClient) {
126-
List<Future> futures = instances.stream()
123+
private Future<List<Future<Instance>>> saveInstances(List<Instance> instances, PostgresClient postgresClient) {
124+
List<Future<Instance>> futures = instances.stream()
127125
.map(instance -> saveInstance(instance, postgresClient))
128-
.collect(Collectors.toList());
126+
.toList();
129127

130-
return CompositeFuture.join(futures)
128+
return Future.join(futures)
131129
// on success and on failure return succeeding future with list of all (succeeded and failed) futures
132130
.map(futures)
133131
.otherwise(futures);
@@ -165,14 +163,14 @@ private Future<Instance> saveInstance(Instance instance, PostgresClient postgres
165163
* @param saveFutures list of completed individual result futures
166164
* @return InstancesBatchResponse
167165
*/
168-
private InstancesBatchResponse constructResponse(List<Future> saveFutures) {
166+
private InstancesBatchResponse constructResponse(List<Future<Instance>> saveFutures) {
169167
InstancesBatchResponse response = new InstancesBatchResponse();
170168

171169
saveFutures.forEach(save -> {
172170
if (save.failed()) {
173171
response.getErrorMessages().add(save.cause().getMessage());
174172
} else {
175-
response.getInstances().add((Instance) save.result());
173+
response.getInstances().add(save.result());
176174
}
177175
});
178176

src/main/java/org/folio/rest/impl/LocationApi.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,8 @@ public void deleteLocationsById(
201201

202202
@SafeVarargs
203203
private CompositeFuture runLocationChecks(Future<LocationCheckError>... futures) {
204-
@SuppressWarnings("rawtypes")
205-
List<Future> allFutures = new ArrayList<>(Arrays.asList(futures));
206-
return CompositeFuture.all(allFutures);
204+
List<Future<LocationCheckError>> allFutures = new ArrayList<>(Arrays.asList(futures));
205+
return Future.all(allFutures);
207206
}
208207

209208
private Future<LocationCheckError> checkIdProvided(Location entity) {

src/main/java/org/folio/rest/support/CollectionUtil.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import com.fasterxml.jackson.databind.ObjectMapper;
55
import java.util.Collection;
66
import java.util.Collections;
7-
import java.util.stream.Collectors;
87
import org.folio.dbschema.ObjectMapperTool;
98

109
public final class CollectionUtil {
@@ -22,7 +21,7 @@ public static <T> Collection<T> deepCopy(Collection<T> collection, Class<T> type
2221

2322
return collection.stream()
2423
.map(r -> clone(r, type))
25-
.collect(Collectors.toList());
24+
.toList();
2625
}
2726

2827
public static <T> T getFirst(Collection<T> collection) {

src/main/java/org/folio/rest/support/CqlQuery.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ public boolean isMatchingAll() {
2121
} catch (Exception e) {
2222
return false;
2323
}
24-
if (!(cqlNode instanceof CQLTermNode)) {
24+
if (!(cqlNode instanceof CQLTermNode node)) {
2525
return false;
2626
}
27-
var node = (CQLTermNode) cqlNode;
2827
// cql.allRecords: A special index which matches every record available. Every record is matched no matter what
2928
// values are provided for the relation and term, but the recommended syntax is: cql.allRecords = 1
3029
// http://docs.oasis-open.org/search-ws/searchRetrieve/v1.0/os/part5-cql/searchRetrieve-v1.0-os-part5-cql.html#_Toc324166821

src/main/java/org/folio/services/ItemEffectiveValuesService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public Future<List<Item>> populateEffectiveValues(List<Item> items) {
3232
return getHoldingsRecordsForItems(items)
3333
.map(holdingsRecordMap -> items.stream()
3434
.map(item -> populateEffectiveValues(item, holdingsRecordMap.get(item.getHoldingsRecordId())))
35-
.collect(Collectors.toList()));
35+
.toList());
3636
}
3737

3838
public Future<Item> populateEffectiveValues(Item item) {

src/main/java/org/folio/services/SuDocCallNumber.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private void appendWithSymbolIfNeeded(StringBuilder key, String cnPart) {
104104
}
105105
var parts = cnPart.split("[./ -]");
106106
for (String part : parts) {
107-
if (key.length() > 0) {
107+
if (!key.isEmpty()) {
108108
key.append(' ');
109109
}
110110
part = part.trim();

src/main/java/org/folio/services/domainevent/CommonDomainEventPublisher.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.folio.services.domainevent;
22

3-
import static io.vertx.core.CompositeFuture.all;
3+
import static io.vertx.core.Future.all;
44
import static io.vertx.core.Future.succeededFuture;
55
import static org.apache.logging.log4j.LogManager.getLogger;
66
import static org.folio.rest.tools.utils.TenantTool.tenantId;
@@ -20,7 +20,6 @@
2020
import java.util.concurrent.atomic.AtomicLong;
2121
import java.util.function.Function;
2222
import java.util.function.LongFunction;
23-
import java.util.stream.Collectors;
2423
import org.apache.commons.lang3.tuple.Pair;
2524
import org.apache.commons.lang3.tuple.Triple;
2625
import org.apache.logging.log4j.Logger;
@@ -124,7 +123,7 @@ Future<Void> publishRecordsUpdated(Collection<Triple<String, T, T>> updatedRecor
124123

125124
return all(updatedRecords.stream()
126125
.map(triple -> publishRecordUpdated(triple.getLeft(), triple.getMiddle(), triple.getRight()))
127-
.collect(Collectors.toList()))
126+
.toList())
128127
.map(notUsed -> null);
129128
}
130129

@@ -141,7 +140,7 @@ Future<Void> publishRecordsCreated(List<Pair<String, T>> records) {
141140

142141
return all(records.stream()
143142
.map(pair -> publishRecordCreated(pair.getKey(), pair.getValue()))
144-
.collect(Collectors.toList()))
143+
.toList())
145144
.map(notUsed -> null);
146145
}
147146

src/main/java/org/folio/services/domainevent/InstanceDomainEventPublisher.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import java.util.Collection;
1111
import java.util.List;
1212
import java.util.Map;
13-
import java.util.stream.Collectors;
1413
import org.apache.commons.lang3.tuple.Pair;
1514
import org.apache.logging.log4j.Logger;
1615
import org.folio.persist.InstanceRepository;
@@ -35,14 +34,14 @@ public Future<Void> publishInstancesCreated(List<Instance> instances) {
3534

3635
return domainEventService.publishRecordsCreated(instances.stream()
3736
.map(instance -> pair(instance.getId(), instance))
38-
.collect(Collectors.toList()));
37+
.toList());
3938
}
4039

4140
@Override
4241
protected Future<List<Pair<String, Instance>>> getInstanceIds(Collection<Instance> instances) {
4342
return succeededFuture(instances.stream()
4443
.map(instance -> pair(instance.getId(), instance))
45-
.collect(Collectors.toList()));
44+
.toList());
4645
}
4746

4847
@Override

src/main/java/org/folio/services/holding/HoldingsService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ private CompositeFuture createShadowInstancesIfNeeded(List<HoldingsRecord> holdi
243243
String instanceId = holdingRecord.getInstanceId();
244244
instanceFuturesMap.computeIfAbsent(instanceId, v -> createShadowInstanceIfNeeded(instanceId, consortiumData));
245245
}
246-
return CompositeFuture.all(new ArrayList<>(instanceFuturesMap.values()));
246+
return Future.all(new ArrayList<>(instanceFuturesMap.values()));
247247
}
248248

249249
private Future<SharingInstance> createShadowInstanceIfNeeded(String instanceId, ConsortiumData consortiumData) {

0 commit comments

Comments
 (0)