Search in sources :

Example 26 with Ds3ResponseType

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

the class AllocateJobChunkParserGenerator_Test method toResponseCodeList_Test.

@Test
public void toResponseCodeList_Test() {
    final ImmutableList<Ds3ResponseCode> responseCodes = ImmutableList.of(new Ds3ResponseCode(200, ImmutableList.of(new Ds3ResponseType("com.spectralogic.s3.server.domain.JobChunkApiBean", null))));
    final ImmutableList<ResponseCode> result = generator.toResponseCodeList(responseCodes, "TestResponse", false);
    assertThat(result.size(), is(3));
    assertThat(result.get(0).getCode(), is(200));
    assertThat(result.get(1).getCode(), is(307));
    assertThat(result.get(2).getCode(), is(503));
}
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) Ds3ResponseType(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType) Test(org.junit.Test)

Example 27 with Ds3ResponseType

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

the class AllocateJobChunkParserGenerator_Test method toParsePayloadCode_Test.

@Test
public void toParsePayloadCode_Test() {
    final String expected = "try (final InputStream inputStream = response.getResponseStream()) {\n" + "                    final JobChunkApiBean result = XmlOutput.fromXml(inputStream, JobChunkApiBean.class);\n" + "                    return new MyResponse(result, 0, MyResponse.Status.ALLOCATED, this.getChecksum(), this.getChecksumType());\n" + "                }\n";
    final Ds3ResponseCode ds3ResponseCode = new Ds3ResponseCode(200, ImmutableList.of(new Ds3ResponseType("com.spectralogic.s3.server.domain.JobChunkApiBean", null)));
    final String result = toParsePayloadCode(ds3ResponseCode, "MyResponse");
    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 28 with Ds3ResponseType

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType 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 29 with Ds3ResponseType

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType 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 30 with Ds3ResponseType

use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType 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)

Aggregations

Ds3ResponseType (com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType)35 Test (org.junit.Test)31 Ds3ResponseCode (com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode)30 ResponseCode (com.spectralogic.ds3autogen.go.models.response.ResponseCode)6 Arguments (com.spectralogic.ds3autogen.api.models.Arguments)5 ResponseCode (com.spectralogic.ds3autogen.java.models.ResponseCode)2 ImmutableList (com.google.common.collect.ImmutableList)1 Ds3ResponseCodeFixtureTestHelper.createPopulatedErrorResponseCode (com.spectralogic.ds3autogen.java.test.helpers.Ds3ResponseCodeFixtureTestHelper.createPopulatedErrorResponseCode)1 Ds3ResponseCodeFixtureTestHelper.createPopulatedResponseCode (com.spectralogic.ds3autogen.java.test.helpers.Ds3ResponseCodeFixtureTestHelper.createPopulatedResponseCode)1