Search in sources :

Example 6 with ResponseCode

use of com.spectralogic.ds3autogen.java.models.ResponseCode 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 7 with ResponseCode

use of com.spectralogic.ds3autogen.java.models.ResponseCode in project ds3_autogen by SpectraLogic.

the class BaseResponseParserGenerator_Test method toResponseCode_NullResponse_Test.

@Test
public void toResponseCode_NullResponse_Test() {
    final String expected = "//There is no payload associated with this code, return a null response\n" + "                return new TestResponse(null, this.getChecksum(), this.getChecksumType());\n";
    final ResponseCode result = toResponseCode(getNullResponseCode(), "TestResponse", true, 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 8 with ResponseCode

use of com.spectralogic.ds3autogen.java.models.ResponseCode in project ds3_autogen by SpectraLogic.

the class BaseResponseParserGenerator_Test method toResponseCode_BaseResponse_Test.

@Test
public void toResponseCode_BaseResponse_Test() {
    final String expected = "try (final InputStream inputStream = response.getResponseStream()) {\n" + "                    final Type result = XmlOutput.fromXml(inputStream, Type.class);\n" + "                    return new TestResponse(result, this.getChecksum(), this.getChecksumType());\n" + "                }\n";
    final ResponseCode result = toResponseCode(getBaseResponseCode(), "TestResponse", true, false);
    assertThat(result.getCode(), is(202));
    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 9 with ResponseCode

use of com.spectralogic.ds3autogen.java.models.ResponseCode in project ds3_autogen by SpectraLogic.

the class BaseResponseParserGenerator_Test method toResponseCode_StringResponse_Test.

@Test
public void toResponseCode_StringResponse_Test() {
    final String expected = "try (final InputStream inputStream = response.getResponseStream()) {\n" + "                    final String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8);\n" + "                    return new TestResponse(result, this.getChecksum(), this.getChecksumType());\n" + "                }\n";
    final ResponseCode result = toResponseCode(getStringResponseCode(), "TestResponse", true, false);
    assertThat(result.getCode(), is(201));
    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 10 with ResponseCode

use of com.spectralogic.ds3autogen.java.models.ResponseCode in project ds3_autogen by SpectraLogic.

the class BaseResponseParserGenerator_Test method toStatusCodeList_FullList_Test.

@Test
public void toStatusCodeList_FullList_Test() {
    final ImmutableList<ResponseCode> responseCodes = ImmutableList.of(new ResponseCode(201, ""), new ResponseCode(202, ""), new ResponseCode(203, ""));
    final String result = toStatusCodeList(responseCodes);
    assertThat(result, is("201, 202, 203"));
}
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)

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