Skip to content

Commit 1741eb9

Browse files
committed
test(runtime): add exception taxonomy RED
1 parent 0a16a4b commit 1741eb9

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

‎src/test/java/io/github/easy4j/kimi/runtime/KimiRuntimeFoundationContractTest.java‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,16 @@
1313

1414
import org.junit.jupiter.api.Test;
1515

16+
import io.github.easy4j.kimi.KimiAuthenticationException;
17+
import io.github.easy4j.kimi.KimiConfigurationException;
18+
import io.github.easy4j.kimi.KimiErrorCategory;
1619
import io.github.easy4j.kimi.KimiException;
20+
import io.github.easy4j.kimi.KimiProcessException;
21+
import io.github.easy4j.kimi.KimiProtocolException;
22+
import io.github.easy4j.kimi.KimiRpcException;
1723
import io.github.easy4j.kimi.KimiRuntimeClosedException;
24+
import io.github.easy4j.kimi.KimiSerializationException;
25+
import io.github.easy4j.kimi.KimiServerException;
1826
import io.github.easy4j.kimi.KimiTimeoutException;
1927
import io.github.easy4j.kimi.KimiUnsupportedCapabilityException;
2028

@@ -67,5 +75,29 @@ void shouldKeepRuntimeExceptionsCompatibleWithKimiException() {
6775

6876
assertTrue(closed instanceof KimiException);
6977
assertTrue(timeout instanceof KimiException);
78+
assertEquals(KimiErrorCategory.RUNTIME_CLOSED, closed.getCategory());
79+
assertEquals(KimiErrorCategory.TIMEOUT, timeout.getCategory());
80+
}
81+
82+
@Test
83+
void shouldExposeStableExceptionTaxonomy() {
84+
assertEquals(KimiErrorCategory.CONFIGURATION,
85+
new KimiConfigurationException("configuration").getCategory());
86+
assertEquals(KimiErrorCategory.PROCESS,
87+
new KimiProcessException("process").getCategory());
88+
assertEquals(KimiErrorCategory.PROTOCOL,
89+
new KimiProtocolException("protocol").getCategory());
90+
assertEquals(KimiErrorCategory.RPC,
91+
new KimiRpcException("rpc").getCategory());
92+
assertEquals(KimiErrorCategory.AUTHENTICATION,
93+
new KimiAuthenticationException("auth").getCategory());
94+
assertEquals(KimiErrorCategory.SERVER,
95+
new KimiServerException("server").getCategory());
96+
assertEquals(KimiErrorCategory.SERIALIZATION,
97+
new KimiSerializationException("serialization").getCategory());
98+
99+
KimiUnsupportedCapabilityException unsupported =
100+
new KimiUnsupportedCapabilityException(KimiCapability.WEBSOCKET);
101+
assertEquals(KimiErrorCategory.UNSUPPORTED_CAPABILITY, unsupported.getCategory());
70102
}
71103
}

0 commit comments

Comments
 (0)