Search in sources :

Example 1 with ResponseCode

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);
}
Also used : Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) ResponseCode(com.spectralogic.ds3autogen.java.models.ResponseCode)

Example 2 with ResponseCode

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);
}
Also used : Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) ResponseCode(com.spectralogic.ds3autogen.java.models.ResponseCode)

Example 3 with ResponseCode

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));
}
Also used : Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) Ds3ResponseCodeFixtureTestHelper.createPopulatedErrorResponseCode(com.spectralogic.ds3autogen.java.test.helpers.Ds3ResponseCodeFixtureTestHelper.createPopulatedErrorResponseCode) ResponseCode(com.spectralogic.ds3autogen.java.models.ResponseCode) Ds3ResponseCodeFixtureTestHelper.createPopulatedResponseCode(com.spectralogic.ds3autogen.java.test.helpers.Ds3ResponseCodeFixtureTestHelper.createPopulatedResponseCode) Ds3ResponseType(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType) Test(org.junit.Test)

Example 4 with ResponseCode

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));
}
Also used : Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) Ds3ResponseCodeFixtureTestHelper.createPopulatedErrorResponseCode(com.spectralogic.ds3autogen.java.test.helpers.Ds3ResponseCodeFixtureTestHelper.createPopulatedErrorResponseCode) ResponseCode(com.spectralogic.ds3autogen.java.models.ResponseCode) Ds3ResponseCodeFixtureTestHelper.createPopulatedResponseCode(com.spectralogic.ds3autogen.java.test.helpers.Ds3ResponseCodeFixtureTestHelper.createPopulatedResponseCode) Test(org.junit.Test)

Example 5 with ResponseCode

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));
}
Also used : Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) ResponseCode(com.spectralogic.ds3autogen.java.models.ResponseCode) Test(org.junit.Test)

Aggregations

Ds3ResponseCode (com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode)14 ResponseCode (com.spectralogic.ds3autogen.java.models.ResponseCode)14 Test (org.junit.Test)9 Ds3ResponseCodeFixtureTestHelper.createPopulatedErrorResponseCode (com.spectralogic.ds3autogen.java.test.helpers.Ds3ResponseCodeFixtureTestHelper.createPopulatedErrorResponseCode)6 Ds3ResponseCodeFixtureTestHelper.createPopulatedResponseCode (com.spectralogic.ds3autogen.java.test.helpers.Ds3ResponseCodeFixtureTestHelper.createPopulatedResponseCode)6 Ds3ResponseType (com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType)2 Ds3Request (com.spectralogic.ds3autogen.api.models.apispec.Ds3Request)1 ResponseAndParserUtils.getDs3ResponseCode (com.spectralogic.ds3autogen.java.utils.ResponseAndParserUtils.getDs3ResponseCode)1