use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode in project ds3_autogen by SpectraLogic.
the class Helper method getResponseCodes.
/**
* Creates a sorted comma separated list of response codes
*/
public static String getResponseCodes(final ImmutableList<Ds3ResponseCode> responseCodes) {
final List<String> sortable = new ArrayList<>();
for (final Ds3ResponseCode responseCode : responseCodes) {
sortable.add(Integer.toString(responseCode.getCode()));
}
Collections.sort(sortable);
final ImmutableList.Builder<String> builder = ImmutableList.builder();
builder.addAll(sortable);
return builder.build().stream().map(i -> i).collect(Collectors.joining(", "));
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode in project ds3_autogen by SpectraLogic.
the class ResponsePayloadUtil method getAllNonErrorResponseCodes.
/**
* Gets the list of non-error and non-null Response Codes from a list of Ds3ResponseCodes
*/
protected static ImmutableList<Integer> getAllNonErrorResponseCodes(final ImmutableList<Ds3ResponseCode> responseCodes) {
final ImmutableList.Builder<Integer> builder = ImmutableList.builder();
if (isEmpty(responseCodes)) {
LOG.error("Could not retrieve response codes because list was empty");
return ImmutableList.of();
}
final ImmutableList<Ds3ResponseCode> codesWithPayloads = removeNullPayloads(responseCodes);
if (isEmpty(codesWithPayloads)) {
LOG.error("There were no response codes with payloads");
return ImmutableList.of();
}
for (final Ds3ResponseCode responseCode : codesWithPayloads) {
if (isNonErrorCode(responseCode.getCode())) {
builder.add(responseCode.getCode());
}
}
return builder.build();
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode 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.Ds3ResponseCode in project ds3_autogen by SpectraLogic.
the class HeadResponseGenerator_Test method getStatusCodes_MissingExpectedCode_Test.
@Test(expected = IllegalArgumentException.class)
public void getStatusCodes_MissingExpectedCode_Test() {
final ImmutableList<Ds3ResponseCode> responseCodes = ImmutableList.of(new Ds3ResponseCode(200, null));
generator.getStatusCodes(responseCodes, "HeadObjectRequest");
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseCode 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"));
}
Aggregations