Skip to content

Commit

Permalink
use Map.of
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
  • Loading branch information
artursouza committed Oct 2, 2024
1 parent 9dbe04f commit 60f4c29
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import java.util.Collections;
import java.util.List;
import java.util.Map;

import static io.dapr.it.Retry.callWithRetry;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -115,14 +116,14 @@ public void inputOutputBinding() throws Exception {

System.out.println("sending first message");
client.invokeBinding(
bidingName, "create", myClass, Collections.singletonMap("MyMetadata", "MyValue"), Void.class).block();
bidingName, "create", myClass, Map.of("MyMetadata", "MyValue"), Void.class).block();

// This is an example of sending a plain string. The input binding will receive
// cat
final String m = "cat";
System.out.println("sending " + m);
client.invokeBinding(
bidingName, "create", m, Collections.singletonMap("MyMetadata", "MyValue"), Void.class).block();
bidingName, "create", m, Map.of("MyMetadata", "MyValue"), Void.class).block();

// Metadata is not used by Kafka component, so it is not possible to validate.
callWithRetry(() -> {
Expand Down
5 changes: 3 additions & 2 deletions sdk-tests/src/test/java/io/dapr/it/pubsub/http/PubSubIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.Set;
Expand Down Expand Up @@ -534,7 +535,7 @@ public void testPubSubTTLMetadata() throws Exception {
PUBSUB_NAME,
TTL_TOPIC_NAME,
message,
Collections.singletonMap(Metadata.TTL_IN_SECONDS, "1")).block();
Map.of(Metadata.TTL_IN_SECONDS, "1")).block();
System.out.println(String.format("Published message: '%s' to topic '%s' pubsub_name '%s'", message, TOPIC_NAME, PUBSUB_NAME));
}
}
Expand Down Expand Up @@ -652,7 +653,7 @@ public void testLongValues() throws Exception {
PUBSUB_NAME,
LONG_TOPIC_NAME,
value,
Collections.singletonMap(Metadata.TTL_IN_SECONDS, "30")).block();
Map.of(Metadata.TTL_IN_SECONDS, "30")).block();

try {
Thread.sleep((long) (1000 * Math.random()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class DaprKeyValueRepositoryIT {
"host=postgres-repository user=postgres password=password port=5432 connect_timeout=10 database=dapr_db_repository";
private static final Map<String, String> STATE_STORE_PROPERTIES = createStateStoreProperties();

private static final Map<String, String> BINDING_PROPERTIES = Collections.singletonMap("connectionString", CONNECTION_STRING);
private static final Map<String, String> BINDING_PROPERTIES = Map.of("connectionString", CONNECTION_STRING);

private static final Network DAPR_NETWORK = Network.newNetwork();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class MySQLDaprKeyValueTemplateIT {
private static final String BINDING_DSN = "mysql:password@tcp(mysql:3306)/dapr_db";
private static final Map<String, String> STATE_STORE_PROPERTIES = createStateStoreProperties();

private static final Map<String, String> BINDING_PROPERTIES = Collections.singletonMap("url", BINDING_DSN);
private static final Map<String, String> BINDING_PROPERTIES = Map.of("url", BINDING_DSN);

private static final Network DAPR_NETWORK = Network.newNetwork();

Expand Down Expand Up @@ -114,7 +114,7 @@ private static Map<String, String> createStateStoreProperties() {
*/
@AfterEach
public void tearDown() {
var meta = Collections.singletonMap("sql", "delete from state");
var meta = Map.of("sql", "delete from state");

daprClient.invokeBinding(BINDING_NAME, "exec", null, meta).block();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class PostgreSQLDaprKeyValueTemplateIT {
"host=postgres user=postgres password=password port=5432 connect_timeout=10 database=dapr_db";
private static final Map<String, String> STATE_STORE_PROPERTIES = createStateStoreProperties();

private static final Map<String, String> BINDING_PROPERTIES = Collections.singletonMap("connectionString", CONNECTION_STRING);
private static final Map<String, String> BINDING_PROPERTIES = Map.of("connectionString", CONNECTION_STRING);

private static final Network DAPR_NETWORK = Network.newNetwork();

Expand Down Expand Up @@ -96,7 +96,7 @@ private static Map<String, String> createStateStoreProperties() {

@BeforeEach
public void setUp() {
var meta = Collections.singletonMap("sql", "delete from state");
var meta = Map.of("sql", "delete from state");

daprClient.invokeBinding(BINDING_NAME, "exec", null, meta).block();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand All @@ -59,7 +60,7 @@ public class DaprWorkflowsIT {
.withAppName("workflow-dapr-app")
.withNetwork(DAPR_NETWORK)
.withComponent(new Component("kvstore", "state.in-memory", "v1",
Collections.singletonMap("actorStateStore", "true")))
Map.of("actorStateStore", "true")))
.withComponent(new Component("pubsub", "pubsub.in-memory", "v1", Collections.emptyMap()))
.withDaprLogLevel(DaprLogLevel.DEBUG)
.withLogConsumer(outputFrame -> System.out.println(outputFrame.getUtf8String()))
Expand Down

0 comments on commit 60f4c29

Please sign in to comment.