toString tests

Original commit: elastic/x-pack-elasticsearch@c3eb1265a4
This commit is contained in:
Nik Everett 2017-07-10 12:13:50 -04:00
parent 3759349db8
commit cd1c78feaf
9 changed files with 32 additions and 3 deletions

View File

@ -46,7 +46,7 @@ public class ErrorResponse extends Response {
protected String toStringBody() {
return "request=[" + requestType
+ "] message=[" + message
+ "] cuase=[" + cause
+ "] cause=[" + cause
+ "] stack=[" + stack + "]";
}

View File

@ -43,7 +43,7 @@ public class ExceptionResponse extends Response {
protected String toStringBody() {
return "request=[" + requestType
+ "] message=[" + message
+ "] cuase=[" + cause + "]";
+ "] cause=[" + cause + "]";
}
@Override

View File

@ -59,7 +59,7 @@ public class InfoResponse extends Response {
+ "]/[major=[" + majorVersion
+ "] minor=[" + minorVersion
+ "] hash=[" + versionHash
+ "] date=[" + versionDate + "]";
+ "] date=[" + versionDate + "]]";
}
@Override

View File

@ -19,4 +19,8 @@ public class CommandRequestTests extends ESTestCase {
public void testRoundTrip() throws IOException {
assertRoundTripCurrentVersion(randomCommandRequest());
}
public void testToString() {
assertEquals("CommandRequest<test>", new CommandRequest("test").toString());
}
}

View File

@ -20,4 +20,9 @@ public class CommandResponseTests extends ESTestCase {
public void testRoundTrip() throws IOException {
assertRoundTripCurrentVersion(randomCommandResponse());
}
public void testToString() {
assertEquals("CommandResponse<received=[123] sent=[332] requestId=[rid] data=[test]>",
new CommandResponse(123, 332, "rid", "test").toString());
}
}

View File

@ -20,4 +20,9 @@ public class ErrorResponseTests extends ESTestCase {
public void testRoundTrip() throws IOException {
assertRoundTripCurrentVersion(randomErrorResponse());
}
public void testToString() {
assertEquals("ErrorResponse<request=[COMMAND] message=[test] cause=[test] stack=[stack\nstack]>",
new ErrorResponse(RequestType.COMMAND, "test", "test", "stack\nstack").toString());
}
}

View File

@ -20,4 +20,9 @@ public class ExceptionResponseTests extends ESTestCase {
public void testRoundTrip() throws IOException {
assertRoundTripCurrentVersion(randomExceptionResponse());
}
public void testToString() {
assertEquals("ExceptionResponse<request=[COMMAND] message=[test] cause=[test]>",
new ExceptionResponse(RequestType.COMMAND, "test", "test").toString());
}
}

View File

@ -20,4 +20,9 @@ public class InfoRequestTests extends ESTestCase {
public void testRoundTrip() throws IOException {
assertRoundTripCurrentVersion(randomInfoRequest());
}
public void testToString() {
assertEquals("InfoRequest<jvm=[version=[1.8.0_131] vendor=[testvendor] classPath=[testcp]] os=[name=[Mac OS X] version=[10.12.5]]>",
new InfoRequest("1.8.0_131", "testvendor", "testcp", "Mac OS X", "10.12.5").toString());
}
}

View File

@ -20,4 +20,9 @@ public class InfoResponseTests extends ESTestCase {
public void testRoundTrip() throws IOException {
assertRoundTripCurrentVersion(randomInfoResponse());
}
public void testToString() {
assertEquals("InfoResponse<node=[adsf] cluster=[test_cluster] version=[6.0.0]/[major=[6] minor=[0] hash=[feed] date=[date]]>",
new InfoResponse("adsf", "test_cluster", (byte) 6, (byte) 0, "6.0.0", "feed", "date").toString());
}
}