use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType in project ds3_autogen by SpectraLogic.
the class AllocateJobChunkParserGenerator_Test method toResponseCodeList_Test.
@Test
public void toResponseCodeList_Test() {
final ImmutableList<Ds3ResponseCode> responseCodes = ImmutableList.of(new Ds3ResponseCode(200, ImmutableList.of(new Ds3ResponseType("com.spectralogic.s3.server.domain.JobChunkApiBean", null))));
final ImmutableList<ResponseCode> result = generator.toResponseCodeList(responseCodes, "TestResponse", false);
assertThat(result.size(), is(3));
assertThat(result.get(0).getCode(), is(200));
assertThat(result.get(1).getCode(), is(307));
assertThat(result.get(2).getCode(), is(503));
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType in project ds3_autogen by SpectraLogic.
the class AllocateJobChunkParserGenerator_Test method toParsePayloadCode_Test.
@Test
public void toParsePayloadCode_Test() {
final String expected = "try (final InputStream inputStream = response.getResponseStream()) {\n" + " final JobChunkApiBean result = XmlOutput.fromXml(inputStream, JobChunkApiBean.class);\n" + " return new MyResponse(result, 0, MyResponse.Status.ALLOCATED, this.getChecksum(), this.getChecksumType());\n" + " }\n";
final Ds3ResponseCode ds3ResponseCode = new Ds3ResponseCode(200, ImmutableList.of(new Ds3ResponseType("com.spectralogic.s3.server.domain.JobChunkApiBean", null)));
final String result = toParsePayloadCode(ds3ResponseCode, "MyResponse");
assertThat(result, is(expected));
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType in project ds3_autogen by SpectraLogic.
the class GetJobChunksReadyParserGenerator_Test method toParsePayloadCode_Test.
@Test
public void toParsePayloadCode_Test() {
final String expected = "try (final InputStream inputStream = response.getResponseStream()) {\n" + " final JobWithChunksApiBean result = XmlOutput.fromXml(inputStream, JobWithChunksApiBean.class);\n" + " if (isNullOrEmpty(result.getObjects())) {\n" + " return new TestResponse(result, parseRetryAfter(response), TestResponse.Status.RETRYLATER, this.getChecksum(), this.getChecksumType());\n" + " }\n" + " return new TestResponse(result, 0, TestResponse.Status.AVAILABLE, this.getChecksum(), this.getChecksumType());\n" + " }\n";
final Ds3ResponseCode ds3ResponseCode = new Ds3ResponseCode(200, ImmutableList.of(new Ds3ResponseType("com.spectralogic.s3.server.domain.JobWithChunksApiBean", null)));
final String result = toParsePayloadCode(ds3ResponseCode, "TestResponse");
assertThat(result, is(expected));
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType in project ds3_autogen by SpectraLogic.
the class BaseResponseGenerator_Test method toResponseCode_NullPayload_Test.
@Test
public void toResponseCode_NullPayload_Test() {
final String expectedGoCode = "return &ResponseName{}, nil";
final Ds3ResponseCode responseCode = new Ds3ResponseCode(200, ImmutableList.of(new Ds3ResponseType("null", "")));
final ResponseCode result = generator.toResponseCode(responseCode, "ResponseName");
assertThat(result.getCode(), is(200));
assertThat(result.getParseResponse(), is(expectedGoCode));
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType in project ds3_autogen by SpectraLogic.
the class GetObjectResponseGenerator_Test method toResponseCode_206_Test.
@Test
public void toResponseCode_206_Test() {
final ResponseCode expected = new ResponseCode(206, "return &GetObjectResponse{}, nil");
final Ds3ResponseCode code = new Ds3ResponseCode(206, ImmutableList.of(new Ds3ResponseType("null", null)));
final ResponseCode result = generator.toResponseCode(code, "GetObjectResponse");
assertThat(result, is(expected));
}
Aggregations