Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -17,10 +17,16 @@

@ConfigurationProperties(prefix = "dapr.client")
public class DaprClientProperties {
private String httpEndpoint;
private String grpcEndpoint;
private Integer httpPort;
private Integer grpcPort;

public static final String DEFAULT_HTTP_ENDPOINT = "http://localhost";
public static final String DEFAULT_GRPC_ENDPOINT = "localhost";
public static final int DEFAULT_HTTP_PORT = 3500;
public static final int DEFAULT_GRPC_PORT = 50001;

private String httpEndpoint = DEFAULT_HTTP_ENDPOINT;
private String grpcEndpoint = DEFAULT_GRPC_ENDPOINT;
private Integer httpPort = DEFAULT_HTTP_PORT;
private Integer grpcPort = DEFAULT_GRPC_PORT;
Comment thread
siri-varma marked this conversation as resolved.
Outdated
private String apiToken;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ public class DaprClientPropertiesTest {
private final ApplicationContextRunner runner = new ApplicationContextRunner()
.withUserConfiguration(EnableDaprClientProperties.class);

@Test
@DisplayName("Should have correct default values when using no-arg constructor")
public void shouldHaveCorrectDefaults() {

DaprClientProperties properties = new DaprClientProperties();

SoftAssertions.assertSoftly(softly -> {
softly.assertThat(properties.getHttpEndpoint()).isEqualTo("http://localhost");
softly.assertThat(properties.getGrpcEndpoint()).isEqualTo("localhost");
softly.assertThat(properties.getHttpPort()).isEqualTo(3500);
softly.assertThat(properties.getGrpcPort()).isEqualTo(50001);
softly.assertThat(properties.getApiToken()).isNull();
});
Comment thread
siri-varma marked this conversation as resolved.
}

@Test
@DisplayName("Should create DaprClientProperties correctly through constructor")
public void shouldCreateDaprClientPropertiesCorrectly() {
Expand All @@ -49,21 +64,36 @@ public void shouldSetDaprClientPropertiesCorrectly() {

DaprClientProperties properties = new DaprClientProperties();

properties.setGrpcEndpoint("localhost");
properties.setGrpcPort(50001);
properties.setHttpEndpoint("http://localhost");
properties.setHttpPort(3500);
properties.setGrpcEndpoint("custom-host");
properties.setGrpcPort(60001);
properties.setHttpEndpoint("http://custom-host");
properties.setHttpPort(4500);
properties.setApiToken("ABC");

SoftAssertions.assertSoftly(softAssertions -> {
softAssertions.assertThat(properties.getGrpcEndpoint()).isEqualTo("localhost");
softAssertions.assertThat(properties.getHttpEndpoint()).isEqualTo("http://localhost");
softAssertions.assertThat(properties.getHttpPort()).isEqualTo(3500);
softAssertions.assertThat(properties.getGrpcPort()).isEqualTo(50001);
softAssertions.assertThat(properties.getGrpcEndpoint()).isEqualTo("custom-host");
softAssertions.assertThat(properties.getHttpEndpoint()).isEqualTo("http://custom-host");
softAssertions.assertThat(properties.getHttpPort()).isEqualTo(4500);
softAssertions.assertThat(properties.getGrpcPort()).isEqualTo(60001);
softAssertions.assertThat(properties.getApiToken()).isEqualTo("ABC");
});
}

@Test
@DisplayName("Should have correct defaults when no properties are configured")
public void shouldHaveDefaultsWhenNoPropertiesConfigured() {
runner.run(context -> {
DaprClientProperties properties = context.getBean(DaprClientProperties.class);
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(properties.getHttpEndpoint()).isEqualTo("http://localhost");
softly.assertThat(properties.getGrpcEndpoint()).isEqualTo("localhost");
softly.assertThat(properties.getHttpPort()).isEqualTo(3500);
softly.assertThat(properties.getGrpcPort()).isEqualTo(50001);
softly.assertThat(properties.getApiToken()).isNull();
});
});
}
Comment thread
siri-varma marked this conversation as resolved.

@Test
@DisplayName("Should map DaprClient properties correctly")
public void shouldMapDaprClientProperties() {
Expand Down
Loading