Skip to content

Commit 42acf22

Browse files
committed
Fix flaky should_include_code_in_json_when_code_is_not_null
Update import
1 parent e56086d commit 42acf22

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/exception/CommonExceptionDataTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import static com.google.common.collect.ImmutableMap.of;
2121
import static org.assertj.core.api.Assertions.assertThat;
2222

23+
import java.util.Map;
24+
2325
import org.junit.jupiter.api.Test;
2426

2527
import io.vertx.core.json.Json;
@@ -36,7 +38,11 @@ void should_not_include_code_in_json_when_code_is_null() {
3638
void should_include_code_in_json_when_code_is_not_null() {
3739
CommonExceptionData data = new CommonExceptionData("code", "msg");
3840

39-
assertThat(Json.encode(data)).isEqualTo("{\"code\":\"code\",\"message\":\"msg\"}");
41+
String json = Json.encode(data);
42+
@SuppressWarnings("unchecked")
43+
Map<String, Object> obj = Json.decodeValue(json, Map.class);
44+
45+
assertThat(obj).containsEntry("code", "code").containsEntry("message", "msg").hasSize(2);
4046
}
4147

4248
@Test

0 commit comments

Comments
 (0)