Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -270,7 +271,7 @@ public static List<Class<?>> 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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void replace() {
Optional<InfinispanRemoteEmbedding> original = cacheContainer.getCache(CACHE_NAME)
.values()
.stream()
.map(obj -> (InfinispanRemoteEmbedding) obj)
.map(InfinispanRemoteEmbedding.class::cast)
.filter(embedding -> embedding.getText().equals(TEXT_EMBEDDING_3))
.findFirst();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -226,7 +227,7 @@ private void queryRetriveNodes(
private List nodeProperties(List<Record> result) {
return result.stream()
.map(record -> record.get(0).asNode())
.map(node -> node.asMap())
.map(MapAccessor::asMap)
.collect(Collectors.toList());
}

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void transform(Message message, DataType from, DataType to) throws Except
List<Points.ScoredPoint> embeddings = message.getBody(List.class);

List<String> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ private void compressedMessage(Object msg, String encoding) throws Exception {

@Test
public void asyncMDNTest() {
assertDoesNotThrow(() -> runAsyncMDNTest());
assertDoesNotThrow(this::runAsyncMDNTest);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void process(Exchange exchange) {

@Test
public void ec2RebootInstancesTest() {
assertDoesNotThrow(() -> issueReboot());
assertDoesNotThrow(this::issueReboot);
}

private void issueReboot() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public void process(Exchange exchange) {

@Test
public void ec2RebootInstancesTest() {
assertDoesNotThrow(() -> issueReboot());
assertDoesNotThrow(this::issueReboot);
}

private void issueReboot() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class EC2ComponentIT extends Aws2EC2Base {

@Test
public void createAndRunInstancesTest() {
assertDoesNotThrow(() -> execCreateAndRun());
assertDoesNotThrow(this::execCreateAndRun);
}

private void execCreateAndRun() {
Expand All @@ -45,7 +45,7 @@ private void execCreateAndRun() {

@Test
public void createAndRunInstancesWithSecurityGroupsTest() {
assertDoesNotThrow(() -> execCreateAndRunWithSecurityGroups());
assertDoesNotThrow(this::execCreateAndRunWithSecurityGroups);
}

private void execCreateAndRunWithSecurityGroups() {
Expand All @@ -63,7 +63,7 @@ private void execCreateAndRunWithSecurityGroups() {

@Test
public void ec2CreateAndRunTestWithKeyPair() {
assertDoesNotThrow(() -> execCreateAndRunWithKeyPair());
assertDoesNotThrow(this::execCreateAndRunWithKeyPair);
}

private void execCreateAndRunWithKeyPair() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected String doCallText(Map<String, Object> options) {

List<Consumer> 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",
Expand All @@ -62,7 +62,7 @@ protected JsonObject doCallJson(Map<String, Object> options) {

List<Consumer> list = getCamelContext().getRoutes()
.stream().map(Route::getConsumer)
.filter(c -> c instanceof AWS2S3Consumer)
.filter(AWS2S3Consumer.class::isInstance)
.collect(Collectors.toList());

List<JsonObject> arr = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -97,12 +98,12 @@ private boolean containsTransientParameters(Map<String, Object> parameters) {

private Map<String, Object> getNonTransientParameters(Map<String, Object> 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<String, Object> getTransientParameters(Map<String, Object> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void setup() {

@Test
public void testAlreadyConnected() {
assertDoesNotThrow(() -> runAlreadyConnectedTest());
assertDoesNotThrow(this::runAlreadyConnectedTest);
}

private void runAlreadyConnectedTest() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ protected ClickUpMockRoutes createMockRoutes() {
String webhookExternalUrl;
try {
Optional<Endpoint> optionalEndpoint = context().getEndpoints().stream()
.filter(endpoint -> endpoint instanceof WebhookEndpoint)
.filter(WebhookEndpoint.class::isInstance)
.findFirst();

if (optionalEndpoint.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -271,15 +272,15 @@ 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);
}

@Test
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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
Expand Down
Loading
Loading