diff --git a/components/camel-ai/camel-langchain4j-agent-api/src/main/java/org/apache/camel/component/langchain4j/agent/api/AgentConfiguration.java b/components/camel-ai/camel-langchain4j-agent-api/src/main/java/org/apache/camel/component/langchain4j/agent/api/AgentConfiguration.java index ae38a94886924..25926d2c7b228 100644 --- a/components/camel-ai/camel-langchain4j-agent-api/src/main/java/org/apache/camel/component/langchain4j/agent/api/AgentConfiguration.java +++ b/components/camel-ai/camel-langchain4j-agent-api/src/main/java/org/apache/camel/component/langchain4j/agent/api/AgentConfiguration.java @@ -20,6 +20,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Objects; import java.util.function.BiPredicate; import dev.langchain4j.agent.tool.ToolSpecification; @@ -270,7 +271,7 @@ public static List> parseGuardrailClasses(String[] guardrailClassNames) .map(String::trim) .filter(name -> !name.isEmpty()) .map(AgentConfiguration::loadGuardrailClass) - .filter(clazz -> clazz != null) + .filter(Objects::nonNull) .collect(java.util.stream.Collectors.toList()); } diff --git a/components/camel-ai/camel-langchain4j-embeddings/src/test/java/org/apache/camel/component/langchain4j/embeddings/LangChain4jEmbeddingsComponentInfinispanTargetIT.java b/components/camel-ai/camel-langchain4j-embeddings/src/test/java/org/apache/camel/component/langchain4j/embeddings/LangChain4jEmbeddingsComponentInfinispanTargetIT.java index d202ffecc15e6..7c23d7dacf134 100644 --- a/components/camel-ai/camel-langchain4j-embeddings/src/test/java/org/apache/camel/component/langchain4j/embeddings/LangChain4jEmbeddingsComponentInfinispanTargetIT.java +++ b/components/camel-ai/camel-langchain4j-embeddings/src/test/java/org/apache/camel/component/langchain4j/embeddings/LangChain4jEmbeddingsComponentInfinispanTargetIT.java @@ -102,7 +102,7 @@ public void replace() { Optional original = cacheContainer.getCache(CACHE_NAME) .values() .stream() - .map(obj -> (InfinispanRemoteEmbedding) obj) + .map(InfinispanRemoteEmbedding.class::cast) .filter(embedding -> embedding.getText().equals(TEXT_EMBEDDING_3)) .findFirst(); diff --git a/components/camel-ai/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jProducer.java b/components/camel-ai/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jProducer.java index 351e750b33f5a..11ee728ff4175 100644 --- a/components/camel-ai/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jProducer.java +++ b/components/camel-ai/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/Neo4jProducer.java @@ -36,6 +36,7 @@ import org.neo4j.driver.Record; import org.neo4j.driver.Values; import org.neo4j.driver.summary.ResultSummary; +import org.neo4j.driver.types.MapAccessor; import static org.apache.camel.component.neo4j.Neo4Operation.RETRIEVE_NODES; import static org.apache.camel.component.neo4j.Neo4Operation.RETRIEVE_NODES_AND_UPDATE_WITH_CYPHER_QUERY; @@ -226,7 +227,7 @@ private void queryRetriveNodes( private List nodeProperties(List result) { return result.stream() .map(record -> record.get(0).asNode()) - .map(node -> node.asMap()) + .map(MapAccessor::asMap) .collect(Collectors.toList()); } @@ -354,7 +355,7 @@ private void createVector(Exchange exchange) { text = neo4jEmbed.getText(); vectors = neo4jEmbed.getVectors(); } else { - id = exchange.getMessage().getHeader(Neo4jHeaders.VECTOR_ID, () -> UUID.randomUUID(), String.class); + id = exchange.getMessage().getHeader(Neo4jHeaders.VECTOR_ID, UUID::randomUUID, String.class); vectors = exchange.getMessage().getHeader(CamelLangchain4jAttributes.CAMEL_LANGCHAIN4J_EMBEDDING_VECTOR, float[].class); text = exchange.getMessage().getBody(String.class); diff --git a/components/camel-ai/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/transformer/Neo4jEmbeddingDataTypeTransformer.java b/components/camel-ai/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/transformer/Neo4jEmbeddingDataTypeTransformer.java index ce9a16f6e7dfc..f0de61b2b5d9b 100644 --- a/components/camel-ai/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/transformer/Neo4jEmbeddingDataTypeTransformer.java +++ b/components/camel-ai/camel-neo4j/src/main/java/org/apache/camel/component/neo4j/transformer/Neo4jEmbeddingDataTypeTransformer.java @@ -38,7 +38,7 @@ public void transform(Message message, DataType fromType, DataType toType) { final TextSegment text = message.getBody(TextSegment.class); - final String id = message.getHeader(Neo4jHeaders.VECTOR_ID, () -> UUID.randomUUID(), String.class); + final String id = message.getHeader(Neo4jHeaders.VECTOR_ID, UUID::randomUUID, String.class); Neo4jEmbedding neo4jEmbedding = new Neo4jEmbedding(id, text.text(), embedding.vector()); diff --git a/components/camel-ai/camel-qdrant/src/main/java/org/apache/camel/component/qdrant/transform/QdrantReverseEmbeddingsDataTypeTransformer.java b/components/camel-ai/camel-qdrant/src/main/java/org/apache/camel/component/qdrant/transform/QdrantReverseEmbeddingsDataTypeTransformer.java index 296e4f2615d5e..569ad0871398d 100644 --- a/components/camel-ai/camel-qdrant/src/main/java/org/apache/camel/component/qdrant/transform/QdrantReverseEmbeddingsDataTypeTransformer.java +++ b/components/camel-ai/camel-qdrant/src/main/java/org/apache/camel/component/qdrant/transform/QdrantReverseEmbeddingsDataTypeTransformer.java @@ -38,7 +38,7 @@ public void transform(Message message, DataType from, DataType to) throws Except List embeddings = message.getBody(List.class); List result = embeddings.stream() - .map(embedding -> embedding.getPayloadMap()) + .map(Points.ScoredPointOrBuilder::getPayloadMap) .map(payloadMap -> payloadMap.getOrDefault("text_segment", ValueFactory.value(""))) .map(JsonWithInt.Value::getStringValue) .collect(Collectors.toList()); diff --git a/components/camel-as2/camel-as2-component/src/test/java/org/apache/camel/component/as2/AS2ClientManagerIT.java b/components/camel-as2/camel-as2-component/src/test/java/org/apache/camel/component/as2/AS2ClientManagerIT.java index 2ab7f4809508b..4caf4f3e72f5d 100644 --- a/components/camel-as2/camel-as2-component/src/test/java/org/apache/camel/component/as2/AS2ClientManagerIT.java +++ b/components/camel-as2/camel-as2-component/src/test/java/org/apache/camel/component/as2/AS2ClientManagerIT.java @@ -844,7 +844,7 @@ private void compressedMessage(Object msg, String encoding) throws Exception { @Test public void asyncMDNTest() { - assertDoesNotThrow(() -> runAsyncMDNTest()); + assertDoesNotThrow(this::runAsyncMDNTest); } diff --git a/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddbstream/ShardIteratorHandlerTest.java b/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddbstream/ShardIteratorHandlerTest.java index d9451d5824381..ddc7839d4fb88 100644 --- a/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddbstream/ShardIteratorHandlerTest.java +++ b/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddbstream/ShardIteratorHandlerTest.java @@ -155,7 +155,7 @@ void shouldThrowIllegalArgumentExceptionIfNoStreamsAreReturned() throws Exceptio ShardIteratorHandler underTest = new ShardIteratorHandler(endpoint); endpoint.doStart(); - assertThrows(IllegalArgumentException.class, () -> underTest.getShardIterators()); + assertThrows(IllegalArgumentException.class, underTest::getShardIterators); } } diff --git a/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddbstream/ShardTreeTest.java b/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddbstream/ShardTreeTest.java index f2a84a4eda728..98ee38b9c6a5f 100644 --- a/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddbstream/ShardTreeTest.java +++ b/components/camel-aws/camel-aws2-ddb/src/test/java/org/apache/camel/component/aws2/ddbstream/ShardTreeTest.java @@ -55,7 +55,7 @@ void shouldThrowIfNoUnparentedShardsCanBeFound() { Shard selfParentingShard = Shard.builder().shardId("SHARD_X").parentShardId("SHARD_X").build(); underTest.populate(Arrays.asList(selfParentingShard)); - assertThrows(IllegalStateException.class, () -> underTest.getRoots()); + assertThrows(IllegalStateException.class, underTest::getRoots); } @Test diff --git a/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/EC2ComponentSpringTest.java b/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/EC2ComponentSpringTest.java index d5c6967789576..7d7928fdac1c4 100644 --- a/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/EC2ComponentSpringTest.java +++ b/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/EC2ComponentSpringTest.java @@ -180,7 +180,7 @@ public void process(Exchange exchange) { @Test public void ec2RebootInstancesTest() { - assertDoesNotThrow(() -> issueReboot()); + assertDoesNotThrow(this::issueReboot); } private void issueReboot() { diff --git a/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/EC2ProducerTest.java b/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/EC2ProducerTest.java index 7a124e29f7f91..7c6b5d4d227f8 100644 --- a/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/EC2ProducerTest.java +++ b/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/EC2ProducerTest.java @@ -205,7 +205,7 @@ public void process(Exchange exchange) { @Test public void ec2RebootInstancesTest() { - assertDoesNotThrow(() -> issueReboot()); + assertDoesNotThrow(this::issueReboot); } private void issueReboot() { diff --git a/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/integration/EC2ComponentIT.java b/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/integration/EC2ComponentIT.java index b7e56837e2500..212b2e0906f51 100644 --- a/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/integration/EC2ComponentIT.java +++ b/components/camel-aws/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/integration/EC2ComponentIT.java @@ -31,7 +31,7 @@ public class EC2ComponentIT extends Aws2EC2Base { @Test public void createAndRunInstancesTest() { - assertDoesNotThrow(() -> execCreateAndRun()); + assertDoesNotThrow(this::execCreateAndRun); } private void execCreateAndRun() { @@ -45,7 +45,7 @@ private void execCreateAndRun() { @Test public void createAndRunInstancesWithSecurityGroupsTest() { - assertDoesNotThrow(() -> execCreateAndRunWithSecurityGroups()); + assertDoesNotThrow(this::execCreateAndRunWithSecurityGroups); } private void execCreateAndRunWithSecurityGroups() { @@ -63,7 +63,7 @@ private void execCreateAndRunWithSecurityGroups() { @Test public void ec2CreateAndRunTestWithKeyPair() { - assertDoesNotThrow(() -> execCreateAndRunWithKeyPair()); + assertDoesNotThrow(this::execCreateAndRunWithKeyPair); } private void execCreateAndRunWithKeyPair() { diff --git a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Console.java b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Console.java index 53b1715116de4..2b076b7dcd66b 100644 --- a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Console.java +++ b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Console.java @@ -40,7 +40,7 @@ protected String doCallText(Map options) { List list = getCamelContext().getRoutes() .stream().map(Route::getConsumer) - .filter(c -> c instanceof AWS2S3Consumer) + .filter(AWS2S3Consumer.class::isInstance) .collect(Collectors.toList()); sb.append(String.format(" %s:%s:%s:%s:%s:%s:%s%n", "bucket", "accessKeys", "defaultCredentialsProvider", @@ -62,7 +62,7 @@ protected JsonObject doCallJson(Map options) { List list = getCamelContext().getRoutes() .stream().map(Route::getConsumer) - .filter(c -> c instanceof AWS2S3Consumer) + .filter(AWS2S3Consumer.class::isInstance) .collect(Collectors.toList()); List arr = new ArrayList<>(); diff --git a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/stream/AWS2S3StreamUploadProducer.java b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/stream/AWS2S3StreamUploadProducer.java index 01b30709e5d16..9696184159e2a 100644 --- a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/stream/AWS2S3StreamUploadProducer.java +++ b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/stream/AWS2S3StreamUploadProducer.java @@ -586,7 +586,7 @@ private void setStartingPart() { ListObjectsV2Iterable listRes = getEndpoint().getS3Client().listObjectsV2Paginator(request); listRes.stream() .flatMap(r -> r.contents().stream()) - .forEach(content -> list.add(content)); + .forEach(list::add); if (!list.isEmpty()) { list.sort(Comparator.comparing(S3Object::lastModified)); int listSize = list.size(); diff --git a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Component.java b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Component.java index c432a615dc8a4..aa6237506f690 100644 --- a/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Component.java +++ b/components/camel-aws/camel-aws2-sns/src/main/java/org/apache/camel/component/aws2/sns/Sns2Component.java @@ -17,6 +17,7 @@ package org.apache.camel.component.aws2.sns; import java.util.Map; +import java.util.Map.Entry; import java.util.stream.Collectors; import org.apache.camel.CamelContext; @@ -97,12 +98,12 @@ private boolean containsTransientParameters(Map parameters) { private Map getNonTransientParameters(Map parameters) { return parameters.entrySet().stream().filter(k -> !k.getKey().equals("configuration")) - .collect(Collectors.toMap(k -> k.getKey(), k -> k.getValue())); + .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); } private Map getTransientParameters(Map parameters) { return parameters.entrySet().stream().filter(k -> k.getKey().equals("configuration")) - .collect(Collectors.toMap(k -> k.getKey(), k -> k.getValue())); + .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); } @Override diff --git a/components/camel-bonita/src/test/java/org/apache/camel/component/bonita/api/BonitaAuthFilterAlreadyConnectedTest.java b/components/camel-bonita/src/test/java/org/apache/camel/component/bonita/api/BonitaAuthFilterAlreadyConnectedTest.java index c8950b6961029..278c094d0373d 100644 --- a/components/camel-bonita/src/test/java/org/apache/camel/component/bonita/api/BonitaAuthFilterAlreadyConnectedTest.java +++ b/components/camel-bonita/src/test/java/org/apache/camel/component/bonita/api/BonitaAuthFilterAlreadyConnectedTest.java @@ -49,7 +49,7 @@ public void setup() { @Test public void testAlreadyConnected() { - assertDoesNotThrow(() -> runAlreadyConnectedTest()); + assertDoesNotThrow(this::runAlreadyConnectedTest); } private void runAlreadyConnectedTest() throws IOException { diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/ResultSetConversionStrategies.java b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/ResultSetConversionStrategies.java index 7c74a2879096e..1d576bf3d3865 100644 --- a/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/ResultSetConversionStrategies.java +++ b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/ResultSetConversionStrategies.java @@ -32,13 +32,9 @@ public final class ResultSetConversionStrategies { private static final Pattern LIMIT_NAME_PATTERN = Pattern.compile("^LIMIT_(\\d+)$", Pattern.CASE_INSENSITIVE); - private static final ResultSetConversionStrategy ALL = (ResultSet resultSet) -> { - return resultSet.all(); - }; + private static final ResultSetConversionStrategy ALL = ResultSet::all; - private static final ResultSetConversionStrategy ONE = (ResultSet resultSet) -> { - return resultSet.one(); - }; + private static final ResultSetConversionStrategy ONE = ResultSet::one; private ResultSetConversionStrategies() { } diff --git a/components/camel-clickup/src/test/java/org/apache/camel/component/clickup/ClickUpConfigurationTest.java b/components/camel-clickup/src/test/java/org/apache/camel/component/clickup/ClickUpConfigurationTest.java index 529ec7922bfcb..7e83b5486c17c 100644 --- a/components/camel-clickup/src/test/java/org/apache/camel/component/clickup/ClickUpConfigurationTest.java +++ b/components/camel-clickup/src/test/java/org/apache/camel/component/clickup/ClickUpConfigurationTest.java @@ -37,7 +37,7 @@ public class ClickUpConfigurationTest extends ClickUpTestSupport { @Test public void testClickUpConfiguration() { ClickUpEndpoint endpoint = (ClickUpEndpoint) context().getEndpoints().stream() - .filter(e -> e instanceof ClickUpEndpoint).findAny().get(); + .filter(ClickUpEndpoint.class::isInstance).findAny().get(); ClickUpConfiguration config = endpoint.getConfiguration(); assertEquals(WORKSPACE_ID, config.getWorkspaceId()); diff --git a/components/camel-clickup/src/test/java/org/apache/camel/component/clickup/ClickUpWebhookRegistrationAlreadyExistsTest.java b/components/camel-clickup/src/test/java/org/apache/camel/component/clickup/ClickUpWebhookRegistrationAlreadyExistsTest.java index c198153205f4a..e21f73ab86bd6 100644 --- a/components/camel-clickup/src/test/java/org/apache/camel/component/clickup/ClickUpWebhookRegistrationAlreadyExistsTest.java +++ b/components/camel-clickup/src/test/java/org/apache/camel/component/clickup/ClickUpWebhookRegistrationAlreadyExistsTest.java @@ -171,7 +171,7 @@ protected ClickUpMockRoutes createMockRoutes() { String webhookExternalUrl; try { Optional optionalEndpoint = context().getEndpoints().stream() - .filter(endpoint -> endpoint instanceof WebhookEndpoint) + .filter(WebhookEndpoint.class::isInstance) .findFirst(); if (optionalEndpoint.isEmpty()) { diff --git a/components/camel-cm-sms/src/test/java/org/apache/camel/component/cm/test/CMTest.java b/components/camel-cm-sms/src/test/java/org/apache/camel/component/cm/test/CMTest.java index 3bca0c65b4b20..57cac60af8a64 100644 --- a/components/camel-cm-sms/src/test/java/org/apache/camel/component/cm/test/CMTest.java +++ b/components/camel-cm-sms/src/test/java/org/apache/camel/component/cm/test/CMTest.java @@ -111,7 +111,7 @@ public void testHostUnavailableException() throws Exception { = "cm-sms://dummy.sgw01.cm.nl/gateway.ashx?defaultFrom=MyBusiness&defaultMaxNumberOfParts=8&productToken=ea723fd7-da81-4826-89bc-fa7144e71c40&testConnectionOnStartup=true"; Service service = context.getEndpoint(schemedUri).createProducer(); assertThrows(HostUnavailableException.class, - () -> service.start()); + service::start); } @Test diff --git a/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvMarshallerFactory.java b/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvMarshallerFactory.java index c1687ac8cb756..3cd4f7621bd6e 100644 --- a/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvMarshallerFactory.java +++ b/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvMarshallerFactory.java @@ -23,9 +23,7 @@ */ public interface CsvMarshallerFactory { - CsvMarshallerFactory DEFAULT = (CSVFormat format, CsvDataFormat dataFormat) -> { - return CsvMarshaller.create(format, dataFormat); - }; + CsvMarshallerFactory DEFAULT = CsvMarshaller::create; /** * Creates and returns a new {@link CsvMarshaller}. diff --git a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingImplTest.java b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingImplTest.java index 6aaa10e4ebf65..eee244edd7ba8 100644 --- a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingImplTest.java +++ b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingImplTest.java @@ -35,6 +35,7 @@ import org.apache.hc.client5.http.classic.methods.HttpPost; import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; import org.apache.hc.client5.http.impl.classic.HttpClientBuilder; +import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.io.entity.EntityUtils; import org.apache.hc.core5.http.io.entity.StringEntity; import org.junit.jupiter.api.Test; @@ -115,7 +116,7 @@ public void testNewCustomerWithQueryParam() throws Exception { post.setEntity(new StringEntity(sw.toString())); post.addHeader("Content-Type", "text/xml"); post.addHeader("Accept", "text/xml"); - Integer status = httpclient.execute(post, response -> response.getCode()); + Integer status = httpclient.execute(post, HttpResponse::getCode); assertEquals(200, status); } } diff --git a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java index af6b165c53b8e..594dee7a9183e 100644 --- a/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java +++ b/components/camel-cxf/camel-cxf-rest/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java @@ -47,6 +47,7 @@ import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; import org.apache.hc.client5.http.impl.classic.HttpClientBuilder; import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.io.entity.EntityUtils; import org.apache.hc.core5.http.io.entity.InputStreamEntity; import org.apache.hc.core5.http.io.entity.StringEntity; @@ -218,7 +219,7 @@ public void testGetCustomerOnlyHeaders() throws Exception { public void testGetCustomerHttp404CustomStatus() throws Exception { HttpGet get = new HttpGet("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/456"); get.addHeader("Accept", "text/xml"); - Integer status = httpclient.execute(get, response -> response.getCode()); + Integer status = httpclient.execute(get, HttpResponse::getCode); assertEquals(404, status); } @@ -230,7 +231,7 @@ public void testUpdateCustomerBodyAndHeaders() throws Exception { put.setEntity(new StringEntity(sw.toString())); put.addHeader("Content-Type", "text/xml"); put.addHeader("Accept", "text/xml"); - Integer status = httpclient.execute(put, response -> response.getCode()); + Integer status = httpclient.execute(put, HttpResponse::getCode); assertEquals(200, status); } @@ -242,7 +243,7 @@ public void testNewCustomerOnlyBody() throws Exception { post.setEntity(new StringEntity(sw.toString())); post.addHeader("Content-Type", "text/xml"); post.addHeader("Accept", "text/xml"); - Integer status = httpclient.execute(post, response -> response.getCode()); + Integer status = httpclient.execute(post, HttpResponse::getCode); assertEquals(200, status); } @@ -271,7 +272,7 @@ public void testUpdateVipCustomer() throws Exception { put.setEntity(new StringEntity(sw.toString())); put.addHeader("Content-Type", "text/xml"); put.addHeader("Accept", "text/xml"); - Integer status = httpclient.execute(put, response -> response.getCode()); + Integer status = httpclient.execute(put, HttpResponse::getCode); assertEquals(200, status); } @@ -279,7 +280,7 @@ public void testUpdateVipCustomer() throws Exception { public void testDeleteVipCustomer() throws Exception { HttpDelete delete = new HttpDelete("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/vip/gold/123"); delete.addHeader("Accept", "text/xml"); - Integer status = httpclient.execute(delete, response -> response.getCode()); + Integer status = httpclient.execute(delete, HttpResponse::getCode); assertEquals(200, status); } @@ -289,7 +290,7 @@ public void testUploadInputStream() throws Exception { post.addHeader("Content-Type", "image/jpeg"); post.addHeader("Accept", "text/xml"); post.setEntity(new InputStreamEntity(this.getClass().getClassLoader().getResourceAsStream("java.jpg"), 100, null)); - Integer status = httpclient.execute(post, response -> response.getCode()); + Integer status = httpclient.execute(post, HttpResponse::getCode); assertEquals(200, status); } @@ -299,7 +300,7 @@ public void testUploadDataHandler() throws Exception { post.addHeader("Content-Type", "image/jpeg"); post.addHeader("Accept", "text/xml"); post.setEntity(new InputStreamEntity(this.getClass().getClassLoader().getResourceAsStream("java.jpg"), 100, null)); - Integer status = httpclient.execute(post, response -> response.getCode()); + Integer status = httpclient.execute(post, HttpResponse::getCode); assertEquals(200, status); } @@ -316,7 +317,7 @@ public void testMultipartPostWithParametersAndPayload() throws Exception { jaxb.createMarshaller().marshal(new Customer(123, "Raul"), sw); builder.addTextBody("body", sw.toString(), ContentType.TEXT_XML); post.setEntity(builder.build()); - Integer status = httpclient.execute(post, response -> response.getCode()); + Integer status = httpclient.execute(post, HttpResponse::getCode); assertEquals(200, status); } @@ -333,7 +334,7 @@ public void testMultipartPostWithoutParameters() throws Exception { jaxb.createMarshaller().marshal(new Customer(123, "Raul"), sw); builder.addTextBody("body", sw.toString(), ContentType.TEXT_XML); post.setEntity(builder.build()); - Integer status = httpclient.execute(post, response -> response.getCode()); + Integer status = httpclient.execute(post, HttpResponse::getCode); assertEquals(200, status); } diff --git a/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfConsumer.java b/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfConsumer.java index e6e7a82c69f5a..471b7d01c2e68 100644 --- a/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfConsumer.java +++ b/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfConsumer.java @@ -88,9 +88,7 @@ protected Server createServer() throws Exception { } final MessageObserver originalOutFaultObserver = ret.getEndpoint().getOutFaultObserver(); - ret.getEndpoint().setOutFaultObserver(message -> { - originalOutFaultObserver.onMessage(message); - }); + ret.getEndpoint().setOutFaultObserver(originalOutFaultObserver::onMessage); // setup the UnitOfWorkCloserInterceptor for OneWayMessageProcessor ret.getEndpoint().getInInterceptors().add(new UnitOfWorkCloserInterceptor(Phase.POST_INVOKE, true)); diff --git a/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsTest.java b/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsTest.java index 20c0579ac17d8..59ae37751d0da 100644 --- a/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsTest.java +++ b/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsTest.java @@ -118,7 +118,7 @@ public void process(Exchange exchange) throws Exception { } }); - Exception ex = assertThrows(IllegalArgumentException.class, () -> cxfConsumer.start()); + Exception ex = assertThrows(IllegalArgumentException.class, cxfConsumer::start); assertNotNull(ex, "Should get a CamelException here"); assertTrue(ex.getMessage().startsWith("serviceClass must be specified")); } diff --git a/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsWithSpringTest.java b/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsWithSpringTest.java index c47b1e57c02df..037c999236668 100644 --- a/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsWithSpringTest.java +++ b/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/util/CxfEndpointUtilsWithSpringTest.java @@ -131,7 +131,7 @@ public void process(Exchange exchange) throws Exception { } }); - Exception ex = assertThrows(IllegalArgumentException.class, () -> cxfConsumer.start()); + Exception ex = assertThrows(IllegalArgumentException.class, cxfConsumer::start); assertNotNull(ex, "Should get a CamelException here"); assertTrue(ex.getMessage().startsWith("serviceClass must be specified")); } diff --git a/components/camel-disruptor/src/test/java/org/apache/camel/component/disruptor/DisruptorTimeoutTest.java b/components/camel-disruptor/src/test/java/org/apache/camel/component/disruptor/DisruptorTimeoutTest.java index c743622b3da27..61fdd28b108b1 100644 --- a/components/camel-disruptor/src/test/java/org/apache/camel/component/disruptor/DisruptorTimeoutTest.java +++ b/components/camel-disruptor/src/test/java/org/apache/camel/component/disruptor/DisruptorTimeoutTest.java @@ -52,9 +52,7 @@ void testDisruptorTimeout() throws Exception { final Future out = template .asyncRequestBody("disruptor:foo?timeout=" + timeout, "World", String.class); - ExecutionException e = assertThrows(ExecutionException.class, () -> { - out.get(); - }); + ExecutionException e = assertThrows(ExecutionException.class, out::get); assertIsInstanceOf(CamelExecutionException.class, e.getCause()); assertIsInstanceOf(ExchangeTimedOutException.class, e.getCause().getCause()); diff --git a/components/camel-docker/src/test/java/org/apache/camel/component/docker/DockerClientProfileTest.java b/components/camel-docker/src/test/java/org/apache/camel/component/docker/DockerClientProfileTest.java index 7db7e417bad36..38e587850954e 100644 --- a/components/camel-docker/src/test/java/org/apache/camel/component/docker/DockerClientProfileTest.java +++ b/components/camel-docker/src/test/java/org/apache/camel/component/docker/DockerClientProfileTest.java @@ -76,7 +76,7 @@ void clientProfileNoPortSpecifiedUrlTest() { DockerClientProfile profile = new DockerClientProfile(); profile.setHost("localhost"); - IllegalArgumentException iaex = assertThrows(IllegalArgumentException.class, () -> profile.toUrl()); + IllegalArgumentException iaex = assertThrows(IllegalArgumentException.class, profile::toUrl); assertEquals("port must be specified", iaex.getMessage()); } diff --git a/components/camel-elasticsearch-rest-client/src/test/java/org/apache/camel/component/elasticsearch/rest/client/integration/ElasticsearchRestClientComponentIT.java b/components/camel-elasticsearch-rest-client/src/test/java/org/apache/camel/component/elasticsearch/rest/client/integration/ElasticsearchRestClientComponentIT.java index 8abd876d8b9e6..a63634183c0fd 100644 --- a/components/camel-elasticsearch-rest-client/src/test/java/org/apache/camel/component/elasticsearch/rest/client/integration/ElasticsearchRestClientComponentIT.java +++ b/components/camel-elasticsearch-rest-client/src/test/java/org/apache/camel/component/elasticsearch/rest/client/integration/ElasticsearchRestClientComponentIT.java @@ -120,10 +120,8 @@ void testProducer() throws ExecutionException, InterruptedException { mockErrorHandler.expectedMessageCount(1); template.asyncRequestBody("direct:get-by-id", "nothingspecial"); - Awaitility.await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> { - // Assert that the direct:get-by-id endpoint received the exception - mockErrorHandler.assertIsSatisfied(); - }); + // Assert that the direct:get-by-id endpoint received the exception + Awaitility.await().atMost(10, TimeUnit.SECONDS).untilAsserted(mockErrorHandler::assertIsSatisfied); // perform a request to fecth all documents without any criteria Awaitility.await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> { @@ -236,10 +234,8 @@ void testProducer() throws ExecutionException, InterruptedException { mockErrorHandler.expectedMessageCount(1); template.asyncRequestBody("direct:delete", "nothingspecial"); - Awaitility.await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> { - // Assert that the direct-delete endpoint received the exception - mockErrorHandler.assertIsSatisfied(); - }); + // Assert that the direct-delete endpoint received the exception + Awaitility.await().atMost(10, TimeUnit.SECONDS).untilAsserted(mockErrorHandler::assertIsSatisfied); // Create an index with settings and Mappings var indexSettings diff --git a/components/camel-elasticsearch-rest-client/src/test/java/org/apache/camel/component/elasticsearch/rest/client/integration/ElasticsearchRestClientITSupport.java b/components/camel-elasticsearch-rest-client/src/test/java/org/apache/camel/component/elasticsearch/rest/client/integration/ElasticsearchRestClientITSupport.java index 246ac6ed24148..97fc06a6bf45e 100644 --- a/components/camel-elasticsearch-rest-client/src/test/java/org/apache/camel/component/elasticsearch/rest/client/integration/ElasticsearchRestClientITSupport.java +++ b/components/camel-elasticsearch-rest-client/src/test/java/org/apache/camel/component/elasticsearch/rest/client/integration/ElasticsearchRestClientITSupport.java @@ -54,9 +54,7 @@ protected void setupResources() throws Exception { builder.setHttpClientConfigCallback( httpClientBuilder -> { httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider); - service.getSslContext().ifPresent(sslContext -> { - httpClientBuilder.setSSLContext(sslContext); - }); + service.getSslContext().ifPresent(httpClientBuilder::setSSLContext); return httpClientBuilder; }); restClient = builder.build(); diff --git a/components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/integration/ElasticsearchTestSupport.java b/components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/integration/ElasticsearchTestSupport.java index ab0eb7388053d..af6c71d0a2336 100644 --- a/components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/integration/ElasticsearchTestSupport.java +++ b/components/camel-elasticsearch/src/test/java/org/apache/camel/component/es/integration/ElasticsearchTestSupport.java @@ -69,9 +69,7 @@ protected void setupResources() throws Exception { builder.setHttpClientConfigCallback( httpClientBuilder -> { httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider); - service.getSslContext().ifPresent(sslContext -> { - httpClientBuilder.setSSLContext(sslContext); - }); + service.getSslContext().ifPresent(httpClientBuilder::setSSLContext); return httpClientBuilder; }); restClient = builder.build(); diff --git a/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/FileWatchComponentTest.java b/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/FileWatchComponentTest.java index fc0c3696d40e4..de606294acabb 100644 --- a/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/FileWatchComponentTest.java +++ b/components/camel-file-watch/src/test/java/org/apache/camel/component/file/watch/FileWatchComponentTest.java @@ -100,7 +100,7 @@ public void testAntMatcher() throws Exception { As such, we have to be lenient checking for the expected number of exchanges received. */ all.expectedMinimumMessageCount(8); // 2 directories, 6 files - Awaitility.await().atMost(2, TimeUnit.SECONDS).untilAsserted(() -> all.assertIsSatisfied()); + Awaitility.await().atMost(2, TimeUnit.SECONDS).untilAsserted(all::assertIsSatisfied); onlyTxtAnywhere.expectedMessageCount(3); // 3 txt files onlyTxtAnywhere.assertIsSatisfied(); diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpNoFilesIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpNoFilesIT.java index 048a177750093..a6474f92e62f0 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpNoFilesIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpNoFilesIT.java @@ -43,7 +43,7 @@ public void testPoolIn3SecondsButNoFiles() { mock.expectedMessageCount(0); await().atMost(3, TimeUnit.SECONDS) - .untilAsserted(() -> mock.assertIsSatisfied()); + .untilAsserted(mock::assertIsSatisfied); } @Override diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpUseListFalseIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpUseListFalseIT.java index 3c0daf91a9a14..4b3be470284fb 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpUseListFalseIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FromFtpUseListFalseIT.java @@ -62,7 +62,7 @@ public void testUseListFalse() { // just allow to poll a few more times, but we should only get the file // once await().atMost(2, TimeUnit.SECONDS) - .untilAsserted(() -> mock.assertIsSatisfied()); + .untilAsserted(mock::assertIsSatisfied); } @Override diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpProducerTempFileExistIssueIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpProducerTempFileExistIssueIT.java index 44ad01a894560..2cf8bf7a35664 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpProducerTempFileExistIssueIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/integration/FtpProducerTempFileExistIssueIT.java @@ -42,7 +42,7 @@ public void testIllegalConfiguration() { String uri = getFtpUrl() + "&fileExist=Append&tempPrefix=foo"; Endpoint endpoint = context.getEndpoint(uri); - Exception ex = assertThrows(IllegalArgumentException.class, () -> endpoint.createProducer()); + Exception ex = assertThrows(IllegalArgumentException.class, endpoint::createProducer); assertEquals("You cannot set both fileExist=Append and tempPrefix/tempFileName options", ex.getMessage()); } diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpConsumerAutoCreateIT.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpConsumerAutoCreateIT.java index e69fd80a7548e..92c7604526376 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpConsumerAutoCreateIT.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpConsumerAutoCreateIT.java @@ -62,7 +62,7 @@ public void testNoAutoCreate() { SftpEndpoint endpoint = (SftpEndpoint) this.getMandatoryEndpoint(getFtpUrl() + "&autoCreate=false"); endpoint.start(); - assertThrows(GenericFileOperationFailedException.class, () -> endpoint.getExchanges(), + assertThrows(GenericFileOperationFailedException.class, endpoint::getExchanges, "Should fail with 550 No such directory."); } diff --git a/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerStreamListTest.java b/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerStreamListTest.java index ffbbc8f20ad51..f2da248e2a1e7 100644 --- a/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerStreamListTest.java +++ b/components/camel-google/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerStreamListTest.java @@ -98,7 +98,7 @@ public void streamListWithNullValues() throws Exception { assertNotNull(iterator); List> rows = new ArrayList<>(); - iterator.forEachRemaining(row -> rows.add(row)); + iterator.forEachRemaining(rows::add); assertEquals(3, rows.size()); @@ -141,7 +141,7 @@ public void streamListHandlesMultipleDataTypes() throws Exception { Iterator> iterator = (Iterator>) message.getBody(); List> rows = new ArrayList<>(); - iterator.forEachRemaining(row -> rows.add(row)); + iterator.forEachRemaining(rows::add); assertEquals(3, rows.size()); diff --git a/components/camel-guava-eventbus/src/test/java/org/apache/camel/component/guava/eventbus/GuavaEventBusConsumerConfigurationTest.java b/components/camel-guava-eventbus/src/test/java/org/apache/camel/component/guava/eventbus/GuavaEventBusConsumerConfigurationTest.java index 7dbb5253384de..d19ef14bbd09f 100644 --- a/components/camel-guava-eventbus/src/test/java/org/apache/camel/component/guava/eventbus/GuavaEventBusConsumerConfigurationTest.java +++ b/components/camel-guava-eventbus/src/test/java/org/apache/camel/component/guava/eventbus/GuavaEventBusConsumerConfigurationTest.java @@ -49,9 +49,7 @@ public void configure() { } }); - Exception e = assertThrows(Exception.class, () -> { - context.start(); - }); + Exception e = assertThrows(Exception.class, context::start); IllegalStateException ise = assertIsInstanceOf(IllegalStateException.class, e.getCause()); assertEquals("You cannot set both 'eventClass' and 'listenerInterface' parameters.", ise.getMessage()); } diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryConstructorsTest.java b/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryConstructorsTest.java index 585d410827876..9b8df8bd90688 100644 --- a/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryConstructorsTest.java +++ b/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryConstructorsTest.java @@ -65,7 +65,7 @@ public void optimisticRepoFailsForNonOptimisticAdd() throws Exception { @Test public void locallyInitializedHazelcastInstanceAdd() { - assertDoesNotThrow(() -> runLocallyInitializedHazelcastInstanceAdd()); + assertDoesNotThrow(this::runLocallyInitializedHazelcastInstanceAdd); } private void runLocallyInitializedHazelcastInstanceAdd() throws Exception { diff --git a/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPNettyDecoderResourceLeakTest.java b/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPNettyDecoderResourceLeakTest.java index 63915569eb312..b0d2c57a11997 100644 --- a/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPNettyDecoderResourceLeakTest.java +++ b/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPNettyDecoderResourceLeakTest.java @@ -59,7 +59,7 @@ public void process(Exchange exchange) throws Exception { @Test public void testSendHL7Message() { - assertDoesNotThrow(() -> sendHL7Message()); + assertDoesNotThrow(this::sendHL7Message); } private void sendHL7Message() { diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareBasicAuthTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareBasicAuthTest.java index 61d93ee0f8aff..5e443753b1521 100644 --- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareBasicAuthTest.java +++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpSendDynamicAwareBasicAuthTest.java @@ -85,7 +85,7 @@ public void testDynamicAware() { assertEquals("Drinking wine", out); // and there should be one http endpoint - long count = context.getEndpoints().stream().filter(e -> e instanceof HttpEndpoint).count(); + long count = context.getEndpoints().stream().filter(HttpEndpoint.class::isInstance).count(); assertEquals(1, count); // we only have one direct and one http diff --git a/components/camel-infinispan/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/remote/InfinispanRemoteTestSupport.java b/components/camel-infinispan/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/remote/InfinispanRemoteTestSupport.java index f2912d1e16aed..312e79afb46c9 100644 --- a/components/camel-infinispan/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/remote/InfinispanRemoteTestSupport.java +++ b/components/camel-infinispan/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/remote/InfinispanRemoteTestSupport.java @@ -148,7 +148,7 @@ public static void waitForCacheReady(RemoteCacheManager manager, String cacheNam Awaitility.await() .atMost(Duration.ofMillis(timeoutMs)) .pollInterval(Duration.ofMillis(250)) - .ignoreExceptionsMatching(e -> e instanceof RemoteIllegalLifecycleStateException) + .ignoreExceptionsMatching(RemoteIllegalLifecycleStateException.class::isInstance) .until(() -> { // Attempt to create/get the cache manager.administration() diff --git a/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatConcurrentTest.java b/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatConcurrentTest.java index d7ada1c36a399..1f73c5623500d 100644 --- a/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatConcurrentTest.java +++ b/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatConcurrentTest.java @@ -48,7 +48,7 @@ public class DataFormatConcurrentTest extends CamelTestSupport { @Test public void testUnmarshalConcurrent() { - assertDoesNotThrow(() -> runUnmarshalConcurrent()); + assertDoesNotThrow(this::runUnmarshalConcurrent); } private void runUnmarshalConcurrent() throws Exception { @@ -69,7 +69,7 @@ public void configure() { @Test public void testUnmarshalFallbackConcurrent() { - assertDoesNotThrow(() -> runUnmarshallFallbackConcurrent()); + assertDoesNotThrow(this::runUnmarshallFallbackConcurrent); } private void runUnmarshallFallbackConcurrent() throws Exception { @@ -90,7 +90,7 @@ public void configure() { @Test public void testMarshallConcurrent() { - assertDoesNotThrow(() -> runMarshallConcurrent()); + assertDoesNotThrow(this::runMarshallConcurrent); } private void runMarshallConcurrent() throws Exception { @@ -111,7 +111,7 @@ public void configure() { @Test public void testMarshallFallbackConcurrent() { - assertDoesNotThrow(() -> runMarshallFallbackConcurrent()); + assertDoesNotThrow(this::runMarshallFallbackConcurrent); } private void runMarshallFallbackConcurrent() throws Exception { diff --git a/components/camel-jcache/src/test/java/org/apache/camel/component/jcache/JCacheManagerTest.java b/components/camel-jcache/src/test/java/org/apache/camel/component/jcache/JCacheManagerTest.java index 9e576ed5b60c3..c5aafc585de3f 100644 --- a/components/camel-jcache/src/test/java/org/apache/camel/component/jcache/JCacheManagerTest.java +++ b/components/camel-jcache/src/test/java/org/apache/camel/component/jcache/JCacheManagerTest.java @@ -43,8 +43,6 @@ public void testCacheCreationFailure() { final JCacheManager objectObjectJCacheManager = new JCacheManager<>(conf); assertThrows(IllegalStateException.class, - () -> { - objectObjectJCacheManager.getCache(); - }); + objectObjectJCacheManager::getCache); } } diff --git a/components/camel-jcache/src/test/java/org/apache/camel/component/jcache/policy/CacheManagerFromRegistryTest.java b/components/camel-jcache/src/test/java/org/apache/camel/component/jcache/policy/CacheManagerFromRegistryTest.java index 9990a22413ea8..5dc65f096b602 100644 --- a/components/camel-jcache/src/test/java/org/apache/camel/component/jcache/policy/CacheManagerFromRegistryTest.java +++ b/components/camel-jcache/src/test/java/org/apache/camel/component/jcache/policy/CacheManagerFromRegistryTest.java @@ -73,7 +73,7 @@ public void configure() { public void after() { super.after(); CacheManager cacheManager = Caching.getCachingProvider().getCacheManager(URI.create("hzsecond"), null); - cacheManager.getCacheNames().forEach(s -> cacheManager.destroyCache(s)); + cacheManager.getCacheNames().forEach(cacheManager::destroyCache); Caching.getCachingProvider().close(URI.create("hzsecond"), null); } diff --git a/components/camel-jcache/src/test/java/org/apache/camel/component/jcache/policy/JCachePolicyTestBase.java b/components/camel-jcache/src/test/java/org/apache/camel/component/jcache/policy/JCachePolicyTestBase.java index 567deede53f18..8a83de1974e7f 100644 --- a/components/camel-jcache/src/test/java/org/apache/camel/component/jcache/policy/JCachePolicyTestBase.java +++ b/components/camel-jcache/src/test/java/org/apache/camel/component/jcache/policy/JCachePolicyTestBase.java @@ -54,7 +54,7 @@ public static String generateValue(String key) { public void after() { //The RouteBuilder code is called for every test, so we destroy cache after each test CacheManager cacheManager = Caching.getCachingProvider().getCacheManager(); - cacheManager.getCacheNames().forEach(s -> cacheManager.destroyCache(s)); + cacheManager.getCacheNames().forEach(cacheManager::destroyCache); Caching.getCachingProvider().close(); } } diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBindingMapHttpMessageFormUrlEncodedFalseBodyTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBindingMapHttpMessageFormUrlEncodedFalseBodyTest.java index 3642e9212995b..387662297e340 100644 --- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBindingMapHttpMessageFormUrlEncodedFalseBodyTest.java +++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpBindingMapHttpMessageFormUrlEncodedFalseBodyTest.java @@ -33,7 +33,7 @@ public class HttpBindingMapHttpMessageFormUrlEncodedFalseBodyTest extends BaseJe @Test public void testSendToJetty() { - assertDoesNotThrow(() -> doSendToJetty()); + assertDoesNotThrow(this::doSendToJetty); } private void doSendToJetty() { diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXEndpointTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXEndpointTest.java index d00a2cd7bb512..ed3e4fdad95dd 100644 --- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXEndpointTest.java +++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXEndpointTest.java @@ -117,7 +117,7 @@ public void remoteServer() { public void noProducer() throws Exception { JMXEndpoint ep = context.getEndpoint("jmx:platform?objectDomain=FooDomain&key.name=theObjectName", JMXEndpoint.class); assertThrows(UnsupportedOperationException.class, - () -> ep.createProducer(), + ep::createProducer, "producer pattern is not supported"); } diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXObjectPropertiesTest.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXObjectPropertiesTest.java index 75acd9ad0ac2c..9a0f67f301289 100644 --- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXObjectPropertiesTest.java +++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXObjectPropertiesTest.java @@ -33,7 +33,7 @@ public class JMXObjectPropertiesTest extends SimpleBeanFixture { @Test public void testObjectProperties() { - assertDoesNotThrow(() -> doTestObjectProperties()); + assertDoesNotThrow(this::doTestObjectProperties); } private void doTestObjectProperties() throws MalformedObjectNameException, InterruptedException { diff --git a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaConsumerTest.java b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaConsumerTest.java index 58f95e07fda42..d9f2fd644343d 100644 --- a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaConsumerTest.java +++ b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaConsumerTest.java @@ -53,7 +53,7 @@ public void consumerRequiresBootstrapServers() { when(clientFactory.getBrokers(any())).thenThrow(new IllegalArgumentException()); final KafkaConsumer kafkaConsumer = new KafkaConsumer(endpoint, processor); - assertThrows(IllegalArgumentException.class, () -> kafkaConsumer.getProps()); + assertThrows(IllegalArgumentException.class, kafkaConsumer::getProps); } @Test diff --git a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorOffUsingKafkaManualCommitIT.java b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorOffUsingKafkaManualCommitIT.java index d77bf3b5f8580..cf0be8f1f0919 100644 --- a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorOffUsingKafkaManualCommitIT.java +++ b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorOffUsingKafkaManualCommitIT.java @@ -129,13 +129,9 @@ public void configure() { .process(exchange -> { LOG.debug(CamelKafkaUtil.buildKafkaLogMessage("Consuming", exchange, true)); }) - .process(exchange -> { - ifIsPayloadWithErrorThrowException(exchange); - }) + .process(KafkaBreakOnFirstErrorOffUsingKafkaManualCommitIT.this::ifIsPayloadWithErrorThrowException) .to(to) - .process(exchange -> { - doCommitOffset(exchange); - }); + .process(KafkaBreakOnFirstErrorOffUsingKafkaManualCommitIT.this::doCommitOffset); } }; } diff --git a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorReleaseResourcesIT.java b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorReleaseResourcesIT.java index 1424e03cec99f..fd6a78236493c 100644 --- a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorReleaseResourcesIT.java +++ b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorReleaseResourcesIT.java @@ -142,9 +142,7 @@ protected RouteBuilder createRouteBuilder() { public void configure() { onException(RuntimeException.class) .handled(false) - .process(exchange -> { - doCommitOffset(exchange); - }) + .process(KafkaBreakOnFirstErrorReleaseResourcesIT.this::doCommitOffset) .end(); from("kafka:" + TOPIC @@ -166,12 +164,8 @@ public void configure() { }) // capturing all of the payloads .to(to) - .process(exchange -> { - ifIsPayloadWithErrorThrowException(exchange); - }) - .process(exchange -> { - doCommitOffset(exchange); - }) + .process(KafkaBreakOnFirstErrorReleaseResourcesIT.this::ifIsPayloadWithErrorThrowException) + .process(KafkaBreakOnFirstErrorReleaseResourcesIT.this::doCommitOffset) .end(); } }; diff --git a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorReplayOldMessagesIT.java b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorReplayOldMessagesIT.java index d70f8c482cda7..6641e1653f090 100644 --- a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorReplayOldMessagesIT.java +++ b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorReplayOldMessagesIT.java @@ -131,9 +131,7 @@ protected RouteBuilder createRouteBuilder() { public void configure() { onException(RuntimeException.class) .handled(false) - .process(exchange -> { - doCommitOffset(exchange); - }) + .process(KafkaBreakOnFirstErrorReplayOldMessagesIT.this::doCommitOffset) .end(); from("kafka:" + TOPIC @@ -156,12 +154,8 @@ public void configure() { }) // capturing all of the payloads .to(to) - .process(exchange -> { - ifIsPayloadWithErrorThrowException(exchange); - }) - .process(exchange -> { - doCommitOffset(exchange); - }) + .process(KafkaBreakOnFirstErrorReplayOldMessagesIT.this::ifIsPayloadWithErrorThrowException) + .process(KafkaBreakOnFirstErrorReplayOldMessagesIT.this::doCommitOffset) .end(); } }; diff --git a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorSeekIssueIT.java b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorSeekIssueIT.java index aa4b5a0106c1d..8f75098526adb 100644 --- a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorSeekIssueIT.java +++ b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorSeekIssueIT.java @@ -173,9 +173,7 @@ public void configure() { .process(exchange -> { LOG.debug(CamelKafkaUtil.buildKafkaLogMessage("Consuming", exchange, true)); }) - .process(exchange -> { - ifIsFifthRecordThrowException(exchange); - }) + .process(KafkaBreakOnFirstErrorSeekIssueIT.this::ifIsFifthRecordThrowException) .to(to) .end(); } diff --git a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorWithBatchUsingAsyncCommitManagerIT.java b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorWithBatchUsingAsyncCommitManagerIT.java index 9d917bd102548..59378b6b861b1 100644 --- a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorWithBatchUsingAsyncCommitManagerIT.java +++ b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorWithBatchUsingAsyncCommitManagerIT.java @@ -143,9 +143,8 @@ public void configure() { .process(exchange -> { LOG.debug(CamelKafkaUtil.buildKafkaLogMessage("Consuming", exchange, true)); }) - .process(exchange -> { - ifIsPayloadWithErrorThrowException(exchange); - }) + .process( + KafkaBreakOnFirstErrorWithBatchUsingAsyncCommitManagerIT.this::ifIsPayloadWithErrorThrowException) .to(to) .end(); } diff --git a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorWithBatchUsingKafkaManualCommitIT.java b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorWithBatchUsingKafkaManualCommitIT.java index 2f95c6f45aa2d..44b16f730181d 100644 --- a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorWithBatchUsingKafkaManualCommitIT.java +++ b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorWithBatchUsingKafkaManualCommitIT.java @@ -118,12 +118,8 @@ public void configure() { // adding error message to end // so we can account for it .to(to) - .process(exchange -> { - // if we don't commit - // camel will continuously - // retry the message with an error - doCommitOffset(exchange); - }); + // if we don't commit, camel will continuously retry the message with an error + .process(KafkaBreakOnFirstErrorWithBatchUsingKafkaManualCommitIT.this::doCommitOffset); from("kafka:" + TOPIC + "?groupId=" + ROUTE_ID @@ -140,13 +136,10 @@ public void configure() { .process(exchange -> { LOG.debug(CamelKafkaUtil.buildKafkaLogMessage("Consuming", exchange, true)); }) - .process(exchange -> { - ifIsPayloadWithErrorThrowException(exchange); - }) + .process( + KafkaBreakOnFirstErrorWithBatchUsingKafkaManualCommitIT.this::ifIsPayloadWithErrorThrowException) .to(to) - .process(exchange -> { - doCommitOffset(exchange); - }); + .process(KafkaBreakOnFirstErrorWithBatchUsingKafkaManualCommitIT.this::doCommitOffset); } }; } diff --git a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorWithBatchUsingKafkaManualCommitRetryIT.java b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorWithBatchUsingKafkaManualCommitRetryIT.java index f240a7ede0c33..e2665ece8c9ca 100644 --- a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorWithBatchUsingKafkaManualCommitRetryIT.java +++ b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorWithBatchUsingKafkaManualCommitRetryIT.java @@ -144,13 +144,10 @@ public void configure() { .process(exchange -> { LOG.debug(CamelKafkaUtil.buildKafkaLogMessage("Consuming", exchange, true)); }) - .process(exchange -> { - ifIsPayloadWithErrorThrowException(exchange); - }) + .process( + KafkaBreakOnFirstErrorWithBatchUsingKafkaManualCommitRetryIT.this::ifIsPayloadWithErrorThrowException) .to(to) - .process(exchange -> { - doCommitOffset(exchange); - }); + .process(KafkaBreakOnFirstErrorWithBatchUsingKafkaManualCommitRetryIT.this::doCommitOffset); } }; } diff --git a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorWithBatchUsingSyncCommitManagerIT.java b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorWithBatchUsingSyncCommitManagerIT.java index 37d795ec4cd4c..720d689ef2014 100644 --- a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorWithBatchUsingSyncCommitManagerIT.java +++ b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaBreakOnFirstErrorWithBatchUsingSyncCommitManagerIT.java @@ -131,9 +131,8 @@ public void configure() { .process(exchange -> { LOG.debug(CamelKafkaUtil.buildKafkaLogMessage("Consuming", exchange, true)); }) - .process(exchange -> { - ifIsPayloadWithErrorThrowException(exchange); - }) + .process( + KafkaBreakOnFirstErrorWithBatchUsingSyncCommitManagerIT.this::ifIsPayloadWithErrorThrowException) .to(to) .end(); } diff --git a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerAsyncManualCommitIT.java b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerAsyncManualCommitIT.java index d76bf88567d6c..3f3cf11e1a828 100644 --- a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerAsyncManualCommitIT.java +++ b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerAsyncManualCommitIT.java @@ -127,7 +127,7 @@ void testLastRecordBeforeCommitHeader() { producer.send(data); } - Awaitility.await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> to.assertIsSatisfied()); // changed to 10 sec for CAMEL-20722 + Awaitility.await().atMost(10, TimeUnit.SECONDS).untilAsserted(to::assertIsSatisfied); // changed to 10 sec for CAMEL-20722 List exchangeList = to.getExchanges(); assertEquals(5, exchangeList.size()); @@ -166,7 +166,7 @@ void testResumeFromTheRightPoint() throws Exception { to.expectedBodiesReceivedInAnyOrder("message-5", "message-6", "message-7"); Awaitility.await().atMost(5, TimeUnit.SECONDS) - .untilAsserted(() -> to.assertIsSatisfied()); + .untilAsserted(to::assertIsSatisfied); assertEquals(0, failCount, "There should have been 0 commit failures"); } diff --git a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/batching/KafkaBatchingProcessingBreakOnFirstErrorManualCommitIT.java b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/batching/KafkaBatchingProcessingBreakOnFirstErrorManualCommitIT.java index 4bbf8aa7a85f2..7732559064468 100644 --- a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/batching/KafkaBatchingProcessingBreakOnFirstErrorManualCommitIT.java +++ b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/batching/KafkaBatchingProcessingBreakOnFirstErrorManualCommitIT.java @@ -96,10 +96,8 @@ public void configure() { } } }).to(KafkaTestUtil.MOCK_RESULT) - .process(exchange -> { - // Manual commit on success - doCommitOffset(exchange); - }); + // Manual commit on success + .process(KafkaBatchingProcessingBreakOnFirstErrorManualCommitIT.this::doCommitOffset); } }; } diff --git a/components/camel-keycloak/src/main/java/org/apache/camel/component/keycloak/security/KeycloakTokenIntrospector.java b/components/camel-keycloak/src/main/java/org/apache/camel/component/keycloak/security/KeycloakTokenIntrospector.java index 61f6f1d62b4bc..e606afe69358c 100644 --- a/components/camel-keycloak/src/main/java/org/apache/camel/component/keycloak/security/KeycloakTokenIntrospector.java +++ b/components/camel-keycloak/src/main/java/org/apache/camel/component/keycloak/security/KeycloakTokenIntrospector.java @@ -149,9 +149,7 @@ public IntrospectionResult introspect(String token) throws IOException { // Execute request try { - IntrospectionResult result = httpClient.execute(request, response -> { - return parseIntrospectionResponse(response); - }); + IntrospectionResult result = httpClient.execute(request, this::parseIntrospectionResponse); // Cache the result if (cache != null && result != null) { diff --git a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/cluster/utils/LeaderRecorder.java b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/cluster/utils/LeaderRecorder.java index f1a4c9c46e6d6..4f03b2e3f95b0 100644 --- a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/cluster/utils/LeaderRecorder.java +++ b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/cluster/utils/LeaderRecorder.java @@ -57,7 +57,7 @@ public List getLeadershipInfo() { } public void waitForAnyLeader(long time, TimeUnit unit) { - waitForLeader(leader -> leader != null, time, unit); + waitForLeader(Objects::nonNull, time, unit); } public void waitForALeaderChange(long time, TimeUnit unit) { diff --git a/components/camel-leveldb/src/test/java/org/apache/camel/component/leveldb/LevelDBAggregateDiscardOnTimeoutTest.java b/components/camel-leveldb/src/test/java/org/apache/camel/component/leveldb/LevelDBAggregateDiscardOnTimeoutTest.java index 3c3218b3cc9dd..c012ba407ea1e 100644 --- a/components/camel-leveldb/src/test/java/org/apache/camel/component/leveldb/LevelDBAggregateDiscardOnTimeoutTest.java +++ b/components/camel-leveldb/src/test/java/org/apache/camel/component/leveldb/LevelDBAggregateDiscardOnTimeoutTest.java @@ -44,7 +44,7 @@ public void testAggregateDiscardOnTimeout() throws Exception { template.sendBodyAndHeader("direct:start", "B", "id", 123); // wait at most 3 seconds - Awaitility.await().atMost(3, TimeUnit.SECONDS).untilAsserted(() -> mock.assertIsSatisfied()); + Awaitility.await().atMost(3, TimeUnit.SECONDS).untilAsserted(mock::assertIsSatisfied); mock.assertIsSatisfied(); diff --git a/components/camel-lra/src/test/java/org/apache/camel/service/lra/AbstractLRATestSupport.java b/components/camel-lra/src/test/java/org/apache/camel/service/lra/AbstractLRATestSupport.java index fa7604767b884..f4f44436a26c6 100644 --- a/components/camel-lra/src/test/java/org/apache/camel/service/lra/AbstractLRATestSupport.java +++ b/components/camel-lra/src/test/java/org/apache/camel/service/lra/AbstractLRATestSupport.java @@ -59,7 +59,7 @@ public void getActiveLRAs() throws IOException, InterruptedException { @AfterEach public void checkActiveLRAs() throws IOException, InterruptedException { - await().atMost(2, SECONDS).until(() -> getNumberOfActiveLRAs(), equalTo(activeLRAs)); + await().atMost(2, SECONDS).until(this::getNumberOfActiveLRAs, equalTo(activeLRAs)); assertEquals(activeLRAs, getNumberOfActiveLRAs(), "Some LRA have been left pending"); } diff --git a/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackMultiThreadIT.java b/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackMultiThreadIT.java index 300ccf46d17a5..35f4650459b18 100644 --- a/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackMultiThreadIT.java +++ b/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackMultiThreadIT.java @@ -71,7 +71,7 @@ void setupTest() { } // sending messages on all parallel sessions - threads.stream().forEach(thread -> thread.start()); + threads.stream().forEach(Thread::start); } @Test diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/InvalidConfigurationTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/InvalidConfigurationTest.java index 35efd10ec7d71..c0ebba6298450 100644 --- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/InvalidConfigurationTest.java +++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/InvalidConfigurationTest.java @@ -33,7 +33,7 @@ public void testSMTPCanNotBeUsedForConsumingMails() throws Exception { Endpoint endpoint = context.getEndpoint("smtp://localhost?username=james"); PollingConsumer consumer = endpoint.createPollingConsumer(); assertThrows(IllegalArgumentException.class, - () -> consumer.start(), + consumer::start, "Should have thrown NoSuchProviderException as smtp protocol cannot be used for consuming mails"); } @@ -42,7 +42,7 @@ public void testSMTPSCanNotBeUsedForConsumingMails() throws Exception { Endpoint endpoint = context.getEndpoint("smtps://localhost?username=james"); PollingConsumer consumer = endpoint.createPollingConsumer(); assertThrows(IllegalArgumentException.class, - () -> consumer.start(), + consumer::start, "Should have thrown NoSuchProviderException as smtp protocol cannot be used for consuming mails"); } diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentsUmlautIssueTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentsUmlautIssueTest.java index 041d19a83f553..c0f22110b47b7 100644 --- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentsUmlautIssueTest.java +++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentsUmlautIssueTest.java @@ -77,9 +77,7 @@ public void testSendAndReceiveMailWithAttachments() throws Exception { mock.expectedMessageCount(1); Exchange out = mock.assertExchangeReceived(0); - Awaitility.await().pollDelay(2, TimeUnit.SECONDS).untilAsserted(() -> { - mock.assertIsSatisfied(); - }); + Awaitility.await().pollDelay(2, TimeUnit.SECONDS).untilAsserted(mock::assertIsSatisfied); // plain text assertEquals("Hello World", out.getIn().getBody(String.class)); diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConsumerAuthenticatorTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConsumerAuthenticatorTest.java index 6e3873e97db50..e949ad6da5acd 100644 --- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConsumerAuthenticatorTest.java +++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailConsumerAuthenticatorTest.java @@ -82,11 +82,11 @@ private void execute(Protocol protocol) throws Exception { MailConsumer consumer = new MailConsumer(endpoint, processor, sender); try { - Assertions.assertThatThrownBy(() -> consumer.poll()) + Assertions.assertThatThrownBy(consumer::poll) .isInstanceOf(MessagingException.class) .message().matches(actualMessage -> Stream.of("LOGIN failed. Invalid login/password for user id", "Authentication failed: com.icegreen.greenmail.user.UserException: Invalid password") - .anyMatch(expectedSubstring -> actualMessage.contains(expectedSubstring))); + .anyMatch(actualMessage::contains)); // poll a second time, this time there should be no exception, because we now provide the correct password authenticator.setPassword(user1.getPassword()); diff --git a/components/camel-micrometer-observability/src/main/java/org/apache/camel/micrometer/observability/MicrometerObservabilityTracer.java b/components/camel-micrometer-observability/src/main/java/org/apache/camel/micrometer/observability/MicrometerObservabilityTracer.java index 76b18dd6fb4cc..42e247951a5c6 100644 --- a/components/camel-micrometer-observability/src/main/java/org/apache/camel/micrometer/observability/MicrometerObservabilityTracer.java +++ b/components/camel-micrometer-observability/src/main/java/org/apache/camel/micrometer/observability/MicrometerObservabilityTracer.java @@ -167,7 +167,7 @@ public void inject(Span span, SpanContextPropagationInjector injector, boolean i propagator.inject( microObsSpan.getSpan().context(), injector, - (carrier, key, value) -> carrier.put(key, value)); + SpanContextPropagationInjector::put); if (includeTracing) { injector.put(org.apache.camel.telemetry.Tracer.TRACE_HEADER, microObsSpan.getSpan().context().traceId()); injector.put(org.apache.camel.telemetry.Tracer.SPAN_HEADER, microObsSpan.getSpan().context().spanId()); diff --git a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/routepolicy/MicrometerRoutePolicyConfigurationTest.java b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/routepolicy/MicrometerRoutePolicyConfigurationTest.java index cd00b39e52951..b532c868d5085 100644 --- a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/routepolicy/MicrometerRoutePolicyConfigurationTest.java +++ b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/routepolicy/MicrometerRoutePolicyConfigurationTest.java @@ -62,7 +62,7 @@ public void testConfigurationPolicy() throws Exception { }); List meters = meterRegistry.getMeters(); assertEquals(3, meters.size(), "additional counters does not disable"); - Timer timer = (Timer) meters.stream().filter(it -> it instanceof Timer) + Timer timer = (Timer) meters.stream().filter(Timer.class::isInstance) .findFirst().orElse(null); assertNotNull(timer, "timer is null"); @@ -71,7 +71,7 @@ public void testConfigurationPolicy() throws Exception { assertEquals("hello", id.getTag("firstTag"), "firstTag not setted"); assertEquals("world", id.getTag("secondTag"), "secondTag not setted"); - LongTaskTimer longTaskTimer = (LongTaskTimer) meters.stream().filter(it -> it instanceof LongTaskTimer) + LongTaskTimer longTaskTimer = (LongTaskTimer) meters.stream().filter(LongTaskTimer.class::isInstance) .findFirst().orElse(null); assertNotNull(longTaskTimer, "LongTaskTimer is null"); id = longTaskTimer.getId(); diff --git a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/routepolicy/SharedMicrometerRoutePolicyTest.java b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/routepolicy/SharedMicrometerRoutePolicyTest.java index 123389189c548..44721f96355fa 100644 --- a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/routepolicy/SharedMicrometerRoutePolicyTest.java +++ b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/routepolicy/SharedMicrometerRoutePolicyTest.java @@ -44,7 +44,7 @@ public void testSharedPolicy() throws Exception { }); List meters = meterRegistry.getMeters(); long timers = meters.stream() - .filter(it -> it instanceof Timer) + .filter(Timer.class::isInstance) .count(); assertEquals(2L, timers, "timers count incorrect"); } diff --git a/components/camel-microprofile/camel-microprofile-health/src/test/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthCheckTest.java b/components/camel-microprofile/camel-microprofile-health/src/test/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthCheckTest.java index acb2459e2d9b4..4e73aed7eb9dc 100644 --- a/components/camel-microprofile/camel-microprofile-health/src/test/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthCheckTest.java +++ b/components/camel-microprofile/camel-microprofile-health/src/test/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthCheckTest.java @@ -31,6 +31,7 @@ import org.apache.camel.impl.health.ContextHealthCheck; import org.eclipse.microprofile.health.HealthCheckResponse; import org.eclipse.microprofile.health.HealthCheckResponse.Status; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -436,13 +437,9 @@ protected void doCall(HealthCheckResultBuilder builder, Map opti assertEquals(2, checks.size()); JsonObject livenessCheck = checks.getJsonObject(0); - assertHealthCheckOutput("liveness-1", HealthCheckResponse.Status.UP, livenessCheck, result -> { - assertNull(result); - }); + assertHealthCheckOutput("liveness-1", HealthCheckResponse.Status.UP, livenessCheck, Assertions::assertNull); JsonObject failedCheck = checks.getJsonObject(1); - assertHealthCheckOutput("failing-check", HealthCheckResponse.Status.DOWN, failedCheck, result -> { - assertNull(result); - }); + assertHealthCheckOutput("failing-check", HealthCheckResponse.Status.DOWN, failedCheck, Assertions::assertNull); } } diff --git a/components/camel-mina-sftp/src/test/java/org/apache/camel/component/file/remote/mina/sftp/SftpConsumerAutoCreateIT.java b/components/camel-mina-sftp/src/test/java/org/apache/camel/component/file/remote/mina/sftp/SftpConsumerAutoCreateIT.java index 9dd7f869cd062..5208dbeb8374d 100644 --- a/components/camel-mina-sftp/src/test/java/org/apache/camel/component/file/remote/mina/sftp/SftpConsumerAutoCreateIT.java +++ b/components/camel-mina-sftp/src/test/java/org/apache/camel/component/file/remote/mina/sftp/SftpConsumerAutoCreateIT.java @@ -62,7 +62,7 @@ public void testNoAutoCreate() { MinaSftpEndpoint endpoint = (MinaSftpEndpoint) this.getMandatoryEndpoint(getFtpUrl() + "&autoCreate=false"); endpoint.start(); - assertThrows(RuntimeCamelException.class, () -> endpoint.getExchanges(), + assertThrows(RuntimeCamelException.class, endpoint::getExchanges, "Should fail with 550 No such directory."); } diff --git a/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/integration/MongoDbTailableCursorConsumerIT.java b/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/integration/MongoDbTailableCursorConsumerIT.java index fa7235096baf2..fbab1ac999ed2 100644 --- a/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/integration/MongoDbTailableCursorConsumerIT.java +++ b/components/camel-mongodb/src/test/java/org/apache/camel/component/mongodb/integration/MongoDbTailableCursorConsumerIT.java @@ -76,7 +76,7 @@ public void testNoRecords() throws Exception { assertEquals(0, cappedTestCollection.countDocuments()); context.getRouteController().startRoute("tailableCursorConsumer1"); - Awaitility.await().atMost(1, TimeUnit.SECONDS).untilAsserted(() -> mock.assertIsSatisfied()); + Awaitility.await().atMost(1, TimeUnit.SECONDS).untilAsserted(mock::assertIsSatisfied); context.getRouteController().stopRoute("tailableCursorConsumer1"); } @@ -345,7 +345,7 @@ private void testThousandRecordsWithRouteId(String routeId) throws Exception { } assertEquals(1000, cappedTestCollection.countDocuments()); context.getRouteController().startRoute(routeId); - Awaitility.await().atMost(1, TimeUnit.SECONDS).untilAsserted(() -> mock.assertIsSatisfied()); + Awaitility.await().atMost(1, TimeUnit.SECONDS).untilAsserted(mock::assertIsSatisfied); context.getRouteController().stopRoute(routeId); } diff --git a/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsConsumerStopTest.java b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsConsumerStopTest.java index df6f5b64c2eda..55a5a1eb95fec 100644 --- a/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsConsumerStopTest.java +++ b/components/camel-nats/src/test/java/org/apache/camel/component/nats/NatsConsumerStopTest.java @@ -30,6 +30,6 @@ public class NatsConsumerStopTest extends CamelTestSupport { public void testConsumerStop() throws Exception { NatsEndpoint endpoint = context.getEndpoint("nats:test?flushConnection=true", NatsEndpoint.class); Consumer consumer = endpoint.createConsumer(null); - assertDoesNotThrow(() -> consumer.stop()); + assertDoesNotThrow(consumer::stop); } } diff --git a/components/camel-observation/src/test/java/org/apache/camel/observation/CurrentSpanTest.java b/components/camel-observation/src/test/java/org/apache/camel/observation/CurrentSpanTest.java index 77418f7c8b723..828c48696bbd9 100644 --- a/components/camel-observation/src/test/java/org/apache/camel/observation/CurrentSpanTest.java +++ b/components/camel-observation/src/test/java/org/apache/camel/observation/CurrentSpanTest.java @@ -318,7 +318,7 @@ public boolean process(Exchange exchange, AsyncCallback callback) { } CompletableFuture.runAsync(() -> { }, DELAYED) - .thenRun(() -> callback.run()); + .thenRun(callback::run); return false; } diff --git a/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Consumer.java b/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Consumer.java index ee1c1d796ca2c..489973eef52da 100644 --- a/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Consumer.java +++ b/components/camel-olingo4/camel-olingo4-component/src/main/java/org/apache/camel/component/olingo4/Olingo4Consumer.java @@ -164,9 +164,7 @@ public Object splitResult(Object result) { } else if (result instanceof ClientValue && ((ClientValue) result).isCollection()) { ClientValue value = (ClientValue) result; ClientCollectionValue collection = value.asCollection(); - collection.forEach(v -> { - splitResult.add(v); - }); + collection.forEach(splitResult::add); } else { splitResult.add(result); } diff --git a/components/camel-opentelemetry/src/test/java/org/apache/camel/opentelemetry/CurrentSpanTest.java b/components/camel-opentelemetry/src/test/java/org/apache/camel/opentelemetry/CurrentSpanTest.java index 36ba7958bce66..cdea5d8b0d04a 100644 --- a/components/camel-opentelemetry/src/test/java/org/apache/camel/opentelemetry/CurrentSpanTest.java +++ b/components/camel-opentelemetry/src/test/java/org/apache/camel/opentelemetry/CurrentSpanTest.java @@ -337,7 +337,7 @@ public boolean process(Exchange exchange, AsyncCallback callback) { } CompletableFuture.runAsync(() -> { }, DELAYED) - .thenRun(() -> callback.run()); + .thenRun(callback::run); return false; } diff --git a/components/camel-opentelemetry2/src/main/java/org/apache/camel/opentelemetry2/OpenTelemetryTracer.java b/components/camel-opentelemetry2/src/main/java/org/apache/camel/opentelemetry2/OpenTelemetryTracer.java index 381488b6e3002..f2a06766718c7 100644 --- a/components/camel-opentelemetry2/src/main/java/org/apache/camel/opentelemetry2/OpenTelemetryTracer.java +++ b/components/camel-opentelemetry2/src/main/java/org/apache/camel/opentelemetry2/OpenTelemetryTracer.java @@ -164,7 +164,7 @@ public void inject(Span span, SpanContextPropagationInjector injector, boolean i ctx = ctx.with(otelSpan.getBaggage()); } contextPropagators.getTextMapPropagator().inject(ctx, injector, - (carrier, key, value) -> carrier.put(key, value)); + SpanContextPropagationInjector::put); if (includeTracing) { injector.put(org.apache.camel.telemetry.Tracer.TRACE_HEADER, otelSpan.getSpan().getSpanContext().getTraceId()); injector.put(org.apache.camel.telemetry.Tracer.SPAN_HEADER, otelSpan.getSpan().getSpanContext().getSpanId()); diff --git a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarProducerInIT.java b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarProducerInIT.java index 678606bd5f20e..f675d24e1d260 100644 --- a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarProducerInIT.java +++ b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/integration/PulsarProducerInIT.java @@ -108,7 +108,7 @@ public void testAMessageToRouteIsSentAndThenConsumed() throws Exception { public void testLargeMessageWithChunkingDisabled() { Throwable e = assertThrows(CamelExecutionException.class, () -> producerTemplate.sendBody(new byte[10 * 1024 * 1024])); - assertTrue(ExceptionUtils.getThrowableList(e).stream().anyMatch(ex -> ex instanceof PulsarClientException)); + assertTrue(ExceptionUtils.getThrowableList(e).stream().anyMatch(PulsarClientException.class::isInstance)); } @Test diff --git a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/utils/PulsarUtilsTest.java b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/utils/PulsarUtilsTest.java index 2b204974564e2..2fb5a1340535c 100644 --- a/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/utils/PulsarUtilsTest.java +++ b/components/camel-pulsar/src/test/java/org/apache/camel/component/pulsar/utils/PulsarUtilsTest.java @@ -69,7 +69,7 @@ public void givenConsumerThrowsPulsarClientExceptionwhenIStopConsumersverifyExce doThrow(new PulsarClientException("A Pulsar Client exception occurred")).when(consumer).close(); assertThrows(PulsarClientException.class, - () -> consumer.close()); + consumer::close); verify(consumer).close(); } diff --git a/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpointV3Test.java b/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpointV3Test.java index 1661583aea3e0..417c3f7935dc9 100644 --- a/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpointV3Test.java +++ b/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpointV3Test.java @@ -66,7 +66,7 @@ public void shouldComplainForUnknownOperations() { Collections.emptyMap()); assertThrows(IllegalArgumentException.class, - () -> endpoint.createProducer()); + endpoint::createProducer); } @Test diff --git a/components/camel-salesforce/camel-salesforce-codegen/src/main/java/org/apache/camel/component/salesforce/codegen/GenerateExecution.java b/components/camel-salesforce/camel-salesforce-codegen/src/main/java/org/apache/camel/component/salesforce/codegen/GenerateExecution.java index 2939407eed081..a093e9d07415a 100644 --- a/components/camel-salesforce/camel-salesforce-codegen/src/main/java/org/apache/camel/component/salesforce/codegen/GenerateExecution.java +++ b/components/camel-salesforce/camel-salesforce-codegen/src/main/java/org/apache/camel/component/salesforce/codegen/GenerateExecution.java @@ -508,8 +508,9 @@ protected void executeWithClient() throws Exception { } getLog().info("Generating Java Classes..."); - Set sObjectNames = StreamSupport.stream(descriptions.fetched().spliterator(), false).map(d -> d.getName()) - .collect(Collectors.toSet()); + Set sObjectNames + = StreamSupport.stream(descriptions.fetched().spliterator(), false).map(SObjectDescription::getName) + .collect(Collectors.toSet()); // generate POJOs for every object description final GeneratorUtility utility = new GeneratorUtility(); for (final SObjectDescription description : descriptions.fetched()) { diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceClientTemplate.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceClientTemplate.java index 37cbba3592f39..8178d4c16cf26 100644 --- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceClientTemplate.java +++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceClientTemplate.java @@ -36,7 +36,7 @@ interface WithClient { } static RestClientSupplier restClientSupplier - = (camelContext, parameters) -> SalesforceComponent.createRestClient(camelContext, parameters); + = SalesforceComponent::createRestClient; private SalesforceClientTemplate() { // utility class diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java index 8224c736f6931..e2beba7103e80 100644 --- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java +++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceComponent.java @@ -437,7 +437,7 @@ protected void doStart() throws Exception { } else { final SSLContextParameters contextParameters = Optional.ofNullable(sslContextParameters) .orElseGet(() -> Optional.ofNullable(retrieveGlobalSslContextParameters()) - .orElseGet(() -> new SSLContextParameters())); + .orElseGet(SSLContextParameters::new)); final SslContextFactory.Client sslContextFactory = new SslContextFactory.Client(); sslContextFactory.setSslContext(contextParameters.createSSLContext(getCamelContext())); @@ -918,7 +918,7 @@ RestClient createRestClientFor(SalesforceEndpointConfig endpointConfig) throws S RestClient createRestClient(final Map properties) throws Exception { final SalesforceEndpointConfig modifiedConfig = Optional.ofNullable(config).map(SalesforceEndpointConfig::copy) - .orElseGet(() -> new SalesforceEndpointConfig()); + .orElseGet(SalesforceEndpointConfig::new); final CamelContext camelContext = getCamelContext(); PropertyBindingSupport.bindProperties(camelContext, modifiedConfig, properties); @@ -937,7 +937,7 @@ static RestClient createRestClient(final CamelContext camelContext, final Map(properties)); final SSLContextParameters sslContextParameters - = Optional.ofNullable(camelContext.getSSLContextParameters()).orElseGet(() -> new SSLContextParameters()); + = Optional.ofNullable(camelContext.getSSLContextParameters()).orElseGet(SSLContextParameters::new); // let's work with a copy so original properties are intact PropertyBindingSupport.bindProperties(camelContext, sslContextParameters, new HashMap<>(properties)); diff --git a/components/camel-servicenow/camel-servicenow-component/src/main/java/org/apache/camel/component/servicenow/AbstractServiceNowProcessor.java b/components/camel-servicenow/camel-servicenow-component/src/main/java/org/apache/camel/component/servicenow/AbstractServiceNowProcessor.java index 27ba88f6935f2..3f5e26ebb20cd 100644 --- a/components/camel-servicenow/camel-servicenow-component/src/main/java/org/apache/camel/component/servicenow/AbstractServiceNowProcessor.java +++ b/components/camel-servicenow/camel-servicenow-component/src/main/java/org/apache/camel/component/servicenow/AbstractServiceNowProcessor.java @@ -81,7 +81,7 @@ public void process(Exchange exchange) throws Exception { protected AbstractServiceNowProcessor setHeaders(Message message, Class responseModel, Response response) throws Exception { - ServiceNowHelper.findOffsets(response, (k, v) -> message.setHeader(k, v)); + ServiceNowHelper.findOffsets(response, message::setHeader); String attachmentMeta = response.getHeaderString(ServiceNowConstants.ATTACHMENT_META_HEADER); if (ObjectHelper.isNotEmpty(attachmentMeta)) { diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/QueueProducerQoSTest.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/QueueProducerQoSTest.java index 459e8831eb453..2ef237725a707 100644 --- a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/QueueProducerQoSTest.java +++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/QueueProducerQoSTest.java @@ -50,7 +50,7 @@ public class QueueProducerQoSTest extends CamelTestSupport { @RegisterExtension public static ArtemisService service = new ArtemisEmbeddedServiceBuilder() .withPersistent(true) - .withCustomConfiguration(configuration -> configureArtemis(configuration)) + .withCustomConfiguration(QueueProducerQoSTest::configureArtemis) .build(); protected ActiveMQConnectionFactory connectionFactory; diff --git a/components/camel-snmp/src/test/java/org/apache/camel/component/snmp/TrapTest.java b/components/camel-snmp/src/test/java/org/apache/camel/component/snmp/TrapTest.java index 723dc468cc364..8a92a84f8361d 100644 --- a/components/camel-snmp/src/test/java/org/apache/camel/component/snmp/TrapTest.java +++ b/components/camel-snmp/src/test/java/org/apache/camel/component/snmp/TrapTest.java @@ -71,7 +71,7 @@ public void testSendReceiveTraps(int version) throws Exception { // wait a bit Awaitility.await().atMost(2, TimeUnit.SECONDS) - .untilAsserted(() -> mock.assertIsSatisfied()); + .untilAsserted(mock::assertIsSatisfied); Message in = mock.getReceivedExchanges().get(0).getIn(); Assertions.assertTrue(in instanceof SnmpMessage, "Expected received object 'SnmpMessage.class'. Got: " + in.getClass()); diff --git a/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/ProducerTest.java b/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/ProducerTest.java index c268c0982fe41..7b264c3375621 100644 --- a/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/ProducerTest.java +++ b/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/ProducerTest.java @@ -132,7 +132,7 @@ public void testTcpWriterWithLocalReceiverPort() throws Exception { DataWriter dw = ((SplunkProducer) tcpProducer).getDataWriter(); //connection is created to socket localhost:-1, which has to fail - Assertions.assertThrows(Exception.class, () -> dw.start()); + Assertions.assertThrows(Exception.class, dw::start); } finally { tcpEndpoint.getConfiguration().setTcpReceiverLocalPort(null); } @@ -147,7 +147,7 @@ public void testTcpWriterWithDifferentHost() throws Exception { DataWriter dw = ((SplunkProducer) tcpProducer).getDataWriter(); //connection is created to socket foo:2222, which has to fail - Assertions.assertThrows(RuntimeException.class, () -> dw.start()); + Assertions.assertThrows(RuntimeException.class, dw::start); } finally { tcpEndpoint.getConfiguration().setHost(host); } diff --git a/components/camel-spring-parent/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchEndpointTest.java b/components/camel-spring-parent/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchEndpointTest.java index 4a3f40538f826..402f7393da051 100644 --- a/components/camel-spring-parent/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchEndpointTest.java +++ b/components/camel-spring-parent/camel-spring-batch/src/test/java/org/apache/camel/component/spring/batch/SpringBatchEndpointTest.java @@ -238,7 +238,7 @@ public void configure() throws Exception { // When assertThrows(FailedToStartRouteException.class, - () -> camelContext.start()); + camelContext::start); } @Test diff --git a/components/camel-spring-parent/camel-spring-main/src/test/java/org/apache/camel/spring/MisspelledRouteRefTest.java b/components/camel-spring-parent/camel-spring-main/src/test/java/org/apache/camel/spring/MisspelledRouteRefTest.java index 492ec36b48b8d..65f9718f6ef12 100644 --- a/components/camel-spring-parent/camel-spring-main/src/test/java/org/apache/camel/spring/MisspelledRouteRefTest.java +++ b/components/camel-spring-parent/camel-spring-main/src/test/java/org/apache/camel/spring/MisspelledRouteRefTest.java @@ -32,7 +32,7 @@ public void testApplicationContextFailed() { Main main = new Main(); main.setApplicationContextUri("org/apache/camel/spring/MisspelledRouteRefTest.xml"); - Exception ex = assertThrows(RuntimeCamelException.class, () -> main.start()); + Exception ex = assertThrows(RuntimeCamelException.class, main::start); CamelException ce = ObjectHelper.getException(CamelException.class, ex); assertNotNull(ce, "Expected a CamelException in the cause chain"); diff --git a/components/camel-spring-parent/camel-spring-redis/src/main/java/org/apache/camel/component/redis/RedisClient.java b/components/camel-spring-parent/camel-spring-redis/src/main/java/org/apache/camel/component/redis/RedisClient.java index f88487036413d..ece0d46dddff7 100644 --- a/components/camel-spring-parent/camel-spring-redis/src/main/java/org/apache/camel/component/redis/RedisClient.java +++ b/components/camel-spring-parent/camel-spring-redis/src/main/java/org/apache/camel/component/redis/RedisClient.java @@ -27,6 +27,7 @@ import org.springframework.data.geo.Distance; import org.springframework.data.geo.GeoResults; import org.springframework.data.geo.Point; +import org.springframework.data.redis.connection.RedisConnectionCommands; import org.springframework.data.redis.connection.RedisGeoCommands.GeoLocation; import org.springframework.data.redis.connection.RedisGeoCommands.GeoRadiusCommandArgs; import org.springframework.data.redis.core.RedisCallback; @@ -256,9 +257,7 @@ public String echo(final String value) { } public String ping() { - return redisTemplate.execute((RedisCallback) connection -> { - return connection.ping(); - }); + return redisTemplate.execute((RedisCallback) RedisConnectionCommands::ping); } public void publish(String channel, Object message) { diff --git a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/LifecycleStrategyInjectionTest.java b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/LifecycleStrategyInjectionTest.java index 741f0e618928e..c4a9988019fc6 100644 --- a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/LifecycleStrategyInjectionTest.java +++ b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/LifecycleStrategyInjectionTest.java @@ -34,7 +34,7 @@ protected AbstractXmlApplicationContext createApplicationContext() { @Test public void testInjectedStrategy() throws Exception { - assertTrue(context.getLifecycleStrategies().stream().anyMatch(s -> s instanceof DummyLifecycleStrategy)); + assertTrue(context.getLifecycleStrategies().stream().anyMatch(DummyLifecycleStrategy.class::isInstance)); } } diff --git a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/MultipleLifecycleStrategyInjectionTest.java b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/MultipleLifecycleStrategyInjectionTest.java index 6695a7a8f5fb0..879ac1a5f02c4 100644 --- a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/MultipleLifecycleStrategyInjectionTest.java +++ b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/MultipleLifecycleStrategyInjectionTest.java @@ -34,7 +34,7 @@ protected AbstractXmlApplicationContext createApplicationContext() { @Test public void testInjectedStrategy() throws Exception { - assertEquals(2, context.getLifecycleStrategies().stream().filter(s -> s instanceof DummyLifecycleStrategy).count()); + assertEquals(2, context.getLifecycleStrategies().stream().filter(DummyLifecycleStrategy.class::isInstance).count()); } } diff --git a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java index b98b3883ba125..db1adf0ab5178 100644 --- a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java +++ b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java @@ -32,9 +32,7 @@ public class ErrorHandlerCamelContextRefNotFoundTest extends SpringTestSupport { @Override @BeforeEach public void setUp() throws Exception { - Exception e = assertThrows(Exception.class, () -> { - super.setUp(); - }); + Exception e = assertThrows(Exception.class, super::setUp); FailedToCreateRouteException cause = assertIsInstanceOf(FailedToCreateRouteException.class, e); NoSuchBeanException nsbe = assertIsInstanceOf(NoSuchBeanException.class, cause.getCause()); assertEquals( diff --git a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.java b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.java index 163cfccf5be89..70a86bea8ea0d 100644 --- a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.java +++ b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.java @@ -32,9 +32,7 @@ public class ErrorHandlerRouteContextRefNotFoundTest extends SpringTestSupport { @Override @BeforeEach public void setUp() throws Exception { - Exception e = assertThrows(Exception.class, () -> { - super.setUp(); - }); + Exception e = assertThrows(Exception.class, super::setUp); FailedToCreateRouteException cause = assertIsInstanceOf(FailedToCreateRouteException.class, e); NoSuchBeanException nsbe = assertIsInstanceOf(NoSuchBeanException.class, cause.getCause()); assertEquals( diff --git a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/config/OnExceptionNoExceptionConfiguredTest.java b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/config/OnExceptionNoExceptionConfiguredTest.java index 69a857e65f229..ce9082ff6356a 100644 --- a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/config/OnExceptionNoExceptionConfiguredTest.java +++ b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/config/OnExceptionNoExceptionConfiguredTest.java @@ -29,9 +29,7 @@ public class OnExceptionNoExceptionConfiguredTest extends SpringTestSupport { @Override @BeforeEach public void setUp() throws Exception { - assertThrows(Exception.class, () -> { - super.setUp(); - }); + assertThrows(Exception.class, super::setUp); } @Override diff --git a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelInvalidDeadLetterUriTest.java b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelInvalidDeadLetterUriTest.java index c160283fcba25..d0f861d2b9e52 100644 --- a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelInvalidDeadLetterUriTest.java +++ b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelInvalidDeadLetterUriTest.java @@ -38,9 +38,7 @@ protected AbstractXmlApplicationContext createApplicationContext() { @Override @BeforeEach public void setUp() throws Exception { - Exception e = assertThrows(Exception.class, () -> { - super.setUp(); - }); + Exception e = assertThrows(Exception.class, super::setUp); FailedToCreateRouteException ftcre = assertIsInstanceOf(FailedToCreateRouteException.class, e); NoSuchEndpointException cause = assertIsInstanceOf(NoSuchEndpointException.class, ftcre.getCause()); assertEquals( diff --git a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelInvalidOptionDeadLetterUriTest.java b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelInvalidOptionDeadLetterUriTest.java index b31d33810ef1e..2abb1a8696fec 100644 --- a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelInvalidOptionDeadLetterUriTest.java +++ b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelInvalidOptionDeadLetterUriTest.java @@ -38,9 +38,7 @@ protected AbstractXmlApplicationContext createApplicationContext() { @Override @BeforeEach public void setUp() throws Exception { - Exception e = assertThrows(Exception.class, () -> { - super.setUp(); - }); + Exception e = assertThrows(Exception.class, super::setUp); FailedToCreateRouteException ftcre = assertIsInstanceOf(FailedToCreateRouteException.class, e); ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, ftcre.getCause()); assertTrue(cause.getMessage().endsWith("Unknown parameters=[{foo=bar}]")); diff --git a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringDoubleLoadBalancerMisconfigurationTest.java b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringDoubleLoadBalancerMisconfigurationTest.java index 9b18dda143282..b6d6cfc02ef01 100644 --- a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringDoubleLoadBalancerMisconfigurationTest.java +++ b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringDoubleLoadBalancerMisconfigurationTest.java @@ -31,9 +31,7 @@ public class SpringDoubleLoadBalancerMisconfigurationTest extends ContextTestSup @Override @BeforeEach public void setUp() throws Exception { - Exception e = assertThrows(Exception.class, () -> { - super.setUp(); - }); + Exception e = assertThrows(Exception.class, super::setUp); FailedToCreateRouteException fe = assertIsInstanceOf(FailedToCreateRouteException.class, e); IllegalArgumentException ie = assertIsInstanceOf(IllegalArgumentException.class, fe.getCause()); assertTrue(ie.getMessage().startsWith( diff --git a/components/camel-stitch/src/test/java/org/apache/camel/component/stitch/client/StitchClientBuilderTest.java b/components/camel-stitch/src/test/java/org/apache/camel/component/stitch/client/StitchClientBuilderTest.java index 74da83dde5f3f..e99f66bf9a071 100644 --- a/components/camel-stitch/src/test/java/org/apache/camel/component/stitch/client/StitchClientBuilderTest.java +++ b/components/camel-stitch/src/test/java/org/apache/camel/component/stitch/client/StitchClientBuilderTest.java @@ -27,13 +27,13 @@ class StitchClientBuilderTest { void shouldNotCreateClientIfTokenOrRegionIsMissing() { final StitchClientBuilder builder = StitchClientBuilder.builder(); - assertThrows(IllegalArgumentException.class, () -> builder.build()); + assertThrows(IllegalArgumentException.class, builder::build); builder.withToken("test"); - assertThrows(IllegalArgumentException.class, () -> builder.build()); + assertThrows(IllegalArgumentException.class, builder::build); final StitchClientBuilder europeBuilder = StitchClientBuilder.builder().withRegion(StitchRegion.EUROPE); - assertThrows(IllegalArgumentException.class, () -> europeBuilder.build()); + assertThrows(IllegalArgumentException.class, europeBuilder::build); } @Test diff --git a/components/camel-stitch/src/test/java/org/apache/camel/component/stitch/client/integration/StitchClientImplIT.java b/components/camel-stitch/src/test/java/org/apache/camel/component/stitch/client/integration/StitchClientImplIT.java index 9a4a9361f2d1d..9d5b1ac55fd19 100644 --- a/components/camel-stitch/src/test/java/org/apache/camel/component/stitch/client/integration/StitchClientImplIT.java +++ b/components/camel-stitch/src/test/java/org/apache/camel/component/stitch/client/integration/StitchClientImplIT.java @@ -111,6 +111,6 @@ void testIfThrowError() throws Exception { .build(); final Mono batch = client.batch(body); - assertThrows(StitchException.class, () -> batch.block()); + assertThrows(StitchException.class, batch::block); } } diff --git a/components/camel-stub/src/main/java/org/apache/camel/component/stub/StubConsole.java b/components/camel-stub/src/main/java/org/apache/camel/component/stub/StubConsole.java index b05d66e24f7e1..e9d0d90e4d7da 100644 --- a/components/camel-stub/src/main/java/org/apache/camel/component/stub/StubConsole.java +++ b/components/camel-stub/src/main/java/org/apache/camel/component/stub/StubConsole.java @@ -70,7 +70,7 @@ protected String doCallText(Map options) { List list = getCamelContext().getEndpoints() .stream() - .filter(e -> e instanceof StubEndpoint) + .filter(StubEndpoint.class::isInstance) .map(StubEndpoint.class::cast) .filter(e -> accept(e.getName(), filter)) .toList(); @@ -130,7 +130,7 @@ protected JsonObject doCallJson(Map options) { JsonArray queues = new JsonArray(); List list = getCamelContext().getEndpoints() - .stream().filter(e -> e instanceof StubEndpoint) + .stream().filter(StubEndpoint.class::isInstance) .map(StubEndpoint.class::cast) .filter(e -> accept(e.getName(), filter)) .toList(); diff --git a/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramChatBotTest.java b/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramChatBotTest.java index 68db643dffa80..a83f34ff25343 100644 --- a/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramChatBotTest.java +++ b/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramChatBotTest.java @@ -45,7 +45,7 @@ public void testChatBotResult() { .until(() -> getMockRoutes().getMock("sendMessage").getRecordedMessages(), rawMessages -> rawMessages.size() >= 2) .stream() - .map(message -> (OutgoingTextMessage) message) + .map(OutgoingTextMessage.class::cast) .toList(); assertCollectionSize(msgs, 2); diff --git a/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramConfigurationTest.java b/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramConfigurationTest.java index ff2bf8163e96a..08b6df2a893b0 100644 --- a/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramConfigurationTest.java +++ b/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramConfigurationTest.java @@ -31,7 +31,7 @@ public class TelegramConfigurationTest extends TelegramTestSupport { @Test public void testChatBotResult() { TelegramEndpoint endpoint = (TelegramEndpoint) context().getEndpoints().stream() - .filter(e -> e instanceof TelegramEndpoint).findAny().get(); + .filter(TelegramEndpoint.class::isInstance).findAny().get(); TelegramConfiguration config = endpoint.getConfiguration(); assertEquals("bots", config.getType()); diff --git a/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramConsumerFallbackConversionTest.java b/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramConsumerFallbackConversionTest.java index b720d039e45b2..6b82246ed90e2 100644 --- a/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramConsumerFallbackConversionTest.java +++ b/components/camel-telegram/src/test/java/org/apache/camel/component/telegram/TelegramConsumerFallbackConversionTest.java @@ -50,7 +50,7 @@ public void testEverythingOk() { .until(() -> getMockRoutes().getMock("sendMessage").getRecordedMessages(), rawMessages -> rawMessages.size() == 1) .stream() - .map(message -> (OutgoingTextMessage) message) + .map(OutgoingTextMessage.class::cast) .toList(); assertCollectionSize(msgs, 1); diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowConsumer.java b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowConsumer.java index 8140a0099537f..b2643412fc1ed 100644 --- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowConsumer.java +++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowConsumer.java @@ -361,7 +361,7 @@ private Exchange createExchange(HttpServerExchange httpExchange) throws Exceptio //securityProvider could add its own header into result exchange if (getEndpoint().getSecurityProvider() != null) { - getEndpoint().getSecurityProvider().addHeader((key, value) -> in.setHeader(key, value), httpExchange); + getEndpoint().getSecurityProvider().addHeader(in::setHeader, httpExchange); } exchange.setProperty(ExchangePropertyKey.CHARSET_NAME, httpExchange.getRequestCharset()); diff --git a/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityFixedDataFormatTest.java b/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityFixedDataFormatTest.java index a4d7fb644a930..b23a530e97175 100644 --- a/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityFixedDataFormatTest.java +++ b/components/camel-univocity-parsers/src/test/java/org/apache/camel/dataformat/univocity/UniVocityFixedDataFormatTest.java @@ -231,7 +231,7 @@ public void shouldConfigureFieldLengthWithHeadersAndLengths() { @Test public void shouldNotAllowNoFieldLengths() { UniVocityFixedDataFormat dataFormat = new UniVocityFixedDataFormat(); - assertThrows(IllegalArgumentException.class, () -> dataFormat.createAndConfigureWriterSettings()); + assertThrows(IllegalArgumentException.class, dataFormat::createAndConfigureWriterSettings); } @Test @@ -243,7 +243,7 @@ public void shouldNotAllowHeadersAndLengthsOfDifferentSize() { assertEquals("1,2,3,4", dataFormat.getFieldLengths()); assertEquals("A,B,C", dataFormat.getHeaders()); - assertThrows(IllegalArgumentException.class, () -> dataFormat.createAndConfigureWriterSettings()); + assertThrows(IllegalArgumentException.class, dataFormat::createAndConfigureWriterSettings); } @Test @@ -255,6 +255,6 @@ public void shouldNotAllowHeadersWithSameName() { assertEquals("1,2,3", dataFormat.getFieldLengths()); assertEquals("A,B,A", dataFormat.getHeaders()); - assertThrows(IllegalArgumentException.class, () -> dataFormat.createAndConfigureWriterSettings()); + assertThrows(IllegalArgumentException.class, dataFormat::createAndConfigureWriterSettings); } } diff --git a/components/camel-wordpress/src/main/java/org/apache/camel/component/wordpress/consumer/WordpressPostConsumer.java b/components/camel-wordpress/src/main/java/org/apache/camel/component/wordpress/consumer/WordpressPostConsumer.java index 21d8b1e488d29..c963a8890ffb9 100644 --- a/components/camel-wordpress/src/main/java/org/apache/camel/component/wordpress/consumer/WordpressPostConsumer.java +++ b/components/camel-wordpress/src/main/java/org/apache/camel/component/wordpress/consumer/WordpressPostConsumer.java @@ -55,7 +55,7 @@ protected int poll() throws Exception { private int pollForPostList() { final List posts = this.servicePosts.list((PostSearchCriteria) getConfiguration().getSearchCriteria()); - posts.stream().forEach(p -> this.process(p)); + posts.stream().forEach(this::process); return posts.size(); } diff --git a/components/camel-wordpress/src/main/java/org/apache/camel/component/wordpress/consumer/WordpressUserConsumer.java b/components/camel-wordpress/src/main/java/org/apache/camel/component/wordpress/consumer/WordpressUserConsumer.java index 5cc285f044a82..fe45f235c1085 100644 --- a/components/camel-wordpress/src/main/java/org/apache/camel/component/wordpress/consumer/WordpressUserConsumer.java +++ b/components/camel-wordpress/src/main/java/org/apache/camel/component/wordpress/consumer/WordpressUserConsumer.java @@ -61,7 +61,7 @@ private int pollForSingle() { private int pollForList() { final List users = this.serviceUsers.list((UserSearchCriteria) getConfiguration().getSearchCriteria()); - users.stream().forEach(p -> this.process(p)); + users.stream().forEach(this::process); LOG.trace("returned users is {}", users); return users.size(); } diff --git a/components/camel-xchange/src/main/java/org/apache/camel/component/xchange/XChange.java b/components/camel-xchange/src/main/java/org/apache/camel/component/xchange/XChange.java index 4dd9fada07d9d..626a78d989bd8 100644 --- a/components/camel-xchange/src/main/java/org/apache/camel/component/xchange/XChange.java +++ b/components/camel-xchange/src/main/java/org/apache/camel/component/xchange/XChange.java @@ -57,7 +57,7 @@ public List getExchangeInstruments() { public List getCurrencyPairs() { return delegate.getExchangeInstruments().stream() - .filter(it -> it instanceof CurrencyPair) + .filter(CurrencyPair.class::isInstance) .map(it -> (CurrencyPair) it) .collect(Collectors.toList()); } diff --git a/components/camel-xchange/src/main/java/org/apache/camel/component/xchange/XChangeEndpoint.java b/components/camel-xchange/src/main/java/org/apache/camel/component/xchange/XChangeEndpoint.java index 8aca542851cd5..f5335cc361363 100644 --- a/components/camel-xchange/src/main/java/org/apache/camel/component/xchange/XChangeEndpoint.java +++ b/components/camel-xchange/src/main/java/org/apache/camel/component/xchange/XChangeEndpoint.java @@ -123,7 +123,7 @@ public CurrencyMetaData getCurrencyMetaData(Currency curr) { public List getCurrencyPairs() { ExchangeMetaData metaData = xchange.getExchangeMetaData(); return metaData.getInstruments().keySet().stream() - .filter(it -> it instanceof CurrencyPair) + .filter(CurrencyPair.class::isInstance) .map(it -> (CurrencyPair) it) .sorted().collect(Collectors.toList()); } diff --git a/components/camel-zookeeper-master/src/main/java/org/apache/camel/component/zookeepermaster/group/internal/ZooKeeperGroup.java b/components/camel-zookeeper-master/src/main/java/org/apache/camel/component/zookeepermaster/group/internal/ZooKeeperGroup.java index d251114fc1063..37064679199d7 100644 --- a/components/camel-zookeeper-master/src/main/java/org/apache/camel/component/zookeepermaster/group/internal/ZooKeeperGroup.java +++ b/components/camel-zookeeper-master/src/main/java/org/apache/camel/component/zookeepermaster/group/internal/ZooKeeperGroup.java @@ -468,7 +468,7 @@ void refresh(final RefreshMode mode) throws Exception { try { ensurePath.ensure(client.getZookeeperClient()); List children = client.getChildren().usingWatcher(childrenWatcher).forPath(path); - children.sort((String left, String right) -> left.compareTo(right)); + children.sort(String::compareTo); processChildren(children, mode); } catch (Exception e) { handleException(e); diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultServiceBootstrapCloseable.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultServiceBootstrapCloseable.java index 4011e88bc9fb8..228f68252bbba 100644 --- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultServiceBootstrapCloseable.java +++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultServiceBootstrapCloseable.java @@ -53,7 +53,7 @@ public void close() { ConfigurerStrategy.clearBootstrapConfigurers(); Set set - = camelContextExtension.getServices().stream().filter(s -> s instanceof BootstrapCloseable) + = camelContextExtension.getServices().stream().filter(BootstrapCloseable.class::isInstance) .collect(Collectors.toSet()); // its a bootstrap service for (Service service : set) { diff --git a/core/camel-base/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java b/core/camel-base/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java index e4acf2cc79682..30613daae8a3d 100644 --- a/core/camel-base/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java +++ b/core/camel-base/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java @@ -369,7 +369,7 @@ public void setLocations(List locations) { this.locations = Collections.unmodifiableList(locations); // we need to re-create the property sources which may have already been created from locations - this.sources.removeIf(s -> s instanceof LocationPropertiesSource); + this.sources.removeIf(LocationPropertiesSource.class::isInstance); // ensure the locations are in the same order as here, and therefore we provide the order number int order = 100; for (PropertiesLocation loc : locations) { diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/SortReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/SortReifier.java index c99fa44a51f7c..5970c746318fa 100644 --- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/SortReifier.java +++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/SortReifier.java @@ -43,7 +43,7 @@ public Processor createProcessor() throws Exception { // if no comparator then default on to string representation if (comp == null) { - comp = (Comparator) (o1, o2) -> ObjectHelper.compare(o1, o2); + comp = (Comparator) ObjectHelper::compare; } // if no expression provided then default to body expression diff --git a/core/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java b/core/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java index 1c7ae939a9eb7..6a703d602b731 100644 --- a/core/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java +++ b/core/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java @@ -816,7 +816,7 @@ protected MockEndpoint getMockEndpoint(String uri, boolean create) throws NoSuch // lookup endpoints in registry and try to find it MockEndpoint found = (MockEndpoint) context.getEndpointRegistry().values().stream() - .filter(e -> e instanceof MockEndpoint).filter(e -> { + .filter(MockEndpoint.class::isInstance).filter(e -> { String t = e.getEndpointUri(); // strip query int idx2 = t.indexOf('?'); diff --git a/core/camel-core/src/test/java/org/apache/camel/builder/FluentProducerTemplateTest.java b/core/camel-core/src/test/java/org/apache/camel/builder/FluentProducerTemplateTest.java index ffc716e90db50..c27d0a914cb74 100644 --- a/core/camel-core/src/test/java/org/apache/camel/builder/FluentProducerTemplateTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/builder/FluentProducerTemplateTest.java @@ -43,10 +43,10 @@ public void testNoEndpoint() { FluentProducerTemplate fluent = context.createFluentProducerTemplate(); FluentProducerTemplate helloWorld = fluent.withBody("Hello World"); - assertThrows(IllegalArgumentException.class, () -> helloWorld.send(), + assertThrows(IllegalArgumentException.class, helloWorld::send, "Should have thrown exception"); - assertThrows(IllegalArgumentException.class, () -> helloWorld.request(), + assertThrows(IllegalArgumentException.class, helloWorld::request, "Should have thrown exception"); } diff --git a/core/camel-core/src/test/java/org/apache/camel/component/direct/DirectNoMultipleConsumersTest.java b/core/camel-core/src/test/java/org/apache/camel/component/direct/DirectNoMultipleConsumersTest.java index c524f5b12c9fa..10b5d31d2c99f 100644 --- a/core/camel-core/src/test/java/org/apache/camel/component/direct/DirectNoMultipleConsumersTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/component/direct/DirectNoMultipleConsumersTest.java @@ -40,7 +40,7 @@ public void configure() { } }); - Assertions.assertThrows(FailedToStartRouteException.class, () -> container.start(), + Assertions.assertThrows(FailedToStartRouteException.class, container::start, "Should have thrown an FailedToStartRouteException"); container.stop(); diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeNoopIdempotentEnabledTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeNoopIdempotentEnabledTest.java index 043bc09da05a4..d9b269b88c685 100644 --- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeNoopIdempotentEnabledTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeNoopIdempotentEnabledTest.java @@ -36,9 +36,7 @@ public void testNoop() { template.sendBodyAndHeader(fileUri(), "Hello World", Exchange.FILE_NAME, "hello.txt"); // give some time to let consumer try to read the file multiple times - Awaitility.await().pollDelay(50, TimeUnit.MILLISECONDS).untilAsserted(() -> { - assertMockEndpointsSatisfied(); - }); + Awaitility.await().pollDelay(50, TimeUnit.MILLISECONDS).untilAsserted(this::assertMockEndpointsSatisfied); } @Override diff --git a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentRefTest.java b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentRefTest.java index 9cc234c810fd4..fa6737f0c6f58 100644 --- a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentRefTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentRefTest.java @@ -77,9 +77,7 @@ public void testIdempotentRef() throws Exception { Files.move(testFile("done/report.txt"), testFile("report.txt")); // should NOT consume the file again, let a bit time go - Awaitility.await().pollDelay(100, TimeUnit.MILLISECONDS).untilAsserted(() -> { - assertMockEndpointsSatisfied(); - }); + Awaitility.await().pollDelay(100, TimeUnit.MILLISECONDS).untilAsserted(this::assertMockEndpointsSatisfied); assertTrue(invoked, "MyIdempotentRepository should have been invoked"); } diff --git a/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltCustomErrorListenerTest.java b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltCustomErrorListenerTest.java index ad16d9b565ab9..53828cf232fd9 100644 --- a/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltCustomErrorListenerTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltCustomErrorListenerTest.java @@ -75,7 +75,7 @@ public void testErrorListener() throws Exception { CamelContext context = new DefaultCamelContext(); context.getRegistry().bind("myListener", listener); context.addRoutes(builder); - assertThrows(RuntimeCamelException.class, () -> context.start()); + assertThrows(RuntimeCamelException.class, context::start); assertFalse(listener.isWarning()); assertTrue(listener.isError(), "My error listener should been invoked"); diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithMockEndpointsTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithMockEndpointsTest.java index 9196ca983f840..a13b57e9601c4 100644 --- a/core/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithMockEndpointsTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithMockEndpointsTest.java @@ -18,6 +18,7 @@ import org.apache.camel.ContextTestSupport; import org.apache.camel.builder.AdviceWith; +import org.apache.camel.builder.AdviceWithRouteBuilder; import org.apache.camel.builder.RouteBuilder; import org.junit.jupiter.api.Test; @@ -41,9 +42,9 @@ public void testNoAdvised() throws Exception { public void testAdvisedMockEndpoints() throws Exception { // advice the start route using the inlined AdviceWith lambda style route builder // which has extended capabilities than the regular route builder - AdviceWith.adviceWith(context, "start", a -> - // mock all endpoints - a.mockEndpoints()); + AdviceWith.adviceWith(context, "start", + // mock all endpoints + AdviceWithRouteBuilder::mockEndpoints); getMockEndpoint("mock:direct:start").expectedBodiesReceived("Hello World"); getMockEndpoint("mock:direct:foo").expectedBodiesReceived("Hello World"); diff --git a/core/camel-core/src/test/java/org/apache/camel/support/ServiceSupportTest.java b/core/camel-core/src/test/java/org/apache/camel/support/ServiceSupportTest.java index 7129dd4c56362..9de495f34f75c 100644 --- a/core/camel-core/src/test/java/org/apache/camel/support/ServiceSupportTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/support/ServiceSupportTest.java @@ -108,7 +108,7 @@ public void testExceptionOnStart() { // forced not being stopped at start assertFalse(service.isStopped()); - assertThrows(RuntimeException.class, () -> service.start(), "RuntimeException expected"); + assertThrows(RuntimeException.class, service::start, "RuntimeException expected"); assertTrue(service.isStopped()); assertFalse(service.isStopping()); diff --git a/core/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java b/core/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java index 981627e9d617f..8eecabd82b139 100644 --- a/core/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java @@ -325,9 +325,7 @@ void testCreateIteratorWithStringAndCommaSeparatorEmptyString() { Iterator it = ObjectHelper.createIterator(s, ",", true); assertEquals("", it.next()); assertFalse(it.hasNext()); - NoSuchElementException nsee = assertThrows(NoSuchElementException.class, () -> { - it.next(); - }); + NoSuchElementException nsee = assertThrows(NoSuchElementException.class, it::next); assertEquals("no more element available for '' at the index 1", nsee.getMessage()); } @@ -368,18 +366,14 @@ void testCreateIteratorWithPrimitiveArrayTypes() { assertEquals(Byte.MIN_VALUE, it.next()); assertFalse(it.hasNext()); final Iterator it1 = it; - NoSuchElementException nsee = assertThrows(NoSuchElementException.class, () -> { - it1.next(); - }); + NoSuchElementException nsee = assertThrows(NoSuchElementException.class, it1::next); assertTrue(nsee.getMessage().startsWith("no more element available for '[B@"), nsee.getMessage()); assertTrue(nsee.getMessage().endsWith("at the index 4"), nsee.getMessage()); it = ObjectHelper.createIterator(new byte[] {}, null); assertFalse(it.hasNext()); final Iterator it2 = it; - nsee = assertThrows(NoSuchElementException.class, () -> { - it2.next(); - }); + nsee = assertThrows(NoSuchElementException.class, it2::next); assertTrue(nsee.getMessage().startsWith("no more element available for '[B@"), nsee.getMessage()); assertTrue(nsee.getMessage().endsWith("at the index 0"), nsee.getMessage()); @@ -394,18 +388,14 @@ void testCreateIteratorWithPrimitiveArrayTypes() { assertEquals(Short.MIN_VALUE, it.next()); assertFalse(it.hasNext()); final Iterator it3 = it; - nsee = assertThrows(NoSuchElementException.class, () -> { - it3.next(); - }); + nsee = assertThrows(NoSuchElementException.class, it3::next); assertTrue(nsee.getMessage().startsWith("no more element available for '[S@"), nsee.getMessage()); assertTrue(nsee.getMessage().endsWith("at the index 4"), nsee.getMessage()); it = ObjectHelper.createIterator(new short[] {}, null); assertFalse(it.hasNext()); final Iterator it4 = it; - nsee = assertThrows(NoSuchElementException.class, () -> { - it4.next(); - }); + nsee = assertThrows(NoSuchElementException.class, it4::next); assertTrue(nsee.getMessage().startsWith("no more element available for '[S@"), nsee.getMessage()); assertTrue(nsee.getMessage().endsWith("at the index 0"), nsee.getMessage()); @@ -420,18 +410,14 @@ void testCreateIteratorWithPrimitiveArrayTypes() { assertEquals(Integer.MIN_VALUE, it.next()); assertFalse(it.hasNext()); final Iterator it5 = it; - nsee = assertThrows(NoSuchElementException.class, () -> { - it5.next(); - }); + nsee = assertThrows(NoSuchElementException.class, it5::next); assertTrue(nsee.getMessage().startsWith("no more element available for '[I@"), nsee.getMessage()); assertTrue(nsee.getMessage().endsWith("at the index 4"), nsee.getMessage()); it = ObjectHelper.createIterator(new int[] {}, null); assertFalse(it.hasNext()); final Iterator it6 = it; - nsee = assertThrows(NoSuchElementException.class, () -> { - it6.next(); - }); + nsee = assertThrows(NoSuchElementException.class, it6::next); assertTrue(nsee.getMessage().startsWith("no more element available for '[I@"), nsee.getMessage()); assertTrue(nsee.getMessage().endsWith("at the index 0"), nsee.getMessage()); @@ -446,18 +432,14 @@ void testCreateIteratorWithPrimitiveArrayTypes() { assertEquals(Long.MIN_VALUE, it.next()); assertFalse(it.hasNext()); final Iterator it7 = it; - nsee = assertThrows(NoSuchElementException.class, () -> { - it7.next(); - }); + nsee = assertThrows(NoSuchElementException.class, it7::next); assertTrue(nsee.getMessage().startsWith("no more element available for '[J@"), nsee.getMessage()); assertTrue(nsee.getMessage().endsWith("at the index 4"), nsee.getMessage()); it = ObjectHelper.createIterator(new long[] {}, null); assertFalse(it.hasNext()); final Iterator it8 = it; - nsee = assertThrows(NoSuchElementException.class, () -> { - it8.next(); - }); + nsee = assertThrows(NoSuchElementException.class, it8::next); assertTrue(nsee.getMessage().startsWith("no more element available for '[J@"), nsee.getMessage()); assertTrue(nsee.getMessage().endsWith("at the index 0"), nsee.getMessage()); @@ -472,18 +454,14 @@ void testCreateIteratorWithPrimitiveArrayTypes() { assertEquals(Float.MIN_VALUE, it.next()); assertFalse(it.hasNext()); final Iterator it9 = it; - nsee = assertThrows(NoSuchElementException.class, () -> { - it9.next(); - }); + nsee = assertThrows(NoSuchElementException.class, it9::next); assertTrue(nsee.getMessage().startsWith("no more element available for '[F@"), nsee.getMessage()); assertTrue(nsee.getMessage().endsWith("at the index 4"), nsee.getMessage()); it = ObjectHelper.createIterator(new float[] {}, null); assertFalse(it.hasNext()); final Iterator it10 = it; - nsee = assertThrows(NoSuchElementException.class, () -> { - it10.next(); - }); + nsee = assertThrows(NoSuchElementException.class, it10::next); assertTrue(nsee.getMessage().startsWith("no more element available for '[F@"), nsee.getMessage()); assertTrue(nsee.getMessage().endsWith("at the index 0"), nsee.getMessage()); @@ -498,18 +476,14 @@ void testCreateIteratorWithPrimitiveArrayTypes() { assertEquals(Double.MIN_VALUE, it.next()); assertFalse(it.hasNext()); final Iterator it11 = it; - nsee = assertThrows(NoSuchElementException.class, () -> { - it11.next(); - }); + nsee = assertThrows(NoSuchElementException.class, it11::next); assertTrue(nsee.getMessage().startsWith("no more element available for '[D@"), nsee.getMessage()); assertTrue(nsee.getMessage().endsWith("at the index 4"), nsee.getMessage()); it = ObjectHelper.createIterator(new double[] {}, null); assertFalse(it.hasNext()); final Iterator it12 = it; - nsee = assertThrows(NoSuchElementException.class, () -> { - it12.next(); - }); + nsee = assertThrows(NoSuchElementException.class, it12::next); assertTrue(nsee.getMessage().startsWith("no more element available for '[D@"), nsee.getMessage()); assertTrue(nsee.getMessage().endsWith("at the index 0"), nsee.getMessage()); @@ -526,18 +500,14 @@ void testCreateIteratorWithPrimitiveArrayTypes() { assertEquals('l', it.next()); assertFalse(it.hasNext()); final Iterator it13 = it; - nsee = assertThrows(NoSuchElementException.class, () -> { - it13.next(); - }); + nsee = assertThrows(NoSuchElementException.class, it13::next); assertTrue(nsee.getMessage().startsWith("no more element available for '[C@"), nsee.getMessage()); assertTrue(nsee.getMessage().endsWith("at the index 5"), nsee.getMessage()); it = ObjectHelper.createIterator(new char[] {}, null); assertFalse(it.hasNext()); final Iterator it14 = it; - nsee = assertThrows(NoSuchElementException.class, () -> { - it14.next(); - }); + nsee = assertThrows(NoSuchElementException.class, it14::next); assertTrue(nsee.getMessage().startsWith("no more element available for '[C@"), nsee.getMessage()); assertTrue(nsee.getMessage().endsWith("at the index 0"), nsee.getMessage()); @@ -554,18 +524,14 @@ void testCreateIteratorWithPrimitiveArrayTypes() { assertEquals(Boolean.TRUE, it.next()); assertFalse(it.hasNext()); final Iterator it15 = it; - nsee = assertThrows(NoSuchElementException.class, () -> { - it15.next(); - }); + nsee = assertThrows(NoSuchElementException.class, it15::next); assertTrue(nsee.getMessage().startsWith("no more element available for '[Z@"), nsee.getMessage()); assertTrue(nsee.getMessage().endsWith("at the index 5"), nsee.getMessage()); it = ObjectHelper.createIterator(new boolean[] {}, null); assertFalse(it.hasNext()); final Iterator it16 = it; - nsee = assertThrows(NoSuchElementException.class, () -> { - it16.next(); - }); + nsee = assertThrows(NoSuchElementException.class, it16::next); assertTrue(nsee.getMessage().startsWith("no more element available for '[Z@"), nsee.getMessage()); assertTrue(nsee.getMessage().endsWith("at the index 0"), nsee.getMessage()); } @@ -627,25 +593,19 @@ void testIteratorEmpty() { Iterator it = ObjectHelper.createIterator(""); assertFalse(it.hasNext()); final Iterator it17 = it; - NoSuchElementException nsee = assertThrows(NoSuchElementException.class, () -> { - it17.next(); - }); + NoSuchElementException nsee = assertThrows(NoSuchElementException.class, it17::next); assertEquals("no more element available for '' at the index 0", nsee.getMessage()); it = ObjectHelper.createIterator(" "); assertFalse(it.hasNext()); final Iterator it18 = it; - nsee = assertThrows(NoSuchElementException.class, () -> { - it18.next(); - }); + nsee = assertThrows(NoSuchElementException.class, it18::next); assertEquals("no more element available for ' ' at the index 0", nsee.getMessage()); it = ObjectHelper.createIterator(null); assertFalse(it.hasNext()); final Iterator it19 = it; - assertThrows(NoSuchElementException.class, () -> { - it19.next(); - }); + assertThrows(NoSuchElementException.class, it19::next); } @Test @@ -655,9 +615,7 @@ void testIteratorIdempotentNext() { assertTrue(it.hasNext()); it.next(); assertFalse(it.hasNext()); - NoSuchElementException nsee = assertThrows(NoSuchElementException.class, () -> { - it.next(); - }); + NoSuchElementException nsee = assertThrows(NoSuchElementException.class, it::next); assertEquals("no more element available for 'a' at the index 1", nsee.getMessage()); } @@ -679,9 +637,7 @@ public int getLength() { assertTrue(it.hasNext()); it.next(); assertFalse(it.hasNext()); - NoSuchElementException nsee = assertThrows(NoSuchElementException.class, () -> { - it.next(); - }); + NoSuchElementException nsee = assertThrows(NoSuchElementException.class, it::next); assertTrue(nsee.getMessage().startsWith("no more element available for 'org.apache.camel.util.ObjectHelperTest$"), nsee.getMessage()); assertTrue(nsee.getMessage().endsWith("at the index 1"), nsee.getMessage()); @@ -838,9 +794,7 @@ void testIteratorWithMessage() { assertEquals("b", it.next()); assertEquals("c", it.next()); assertFalse(it.hasNext()); - assertThrows(NoSuchElementException.class, () -> { - it.next(); - }); + assertThrows(NoSuchElementException.class, it::next); } @Test @@ -850,9 +804,7 @@ void testIteratorWithEmptyMessage() { Iterator it = ObjectHelper.createIterator(msg); assertFalse(it.hasNext()); - NoSuchElementException nsee = assertThrows(NoSuchElementException.class, () -> { - it.next(); - }); + NoSuchElementException nsee = assertThrows(NoSuchElementException.class, it::next); assertEquals("no more element available for '' at the index 0", nsee.getMessage()); } @@ -863,9 +815,7 @@ void testIteratorWithNullMessage() { Iterator it = ObjectHelper.createIterator(msg); assertFalse(it.hasNext()); - assertThrows(NoSuchElementException.class, () -> { - it.next(); - }); + assertThrows(NoSuchElementException.class, it::next); } @Test @@ -885,9 +835,7 @@ public Iterator iterator() { assertEquals("B", it.next()); assertEquals("C", it.next()); assertFalse(it.hasNext()); - assertThrows(NoSuchElementException.class, () -> { - it.next(); - }); + assertThrows(NoSuchElementException.class, it::next); } @Test diff --git a/core/camel-health/src/main/java/org/apache/camel/impl/health/DefaultHealthCheckRegistry.java b/core/camel-health/src/main/java/org/apache/camel/impl/health/DefaultHealthCheckRegistry.java index e8d36777c1ba0..84c80cb63b6bc 100644 --- a/core/camel-health/src/main/java/org/apache/camel/impl/health/DefaultHealthCheckRegistry.java +++ b/core/camel-health/src/main/java/org/apache/camel/impl/health/DefaultHealthCheckRegistry.java @@ -121,7 +121,7 @@ protected void doInit() throws Exception { super.doInit(); Optional hcr = repositories.stream() - .filter(repository -> repository instanceof HealthCheckRegistryRepository) + .filter(HealthCheckRegistryRepository.class::isInstance) .findFirst(); if (hcr.isEmpty()) { diff --git a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java index e73e1565752cb..7f3b8058dad21 100644 --- a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java +++ b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java @@ -928,7 +928,7 @@ protected void postProcessCamelContext(CamelContext camelContext) throws Excepti final OrderedLocationProperties propertyPlaceholders = new OrderedLocationProperties(); // use the main autowired lifecycle strategy instead of the default - camelContext.getLifecycleStrategies().removeIf(s -> s instanceof AutowiredLifecycleStrategy); + camelContext.getLifecycleStrategies().removeIf(AutowiredLifecycleStrategy.class::isInstance); camelContext.addLifecycleStrategy(createLifecycleStrategy(camelContext)); // setup properties diff --git a/core/camel-main/src/test/java/org/apache/camel/main/MainIoCBeanPostProcessorDisabledTest.java b/core/camel-main/src/test/java/org/apache/camel/main/MainIoCBeanPostProcessorDisabledTest.java index 67b0d98cb1e1e..a0db8c350c913 100644 --- a/core/camel-main/src/test/java/org/apache/camel/main/MainIoCBeanPostProcessorDisabledTest.java +++ b/core/camel-main/src/test/java/org/apache/camel/main/MainIoCBeanPostProcessorDisabledTest.java @@ -53,7 +53,7 @@ public void testMainIoCDisabled() { main.configure().addRoutesBuilder(new MyRouteBuilder()); main.configure().withBeanPostProcessorEnabled(false); - FailedToCreateRouteException e = assertThrows(FailedToCreateRouteException.class, () -> main.start()); + FailedToCreateRouteException e = assertThrows(FailedToCreateRouteException.class, main::start); NoSuchBeanException nsbe = (NoSuchBeanException) e.getCause(); assertEquals("tiger", nsbe.getName()); } diff --git a/core/camel-main/src/test/java/org/apache/camel/main/MainScan3Test.java b/core/camel-main/src/test/java/org/apache/camel/main/MainScan3Test.java index a1a631bcc30b0..3568585446431 100644 --- a/core/camel-main/src/test/java/org/apache/camel/main/MainScan3Test.java +++ b/core/camel-main/src/test/java/org/apache/camel/main/MainScan3Test.java @@ -28,7 +28,7 @@ public class MainScan3Test { public void testScan3() { Main main = new Main(); main.configure().withBasePackageScan("org.apache.camel.main.scan3"); - FailedToCreateRouteException e = assertThrows(FailedToCreateRouteException.class, () -> main.start()); + FailedToCreateRouteException e = assertThrows(FailedToCreateRouteException.class, main::start); assertEquals( "Failed to create route because: Duplicate route ids detected: foo2. Please correct ids to be unique among all your routes.", e.getMessage()); diff --git a/core/camel-main/src/test/java/org/apache/camel/main/MainStartupConditionTest.java b/core/camel-main/src/test/java/org/apache/camel/main/MainStartupConditionTest.java index c076b287d1c8d..e54cfeb5fc4fb 100644 --- a/core/camel-main/src/test/java/org/apache/camel/main/MainStartupConditionTest.java +++ b/core/camel-main/src/test/java/org/apache/camel/main/MainStartupConditionTest.java @@ -33,7 +33,7 @@ public void testCustomCondition() { main.configure().withRoutesBuilderClasses("org.apache.camel.main.MainStartupConditionTest$MyRoute"); main.configure().startupCondition().withEnabled(true).withTimeout(250).withInterval(100) .withCustomClassNames("org.apache.camel.main.MainStartupConditionTest$MyCondition"); - Exception e = assertThrows(Exception.class, () -> main.start()); + Exception e = assertThrows(Exception.class, main::start); Assertions.assertEquals("Startup condition timeout error", e.getCause().getMessage()); } finally { main.stop(); diff --git a/core/camel-main/src/test/java/org/apache/camel/main/MainStartupConditionTimeoutTest.java b/core/camel-main/src/test/java/org/apache/camel/main/MainStartupConditionTimeoutTest.java index 8804f36fd0b4b..dd373a7224447 100644 --- a/core/camel-main/src/test/java/org/apache/camel/main/MainStartupConditionTimeoutTest.java +++ b/core/camel-main/src/test/java/org/apache/camel/main/MainStartupConditionTimeoutTest.java @@ -34,7 +34,7 @@ public void testCustomCondition() { .withOnTimeout("fail") .withTimeout(250) .withCustomClassNames("org.apache.camel.main.MainStartupConditionTimeoutTest$MyEnvCondition"); - Exception e = assertThrows(Exception.class, () -> main.start()); + Exception e = assertThrows(Exception.class, main::start); Assertions.assertEquals( "Startup condition: ENV cannot continue due to: OS Environment Variable: MY_ENV does not exist", e.getCause().getMessage()); diff --git a/core/camel-main/src/test/java/org/apache/camel/main/MainSupervisingRouteControllerFilterFailToStartRouteTest.java b/core/camel-main/src/test/java/org/apache/camel/main/MainSupervisingRouteControllerFilterFailToStartRouteTest.java index ff53d08829883..3daad16ed3434 100644 --- a/core/camel-main/src/test/java/org/apache/camel/main/MainSupervisingRouteControllerFilterFailToStartRouteTest.java +++ b/core/camel-main/src/test/java/org/apache/camel/main/MainSupervisingRouteControllerFilterFailToStartRouteTest.java @@ -45,7 +45,7 @@ public void testMain() { main.configure().routeControllerConfig().setThreadPoolSize(2); main.configure().routeControllerConfig().setExcludeRoutes("inbox"); - FailedToStartRouteException e = assertThrows(FailedToStartRouteException.class, () -> main.start()); + FailedToStartRouteException e = assertThrows(FailedToStartRouteException.class, main::start); assertEquals("inbox", e.getRouteId()); main.stop(); diff --git a/core/camel-main/src/test/java/org/apache/camel/main/MainTest.java b/core/camel-main/src/test/java/org/apache/camel/main/MainTest.java index 57d8a090b4cad..187793c079cf8 100644 --- a/core/camel-main/src/test/java/org/apache/camel/main/MainTest.java +++ b/core/camel-main/src/test/java/org/apache/camel/main/MainTest.java @@ -189,7 +189,7 @@ protected void configureLifecycle(CamelContext camelContext) throws Exception { ManagementStrategy strategy = camelContext.getManagementStrategy(); assertEquals(1, durationMaxMessages.get(), "DurationMaxMessages should be set to 1"); - assertTrue(strategy.getEventNotifiers().stream().anyMatch(n -> n instanceof MainDurationEventNotifier)); + assertTrue(strategy.getEventNotifiers().stream().anyMatch(MainDurationEventNotifier.class::isInstance)); main.stop(); } diff --git a/core/camel-management/src/main/java/org/apache/camel/management/JmxManagementStrategyFactory.java b/core/camel-management/src/main/java/org/apache/camel/management/JmxManagementStrategyFactory.java index c6441361d8f6b..4d29ed17273ec 100644 --- a/core/camel-management/src/main/java/org/apache/camel/management/JmxManagementStrategyFactory.java +++ b/core/camel-management/src/main/java/org/apache/camel/management/JmxManagementStrategyFactory.java @@ -56,7 +56,7 @@ public void setupManagement(CamelContext camelContext, ManagementStrategy strate // and therefore will be in use List> preServices = null; JmxManagementLifecycleStrategy jmx = camelContext.getLifecycleStrategies().stream() - .filter(s -> s instanceof JmxManagementLifecycleStrategy) + .filter(JmxManagementLifecycleStrategy.class::isInstance) .map(JmxManagementLifecycleStrategy.class::cast) .findFirst().orElse(null); if (jmx != null) { @@ -70,7 +70,7 @@ public void setupManagement(CamelContext camelContext, ManagementStrategy strate } // camel-spring may re-initialize JMX during startup, so remove any previous - camelContext.getLifecycleStrategies().removeIf(s -> s instanceof JmxManagementLifecycleStrategy); + camelContext.getLifecycleStrategies().removeIf(JmxManagementLifecycleStrategy.class::isInstance); } camelContext.getLifecycleStrategies().add(0, lifecycle); } diff --git a/dsl/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/AwsS3PollEnrichTest.java b/dsl/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/AwsS3PollEnrichTest.java index d4971c60efacb..a07ae64e20e2d 100644 --- a/dsl/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/AwsS3PollEnrichTest.java +++ b/dsl/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/AwsS3PollEnrichTest.java @@ -28,7 +28,7 @@ public boolean isUseRouteBuilder() { @Test public void test() throws Exception { - Assertions.assertDoesNotThrow(() -> doRun()); + Assertions.assertDoesNotThrow(this::doRun); } private void doRun() throws Exception { diff --git a/dsl/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/HttpProxyTest.java b/dsl/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/HttpProxyTest.java index e47738985a9ac..6f62d8af2eec6 100644 --- a/dsl/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/HttpProxyTest.java +++ b/dsl/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/HttpProxyTest.java @@ -49,7 +49,7 @@ public void configure() throws Exception { } }); - HttpEndpoint he = (HttpEndpoint) context.getEndpoints().stream().filter(e -> e instanceof HttpEndpoint).findFirst() + HttpEndpoint he = (HttpEndpoint) context.getEndpoints().stream().filter(HttpEndpoint.class::isInstance).findFirst() .orElse(null); assertEquals("myproxy", he.getProxyHost()); assertEquals(3280, he.getProxyPort()); @@ -76,7 +76,7 @@ public void configure() throws Exception { } }); - HttpEndpoint he = (HttpEndpoint) context.getEndpoints().stream().filter(e -> e instanceof HttpEndpoint).findFirst() + HttpEndpoint he = (HttpEndpoint) context.getEndpoints().stream().filter(HttpEndpoint.class::isInstance).findFirst() .orElse(null); assertEquals("myproxy", he.getProxyHost()); assertEquals(0, he.getProxyPort()); diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java index 24ccf486aa70c..eda7a40f026fb 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java +++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java @@ -1291,7 +1291,7 @@ private void copyAgentLibDependencies(MavenGav gav) { protected void copyApplicationPropertiesFiles(Path srcResourcesDir) throws Exception { try (Stream files = Files.list(exportBaseDir)) { - files.filter(p -> Files.isRegularFile(p)) + files.filter(Files::isRegularFile) .filter(p -> { String fileName = p.getFileName().toString(); String ext = FileUtil.onlyExt(fileName); diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/update/CamelUpdate.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/update/CamelUpdate.java index 591275beb6a34..827b288c4acdb 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/update/CamelUpdate.java +++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/update/CamelUpdate.java @@ -65,11 +65,11 @@ public List activeRecipes() throws CamelUpdateException { // The recipe named latest.yaml contains all the recipe for the update up to the selected version if (recipe.name().contains("latest")) { activeRecipes.clear(); - recipe.recipeName().ifPresent(name -> activeRecipes.add(name)); + recipe.recipeName().ifPresent(activeRecipes::add); break; } - recipe.recipeName().ifPresent(name -> activeRecipes.add(name)); + recipe.recipeName().ifPresent(activeRecipes::add); } return activeRecipes; diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/update/UpdateList.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/update/UpdateList.java index 70fa469ea396a..6bc46d16220e4 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/update/UpdateList.java +++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/update/UpdateList.java @@ -190,11 +190,11 @@ public Integer doCall() throws Exception { new Column().header("VERSION").minWidth(10).dataAlign(HorizontalAlign.LEFT) .with(r -> r.version().toString()), new Column().header("RUNTIME") - .dataAlign(HorizontalAlign.LEFT).with(r -> r.runtime()), + .dataAlign(HorizontalAlign.LEFT).with(Row::runtime), new Column().header("RUNTIME VERSION") - .dataAlign(HorizontalAlign.LEFT).with(r -> r.runtimeVersion()), + .dataAlign(HorizontalAlign.LEFT).with(Row::runtimeVersion), new Column().header("DESCRIPTION").maxWidth(descWidth) - .dataAlign(HorizontalAlign.LEFT).with(r -> r.description())))); + .dataAlign(HorizontalAlign.LEFT).with(Row::description)))); } return 0; diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/java/org/apache/camel/yaml/dsl/kamelet/AwsRawSecretTest.java b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/java/org/apache/camel/yaml/dsl/kamelet/AwsRawSecretTest.java index c095b60c17487..a75e31d98265a 100644 --- a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/java/org/apache/camel/yaml/dsl/kamelet/AwsRawSecretTest.java +++ b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/java/org/apache/camel/yaml/dsl/kamelet/AwsRawSecretTest.java @@ -43,7 +43,7 @@ public void testAwsRawSecret() throws Exception { context.setRouteController(new DefaultSupervisingRouteController()); context.start(); - Endpoint e = context.getEndpoints().stream().filter(p -> p instanceof AWS2S3Endpoint).findFirst().orElse(null); + Endpoint e = context.getEndpoints().stream().filter(AWS2S3Endpoint.class::isInstance).findFirst().orElse(null); AWS2S3Endpoint a = Assertions.assertInstanceOf(AWS2S3Endpoint.class, e); Assertions.assertEquals(KEY_1, a.getConfiguration().getAccessKey()); Assertions.assertEquals(KEY_2, a.getConfiguration().getSecretKey()); diff --git a/test-infra/camel-test-infra-cli/src/main/java/org/apache/camel/test/infra/cli/services/CliBuiltContainer.java b/test-infra/camel-test-infra-cli/src/main/java/org/apache/camel/test/infra/cli/services/CliBuiltContainer.java index bbdf855b64571..25a8e2d2b9617 100644 --- a/test-infra/camel-test-infra-cli/src/main/java/org/apache/camel/test/infra/cli/services/CliBuiltContainer.java +++ b/test-infra/camel-test-infra-cli/src/main/java/org/apache/camel/test/infra/cli/services/CliBuiltContainer.java @@ -103,7 +103,7 @@ public CliBuiltContainer(CliBuiltContainerParams params) { } withExposedPorts(DEV_CONSOLE_PORT, SSH_PORT); if (Objects.nonNull(params.getExtraHosts())) { - params.getExtraHosts().forEach((host, ip) -> withExtraHost(host, ip)); + params.getExtraHosts().forEach(this::withExtraHost); } if (Objects.nonNull(params.getTrustedCertPaths())) { params.getTrustedCertPaths().forEach(t -> { diff --git a/test-infra/camel-test-infra-core/src/main/java/org/apache/camel/test/infra/core/MockUtils.java b/test-infra/camel-test-infra-core/src/main/java/org/apache/camel/test/infra/core/MockUtils.java index c7aa6a1abd001..feaceb59e48ec 100644 --- a/test-infra/camel-test-infra-core/src/main/java/org/apache/camel/test/infra/core/MockUtils.java +++ b/test-infra/camel-test-infra-core/src/main/java/org/apache/camel/test/infra/core/MockUtils.java @@ -87,7 +87,7 @@ public static MockEndpoint getMockEndpoint(CamelContext context, String uri, boo // lookup endpoints in registry and try to find it MockEndpoint found = (MockEndpoint) context.getEndpointRegistry().values().stream() - .filter(e -> e instanceof MockEndpoint).filter(e -> { + .filter(MockEndpoint.class::isInstance).filter(e -> { String t = e.getEndpointUri(); // strip query int idx2 = t.indexOf('?'); diff --git a/test-infra/camel-test-infra-fhir/src/main/java/org/apache/camel/test/infra/fhir/services/FhirServiceFactory.java b/test-infra/camel-test-infra-fhir/src/main/java/org/apache/camel/test/infra/fhir/services/FhirServiceFactory.java index 0a90d245920a3..3877615f00c1c 100644 --- a/test-infra/camel-test-infra-fhir/src/main/java/org/apache/camel/test/infra/fhir/services/FhirServiceFactory.java +++ b/test-infra/camel-test-infra-fhir/src/main/java/org/apache/camel/test/infra/fhir/services/FhirServiceFactory.java @@ -40,7 +40,7 @@ public static FhirService createService() { public static FhirService createSingletonService() { return builder() - .addLocalMapping(() -> new FhirLocalSingletonContainerService()) + .addLocalMapping(FhirLocalSingletonContainerService::new) .addRemoteMapping(FhirRemoteTestService::new) .build(); } diff --git a/test-infra/camel-test-infra-openai-mock/src/main/java/org/apache/camel/test/infra/openai/mock/OpenAIMockFailuresTest.java b/test-infra/camel-test-infra-openai-mock/src/main/java/org/apache/camel/test/infra/openai/mock/OpenAIMockFailuresTest.java index 74aa778a50439..3fc5f7cc27a2d 100644 --- a/test-infra/camel-test-infra-openai-mock/src/main/java/org/apache/camel/test/infra/openai/mock/OpenAIMockFailuresTest.java +++ b/test-infra/camel-test-infra-openai-mock/src/main/java/org/apache/camel/test/infra/openai/mock/OpenAIMockFailuresTest.java @@ -67,7 +67,7 @@ public void testBuilderExceptions() { assertThrows(IllegalStateException.class, () -> builder.invokeTool("test")); assertThrows(IllegalStateException.class, () -> builder.withParam("key", "value")); assertThrows(IllegalStateException.class, () -> builder.thenRespondWith((req, in) -> null)); - assertThrows(IllegalStateException.class, () -> builder.end()); + assertThrows(IllegalStateException.class, builder::end); builder.when("sentence"); assertThrows(IllegalStateException.class, () -> builder.withParam("key", "value")); diff --git a/tooling/maven/sync-properties-maven-plugin/src/main/java/org/apache/camel/maven/sync/properties/SyncPropertiesMojo.java b/tooling/maven/sync-properties-maven-plugin/src/main/java/org/apache/camel/maven/sync/properties/SyncPropertiesMojo.java index 11699c654ba86..3f339f760c0b8 100644 --- a/tooling/maven/sync-properties-maven-plugin/src/main/java/org/apache/camel/maven/sync/properties/SyncPropertiesMojo.java +++ b/tooling/maven/sync-properties-maven-plugin/src/main/java/org/apache/camel/maven/sync/properties/SyncPropertiesMojo.java @@ -25,6 +25,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.List; +import java.util.Map.Entry; import java.util.function.Predicate; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -179,7 +180,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { camelPomXmlModel.getProperties().entrySet().stream() .filter(property -> !(property.getKey().equals("jdk.version")))) .filter(property -> invalids.test((String) property.getKey()) && !excludes.test((String) property.getKey())) - .map(property -> property.getKey()) + .map(Entry::getKey) .sorted() .collect(Collectors.toList());