Skip to content

Commit f46d6d8

Browse files
committed
Add test for some classes
1 parent 8665af6 commit f46d6d8

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

sdk/src/test/java/io/dapr/client/domain/BulkPublishEntryTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import org.junit.jupiter.api.Assertions;
1616
import org.junit.jupiter.api.Test;
1717

18+
import java.util.Map;
19+
1820
class BulkPublishEntryTest {
1921

2022
@Test
@@ -25,4 +27,14 @@ public void shouldCreateWithEmptyMetadataWhenMetadataIsNull() {
2527
Assertions.assertEquals(0, entry.getMetadata().size());
2628
}
2729

30+
@Test
31+
public void shouldCreateWithMetadata() {
32+
BulkPublishEntry<String> entry = new BulkPublishEntry<>(
33+
"entryId", "event", "application/json", Map.of(
34+
"repo", "dapr/java-sdk"
35+
));
36+
37+
Assertions.assertEquals(1, entry.getMetadata().size());
38+
}
39+
2840
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright 2025 The Dapr Authors
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
package io.dapr.client.domain;
14+
15+
import org.junit.jupiter.api.Assertions;
16+
import org.junit.jupiter.api.DisplayName;
17+
import org.junit.jupiter.api.Test;
18+
19+
import java.util.Map;
20+
21+
class ConfigurationItemTest {
22+
23+
@Test
24+
@DisplayName("Should create ConfiguratiotruenItem correctly")
25+
void shouldCreateConfigurationItemCorrectly() {
26+
ConfigurationItem item = new ConfigurationItem("application", "java-sdk", "0.0.1", Map.of(
27+
"creator", "devs"
28+
));
29+
30+
Assertions.assertEquals("application", item.getKey());
31+
Assertions.assertEquals("java-sdk", item.getValue());
32+
Assertions.assertEquals("0.0.1", item.getVersion());
33+
Assertions.assertEquals(1, item.getMetadata().size());
34+
Assertions.assertEquals("devs", item.getMetadata().get("creator"));
35+
}
36+
37+
@Test
38+
@DisplayName("Should create with immutable metadata")
39+
void shouldCreateWithImmutableMetadata() {
40+
ConfigurationItem item = new ConfigurationItem("application", "java-sdk", "0.0.1", Map.of(
41+
"creator", "devs"
42+
));
43+
44+
Assertions.assertThrows(UnsupportedOperationException.class, () -> {
45+
item.getMetadata().put("language", "javascript");
46+
});
47+
}
48+
}

0 commit comments

Comments
 (0)