use of com.spectralogic.ds3autogen.java.models.ResponseCode in project ds3_autogen by SpectraLogic.
the class GetObjectParserGenerator method toResponseCodeList.
/**
* Gets the expected response codes with no java code values since they are
* only being used to determine the expected response codes within the template
*/
@Override
public ImmutableList<ResponseCode> toResponseCodeList(final ImmutableList<Ds3ResponseCode> ds3ResponseCodes, final String responseName, final boolean hasPaginationHeaders) {
final ImmutableList<Integer> codes = getResponseCodes(ds3ResponseCodes);
if (!codes.containsAll(EXPECTED_RESPONSE_CODES)) {
throw new IllegalArgumentException("Does not contain expected response codes: " + EXPECTED_RESPONSE_CODES.toString());
}
final ResponseCode code200 = new ResponseCode(200, "");
final ResponseCode code206 = new ResponseCode(206, "");
return ImmutableList.of(code200, code206);
}
use of com.spectralogic.ds3autogen.java.models.ResponseCode in project ds3_autogen by SpectraLogic.
the class HeadObjectParserGenerator method toResponseCodeList.
/**
* Gets the non-error response codes required to generate this response
*/
@Override
public ImmutableList<ResponseCode> toResponseCodeList(final ImmutableList<Ds3ResponseCode> ds3ResponseCodes, final String responseName, final boolean hasPaginationHeaders) {
//Verify that the expected status codes are present
final ImmutableList<Integer> codes = getResponseCodes(ds3ResponseCodes);
if (!codes.containsAll(EXPECTED_RESPONSE_CODES)) {
throw new IllegalArgumentException("Does not contain expected response codes: " + EXPECTED_RESPONSE_CODES.toString());
}
final ResponseCode code200 = new ResponseCode(200, toReturnCode(responseName, "EXISTS"));
final ResponseCode code404 = new ResponseCode(404, toReturnCode(responseName, "DOESNTEXIST"));
return ImmutableList.of(code200, code404);
}
use of com.spectralogic.ds3autogen.java.models.ResponseCode in project ds3_autogen by SpectraLogic.
the class BaseResponseParserGenerator_Test method toResponseCodes_Test.
@Test
public void toResponseCodes_Test() {
final String expectedProcessingCode = "try (final InputStream inputStream = response.getResponseStream()) {\n" + " final DefaultType result = XmlOutput.fromXml(inputStream, DefaultType.class);\n" + " return new TestResponse(result, this.getChecksum(), this.getChecksumType());\n" + " }\n";
final ImmutableList<Ds3ResponseType> defaultResponseType = ImmutableList.of(new Ds3ResponseType("DefaultType", null));
final ImmutableList<Ds3ResponseCode> responseCodes = ImmutableList.of(new Ds3ResponseCode(200, defaultResponseType), new Ds3ResponseCode(206, defaultResponseType), new Ds3ResponseCode(307, defaultResponseType), new Ds3ResponseCode(400, defaultResponseType), new Ds3ResponseCode(503, defaultResponseType));
final ImmutableList<ResponseCode> result = generator.toResponseCodeList(responseCodes, "TestResponse", false);
assertThat(result.size(), is(3));
assertThat(result.get(0).getCode(), is(200));
assertThat(result.get(0).getProcessingCode(), is(expectedProcessingCode));
assertThat(result.get(1).getCode(), is(206));
assertThat(result.get(1).getProcessingCode(), is(expectedProcessingCode));
assertThat(result.get(2).getCode(), is(307));
assertThat(result.get(2).getProcessingCode(), is(expectedProcessingCode));
}
use of com.spectralogic.ds3autogen.java.models.ResponseCode in project ds3_autogen by SpectraLogic.
the class BaseResponseParserGenerator_Test method toResponseCode_EmptyResponse_Test.
@Test
public void toResponseCode_EmptyResponse_Test() {
final String expected = "//There is no payload, return an empty response handler\n" + " return new TestResponse(this.getChecksum(), this.getChecksumType());\n";
final ResponseCode result = toResponseCode(getNullResponseCode(), "TestResponse", false, false);
assertThat(result.getCode(), is(200));
assertThat(result.getProcessingCode(), is(expected));
}
use of com.spectralogic.ds3autogen.java.models.ResponseCode in project ds3_autogen by SpectraLogic.
the class GetObjectParserGenerator_Test method toResponseCodeList_Test.
@Test
public void toResponseCodeList_Test() {
final ImmutableList<Ds3ResponseCode> ds3ResponseCodes = ImmutableList.of(new Ds3ResponseCode(200, null), new Ds3ResponseCode(206, null));
final ImmutableList<ResponseCode> result = generator.toResponseCodeList(ds3ResponseCodes, "TestResponse", false);
assertThat(result.size(), is(2));
assertThat(result.get(0).getCode(), is(200));
assertThat(result.get(1).getCode(), is(206));
}
Aggregations