Search in sources :

Example 36 with Ds3ResponseCode

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

Example 37 with Ds3ResponseCode

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

Example 38 with Ds3ResponseCode

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

Example 39 with Ds3ResponseCode

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

Example 40 with Ds3ResponseCode

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

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