From 23eab66c120bffd002dc76ec6841bd606163578f Mon Sep 17 00:00:00 2001 From: Otavio Rodolfo Piske Date: Sat, 28 Mar 2026 10:25:22 +0000 Subject: [PATCH] (chores): fix SonarCloud S1612 across multiple modules Replace lambdas with method references where applicable (S1612). Covers core, components, dsl, test-infra, and tooling modules. Some cases involving assertDoesNotThrow ambiguity or Camel DSL body() method overloads were left as lambdas since method references cause type inference ambiguity in those contexts. --- .../agent/api/AgentConfiguration.java | 3 +- ...EmbeddingsComponentInfinispanTargetIT.java | 2 +- .../camel/component/neo4j/Neo4jProducer.java | 5 +- .../Neo4jEmbeddingDataTypeTransformer.java | 2 +- ...tReverseEmbeddingsDataTypeTransformer.java | 2 +- .../component/as2/AS2ClientManagerIT.java | 2 +- .../ddbstream/ShardIteratorHandlerTest.java | 2 +- .../aws2/ddbstream/ShardTreeTest.java | 2 +- .../aws2/ec2/EC2ComponentSpringTest.java | 2 +- .../component/aws2/ec2/EC2ProducerTest.java | 2 +- .../aws2/ec2/integration/EC2ComponentIT.java | 6 +- .../component/aws2/s3/AWS2S3Console.java | 4 +- .../s3/stream/AWS2S3StreamUploadProducer.java | 2 +- .../component/aws2/sns/Sns2Component.java | 5 +- .../BonitaAuthFilterAlreadyConnectedTest.java | 2 +- .../ResultSetConversionStrategies.java | 8 +- .../clickup/ClickUpConfigurationTest.java | 2 +- ...pWebhookRegistrationAlreadyExistsTest.java | 2 +- .../camel/component/cm/test/CMTest.java | 2 +- .../dataformat/csv/CsvMarshallerFactory.java | 4 +- .../CxfRsConsumerSimpleBindingImplTest.java | 3 +- .../CxfRsConsumerSimpleBindingTest.java | 19 +- .../component/cxf/jaxws/CxfConsumer.java | 4 +- .../cxf/util/CxfEndpointUtilsTest.java | 2 +- .../util/CxfEndpointUtilsWithSpringTest.java | 2 +- .../disruptor/DisruptorTimeoutTest.java | 4 +- .../docker/DockerClientProfileTest.java | 2 +- .../ElasticsearchRestClientComponentIT.java | 10 +- .../ElasticsearchRestClientITSupport.java | 4 +- .../integration/ElasticsearchTestSupport.java | 4 +- .../file/watch/FileWatchComponentTest.java | 2 +- .../remote/integration/FromFtpNoFilesIT.java | 2 +- .../integration/FromFtpUseListFalseIT.java | 2 +- .../FtpProducerTempFileExistIssueIT.java | 2 +- .../integration/SftpConsumerAutoCreateIT.java | 2 +- ...ogleBigQuerySQLProducerStreamListTest.java | 4 +- ...uavaEventBusConsumerConfigurationTest.java | 4 +- ...AggregationRepositoryConstructorsTest.java | 2 +- .../HL7MLLPNettyDecoderResourceLeakTest.java | 2 +- .../HttpSendDynamicAwareBasicAuthTest.java | 2 +- .../remote/InfinispanRemoteTestSupport.java | 2 +- .../example/DataFormatConcurrentTest.java | 8 +- .../component/jcache/JCacheManagerTest.java | 4 +- .../policy/CacheManagerFromRegistryTest.java | 2 +- .../jcache/policy/JCachePolicyTestBase.java | 2 +- ...ttpMessageFormUrlEncodedFalseBodyTest.java | 2 +- .../camel/component/jmx/JMXEndpointTest.java | 2 +- .../jmx/JMXObjectPropertiesTest.java | 2 +- .../component/kafka/KafkaConsumerTest.java | 2 +- ...FirstErrorOffUsingKafkaManualCommitIT.java | 8 +- ...kaBreakOnFirstErrorReleaseResourcesIT.java | 12 +- ...aBreakOnFirstErrorReplayOldMessagesIT.java | 12 +- .../KafkaBreakOnFirstErrorSeekIssueIT.java | 4 +- ...rorWithBatchUsingAsyncCommitManagerIT.java | 5 +- ...rrorWithBatchUsingKafkaManualCommitIT.java | 16 +- ...ithBatchUsingKafkaManualCommitRetryIT.java | 9 +- ...rrorWithBatchUsingSyncCommitManagerIT.java | 5 +- .../KafkaConsumerAsyncManualCommitIT.java | 4 +- ...essingBreakOnFirstErrorManualCommitIT.java | 5 +- .../security/KeycloakTokenIntrospector.java | 4 +- .../cluster/utils/LeaderRecorder.java | 2 +- .../LevelDBAggregateDiscardOnTimeoutTest.java | 2 +- .../service/lra/AbstractLRATestSupport.java | 2 +- .../lumberjack/LumberjackMultiThreadIT.java | 2 +- .../mail/InvalidConfigurationTest.java | 4 +- .../mail/MailAttachmentsUmlautIssueTest.java | 4 +- .../mail/MailConsumerAuthenticatorTest.java | 4 +- .../MicrometerObservabilityTracer.java | 2 +- ...icrometerRoutePolicyConfigurationTest.java | 4 +- .../SharedMicrometerRoutePolicyTest.java | 2 +- .../CamelMicroProfileHealthCheckTest.java | 9 +- .../mina/sftp/SftpConsumerAutoCreateIT.java | 2 +- .../MongoDbTailableCursorConsumerIT.java | 4 +- .../component/nats/NatsConsumerStopTest.java | 2 +- .../camel/observation/CurrentSpanTest.java | 2 +- .../component/olingo4/Olingo4Consumer.java | 4 +- .../camel/opentelemetry/CurrentSpanTest.java | 2 +- .../opentelemetry2/OpenTelemetryTracer.java | 2 +- .../integration/PulsarProducerInIT.java | 2 +- .../pulsar/utils/PulsarUtilsTest.java | 2 +- .../openapi/RestOpenApiEndpointV3Test.java | 2 +- .../salesforce/codegen/GenerateExecution.java | 5 +- .../salesforce/SalesforceClientTemplate.java | 2 +- .../salesforce/SalesforceComponent.java | 6 +- .../AbstractServiceNowProcessor.java | 2 +- .../sjms/producer/QueueProducerQoSTest.java | 2 +- .../apache/camel/component/snmp/TrapTest.java | 2 +- .../camel/component/splunk/ProducerTest.java | 4 +- .../spring/batch/SpringBatchEndpointTest.java | 2 +- .../camel/spring/MisspelledRouteRefTest.java | 2 +- .../camel/component/redis/RedisClient.java | 5 +- .../LifecycleStrategyInjectionTest.java | 2 +- ...ultipleLifecycleStrategyInjectionTest.java | 2 +- ...rorHandlerCamelContextRefNotFoundTest.java | 4 +- ...rorHandlerRouteContextRefNotFoundTest.java | 4 +- .../OnExceptionNoExceptionConfiguredTest.java | 4 +- ...LetterChannelInvalidDeadLetterUriTest.java | 4 +- ...ChannelInvalidOptionDeadLetterUriTest.java | 4 +- ...oubleLoadBalancerMisconfigurationTest.java | 4 +- .../client/StitchClientBuilderTest.java | 6 +- .../integration/StitchClientImplIT.java | 2 +- .../camel/component/stub/StubConsole.java | 4 +- .../telegram/TelegramChatBotTest.java | 2 +- .../telegram/TelegramConfigurationTest.java | 2 +- ...elegramConsumerFallbackConversionTest.java | 2 +- .../component/undertow/UndertowConsumer.java | 2 +- .../UniVocityFixedDataFormatTest.java | 6 +- .../consumer/WordpressPostConsumer.java | 2 +- .../consumer/WordpressUserConsumer.java | 2 +- .../camel/component/xchange/XChange.java | 2 +- .../component/xchange/XChangeEndpoint.java | 2 +- .../group/internal/ZooKeeperGroup.java | 2 +- .../DefaultServiceBootstrapCloseable.java | 2 +- .../properties/PropertiesComponent.java | 2 +- .../org/apache/camel/reifier/SortReifier.java | 2 +- .../org/apache/camel/ContextTestSupport.java | 2 +- .../builder/FluentProducerTemplateTest.java | 4 +- .../direct/DirectNoMultipleConsumersTest.java | 2 +- .../FileConsumeNoopIdempotentEnabledTest.java | 4 +- .../file/FileConsumerIdempotentRefTest.java | 4 +- .../xslt/XsltCustomErrorListenerTest.java | 2 +- .../AdviceWithMockEndpointsTest.java | 7 +- .../camel/support/ServiceSupportTest.java | 2 +- .../apache/camel/util/ObjectHelperTest.java | 104 +- .../health/DefaultHealthCheckRegistry.java | 2 +- .../apache/camel/main/BaseMainSupport.java | 2 +- .../MainIoCBeanPostProcessorDisabledTest.java | 2 +- .../org/apache/camel/main/MainScan3Test.java | 2 +- .../camel/main/MainStartupConditionTest.java | 2 +- .../main/MainStartupConditionTimeoutTest.java | 2 +- ...eControllerFilterFailToStartRouteTest.java | 2 +- .../java/org/apache/camel/main/MainTest.java | 2 +- .../JmxManagementStrategyFactory.java | 4 +- .../builder/endpoint/AwsS3PollEnrichTest.java | 2 +- .../camel/builder/endpoint/HttpProxyTest.java | 4 +- .../core/commands/ExportBaseCommand.java | 2 +- .../core/commands/update/CamelUpdate.java | 4 +- .../core/commands/update/UpdateList.java | 6 +- .../resources/schema/camelYamlDsl.json | 1574 ++++++++++++++--- .../yaml/dsl/kamelet/AwsRawSecretTest.java | 2 +- .../infra/cli/services/CliBuiltContainer.java | 2 +- .../camel/test/infra/core/MockUtils.java | 2 +- .../fhir/services/FhirServiceFactory.java | 2 +- .../openai/mock/OpenAIMockFailuresTest.java | 2 +- .../sync/properties/SyncPropertiesMojo.java | 3 +- 145 files changed, 1568 insertions(+), 600 deletions(-) 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..d081b81fa71dc 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,7 @@ 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(); - }); + 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 +233,7 @@ 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(); - }); + 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..bd6c2e1e4d1dc 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,7 @@ 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); - }); + .process(KafkaBreakOnFirstErrorWithBatchUsingKafkaManualCommitIT.this::doCommitOffset); from("kafka:" + TOPIC + "?groupId=" + ROUTE_ID @@ -140,13 +135,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..f95c85b0723dc 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,7 @@ public void configure() { } } }).to(KafkaTestUtil.MOCK_RESULT) - .process(exchange -> { - // Manual commit on success - doCommitOffset(exchange); - }); + .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..23f015cbaac0e 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(Comparable::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/generated/resources/schema/camelYamlDsl.json b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json index 7ca5baed769af..ce29a4f4a41ff 100644 --- a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json +++ b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json @@ -3032,8 +3032,6 @@ "required" : [ "fory" ] }, { "required" : [ "grok" ] - }, { - "required" : [ "groovyJson" ] }, { "required" : [ "groovyXml" ] }, { @@ -3218,14 +3216,6 @@ "$ref" : "#/items/definitions/org.apache.camel.model.dataformat.GrokDataFormat" } } - }, { - "type" : "object", - "required" : [ "groovyJson" ], - "properties" : { - "groovyJson" : { - "$ref" : "#/items/definitions/org.apache.camel.model.dataformat.GroovyJSonDataFormat" - } - } }, { "type" : "object", "required" : [ "groovyXml" ], @@ -3524,7 +3514,6 @@ "flatpack" : { }, "fory" : { }, "grok" : { }, - "groovyJson" : { }, "groovyXml" : { }, "gzipDeflater" : { }, "hl7" : { }, @@ -6110,6 +6099,35 @@ } } ] }, + "org.apache.camel.model.SagaActionUriDefinition" : { + "oneOf" : [ { + "type" : "string" + }, { + "type" : "object", + "additionalProperties" : false, + "properties" : { + "description" : { + "type" : "string" + }, + "disabled" : { + "type" : "boolean" + }, + "id" : { + "type" : "string" + }, + "note" : { + "type" : "string" + }, + "parameters" : { + "type" : "object" + }, + "uri" : { + "type" : "string" + } + } + } ], + "required" : [ "uri" ] + }, "org.apache.camel.model.SagaDefinition" : { "title" : "Saga", "description" : "Enables Sagas on the route", @@ -6117,14 +6135,14 @@ "additionalProperties" : false, "properties" : { "compensation" : { - "type" : "string", "title" : "Compensation", - "description" : "The compensation endpoint URI that must be called to compensate all changes done in the route. The route corresponding to the compensation URI must perform compensation and complete without error. If errors occur during compensation, the saga service may call again the compensation URI to retry." + "description" : "The compensation endpoint URI that must be called to compensate all changes done in the route. The route corresponding to the compensation URI must perform compensation and complete without error. If errors occur during compensation, the saga service may call again the compensation URI to retry.", + "$ref" : "#/items/definitions/org.apache.camel.model.SagaActionUriDefinition" }, "completion" : { - "type" : "string", "title" : "Completion", - "description" : "The completion endpoint URI that will be called when the Saga is completed successfully. The route corresponding to the completion URI must perform completion tasks and terminate without error. If errors occur during completion, the saga service may call again the completion URI to retry." + "description" : "The completion endpoint URI that will be called when the Saga is completed successfully. The route corresponding to the completion URI must perform completion tasks and terminate without error. If errors occur during completion, the saga service may call again the completion URI to retry.", + "$ref" : "#/items/definitions/org.apache.camel.model.SagaActionUriDefinition" }, "completionMode" : { "type" : "string", @@ -8385,7 +8403,6 @@ "flatpack" : { }, "fory" : { }, "grok" : { }, - "groovyJson" : { }, "groovyXml" : { }, "gzipDeflater" : { }, "hl7" : { }, @@ -8461,8 +8478,6 @@ "required" : [ "fory" ] }, { "required" : [ "grok" ] - }, { - "required" : [ "groovyJson" ] }, { "required" : [ "groovyXml" ] }, { @@ -8647,14 +8662,6 @@ "$ref" : "#/items/definitions/org.apache.camel.model.dataformat.GrokDataFormat" } } - }, { - "type" : "object", - "required" : [ "groovyJson" ], - "properties" : { - "groovyJson" : { - "$ref" : "#/items/definitions/org.apache.camel.model.dataformat.GroovyJSonDataFormat" - } - } }, { "type" : "object", "required" : [ "groovyXml" ], @@ -9192,244 +9199,1376 @@ "expression" : { } } }, - "org.apache.camel.model.WireTapDefinition" : { - "title" : "Wire Tap", - "description" : "Routes a copy of a message (or creates a new message) to a secondary destination while continue routing the original message.", + "org.apache.camel.model.WireTapDefinition" : { + "title" : "Wire Tap", + "description" : "Routes a copy of a message (or creates a new message) to a secondary destination while continue routing the original message.", + "type" : "object", + "additionalProperties" : false, + "properties" : { + "allowOptimisedComponents" : { + "type" : "boolean", + "title" : "Allow Optimised Components", + "description" : "Whether to allow components to optimise toD if they are org.apache.camel.spi.SendDynamicAware .", + "default" : true + }, + "autoStartComponents" : { + "type" : "boolean", + "title" : "Auto Start Components", + "description" : "Whether to auto startup components when toD is starting up.", + "default" : true + }, + "cacheSize" : { + "type" : "number", + "title" : "Cache Size", + "description" : "Sets the maximum size used by the org.apache.camel.spi.ProducerCache which is used to cache and reuse producers when using this recipient list, when uris are reused. Beware that when using dynamic endpoints then it affects how well the cache can be utilized. If each dynamic endpoint is unique then its best to turn off caching by setting this to -1, which allows Camel to not cache both the producers and endpoints; they are regarded as prototype scoped and will be stopped and discarded after use. This reduces memory usage as otherwise producers/endpoints are stored in memory in the caches. However if there are a high degree of dynamic endpoints that have been used before, then it can benefit to use the cache to reuse both producers and endpoints and therefore the cache size can be set accordingly or rely on the default size (1000). If there is a mix of unique and used before dynamic endpoints, then setting a reasonable cache size can help reduce memory usage to avoid storing too many non frequent used producers." + }, + "copy" : { + "type" : "boolean", + "title" : "Copy", + "description" : "Uses a copy of the original exchange", + "default" : true + }, + "description" : { + "type" : "string", + "title" : "Description", + "description" : "Sets the description of this node" + }, + "disabled" : { + "type" : "boolean", + "title" : "Disabled", + "description" : "Disables this EIP from the route.", + "default" : false + }, + "dynamicUri" : { + "type" : "boolean", + "title" : "Dynamic Uri", + "description" : "Whether the uri is dynamic or static. If the uri is dynamic then the simple language is used to evaluate a dynamic uri to use as the wire-tap destination, for each incoming message. This works similar to how the toD EIP pattern works. If static then the uri is used as-is as the wire-tap destination.", + "default" : true + }, + "executorService" : { + "type" : "string", + "title" : "Executor Service", + "description" : "Uses a custom thread pool" + }, + "id" : { + "type" : "string", + "title" : "Id", + "description" : "Sets the id of this node" + }, + "ignoreInvalidEndpoint" : { + "type" : "boolean", + "title" : "Ignore Invalid Endpoint", + "description" : "Whether to ignore invalid endpoint URIs and skip sending the message.", + "default" : false + }, + "note" : { + "type" : "string", + "title" : "Note", + "description" : "Sets the note of this node" + }, + "onPrepare" : { + "type" : "string", + "title" : "On Prepare", + "description" : "Uses the Processor when preparing the org.apache.camel.Exchange to be sent. This can be used to deep-clone messages that should be sent, or any custom logic needed before the exchange is sent." + }, + "parameters" : { + "type" : "object" + }, + "uri" : { + "type" : "string", + "title" : "Uri", + "description" : "The uri of the endpoint to send to. The uri can be dynamic computed using the org.apache.camel.language.simple.SimpleLanguage expression." + }, + "variableReceive" : { + "type" : "string", + "title" : "Variable Receive", + "description" : "To use a variable as the source for the message body to send. This makes it handy to use variables for user data and to easily control what data to use for sending and receiving. Important: When using send variable then the message body is taken from this variable instead of the current Message , however the headers from the Message will still be used as well. In other words, the variable is used instead of the message body, but everything else is as usual." + }, + "variableSend" : { + "type" : "string", + "title" : "Variable Send", + "description" : "To use a variable as the source for the message body to send. This makes it handy to use variables for user data and to easily control what data to use for sending and receiving. Important: When using send variable then the message body is taken from this variable instead of the current message, however the headers from the message will still be used as well. In other words, the variable is used instead of the message body, but everything else is as usual." + } + }, + "required" : [ "uri" ] + }, + "org.apache.camel.model.app.BeanConstructorDefinition" : { + "type" : "object", + "additionalProperties" : false, + "properties" : { + "index" : { + "type" : "number" + }, + "value" : { + "type" : "string" + } + }, + "required" : [ "value" ] + }, + "org.apache.camel.model.app.BeanConstructorsDefinition" : { + "type" : "object", + "additionalProperties" : false, + "properties" : { + "constructor" : { + "type" : "array", + "items" : { + "$ref" : "#/items/definitions/org.apache.camel.model.app.BeanConstructorDefinition" + } + } + } + }, + "org.apache.camel.model.app.BeanPropertiesDefinition" : { + "type" : "object", + "additionalProperties" : false, + "properties" : { + "property" : { + "type" : "array", + "items" : { + "$ref" : "#/items/definitions/org.apache.camel.model.app.BeanPropertyDefinition" + } + } + } + }, + "org.apache.camel.model.app.BeanPropertyDefinition" : { + "type" : "object", + "additionalProperties" : false, + "properties" : { + "key" : { + "type" : "string" + }, + "properties" : { + "$ref" : "#/items/definitions/org.apache.camel.model.app.BeanPropertiesDefinition" + }, + "value" : { + "type" : "string" + } + } + }, + "org.apache.camel.model.app.ComponentScanDefinition" : { + "type" : "object", + "additionalProperties" : false, + "properties" : { + "basePackage" : { + "type" : "string" + } + } + }, + "org.apache.camel.model.cloud.BlacklistServiceCallServiceFilterConfiguration" : { + "title" : "Blacklist Service Filter", + "deprecated" : true, + "type" : "object", + "additionalProperties" : false, + "properties" : { + "id" : { + "type" : "string", + "title" : "Id", + "description" : "The id of this node" + }, + "properties" : { + "type" : "array", + "title" : "Properties", + "description" : "Set client properties to use. These properties are specific to what service call implementation are in use. For example if using a different one, then the client properties are defined according to the specific service in use.", + "items" : { + "$ref" : "#/items/definitions/org.apache.camel.model.PropertyDefinition" + } + }, + "servers" : { + "type" : "array", + "title" : "Servers", + "description" : "Sets the server blacklist. Each entry can be a list of servers separated by comma in the format: servicehost:port,servicehost2:port,servicehost3:port", + "items" : { + "type" : "string" + } + } + } + }, + "org.apache.camel.model.cloud.CachingServiceCallServiceDiscoveryConfiguration" : { + "title" : "Caching Service Discovery", + "deprecated" : true, + "type" : "object", + "additionalProperties" : false, + "anyOf" : [ { + "oneOf" : [ { + "type" : "object", + "required" : [ "combinedServiceDiscovery" ], + "properties" : { + "combinedServiceDiscovery" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.CombinedServiceCallServiceDiscoveryConfiguration" + } + } + }, { + "not" : { + "anyOf" : [ { + "required" : [ "combinedServiceDiscovery" ] + }, { + "required" : [ "consulServiceDiscovery" ] + }, { + "required" : [ "dnsServiceDiscovery" ] + }, { + "required" : [ "kubernetesServiceDiscovery" ] + }, { + "required" : [ "staticServiceDiscovery" ] + } ] + } + }, { + "type" : "object", + "required" : [ "consulServiceDiscovery" ], + "properties" : { + "consulServiceDiscovery" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.ConsulServiceCallServiceDiscoveryConfiguration" + } + } + }, { + "type" : "object", + "required" : [ "dnsServiceDiscovery" ], + "properties" : { + "dnsServiceDiscovery" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.DnsServiceCallServiceDiscoveryConfiguration" + } + } + }, { + "type" : "object", + "required" : [ "kubernetesServiceDiscovery" ], + "properties" : { + "kubernetesServiceDiscovery" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.KubernetesServiceCallServiceDiscoveryConfiguration" + } + } + }, { + "type" : "object", + "required" : [ "staticServiceDiscovery" ], + "properties" : { + "staticServiceDiscovery" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.StaticServiceCallServiceDiscoveryConfiguration" + } + } + } ] + } ], + "properties" : { + "id" : { + "type" : "string", + "title" : "Id", + "description" : "The id of this node" + }, + "properties" : { + "type" : "array", + "title" : "Properties", + "description" : "Set client properties to use. These properties are specific to what service call implementation are in use. For example if using a different one, then the client properties are defined according to the specific service in use.", + "items" : { + "$ref" : "#/items/definitions/org.apache.camel.model.PropertyDefinition" + } + }, + "timeout" : { + "type" : "number", + "title" : "Timeout", + "description" : "Set the time the services will be retained.", + "default" : 60 + }, + "units" : { + "type" : "string", + "title" : "Units", + "description" : "Set the time unit for the timeout.", + "default" : "SECONDS", + "enum" : [ "NANOSECONDS", "MICROSECONDS", "MILLISECONDS", "SECONDS", "MINUTES", "HOURS", "DAYS" ] + }, + "combinedServiceDiscovery" : { }, + "consulServiceDiscovery" : { }, + "dnsServiceDiscovery" : { }, + "kubernetesServiceDiscovery" : { }, + "staticServiceDiscovery" : { } + } + }, + "org.apache.camel.model.cloud.CombinedServiceCallServiceDiscoveryConfiguration" : { + "title" : "Combined Service Discovery", + "deprecated" : true, + "type" : "object", + "additionalProperties" : false, + "properties" : { + "cachingServiceDiscovery" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.CachingServiceCallServiceDiscoveryConfiguration" + }, + "consulServiceDiscovery" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.ConsulServiceCallServiceDiscoveryConfiguration" + }, + "dnsServiceDiscovery" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.DnsServiceCallServiceDiscoveryConfiguration" + }, + "id" : { + "type" : "string", + "title" : "Id", + "description" : "The id of this node" + }, + "kubernetesServiceDiscovery" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.KubernetesServiceCallServiceDiscoveryConfiguration" + }, + "properties" : { + "type" : "array", + "title" : "Properties", + "description" : "Set client properties to use. These properties are specific to what service call implementation are in use. For example if using a different one, then the client properties are defined according to the specific service in use.", + "items" : { + "$ref" : "#/items/definitions/org.apache.camel.model.PropertyDefinition" + } + }, + "staticServiceDiscovery" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.StaticServiceCallServiceDiscoveryConfiguration" + } + } + }, + "org.apache.camel.model.cloud.CombinedServiceCallServiceFilterConfiguration" : { + "title" : "Combined Service Filter", + "deprecated" : true, + "type" : "object", + "additionalProperties" : false, + "properties" : { + "blacklistServiceFilter" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.BlacklistServiceCallServiceFilterConfiguration" + }, + "customServiceFilter" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.CustomServiceCallServiceFilterConfiguration" + }, + "healthyServiceFilter" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.HealthyServiceCallServiceFilterConfiguration" + }, + "id" : { + "type" : "string", + "title" : "Id", + "description" : "The id of this node" + }, + "passThroughServiceFilter" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.PassThroughServiceCallServiceFilterConfiguration" + }, + "properties" : { + "type" : "array", + "title" : "Properties", + "description" : "Set client properties to use. These properties are specific to what service call implementation are in use. For example if using a different one, then the client properties are defined according to the specific service in use.", + "items" : { + "$ref" : "#/items/definitions/org.apache.camel.model.PropertyDefinition" + } + } + } + }, + "org.apache.camel.model.cloud.ConsulServiceCallServiceDiscoveryConfiguration" : { + "title" : "Consul Service Discovery", + "deprecated" : true, + "type" : "object", + "additionalProperties" : false, + "properties" : { + "aclToken" : { + "type" : "string", + "title" : "Acl Token", + "description" : "Sets the ACL token to be used with Consul" + }, + "blockSeconds" : { + "type" : "number", + "title" : "Block Seconds", + "description" : "The seconds to wait for a watch event, default 10 seconds", + "default" : 10 + }, + "connectTimeoutMillis" : { + "type" : "number", + "title" : "Connect Timeout Millis", + "description" : "Connect timeout for OkHttpClient" + }, + "datacenter" : { + "type" : "string", + "title" : "Datacenter", + "description" : "The data center" + }, + "id" : { + "type" : "string", + "title" : "Id", + "description" : "The id of this node" + }, + "password" : { + "type" : "string", + "title" : "Password", + "description" : "Sets the password to be used for basic authentication" + }, + "properties" : { + "type" : "array", + "title" : "Properties", + "description" : "Set client properties to use. These properties are specific to what service call implementation are in use. For example if using a different one, then the client properties are defined according to the specific service in use.", + "items" : { + "$ref" : "#/items/definitions/org.apache.camel.model.PropertyDefinition" + } + }, + "readTimeoutMillis" : { + "type" : "number", + "title" : "Read Timeout Millis", + "description" : "Read timeout for OkHttpClient" + }, + "url" : { + "type" : "string", + "title" : "Url", + "description" : "The Consul agent URL" + }, + "userName" : { + "type" : "string", + "title" : "User Name", + "description" : "Sets the username to be used for basic authentication" + }, + "writeTimeoutMillis" : { + "type" : "number", + "title" : "Write Timeout Millis", + "description" : "Write timeout for OkHttpClient" + } + } + }, + "org.apache.camel.model.cloud.CustomServiceCallServiceFilterConfiguration" : { + "title" : "Custom Service Filter", + "deprecated" : true, + "type" : "object", + "additionalProperties" : false, + "properties" : { + "id" : { + "type" : "string", + "title" : "Id", + "description" : "The id of this node" + }, + "properties" : { + "type" : "array", + "title" : "Properties", + "description" : "Set client properties to use. These properties are specific to what service call implementation are in use. For example if using a different one, then the client properties are defined according to the specific service in use.", + "items" : { + "$ref" : "#/items/definitions/org.apache.camel.model.PropertyDefinition" + } + }, + "ref" : { + "type" : "string", + "title" : "Ref", + "description" : "Reference of a ServiceFilter" + } + } + }, + "org.apache.camel.model.cloud.DefaultServiceCallServiceLoadBalancerConfiguration" : { + "title" : "Default Load Balancer", + "deprecated" : true, + "type" : "object", + "additionalProperties" : false, + "properties" : { + "id" : { + "type" : "string", + "title" : "Id", + "description" : "The id of this node" + }, + "properties" : { + "type" : "array", + "title" : "Properties", + "description" : "Set client properties to use. These properties are specific to what service call implementation are in use. For example if using a different one, then the client properties are defined according to the specific service in use.", + "items" : { + "$ref" : "#/items/definitions/org.apache.camel.model.PropertyDefinition" + } + } + } + }, + "org.apache.camel.model.cloud.DnsServiceCallServiceDiscoveryConfiguration" : { + "title" : "Dns Service Discovery", + "deprecated" : true, + "type" : "object", + "additionalProperties" : false, + "properties" : { + "domain" : { + "type" : "string", + "title" : "Domain", + "description" : "The domain name;" + }, + "id" : { + "type" : "string", + "title" : "Id", + "description" : "The id of this node" + }, + "properties" : { + "type" : "array", + "title" : "Properties", + "description" : "Set client properties to use. These properties are specific to what service call implementation are in use. For example if using a different one, then the client properties are defined according to the specific service in use.", + "items" : { + "$ref" : "#/items/definitions/org.apache.camel.model.PropertyDefinition" + } + }, + "proto" : { + "type" : "string", + "title" : "Proto", + "description" : "The transport protocol of the desired service.", + "default" : "_tcp" + } + } + }, + "org.apache.camel.model.cloud.HealthyServiceCallServiceFilterConfiguration" : { + "title" : "Healthy Service Filter", + "deprecated" : true, + "type" : "object", + "additionalProperties" : false, + "properties" : { + "id" : { + "type" : "string", + "title" : "Id", + "description" : "The id of this node" + }, + "properties" : { + "type" : "array", + "title" : "Properties", + "description" : "Set client properties to use. These properties are specific to what service call implementation are in use. For example if using a different one, then the client properties are defined according to the specific service in use.", + "items" : { + "$ref" : "#/items/definitions/org.apache.camel.model.PropertyDefinition" + } + } + } + }, + "org.apache.camel.model.cloud.KubernetesServiceCallServiceDiscoveryConfiguration" : { + "title" : "Kubernetes Service Discovery", + "deprecated" : true, + "type" : "object", + "additionalProperties" : false, + "properties" : { + "apiVersion" : { + "type" : "string", + "title" : "Api Version", + "description" : "Sets the API version when using client lookup" + }, + "caCertData" : { + "type" : "string", + "title" : "Ca Cert Data", + "description" : "Sets the Certificate Authority data when using client lookup" + }, + "caCertFile" : { + "type" : "string", + "title" : "Ca Cert File", + "description" : "Sets the Certificate Authority data that are loaded from the file when using client lookup" + }, + "clientCertData" : { + "type" : "string", + "title" : "Client Cert Data", + "description" : "Sets the Client Certificate data when using client lookup" + }, + "clientCertFile" : { + "type" : "string", + "title" : "Client Cert File", + "description" : "Sets the Client Certificate data that are loaded from the file when using client lookup" + }, + "clientKeyAlgo" : { + "type" : "string", + "title" : "Client Key Algo", + "description" : "Sets the Client Keystore algorithm, such as RSA when using client lookup" + }, + "clientKeyData" : { + "type" : "string", + "title" : "Client Key Data", + "description" : "Sets the Client Keystore data when using client lookup" + }, + "clientKeyFile" : { + "type" : "string", + "title" : "Client Key File", + "description" : "Sets the Client Keystore data that are loaded from the file when using client lookup" + }, + "clientKeyPassphrase" : { + "type" : "string", + "title" : "Client Key Passphrase", + "description" : "Sets the Client Keystore passphrase when using client lookup" + }, + "dnsDomain" : { + "type" : "string", + "title" : "Dns Domain", + "description" : "Sets the DNS domain to use for DNS lookup." + }, + "id" : { + "type" : "string", + "title" : "Id", + "description" : "The id of this node" + }, + "lookup" : { + "type" : "string", + "title" : "Lookup", + "description" : "How to perform service lookup. Possible values: client, dns, environment. When using client, then the client queries the kubernetes master to obtain a list of active pods that provides the service, and then random (or round robin) select a pod. When using dns the service name is resolved as name.namespace.svc.dnsDomain. When using dnssrv the service name is resolved with SRV query for _._...svc... When using environment then environment variables are used to lookup the service. By default environment is used.", + "default" : "environment", + "enum" : [ "environment", "dns", "client" ] + }, + "masterUrl" : { + "type" : "string", + "title" : "Master Url", + "description" : "Sets the URL to the master when using client lookup" + }, + "namespace" : { + "type" : "string", + "title" : "Namespace", + "description" : "Sets the namespace to use. Will by default use namespace from the ENV variable KUBERNETES_MASTER." + }, + "oauthToken" : { + "type" : "string", + "title" : "Oauth Token", + "description" : "Sets the OAUTH token for authentication (instead of username/password) when using client lookup" + }, + "password" : { + "type" : "string", + "title" : "Password", + "description" : "Sets the password for authentication when using client lookup" + }, + "portName" : { + "type" : "string", + "title" : "Port Name", + "description" : "Sets the Port Name to use for DNS/DNSSRV lookup." + }, + "portProtocol" : { + "type" : "string", + "title" : "Port Protocol", + "description" : "Sets the Port Protocol to use for DNS/DNSSRV lookup." + }, + "properties" : { + "type" : "array", + "title" : "Properties", + "description" : "Set client properties to use. These properties are specific to what service call implementation are in use. For example if using a different one, then the client properties are defined according to the specific service in use.", + "items" : { + "$ref" : "#/items/definitions/org.apache.camel.model.PropertyDefinition" + } + }, + "trustCerts" : { + "type" : "boolean", + "title" : "Trust Certs", + "description" : "Sets whether to turn on trust certificate check when using client lookup", + "default" : false + }, + "username" : { + "type" : "string", + "title" : "Username", + "description" : "Sets the username for authentication when using client lookup" + } + } + }, + "org.apache.camel.model.cloud.PassThroughServiceCallServiceFilterConfiguration" : { + "title" : "Pass Through Service Filter", + "deprecated" : true, + "type" : "object", + "additionalProperties" : false, + "properties" : { + "id" : { + "type" : "string", + "title" : "Id", + "description" : "The id of this node" + }, + "properties" : { + "type" : "array", + "title" : "Properties", + "description" : "Set client properties to use. These properties are specific to what service call implementation are in use. For example if using a different one, then the client properties are defined according to the specific service in use.", + "items" : { + "$ref" : "#/items/definitions/org.apache.camel.model.PropertyDefinition" + } + } + } + }, + "org.apache.camel.model.cloud.ServiceCallConfigurationDefinition" : { + "title" : "Service Call Configuration", + "description" : "Remote service call configuration", + "deprecated" : true, + "type" : "object", + "additionalProperties" : false, + "anyOf" : [ { + "oneOf" : [ { + "type" : "object", + "required" : [ "blacklistServiceFilter" ], + "properties" : { + "blacklistServiceFilter" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.BlacklistServiceCallServiceFilterConfiguration" + } + } + }, { + "not" : { + "anyOf" : [ { + "required" : [ "blacklistServiceFilter" ] + }, { + "required" : [ "combinedServiceFilter" ] + }, { + "required" : [ "customServiceFilter" ] + }, { + "required" : [ "healthyServiceFilter" ] + }, { + "required" : [ "passThroughServiceFilter" ] + } ] + } + }, { + "type" : "object", + "required" : [ "combinedServiceFilter" ], + "properties" : { + "combinedServiceFilter" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.CombinedServiceCallServiceFilterConfiguration" + } + } + }, { + "type" : "object", + "required" : [ "customServiceFilter" ], + "properties" : { + "customServiceFilter" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.CustomServiceCallServiceFilterConfiguration" + } + } + }, { + "type" : "object", + "required" : [ "healthyServiceFilter" ], + "properties" : { + "healthyServiceFilter" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.HealthyServiceCallServiceFilterConfiguration" + } + } + }, { + "type" : "object", + "required" : [ "passThroughServiceFilter" ], + "properties" : { + "passThroughServiceFilter" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.PassThroughServiceCallServiceFilterConfiguration" + } + } + } ] + }, { + "oneOf" : [ { + "type" : "object", + "required" : [ "cachingServiceDiscovery" ], + "properties" : { + "cachingServiceDiscovery" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.CachingServiceCallServiceDiscoveryConfiguration" + } + } + }, { + "not" : { + "anyOf" : [ { + "required" : [ "cachingServiceDiscovery" ] + }, { + "required" : [ "combinedServiceDiscovery" ] + }, { + "required" : [ "consulServiceDiscovery" ] + }, { + "required" : [ "dnsServiceDiscovery" ] + }, { + "required" : [ "kubernetesServiceDiscovery" ] + }, { + "required" : [ "staticServiceDiscovery" ] + }, { + "required" : [ "zookeeperServiceDiscovery" ] + } ] + } + }, { + "type" : "object", + "required" : [ "combinedServiceDiscovery" ], + "properties" : { + "combinedServiceDiscovery" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.CombinedServiceCallServiceDiscoveryConfiguration" + } + } + }, { + "type" : "object", + "required" : [ "consulServiceDiscovery" ], + "properties" : { + "consulServiceDiscovery" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.ConsulServiceCallServiceDiscoveryConfiguration" + } + } + }, { + "type" : "object", + "required" : [ "dnsServiceDiscovery" ], + "properties" : { + "dnsServiceDiscovery" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.DnsServiceCallServiceDiscoveryConfiguration" + } + } + }, { + "type" : "object", + "required" : [ "kubernetesServiceDiscovery" ], + "properties" : { + "kubernetesServiceDiscovery" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.KubernetesServiceCallServiceDiscoveryConfiguration" + } + } + }, { + "type" : "object", + "required" : [ "staticServiceDiscovery" ], + "properties" : { + "staticServiceDiscovery" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.StaticServiceCallServiceDiscoveryConfiguration" + } + } + }, { + "type" : "object", + "required" : [ "zookeeperServiceDiscovery" ], + "properties" : { + "zookeeperServiceDiscovery" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.ZooKeeperServiceCallServiceDiscoveryConfiguration" + } + } + } ] + }, { + "oneOf" : [ { + "type" : "object", + "required" : [ "defaultLoadBalancer" ], + "properties" : { + "defaultLoadBalancer" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.DefaultServiceCallServiceLoadBalancerConfiguration" + } + } + }, { + "not" : { + "anyOf" : [ { + "required" : [ "defaultLoadBalancer" ] + } ] + } + } ] + }, { + "oneOf" : [ { + "type" : "object", + "required" : [ "expression" ], + "properties" : { + "expression" : { + "title" : "Expression", + "description" : "Configures the Expression using the given configuration.", + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.ServiceCallExpressionConfiguration" + } + } + }, { + "not" : { + "anyOf" : [ { + "required" : [ "expression" ] + } ] + } + } ] + } ], + "properties" : { + "component" : { + "type" : "string", + "title" : "Component", + "description" : "The component to use.", + "default" : "http" + }, + "expressionRef" : { + "type" : "string", + "title" : "Expression Ref", + "description" : "Set a reference to a custom Expression to use." + }, + "id" : { + "type" : "string", + "title" : "Id", + "description" : "The id of this node" + }, + "loadBalancerRef" : { + "type" : "string", + "title" : "Load Balancer Ref", + "description" : "Sets a reference to a custom ServiceLoadBalancer to use." + }, + "pattern" : { + "type" : "string", + "title" : "Pattern", + "description" : "Sets the optional ExchangePattern used to invoke this endpoint", + "enum" : [ "InOnly", "InOut" ] + }, + "serviceChooserRef" : { + "type" : "string", + "title" : "Service Chooser Ref", + "description" : "Sets a reference to a custom ServiceChooser to use." + }, + "serviceDiscoveryRef" : { + "type" : "string", + "title" : "Service Discovery Ref", + "description" : "Sets a reference to a custom ServiceDiscovery to use." + }, + "serviceFilterRef" : { + "type" : "string", + "title" : "Service Filter Ref", + "description" : "Sets a reference to a custom ServiceFilter to use." + }, + "uri" : { + "type" : "string", + "title" : "Uri", + "description" : "The uri of the endpoint to send to. The uri can be dynamic computed using the simple language expression." + }, + "blacklistServiceFilter" : { }, + "combinedServiceFilter" : { }, + "customServiceFilter" : { }, + "healthyServiceFilter" : { }, + "passThroughServiceFilter" : { }, + "cachingServiceDiscovery" : { }, + "combinedServiceDiscovery" : { }, + "consulServiceDiscovery" : { }, + "dnsServiceDiscovery" : { }, + "kubernetesServiceDiscovery" : { }, + "staticServiceDiscovery" : { }, + "zookeeperServiceDiscovery" : { }, + "defaultLoadBalancer" : { }, + "expression" : { } + } + }, + "org.apache.camel.model.cloud.ServiceCallDefinition" : { + "title" : "Service Call", + "description" : "To call remote services", + "deprecated" : true, + "oneOf" : [ { + "type" : "string" + }, { + "type" : "object", + "additionalProperties" : false, + "anyOf" : [ { + "oneOf" : [ { + "type" : "object", + "required" : [ "blacklistServiceFilter" ], + "properties" : { + "blacklistServiceFilter" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.BlacklistServiceCallServiceFilterConfiguration" + } + } + }, { + "not" : { + "anyOf" : [ { + "required" : [ "blacklistServiceFilter" ] + }, { + "required" : [ "combinedServiceFilter" ] + }, { + "required" : [ "customServiceFilter" ] + }, { + "required" : [ "healthyServiceFilter" ] + }, { + "required" : [ "passThroughServiceFilter" ] + } ] + } + }, { + "type" : "object", + "required" : [ "combinedServiceFilter" ], + "properties" : { + "combinedServiceFilter" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.CombinedServiceCallServiceFilterConfiguration" + } + } + }, { + "type" : "object", + "required" : [ "customServiceFilter" ], + "properties" : { + "customServiceFilter" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.CustomServiceCallServiceFilterConfiguration" + } + } + }, { + "type" : "object", + "required" : [ "healthyServiceFilter" ], + "properties" : { + "healthyServiceFilter" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.HealthyServiceCallServiceFilterConfiguration" + } + } + }, { + "type" : "object", + "required" : [ "passThroughServiceFilter" ], + "properties" : { + "passThroughServiceFilter" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.PassThroughServiceCallServiceFilterConfiguration" + } + } + } ] + }, { + "oneOf" : [ { + "type" : "object", + "required" : [ "cachingServiceDiscovery" ], + "properties" : { + "cachingServiceDiscovery" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.CachingServiceCallServiceDiscoveryConfiguration" + } + } + }, { + "not" : { + "anyOf" : [ { + "required" : [ "cachingServiceDiscovery" ] + }, { + "required" : [ "combinedServiceDiscovery" ] + }, { + "required" : [ "consulServiceDiscovery" ] + }, { + "required" : [ "dnsServiceDiscovery" ] + }, { + "required" : [ "kubernetesServiceDiscovery" ] + }, { + "required" : [ "staticServiceDiscovery" ] + }, { + "required" : [ "zookeeperServiceDiscovery" ] + } ] + } + }, { + "type" : "object", + "required" : [ "combinedServiceDiscovery" ], + "properties" : { + "combinedServiceDiscovery" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.CombinedServiceCallServiceDiscoveryConfiguration" + } + } + }, { + "type" : "object", + "required" : [ "consulServiceDiscovery" ], + "properties" : { + "consulServiceDiscovery" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.ConsulServiceCallServiceDiscoveryConfiguration" + } + } + }, { + "type" : "object", + "required" : [ "dnsServiceDiscovery" ], + "properties" : { + "dnsServiceDiscovery" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.DnsServiceCallServiceDiscoveryConfiguration" + } + } + }, { + "type" : "object", + "required" : [ "kubernetesServiceDiscovery" ], + "properties" : { + "kubernetesServiceDiscovery" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.KubernetesServiceCallServiceDiscoveryConfiguration" + } + } + }, { + "type" : "object", + "required" : [ "staticServiceDiscovery" ], + "properties" : { + "staticServiceDiscovery" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.StaticServiceCallServiceDiscoveryConfiguration" + } + } + }, { + "type" : "object", + "required" : [ "zookeeperServiceDiscovery" ], + "properties" : { + "zookeeperServiceDiscovery" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.ZooKeeperServiceCallServiceDiscoveryConfiguration" + } + } + } ] + }, { + "oneOf" : [ { + "type" : "object", + "required" : [ "defaultLoadBalancer" ], + "properties" : { + "defaultLoadBalancer" : { + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.DefaultServiceCallServiceLoadBalancerConfiguration" + } + } + }, { + "not" : { + "anyOf" : [ { + "required" : [ "defaultLoadBalancer" ] + } ] + } + } ] + }, { + "oneOf" : [ { + "type" : "object", + "required" : [ "expression" ], + "properties" : { + "expression" : { + "title" : "Expression", + "description" : "Configures the Expression using the given configuration.", + "$ref" : "#/items/definitions/org.apache.camel.model.cloud.ServiceCallExpressionConfiguration" + } + } + }, { + "not" : { + "anyOf" : [ { + "required" : [ "expression" ] + } ] + } + } ] + } ], + "properties" : { + "component" : { + "type" : "string", + "title" : "Component", + "description" : "The component to use.", + "default" : "http" + }, + "configurationRef" : { + "type" : "string", + "title" : "Configuration Ref", + "description" : "Refers to a ServiceCall configuration to use" + }, + "description" : { + "type" : "string", + "title" : "Description", + "description" : "Sets the description of this node" + }, + "disabled" : { + "type" : "boolean", + "title" : "Disabled", + "description" : "Disables this EIP from the route.", + "default" : false + }, + "expressionRef" : { + "type" : "string", + "title" : "Expression Ref", + "description" : "Set a reference to a custom Expression to use." + }, + "id" : { + "type" : "string", + "title" : "Id", + "description" : "Sets the id of this node" + }, + "loadBalancerRef" : { + "type" : "string", + "title" : "Load Balancer Ref", + "description" : "Sets a reference to a custom ServiceLoadBalancer to use." + }, + "name" : { + "type" : "string", + "title" : "Name", + "description" : "Sets the name of the service to use" + }, + "note" : { + "type" : "string", + "title" : "Note", + "description" : "Sets the note of this node" + }, + "pattern" : { + "type" : "string", + "title" : "Pattern", + "description" : "Sets the optional ExchangePattern used to invoke this endpoint", + "enum" : [ "InOnly", "InOut" ] + }, + "serviceChooserRef" : { + "type" : "string", + "title" : "Service Chooser Ref", + "description" : "Sets a reference to a custom ServiceChooser to use." + }, + "serviceDiscoveryRef" : { + "type" : "string", + "title" : "Service Discovery Ref", + "description" : "Sets a reference to a custom ServiceDiscovery to use." + }, + "serviceFilterRef" : { + "type" : "string", + "title" : "Service Filter Ref", + "description" : "Sets a reference to a custom ServiceFilter to use." + }, + "uri" : { + "type" : "string", + "title" : "Uri", + "description" : "The uri of the endpoint to send to. The uri can be dynamic computed using the org.apache.camel.language.simple.SimpleLanguage expression." + }, + "blacklistServiceFilter" : { }, + "combinedServiceFilter" : { }, + "customServiceFilter" : { }, + "healthyServiceFilter" : { }, + "passThroughServiceFilter" : { }, + "cachingServiceDiscovery" : { }, + "combinedServiceDiscovery" : { }, + "consulServiceDiscovery" : { }, + "dnsServiceDiscovery" : { }, + "kubernetesServiceDiscovery" : { }, + "staticServiceDiscovery" : { }, + "zookeeperServiceDiscovery" : { }, + "defaultLoadBalancer" : { }, + "expression" : { } + } + } ], + "required" : [ "name" ] + }, + "org.apache.camel.model.cloud.ServiceCallExpressionConfiguration" : { + "title" : "Service Expression", + "deprecated" : true, "type" : "object", "additionalProperties" : false, "properties" : { - "allowOptimisedComponents" : { - "type" : "boolean", - "title" : "Allow Optimised Components", - "description" : "Whether to allow components to optimise toD if they are org.apache.camel.spi.SendDynamicAware .", - "default" : true - }, - "autoStartComponents" : { - "type" : "boolean", - "title" : "Auto Start Components", - "description" : "Whether to auto startup components when toD is starting up.", - "default" : true - }, - "cacheSize" : { - "type" : "number", - "title" : "Cache Size", - "description" : "Sets the maximum size used by the org.apache.camel.spi.ProducerCache which is used to cache and reuse producers when using this recipient list, when uris are reused. Beware that when using dynamic endpoints then it affects how well the cache can be utilized. If each dynamic endpoint is unique then its best to turn off caching by setting this to -1, which allows Camel to not cache both the producers and endpoints; they are regarded as prototype scoped and will be stopped and discarded after use. This reduces memory usage as otherwise producers/endpoints are stored in memory in the caches. However if there are a high degree of dynamic endpoints that have been used before, then it can benefit to use the cache to reuse both producers and endpoints and therefore the cache size can be set accordingly or rely on the default size (1000). If there is a mix of unique and used before dynamic endpoints, then setting a reasonable cache size can help reduce memory usage to avoid storing too many non frequent used producers." - }, - "copy" : { - "type" : "boolean", - "title" : "Copy", - "description" : "Uses a copy of the original exchange", - "default" : true - }, - "description" : { - "type" : "string", - "title" : "Description", - "description" : "Sets the description of this node" - }, - "disabled" : { - "type" : "boolean", - "title" : "Disabled", - "description" : "Disables this EIP from the route.", - "default" : false - }, - "dynamicUri" : { - "type" : "boolean", - "title" : "Dynamic Uri", - "description" : "Whether the uri is dynamic or static. If the uri is dynamic then the simple language is used to evaluate a dynamic uri to use as the wire-tap destination, for each incoming message. This works similar to how the toD EIP pattern works. If static then the uri is used as-is as the wire-tap destination.", - "default" : true + "expressionType" : { + "$ref" : "#/items/definitions/org.apache.camel.model.language.ExpressionDefinition" }, - "executorService" : { + "hostHeader" : { "type" : "string", - "title" : "Executor Service", - "description" : "Uses a custom thread pool" + "title" : "Host Header", + "description" : "The header that holds the service host information, default ServiceCallConstants.SERVICE_HOST", + "default" : "CamelServiceCallServiceHost" }, "id" : { "type" : "string", "title" : "Id", - "description" : "Sets the id of this node" - }, - "ignoreInvalidEndpoint" : { - "type" : "boolean", - "title" : "Ignore Invalid Endpoint", - "description" : "Whether to ignore invalid endpoint URIs and skip sending the message.", - "default" : false - }, - "note" : { - "type" : "string", - "title" : "Note", - "description" : "Sets the note of this node" - }, - "onPrepare" : { - "type" : "string", - "title" : "On Prepare", - "description" : "Uses the Processor when preparing the org.apache.camel.Exchange to be sent. This can be used to deep-clone messages that should be sent, or any custom logic needed before the exchange is sent." - }, - "parameters" : { - "type" : "object" - }, - "uri" : { - "type" : "string", - "title" : "Uri", - "description" : "The uri of the endpoint to send to. The uri can be dynamic computed using the org.apache.camel.language.simple.SimpleLanguage expression." + "description" : "The id of this node" }, - "variableReceive" : { + "portHeader" : { "type" : "string", - "title" : "Variable Receive", - "description" : "To use a variable as the source for the message body to send. This makes it handy to use variables for user data and to easily control what data to use for sending and receiving. Important: When using send variable then the message body is taken from this variable instead of the current Message , however the headers from the Message will still be used as well. In other words, the variable is used instead of the message body, but everything else is as usual." + "title" : "Port Header", + "description" : "The header that holds the service port information, default ServiceCallConstants.SERVICE_PORT", + "default" : "CamelServiceCallServicePort" }, - "variableSend" : { - "type" : "string", - "title" : "Variable Send", - "description" : "To use a variable as the source for the message body to send. This makes it handy to use variables for user data and to easily control what data to use for sending and receiving. Important: When using send variable then the message body is taken from this variable instead of the current message, however the headers from the message will still be used as well. In other words, the variable is used instead of the message body, but everything else is as usual." + "properties" : { + "type" : "array", + "title" : "Properties", + "description" : "Set client properties to use. These properties are specific to what service call implementation are in use. For example if using a different one, then the client properties are defined according to the specific service in use.", + "items" : { + "$ref" : "#/items/definitions/org.apache.camel.model.PropertyDefinition" + } } - }, - "required" : [ "uri" ] + } }, - "org.apache.camel.model.app.BeanConstructorDefinition" : { + "org.apache.camel.model.cloud.ServiceCallServiceChooserConfiguration" : { + "title" : "Service Chooser Configuration", + "deprecated" : true, "type" : "object", "additionalProperties" : false, "properties" : { - "index" : { - "type" : "number" + "id" : { + "type" : "string", + "title" : "Id", + "description" : "The id of this node" }, - "value" : { - "type" : "string" + "properties" : { + "type" : "array", + "title" : "Properties", + "description" : "Set client properties to use. These properties are specific to what service call implementation are in use. For example if using a different one, then the client properties are defined according to the specific service in use.", + "items" : { + "$ref" : "#/items/definitions/org.apache.camel.model.PropertyDefinition" + } } - }, - "required" : [ "value" ] + } }, - "org.apache.camel.model.app.BeanConstructorsDefinition" : { + "org.apache.camel.model.cloud.ServiceCallServiceDiscoveryConfiguration" : { + "title" : "Service Discovery Configuration", + "deprecated" : true, "type" : "object", "additionalProperties" : false, "properties" : { - "constructor" : { + "id" : { + "type" : "string", + "title" : "Id", + "description" : "The id of this node" + }, + "properties" : { "type" : "array", + "title" : "Properties", + "description" : "Set client properties to use. These properties are specific to what service call implementation are in use. For example if using a different one, then the client properties are defined according to the specific service in use.", "items" : { - "$ref" : "#/items/definitions/org.apache.camel.model.app.BeanConstructorDefinition" + "$ref" : "#/items/definitions/org.apache.camel.model.PropertyDefinition" } } } }, - "org.apache.camel.model.app.BeanPropertiesDefinition" : { + "org.apache.camel.model.cloud.ServiceCallServiceFilterConfiguration" : { + "title" : "Service Filter Configuration", + "deprecated" : true, "type" : "object", "additionalProperties" : false, "properties" : { - "property" : { + "id" : { + "type" : "string", + "title" : "Id", + "description" : "The id of this node" + }, + "properties" : { "type" : "array", + "title" : "Properties", + "description" : "Set client properties to use. These properties are specific to what service call implementation are in use. For example if using a different one, then the client properties are defined according to the specific service in use.", "items" : { - "$ref" : "#/items/definitions/org.apache.camel.model.app.BeanPropertyDefinition" + "$ref" : "#/items/definitions/org.apache.camel.model.PropertyDefinition" } } } }, - "org.apache.camel.model.app.BeanPropertyDefinition" : { + "org.apache.camel.model.cloud.ServiceCallServiceLoadBalancerConfiguration" : { + "title" : "Load Balancer Configuration", + "deprecated" : true, "type" : "object", "additionalProperties" : false, "properties" : { - "key" : { - "type" : "string" + "id" : { + "type" : "string", + "title" : "Id", + "description" : "The id of this node" }, "properties" : { - "$ref" : "#/items/definitions/org.apache.camel.model.app.BeanPropertiesDefinition" - }, - "value" : { - "type" : "string" + "type" : "array", + "title" : "Properties", + "description" : "Set client properties to use. These properties are specific to what service call implementation are in use. For example if using a different one, then the client properties are defined according to the specific service in use.", + "items" : { + "$ref" : "#/items/definitions/org.apache.camel.model.PropertyDefinition" + } } } }, - "org.apache.camel.model.app.ComponentScanDefinition" : { + "org.apache.camel.model.cloud.StaticServiceCallServiceDiscoveryConfiguration" : { + "title" : "Static Service Discovery", + "deprecated" : true, "type" : "object", "additionalProperties" : false, "properties" : { - "basePackage" : { - "type" : "string" + "id" : { + "type" : "string", + "title" : "Id", + "description" : "The id of this node" + }, + "properties" : { + "type" : "array", + "title" : "Properties", + "description" : "Set client properties to use. These properties are specific to what service call implementation are in use. For example if using a different one, then the client properties are defined according to the specific service in use.", + "items" : { + "$ref" : "#/items/definitions/org.apache.camel.model.PropertyDefinition" + } + }, + "servers" : { + "type" : "array", + "title" : "Servers", + "description" : "Sets the server list. Each entry can be a list of servers separated by comma in the format: servicehost:port,servicehost2:port,servicehost3:port", + "items" : { + "type" : "string" + } } } }, - "org.apache.camel.model.app.SSLContextParametersDefinition" : { + "org.apache.camel.model.cloud.ZooKeeperServiceCallServiceDiscoveryConfiguration" : { + "title" : "Zookeeper Service Discovery", + "deprecated" : true, "type" : "object", "additionalProperties" : false, "properties" : { - "certAlias" : { - "type" : "string" - }, - "cipherSuites" : { - "type" : "string" - }, - "cipherSuitesExclude" : { - "type" : "string" - }, - "cipherSuitesInclude" : { - "type" : "string" + "basePath" : { + "type" : "string", + "title" : "Base Path", + "description" : "Set the base path to store in ZK" }, - "clientAuthentication" : { + "connectionTimeout" : { "type" : "string", - "enum" : [ "NONE", "WANT", "REQUIRE" ] + "title" : "Connection Timeout", + "description" : "Connection timeout." }, "id" : { - "type" : "string" - }, - "keyManagerAlgorithm" : { - "type" : "string" - }, - "keyManagerProvider" : { - "type" : "string" - }, - "keyStore" : { - "type" : "string" - }, - "keyStoreProvider" : { - "type" : "string" - }, - "keyStoreType" : { - "type" : "string" - }, - "keystorePassword" : { - "type" : "string" - }, - "namedGroups" : { - "type" : "string" + "type" : "string", + "title" : "Id", + "description" : "The id of this node" }, - "namedGroupsExclude" : { - "type" : "string" + "namespace" : { + "type" : "string", + "title" : "Namespace", + "description" : "As ZooKeeper is a shared space, users of a given cluster should stay within a pre-defined namespace. If a namespace is set here, all paths will get pre-pended with the namespace" }, - "namedGroupsInclude" : { - "type" : "string" + "nodes" : { + "type" : "string", + "title" : "Nodes", + "description" : "A comma separate list of servers to connect to in the form host:port" }, - "provider" : { - "type" : "string" + "properties" : { + "type" : "array", + "title" : "Properties", + "description" : "Set client properties to use. These properties are specific to what service call implementation are in use. For example if using a different one, then the client properties are defined according to the specific service in use.", + "items" : { + "$ref" : "#/items/definitions/org.apache.camel.model.PropertyDefinition" + } }, - "secureRandomAlgorithm" : { - "type" : "string" + "reconnectBaseSleepTime" : { + "type" : "string", + "title" : "Reconnect Base Sleep Time", + "description" : "Initial amount of time to wait between retries." }, - "secureRandomProvider" : { - "type" : "string" + "reconnectMaxRetries" : { + "type" : "string", + "title" : "Reconnect Max Retries", + "description" : "Max number of times to retry" }, - "secureSocketProtocol" : { - "type" : "string" + "reconnectMaxSleepTime" : { + "type" : "string", + "title" : "Reconnect Max Sleep Time", + "description" : "Max time in ms to sleep on each retry" }, "sessionTimeout" : { - "type" : "string" - }, - "signatureSchemes" : { - "type" : "string" - }, - "signatureSchemesExclude" : { - "type" : "string" - }, - "signatureSchemesInclude" : { - "type" : "string" - }, - "trustAllCertificates" : { - "type" : "string" - }, - "trustStore" : { - "type" : "string" - }, - "trustStorePassword" : { - "type" : "string" + "type" : "string", + "title" : "Session Timeout", + "description" : "Session timeout." } - } + }, + "required" : [ "basePath", "nodes" ] }, "org.apache.camel.model.config.BatchResequencerConfig" : { "title" : "Batch Config", @@ -10223,9 +11362,6 @@ "grok" : { "$ref" : "#/items/definitions/org.apache.camel.model.dataformat.GrokDataFormat" }, - "groovyJson" : { - "$ref" : "#/items/definitions/org.apache.camel.model.dataformat.GroovyJSonDataFormat" - }, "groovyXml" : { "$ref" : "#/items/definitions/org.apache.camel.model.dataformat.GroovyXmlDataFormat" }, @@ -10705,25 +11841,6 @@ }, "required" : [ "pattern" ] }, - "org.apache.camel.model.dataformat.GroovyJSonDataFormat" : { - "title" : "Groovy JSon", - "description" : "Transform between JSon and java.util.Map or java.util.List objects.", - "type" : "object", - "additionalProperties" : false, - "properties" : { - "id" : { - "type" : "string", - "title" : "Id", - "description" : "The id of this node" - }, - "prettyPrint" : { - "type" : "boolean", - "title" : "Pretty Print", - "description" : "To pretty printing output nicely formatted. Is by default true.", - "default" : true - } - } - }, "org.apache.camel.model.dataformat.GroovyXmlDataFormat" : { "title" : "Groovy XML", "description" : "Transform between XML and Groovy Node (Map structure) objects.", @@ -12824,7 +13941,6 @@ "org.apache.camel.model.language.CSimpleExpression" : { "title" : "CSimple", "description" : "Evaluate a compiled simple expression.", - "deprecated" : true, "oneOf" : [ { "type" : "string" }, { @@ -16461,8 +17577,6 @@ "required" : [ "fory" ] }, { "required" : [ "grok" ] - }, { - "required" : [ "groovyJson" ] }, { "required" : [ "groovyXml" ] }, { @@ -16643,14 +17757,6 @@ "$ref" : "#/items/definitions/org.apache.camel.model.dataformat.GrokDataFormat" } } - }, { - "type" : "object", - "required" : [ "groovyJson" ], - "properties" : { - "groovyJson" : { - "$ref" : "#/items/definitions/org.apache.camel.model.dataformat.GroovyJSonDataFormat" - } - } }, { "type" : "object", "required" : [ "groovyXml" ], @@ -16922,7 +18028,6 @@ "flatpack" : { }, "fory" : { }, "grok" : { }, - "groovyJson" : { }, "groovyXml" : { }, "gzipDeflater" : { }, "hl7" : { }, @@ -17188,20 +18293,11 @@ "templatedRoute" : { "$ref" : "#/items/definitions/org.apache.camel.model.TemplatedRouteDefinition" }, - "sslContextParameters" : { - "$ref" : "#/items/definitions/org.apache.camel.model.app.SSLContextParametersDefinition" - }, "restConfiguration" : { "$ref" : "#/items/definitions/org.apache.camel.model.rest.RestConfigurationDefinition" }, "rest" : { "$ref" : "#/items/definitions/org.apache.camel.model.rest.RestDefinition" - }, - "transformers" : { - "$ref" : "#/items/definitions/org.apache.camel.model.transformer.TransformersDefinition" - }, - "validators" : { - "$ref" : "#/items/definitions/org.apache.camel.model.validator.ValidatorsDefinition" } } } 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());