Search in sources :

Example 41 with Ds3ResponseCode

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode in project ds3_autogen by SpectraLogic.

the class BaseResponseGenerator_Test method toResponsePayloadType_MultipleCodes_Test.

@Test
public void toResponsePayloadType_MultipleCodes_Test() {
    final String expected = "*Type";
    final ImmutableList<Ds3ResponseCode> input = ImmutableList.of(new Ds3ResponseCode(200, ImmutableList.of()), new Ds3ResponseCode(204, ImmutableList.of()), new Ds3ResponseCode(300, ImmutableList.of()));
    final String result = generator.toResponsePayloadType("com.test.Type", input);
    assertThat(result, is(expected));
}
Also used : Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) Test(org.junit.Test)

Example 42 with Ds3ResponseCode

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode in project ds3_autogen by SpectraLogic.

the class BaseResponseGenerator_Test method toExpectedStatusCodes_Test.

@Test
public void toExpectedStatusCodes_Test() {
    final String expected = "200, 204";
    final ImmutableList<Ds3ResponseCode> responseCodes = ImmutableList.of(new Ds3ResponseCode(200, ImmutableList.of()), new Ds3ResponseCode(204, ImmutableList.of()), new Ds3ResponseCode(300, ImmutableList.of()));
    final String result = generator.toExpectedStatusCodes(responseCodes);
    assertThat(result, is(expected));
}
Also used : Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) Test(org.junit.Test)

Example 43 with Ds3ResponseCode

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode in project ds3_autogen by SpectraLogic.

the class AllocateJobChunkParserGenerator 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, toParsePayloadCode(getDs3ResponseCode(ds3ResponseCodes, 200), responseName));
    // The switch case for 307 should fall through to the 503 handling
    final ResponseCode code307 = new ResponseCode(307, "");
    final ResponseCode code503 = new ResponseCode(503, toRetryLaterCode(responseName));
    return ImmutableList.of(code200, code307, code503);
}
Also used : Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) ResponseCode(com.spectralogic.ds3autogen.java.models.ResponseCode)

Example 44 with Ds3ResponseCode

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode in project ds3_autogen by SpectraLogic.

the class GetJobChunksReadyParserGenerator 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 Ds3ResponseCode ds3ResponseCode = getDs3ResponseCode(ds3ResponseCodes, 200);
    final ResponseCode code200 = new ResponseCode(200, toParsePayloadCode(ds3ResponseCode, responseName));
    return ImmutableList.of(code200);
}
Also used : Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) ResponseAndParserUtils.getDs3ResponseCode(com.spectralogic.ds3autogen.java.utils.ResponseAndParserUtils.getDs3ResponseCode) Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) ResponseAndParserUtils.getDs3ResponseCode(com.spectralogic.ds3autogen.java.utils.ResponseAndParserUtils.getDs3ResponseCode) ResponseCode(com.spectralogic.ds3autogen.java.models.ResponseCode)

Example 45 with Ds3ResponseCode

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode in project ds3_autogen by SpectraLogic.

the class HeadBucketParserGenerator 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 code403 = new ResponseCode(403, toReturnCode(responseName, "NOTAUTHORIZED"));
    final ResponseCode code404 = new ResponseCode(404, toReturnCode(responseName, "DOESNTEXIST"));
    return ImmutableList.of(code200, code403, code404);
}
Also used : Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) ResponseCode(com.spectralogic.ds3autogen.java.models.ResponseCode)

Aggregations

Ds3ResponseCode (com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode)52 Test (org.junit.Test)43 Ds3ResponseType (com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType)30 ResponseCode (com.spectralogic.ds3autogen.java.models.ResponseCode)8 ResponseCode (com.spectralogic.ds3autogen.go.models.response.ResponseCode)6 Arguments (com.spectralogic.ds3autogen.api.models.Arguments)4 ImmutableList (com.google.common.collect.ImmutableList)3 CaseFormat (com.google.common.base.CaseFormat)1 com.spectralogic.ds3autogen.api.models (com.spectralogic.ds3autogen.api.models)1 Action (com.spectralogic.ds3autogen.api.models.enums.Action)1 HttpVerb (com.spectralogic.ds3autogen.api.models.enums.HttpVerb)1 Operation (com.spectralogic.ds3autogen.api.models.enums.Operation)1 Ds3ResponseCodeFixtureTestHelper.createPopulatedErrorResponseCode (com.spectralogic.ds3autogen.java.test.helpers.Ds3ResponseCodeFixtureTestHelper.createPopulatedErrorResponseCode)1 Ds3ResponseCodeFixtureTestHelper.createPopulatedResponseCode (com.spectralogic.ds3autogen.java.test.helpers.Ds3ResponseCodeFixtureTestHelper.createPopulatedResponseCode)1 ResponseAndParserUtils.getDs3ResponseCode (com.spectralogic.ds3autogen.java.utils.ResponseAndParserUtils.getDs3ResponseCode)1 ConverterUtil.isEmpty (com.spectralogic.ds3autogen.utils.ConverterUtil.isEmpty)1 CustomArgumentComparator (com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang3.StringUtils)1