Search in sources :

Example 16 with Ds3ResponseType

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

the class RequestConverter method getResponseType.

public static String getResponseType(final ImmutableList<Ds3ResponseCode> responseCodes) {
    if (isEmpty(responseCodes))
        return "";
    String responseTypeName = "";
    for (final Ds3ResponseCode responseCode : responseCodes) {
        final int rc = responseCode.getCode();
        if (rc < 200 || rc >= 300)
            continue;
        for (final Ds3ResponseType responseType : responseCode.getDs3ResponseTypes()) {
            if (ConverterUtil.hasContent(responseType.getType()) && !responseType.getType().contentEquals("null")) {
                responseTypeName = responseType.getType();
            } else if (ConverterUtil.hasContent(responseType.getComponentType()) && !responseType.getComponentType().contentEquals("null")) {
                responseTypeName = responseType.getComponentType();
            }
        }
    }
    LOG.debug("\tResponse Type: " + responseTypeName);
    if (responseTypeName.equalsIgnoreCase("java.lang.String")) {
        return "ds3_str";
    } else if (!responseTypeName.isEmpty()) {
        return StructHelper.getResponseTypeName(responseTypeName);
    }
    return "";
}
Also used : Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) Ds3ResponseType(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType)

Example 17 with Ds3ResponseType

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

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

the class ResponseAndParserUtil_Test method getImportFromResponseCode_ErrorComponentType_Test.

@Test(expected = IllegalArgumentException.class)
public void getImportFromResponseCode_ErrorComponentType_Test() {
    final Ds3ResponseCode responseCode = new Ds3ResponseCode(400, ImmutableList.of(new Ds3ResponseType("array", "com.spectralogic.Test.Type")));
    getImportFromResponseCode(responseCode);
}
Also used : Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) Ds3ResponseType(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType) Test(org.junit.Test)

Example 19 with Ds3ResponseType

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

the class ResponseAndParserUtil_Test method getResponseModelName_SimpleType_Test.

@Test
public void getResponseModelName_SimpleType_Test() {
    final Ds3ResponseType responseType = new Ds3ResponseType("com.test.MyType", null);
    assertThat(getResponseModelName(responseType), is("MyType"));
}
Also used : Ds3ResponseType(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType) Test(org.junit.Test)

Example 20 with Ds3ResponseType

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

the class ResponsePayloadUtil_Test method removeNullPayloads_FullList_Test.

@Test
public void removeNullPayloads_FullList_Test() {
    final ImmutableList<Ds3ResponseCode> codes = ImmutableList.of(new Ds3ResponseCode(200, ImmutableList.of(new Ds3ResponseType("null", null))), new Ds3ResponseCode(207, ImmutableList.of(new Ds3ResponseType("com.test.ResponsePayload", null))));
    final ImmutableList<Ds3ResponseCode> result = removeNullPayloads(codes);
    assertThat(result.size(), is(1));
    assertThat(result.get(0).getCode(), is(207));
}
Also used : 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