-
Notifications
You must be signed in to change notification settings - Fork 227
Add coverage for some properties #1297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2aeebff
Add coverage for some classes
mcruzdev 63c7b0b
Adjust shouldCreateConfigurationItemCorrectly test
mcruzdev 1ba2662
Remove use of ReflectionTestUtils
mcruzdev 30b8e0d
Merge branch 'master' into add-tests
artur-ciocanu 1404918
Update DaprClientAutoConfigurationTests.java
artur-ciocanu 8ec0d3e
Update DaprClientAutoConfigurationTests.java
artur-ciocanu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...gure/src/test/java/io/dapr/spring/boot/autoconfigure/pubsub/DaprPubSubPropertiesTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /* | ||
| * Copyright 2025 The Dapr Authors | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package io.dapr.spring.boot.autoconfigure.pubsub; | ||
|
|
||
| import org.assertj.core.api.SoftAssertions; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
| import org.springframework.boot.test.context.runner.ApplicationContextRunner; | ||
|
|
||
| public class DaprPubSubPropertiesTest { | ||
|
|
||
| final ApplicationContextRunner runner = new ApplicationContextRunner() | ||
| .withUserConfiguration(EnableDaprPubSubProperties.class); | ||
|
|
||
|
|
||
| @Test | ||
| @DisplayName("Should configure properties with setters") | ||
| void shouldSetProperties() { | ||
| DaprPubSubProperties properties = new DaprPubSubProperties(); | ||
| properties.setName("pubsub"); | ||
| properties.setObservationEnabled(false); | ||
|
|
||
| SoftAssertions.assertSoftly(softAssertions -> { | ||
| softAssertions.assertThat(properties.getName()).isEqualTo("pubsub"); | ||
| softAssertions.assertThat(properties.isObservationEnabled()).isEqualTo(false); | ||
| }); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("Should map DaprPubSubProperties correctly") | ||
| void shouldMapDaprPubSubPropertiesCorrectly() { | ||
| runner.withPropertyValues( | ||
| "dapr.pubsub.name=pubsub", | ||
| "dapr.pubsub.observation-enabled=true" | ||
| ).run(context -> { | ||
| DaprPubSubProperties properties = context.getBean(DaprPubSubProperties.class); | ||
|
|
||
| SoftAssertions.assertSoftly(softAssertions -> { | ||
| softAssertions.assertThat(properties.getName()).isEqualTo("pubsub"); | ||
| softAssertions.assertThat(properties.isObservationEnabled()).isEqualTo(true); | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| @EnableConfigurationProperties(DaprPubSubProperties.class) | ||
| static class EnableDaprPubSubProperties { | ||
| } | ||
| } |
63 changes: 63 additions & 0 deletions
63
.../test/java/io/dapr/spring/boot/autoconfigure/statestore/DaprStateStorePropertiesTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /* | ||
| * Copyright 2021 The Dapr Authors | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package io.dapr.spring.boot.autoconfigure.statestore; | ||
|
|
||
| import org.assertj.core.api.SoftAssertions; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
| import org.springframework.boot.test.context.runner.ApplicationContextRunner; | ||
|
|
||
| public class DaprStateStorePropertiesTest { | ||
|
|
||
|
|
||
| final ApplicationContextRunner runner = new ApplicationContextRunner() | ||
| .withUserConfiguration(EnableDaprStateStoreProperties.class); | ||
|
|
||
| @Test | ||
| @DisplayName("Should create DaprStateStoreProperties via constructor") | ||
| void shouldSetDaprStateStorePropertiesCorrectly() { | ||
| DaprStateStoreProperties properties = new DaprStateStoreProperties(); | ||
| properties.setBinding("binding"); | ||
| properties.setName("name"); | ||
|
|
||
| SoftAssertions.assertSoftly(softAssertions -> { | ||
| softAssertions.assertThat(properties.getName()).isEqualTo("name"); | ||
| softAssertions.assertThat(properties.getBinding()).isEqualTo("binding"); | ||
| }); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("Should map Dapr state store properties correctly") | ||
| void shouldMapDaprStateStoreProperties() { | ||
| runner.withPropertyValues( | ||
| "dapr.statestore.name=name", | ||
| "dapr.statestore.binding=binding" | ||
| ).run(context -> { | ||
| DaprStateStoreProperties properties = context.getBean(DaprStateStoreProperties.class); | ||
|
|
||
| SoftAssertions.assertSoftly(softly -> { | ||
| softly.assertThat(properties.getBinding()).isEqualTo("binding"); | ||
| softly.assertThat(properties.getName()).isEqualTo("name"); | ||
| }); | ||
| }); | ||
|
|
||
| } | ||
|
|
||
| @EnableConfigurationProperties(DaprStateStoreProperties.class) | ||
| static class EnableDaprStateStoreProperties { | ||
|
|
||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
sdk/src/test/java/io/dapr/client/domain/BulkPublishEntryTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /* | ||
| * Copyright 2025 The Dapr Authors | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
| package io.dapr.client.domain; | ||
|
|
||
| import org.junit.jupiter.api.Assertions; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| class BulkPublishEntryTest { | ||
|
|
||
| @Test | ||
| @DisplayName("Should create an empty metadata when metadata argument is null") | ||
| public void shouldCreateWithEmptyMetadataWhenMetadataIsNull() { | ||
| BulkPublishEntry<String> entry = new BulkPublishEntry<>( | ||
| "entryId", "event", "contentType", null | ||
| ); | ||
| assertThat(entry.getMetadata()).isEmpty(); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("Should create with non null metadata") | ||
| public void shouldCreateWithMetadata() { | ||
| BulkPublishEntry<String> entry = new BulkPublishEntry<>( | ||
| "entryId", "event", "application/json", Map.of( | ||
| "repo", "dapr/java-sdk" | ||
| )); | ||
| assertThat(entry.getMetadata()).hasSize(1); | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
sdk/src/test/java/io/dapr/client/domain/ConfigurationItemTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /* | ||
| * Copyright 2025 The Dapr Authors | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
| package io.dapr.client.domain; | ||
|
|
||
| import org.junit.jupiter.api.Assertions; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
|
||
| class ConfigurationItemTest { | ||
|
|
||
| @Test | ||
| @DisplayName("Should create ConfigurationItem correctly") | ||
| void shouldCreateConfigurationItemCorrectly() { | ||
| ConfigurationItem item = new ConfigurationItem("application", "java-sdk", "0.0.1", Map.of( | ||
| "creator", "devs" | ||
| )); | ||
|
|
||
| assertThat(item.getKey()).isEqualTo("application"); | ||
| assertThat(item.getValue()).isEqualTo("java-sdk"); | ||
| assertThat(item.getVersion()).isEqualTo("0.0.1"); | ||
| assertThat(item.getMetadata()).hasSize(1); | ||
| assertThat(item.getMetadata()).hasEntrySatisfying("creator", value -> { | ||
| assertThat(value).isEqualTo("devs"); | ||
| }); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("Should create with immutable metadata") | ||
| void shouldCreateWithImmutableMetadata() { | ||
| ConfigurationItem item = new ConfigurationItem("application", "java-sdk", "0.0.1", Map.of( | ||
| "creator", "devs" | ||
| )); | ||
| assertThatThrownBy(() -> item.getMetadata().put("language", "javascript")); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.