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