Skip to content

Commit

Permalink
chore: improve rpcresponseFactoryTest
Browse files Browse the repository at this point in the history
  • Loading branch information
caicancai committed Sep 2, 2024
1 parent 494f868 commit e0a8093
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
import static org.junit.Assert.assertEquals;

public class RpcResponseFactoryTest {
@Test
public void testNewResponseWithNull() {
ErrorResponse response = (ErrorResponse) RpcFactoryHelper.responseFactory().newResponse(null, null);
assertEquals(response.getErrorCode(), 0);
assertEquals(response.getErrorMsg(), "OK");
}

@Test
public void testNewResponseFromStatus() {
ErrorResponse response = (ErrorResponse) RpcFactoryHelper.responseFactory().newResponse(null, Status.OK());
Expand All @@ -42,13 +49,21 @@ public void testNewResponseWithErrorStatus() {
}

@Test
public void testNewResponseWithVaridicArgs() {
public void testNewResponseWithVaridicNumberArgs() {
ErrorResponse response = (ErrorResponse) RpcFactoryHelper.responseFactory().newResponse(null, 300,
"hello %s %d", "world", 99);
assertEquals(response.getErrorCode(), 300);
assertEquals(response.getErrorMsg(), "hello world 99");
}

@Test
public void testNewResponseWithVaridicStringArgs() {
ErrorResponse response = (ErrorResponse) RpcFactoryHelper.responseFactory().newResponse(null, 300,
"hello %s %s", "world", "99");
assertEquals(response.getErrorCode(), 300);
assertEquals(response.getErrorMsg(), "hello world 99");
}

@Test
public void testNewResponseWithArgs() {
ErrorResponse response = (ErrorResponse) RpcFactoryHelper.responseFactory().newResponse(null, 300,
Expand Down

0 comments on commit e0a8093

Please sign in to comment.