Search in sources :

Example 31 with Ds3ResponseType

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

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

the class BaseResponseGenerator method toParam.

/**
     * Creates an optional Argument that contains the parameter described in the
     * response code. If no parameter is described (i.e. type = "null") then an
     * empty optional is returned.
     */
protected static Optional<Arguments> toParam(final Ds3ResponseCode responseCode) {
    if (isEmpty(responseCode.getDs3ResponseTypes())) {
        throw new IllegalArgumentException("Ds3ResponseCodes does not have a type: " + responseCode.getCode());
    }
    final Ds3ResponseType ds3ResponseType = responseCode.getDs3ResponseTypes().get(0);
    final String paramName = createDs3ResponseTypeParamName(ds3ResponseType);
    final String paramType = getResponseModelName(ds3ResponseType);
    if (isEmpty(paramName) || isEmpty(paramType)) {
        return Optional.empty();
    }
    return Optional.of(new Arguments(paramType, paramName));
}
Also used : Ds3ResponseType(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType) Arguments(com.spectralogic.ds3autogen.api.models.Arguments)

Example 33 with Ds3ResponseType

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

the class Ds3ResponseCodeFixture method createTestResponseCodes.

/**
     * Creates a list of populated response codes for testing purposes. If hasPayload is true,
     * then one of the response types will be non-null. Else, both non-error response types
     * will have a type of "null"
     */
public static ImmutableList<Ds3ResponseCode> createTestResponseCodes(final boolean hasPayload) {
    final ImmutableList.Builder<Ds3ResponseCode> builder = ImmutableList.builder();
    if (hasPayload) {
        builder.add(new Ds3ResponseCode(200, ImmutableList.of(new Ds3ResponseType("com.spectralogic.s3.server.domain.JobWithChunksApiBean", null))));
    } else {
        builder.add(new Ds3ResponseCode(200, ImmutableList.of(new Ds3ResponseType("null", null))));
    }
    builder.add(new Ds3ResponseCode(204, ImmutableList.of(new Ds3ResponseType("null", null))));
    builder.add(new Ds3ResponseCode(404, ImmutableList.of(new Ds3ResponseType("com.spectralogic.s3.server.domain.HttpErrorResultApiBean", null))));
    return builder.build();
}
Also used : Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) ImmutableList(com.google.common.collect.ImmutableList) Ds3ResponseType(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType)

Example 34 with Ds3ResponseType

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

the class ResponsePayloadUtil_Test method getResponsePayload_FullList_Test.

@Test
public void getResponsePayload_FullList_Test() {
    final ImmutableList<Ds3ResponseCode> codes = ImmutableList.of(new Ds3ResponseCode(200, ImmutableList.of(new Ds3ResponseType("ResponseType", null))), new Ds3ResponseCode(204, ImmutableList.of(new Ds3ResponseType("null", null))));
    assertThat(getResponsePayload(codes), is("ResponseType"));
}
Also used : Ds3ResponseCode(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode) Ds3ResponseType(com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType) Test(org.junit.Test)

Example 35 with Ds3ResponseType

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

the class ResponsePayloadUtil_Test method getResponseType_ListSizeTwo_Test.

@Test(expected = IllegalArgumentException.class)
public void getResponseType_ListSizeTwo_Test() {
    final ImmutableList<Ds3ResponseType> responseTypes = ImmutableList.of(new Ds3ResponseType("null", null), new Ds3ResponseType("com.spectralogic.s3.server.domain.HttpErrorResultApiBean", null));
    getResponseType(responseTypes);
}
Also used : 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