Skip to content
Merged
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 @@ -68,7 +68,7 @@ protected static void prepareIndex(
int port, org.apache.pekko.stream.connectors.elasticsearch.ApiVersionBase version)
throws IOException {
connectionSettings =
ElasticsearchConnectionSettings.create(String.format("http://localhost:%d", port));
ElasticsearchConnectionSettings.create("http://localhost:%d".formatted(port));

register("source", "Akka in Action");
register("source", "Programming in Scala");
Expand All @@ -81,25 +81,24 @@ protected static void prepareIndex(
}

protected static void cleanIndex() throws IOException {
HttpRequest request =
HttpRequest.DELETE(String.format("%s/_all", connectionSettings.baseUrl()));
HttpRequest request = HttpRequest.DELETE("%s/_all".formatted(connectionSettings.baseUrl()));
http.singleRequest(request).toCompletableFuture().join();
}

protected static void flushAndRefresh(String indexName) throws IOException {
HttpRequest flushRequest =
HttpRequest.POST(String.format("%s/%s/_flush", connectionSettings.baseUrl(), indexName));
HttpRequest.POST("%s/%s/_flush".formatted(connectionSettings.baseUrl(), indexName));
http.singleRequest(flushRequest).toCompletableFuture().join();

HttpRequest refreshRequest =
HttpRequest.POST(String.format("%s/%s/_refresh", connectionSettings.baseUrl(), indexName));
HttpRequest.POST("%s/%s/_refresh".formatted(connectionSettings.baseUrl(), indexName));
http.singleRequest(refreshRequest).toCompletableFuture().join();
}

protected static void register(String indexName, String title) {
HttpRequest request =
HttpRequest.POST(String.format("%s/%s/_doc", connectionSettings.baseUrl(), indexName))
.withEntity(ContentTypes.APPLICATION_JSON, String.format("{\"title\": \"%s\"}", title));
HttpRequest.POST("%s/%s/_doc".formatted(connectionSettings.baseUrl(), indexName))
.withEntity(ContentTypes.APPLICATION_JSON, "{\"title\": \"%s\"}".formatted(title));

http.singleRequest(request).toCompletableFuture().join();
}
Expand Down
5 changes: 2 additions & 3 deletions geode/src/test/java/docs/javadsl/GeodeBaseTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,11 @@ public static void setup() {

static Source<Person, NotUsed> buildPersonsSource(Integer... ids) {
return Source.from(List.of(ids))
.map((i) -> new Person(i, String.format("Person Java %d", i), new Date()));
.map((i) -> new Person(i, "Person Java %d".formatted(i), new Date()));
}

static Source<Animal, NotUsed> buildAnimalsSource(Integer... ids) {
return Source.from(List.of(ids))
.map((i) -> new Animal(i, String.format("Animal Java %d", i), 1));
return Source.from(List.of(ids)).map((i) -> new Animal(i, "Animal Java %d".formatted(i), 1));
}

protected Geode createGeodeClient() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void continuousSourceTest() throws ExecutionException, InterruptedExcepti

Pair<NotUsed, CompletionStage<List<Person>>> run =
Source.from(List.of(120))
.map((i) -> new Person(i, String.format("Java flow %d", i), new Date()))
.map((i) -> new Person(i, "Java flow %d".formatted(i), new Date()))
.via(flow)
.toMat(Sink.seq(), Keep.both())
.run(system);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void docs() {

// #run-query
String sqlQuery =
String.format("SELECT name, addresses FROM %s.%s WHERE age >= 100", datasetId, tableId);
"SELECT name, addresses FROM %s.%s WHERE age >= 100".formatted(datasetId, tableId);
Unmarshaller<HttpEntity, QueryResponse<NameAddressesPair>> queryResponseUnmarshaller =
BigQueryMarshallers.queryResponseUnmarshaller(NameAddressesPair.class);
Source<NameAddressesPair, CompletionStage<QueryResponse<NameAddressesPair>>> centenarians =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ public void retrieveRows() throws ExecutionException, InterruptedException {
@Test
public void runQuery() throws ExecutionException, InterruptedException {
String query =
String.format(
"SELECT string, record, integer FROM %s.%s WHERE boolean;", datasetId(), tableId());
"SELECT string, record, integer FROM %s.%s WHERE boolean;"
.formatted(datasetId(), tableId());
List<Tuple3<String, B, Integer>> expectedResults =
getRows().stream()
.filter(A::getBoolean)
Expand All @@ -281,8 +281,8 @@ public void runQuery() throws ExecutionException, InterruptedException {
@Test
public void dryRunQuery() throws ExecutionException, InterruptedException {
String query =
String.format(
"SELECT string, record, integer FROM %s.%s WHERE boolean;", datasetId(), tableId());
"SELECT string, record, integer FROM %s.%s WHERE boolean;"
.formatted(datasetId(), tableId());
QueryResponse<JsonNode> response =
BigQuery.query(
query, true, false, BigQueryMarshallers.queryResponseUnmarshaller(JsonNode.class))
Expand Down
14 changes: 7 additions & 7 deletions hbase/src/test/java/docs/javadsl/HBaseStageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static void teardown() {
Function<Person, List<Mutation>> hBaseConverter =
person -> {
try {
Put put = new Put(String.format("id_%d", person.id).getBytes("UTF-8"));
Put put = new Put("id_%d".formatted(person.id).getBytes("UTF-8"));
put.addColumn(
"info".getBytes("UTF-8"), "name".getBytes("UTF-8"), person.name.getBytes("UTF-8"));

Expand All @@ -80,7 +80,7 @@ public static void teardown() {
Function<Person, List<Mutation>> appendHBaseConverter =
person -> {
try {
Append append = new Append(String.format("id_%d", person.id).getBytes("UTF-8"));
Append append = new Append("id_%d".formatted(person.id).getBytes("UTF-8"));
append.add(
"info".getBytes("UTF-8"), "aliases".getBytes("UTF-8"), person.name.getBytes("UTF-8"));

Expand All @@ -96,7 +96,7 @@ public static void teardown() {
Function<Person, List<Mutation>> deleteHBaseConverter =
person -> {
try {
Delete delete = new Delete(String.format("id_%d", person.id).getBytes("UTF-8"));
Delete delete = new Delete("id_%d".formatted(person.id).getBytes("UTF-8"));

return List.of(delete);
} catch (UnsupportedEncodingException e) {
Expand All @@ -110,7 +110,7 @@ public static void teardown() {
Function<Person, List<Mutation>> incrementHBaseConverter =
person -> {
try {
Increment increment = new Increment(String.format("id_%d", person.id).getBytes("UTF-8"));
Increment increment = new Increment("id_%d".formatted(person.id).getBytes("UTF-8"));
increment.addColumn("info".getBytes("UTF-8"), "numberOfChanges".getBytes("UTF-8"), 1);

return List.of(increment);
Expand All @@ -125,7 +125,7 @@ public static void teardown() {
Function<Person, List<Mutation>> complexHBaseConverter =
person -> {
try {
byte[] id = String.format("id_%d", person.id).getBytes("UTF-8");
byte[] id = "id_%d".formatted(person.id).getBytes("UTF-8");
byte[] infoFamily = "info".getBytes("UTF-8");

if (person.id != 0 && person.name.isEmpty()) {
Expand Down Expand Up @@ -166,7 +166,7 @@ public void writeToSink() throws InterruptedException, TimeoutException, Executi
final Sink<Person, CompletionStage<Done>> sink = HTableStage.sink(tableSettings);
CompletionStage<Done> o =
Source.from(List.of(100, 101, 102, 103, 104))
.map((i) -> new Person(i, String.format("name %d", i)))
.map((i) -> new Person(i, "name %d".formatted(i)))
.runWith(sink, system);
// #sink

Expand All @@ -187,7 +187,7 @@ public void writeThroughFlow() throws ExecutionException, InterruptedException {
Flow<Person, Person, NotUsed> flow = HTableStage.flow(tableSettings);
Pair<NotUsed, CompletionStage<List<Person>>> run =
Source.from(List.of(200, 201, 202, 203, 204))
.map((i) -> new Person(i, String.format("name_%d", i)))
.map((i) -> new Person(i, "name_%d".formatted(i)))
.via(flow)
.toMat(Sink.seq(), Keep.both())
.run(system);
Expand Down
6 changes: 3 additions & 3 deletions kudu/src/test/java/docs/javadsl/KuduTableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void sink() throws Exception {

CompletionStage<Done> o =
Source.from(List.of(100, 101, 102, 103, 104))
.map((i) -> new Person(i, String.format("name %d", i)))
.map((i) -> new Person(i, "name %d".formatted(i)))
.runWith(sink, system);
// #sink
assertEquals(Done.getInstance(), o.toCompletableFuture().get(5, TimeUnit.SECONDS));
Expand All @@ -111,7 +111,7 @@ public void flow() throws Exception {

CompletionStage<List<Person>> run =
Source.from(List.of(200, 201, 202, 203, 204))
.map((i) -> new Person(i, String.format("name_%d", i)))
.map((i) -> new Person(i, "name_%d".formatted(i)))
.via(flow)
.toMat(Sink.seq(), Keep.right())
.run(system);
Expand Down Expand Up @@ -140,7 +140,7 @@ public void customClient() throws Exception {

CompletionStage<List<Person>> run =
Source.from(List.of(200, 201, 202, 203, 204))
.map((i) -> new Person(i, String.format("name_%d", i)))
.map((i) -> new Person(i, "name_%d".formatted(i)))
.via(flow)
.toMat(Sink.seq(), Keep.right())
.run(system);
Expand Down
14 changes: 6 additions & 8 deletions mongodb/src/test/java/docs/javadsl/MongoSinkTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,8 @@ private void insertDomainObjects() throws Exception {
i -> {
DomainObject domainObject =
new DomainObject(
i,
String.format("first-property-%s", i),
String.format("second-property-%s", i));
System.out.println(String.format("%s inserting %s", i, domainObject));
i, "first-property-%s".formatted(i), "second-property-%s".formatted(i));
System.out.println("%s inserting %s".formatted(i, domainObject));
return domainObject;
})
.runWith(MongoSink.insertOne(domainObjectsColl), system)
Expand Down Expand Up @@ -340,8 +338,8 @@ public void replaceWithReplaceOne() throws Exception {
Filters.eq("_id", i),
new DomainObject(
i,
String.format("updated-first-property-%s", i),
String.format("updated-second-property-%s", i))));
"updated-first-property-%s".formatted(i),
"updated-second-property-%s".formatted(i))));
final CompletionStage<Done> completion =
source.runWith(MongoSink.replaceOne(domainObjectsColl), system);
// #replace-one
Expand All @@ -361,8 +359,8 @@ public void replaceWithReplaceOne() throws Exception {
i ->
new DomainObject(
i,
String.format("updated-first-property-%s", i),
String.format("updated-second-property-%s", i)))
"updated-first-property-%s".formatted(i),
"updated-second-property-%s".formatted(i)))
.toList();

assertEquals(expected, found);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void writeAndReadInKVTable()

String result = readingDone.toCompletableFuture().get(timeoutSeconds, TimeUnit.SECONDS);
Assertions.assertTrue(
result.equals("One, Two, Three, Four"), String.format("Read 2 elements [%s]", result));
result.equals("One, Two, Three, Four"), "Read 2 elements [%s]".formatted(result));

Flow<Integer, Optional<String>, NotUsed> readFlow =
PravegaTable.readFlow(scope, tableName, tableReaderSettings);
Expand Down
2 changes: 1 addition & 1 deletion solr/src/test/java/docs/javadsl/SolrTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ private TupleStream getTupleStream(String collection) throws IOException {
streamContext.setSolrClientCache(solrClientCache);

String expressionStr =
String.format("search(%s, q=*:*, fl=\"title,comment\", sort=\"title asc\")", collection);
"search(%s, q=*:*, fl=\"title,comment\", sort=\"title asc\")".formatted(collection);
StreamExpression expression = StreamExpressionParser.parse(expressionStr);
TupleStream stream = new CloudSolrStream(expression, factory);
stream.setStreamContext(streamContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ public SpringWebPekkoStreamsProperties getProperties() {
private String getActorSystemName(final SpringWebPekkoStreamsProperties properties) {
Objects.requireNonNull(
properties,
String.format(
"%s is not present in application context",
SpringWebPekkoStreamsProperties.class.getSimpleName()));
"%s is not present in application context"
.formatted(SpringWebPekkoStreamsProperties.class.getSimpleName()));

if (isBlank(properties.getActorSystemName())) {
return DEFAULT_FACTORY_SYSTEM_NAME;
Expand Down
2 changes: 1 addition & 1 deletion sqs/src/test/java/docs/javadsl/SqsPublishTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,6 @@ public void ackViaFlow() throws Exception {
private String toMd5(String s) throws Exception {
MessageDigest m = MessageDigest.getInstance("MD5");
BigInteger bigInt = new BigInteger(1, m.digest(s.getBytes()));
return String.format("%032x", bigInt);
return "%032x".formatted(bigInt);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected String randomQueueUrl() throws Exception {
return sqsClient
.createQueue(
CreateQueueRequest.builder()
.queueName(String.format("queue-%s", new Random().nextInt()))
.queueName("queue-%s".formatted(new Random().nextInt()))
.build())
.get(2, TimeUnit.SECONDS)
.queueUrl();
Expand Down
2 changes: 1 addition & 1 deletion sse/src/test/java/docs/javadsl/EventSourceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static void compileTest() {
Function<HttpRequest, CompletionStage<HttpResponse>> send =
(request) -> http.singleRequest(request);

final Uri targetUri = Uri.create(String.format("http://%s:%d", host, port));
final Uri targetUri = Uri.create("http://%s:%d".formatted(host, port));
final Optional<String> lastEventId = Optional.of("2");
Source<ServerSentEvent, NotUsed> eventSource =
EventSource.create(targetUri, send, lastEventId, system);
Expand Down
Loading