use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode 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.Ds3ResponseCode 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.Ds3ResponseCode 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));
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode in project ds3_autogen by SpectraLogic.
the class BaseResponseGenerator_Test method getResponsePayload_MultiplePayloads_Test.
@Test(expected = IllegalArgumentException.class)
public void getResponsePayload_MultiplePayloads_Test() {
final ImmutableList<Ds3ResponseCode> input = ImmutableList.of(new Ds3ResponseCode(200, ImmutableList.of(new Ds3ResponseType("com.test.Type1", ""))), new Ds3ResponseCode(204, ImmutableList.of(new Ds3ResponseType("com.test.Type2", ""))));
generator.getResponsePayload(input);
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode in project ds3_autogen by SpectraLogic.
the class BaseResponseGenerator_Test method toResponsePayloadType_SingleCode_Test.
@Test
public void toResponsePayloadType_SingleCode_Test() {
final String expected = "Type";
final ImmutableList<Ds3ResponseCode> input = ImmutableList.of(new Ds3ResponseCode(200, ImmutableList.of()), new Ds3ResponseCode(300, ImmutableList.of()));
final String result = generator.toResponsePayloadType("com.test.Type", input);
assertThat(result, is(expected));
}
Aggregations