Skip to content

Commit 007f58a

Browse files
committed
Add test coverage for StableConfigMappingException
1 parent 6ab4b6c commit 007f58a

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

internal-api/src/main/java/datadog/trace/bootstrap/config/provider/stableconfig/StableConfigMappingException.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ public StableConfigMappingException(String message) {
55
super(message);
66
}
77

8-
public StableConfigMappingException(String message, Throwable cause) {
9-
super(message, cause);
10-
}
11-
128
public static String safeToString(Object value) {
139
if (value == null) return "null";
1410
String str = value.toString();
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package datadog.trace.bootstrap.config.provider
2+
3+
import datadog.trace.bootstrap.config.provider.stableconfig.StableConfigMappingException
4+
import spock.lang.Specification
5+
6+
class StableConfigMappingExceptionTest extends Specification {
7+
8+
def "constructors work as expected"() {
9+
when:
10+
def ex1 = new StableConfigMappingException("msg")
11+
def ex2 = new StableConfigMappingException("msg2")
12+
13+
then:
14+
ex1.message == "msg"
15+
ex1.cause == null
16+
ex2.message == "msg2"
17+
}
18+
19+
def "safeToString handles null"() {
20+
expect:
21+
StableConfigMappingException.safeToString(null) == "null"
22+
}
23+
24+
def "safeToString handles short string"() {
25+
expect:
26+
StableConfigMappingException.safeToString("short string") == "short string"
27+
}
28+
29+
def "safeToString handles long string"() {
30+
given:
31+
def longStr = "a" * 101
32+
expect:
33+
StableConfigMappingException.safeToString(longStr) == ("a" * 100) + "...(truncated)"
34+
}
35+
}

0 commit comments

Comments
 (0)