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);
}
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));
}
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();
}
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"));
}
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);
}
Aggregations