use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Request in project ds3_autogen by SpectraLogic.
the class ObjectsPayloadGenerator_Test method getAdditionalContent_RequiredFileObjectList_Test.
@Test
public void getAdditionalContent_RequiredFileObjectList_Test() {
final String expected = "if object_list is not None:\n" + " if not isinstance(object_list, FileObjectList):\n" + " raise TypeError('com.spectralogic.s3.server.handler.reqhandler.spectrads3.job.CreateGetJobRequestHandler should have request payload of type: FileObjectList')\n" + " self.body = xmldom.tostring(object_list.to_xml())\n";
final Ds3Request request = getRequestBulkGet();
final String result = generator.getAdditionalContent(request, request.getName());
assertThat(result, is(expected));
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Request in project ds3_autogen by SpectraLogic.
the class NameConverter_Test method renameRequests_FullList_Test.
@Test
public void renameRequests_FullList_Test() {
final Ds3ApiSpec spec = new Ds3ApiSpec(ImmutableList.of(new Ds3Request("com.spectralogic.test.MyTestOneRequestHandler", null, Classification.spectrads3, null, null, null, null, null, null, false, null, null, null), new Ds3Request("com.spectralogic.test.MyTestTwoRequestHandler", null, Classification.amazons3, null, null, null, null, null, null, false, null, null, null)), null);
final Ds3ApiSpec result = renameRequests(spec);
assertThat(result.getRequests().size(), is(2));
assertThat(result.getRequests().get(0).getName(), is("com.spectralogic.test.MyTestOneSpectraS3Request"));
assertThat(result.getRequests().get(1).getName(), is("com.spectralogic.test.MyTestTwoRequest"));
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Request in project ds3_autogen by SpectraLogic.
the class RemoveSpectraInternalConverter_Test method removeInternalRequestsFromSpec_RemoveRequests_Test.
@Test
public void removeInternalRequestsFromSpec_RemoveRequests_Test() {
final ImmutableList<Ds3Request> requests = createTestRequests();
final Ds3ApiSpec spec = new Ds3ApiSpec(requests, null);
final Ds3ApiSpec result = removeInternalRequestsFromSpec(spec, false);
assertThat(result.getRequests().size(), is(2));
for (final Ds3Request request : result.getRequests()) {
assertThat(request.getClassification(), not(Classification.spectrainternal));
}
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Request in project ds3_autogen by SpectraLogic.
the class CCodeGeneratorAmazonS3InitRequests_Test method testGenerateInitAmazonS3WithRequiredQueryParams.
@Test
public void testGenerateInitAmazonS3WithRequiredQueryParams() throws IOException, ParseException, TemplateModelException {
final Map<String, Object> testMap = new HashMap<>();
final Request testRequest = RequestConverter.toRequest(new Ds3Request("com.spectralogic.s3.server.handler.reqhandler.amazons3.InitiateMultiPartUploadRequestHandler", HttpVerb.POST, Classification.amazons3, Requirement.REQUIRED, Requirement.REQUIRED, null, null, null, null, false, null, ImmutableList.of(new Ds3Param("Job", "java.util.UUID", true), new Ds3Param("Offset", "long", false)), ImmutableList.of()), new Ds3DocSpecEmptyImpl());
testMap.put("requestEntry", testRequest);
final CCodeGenerator codeGenerator = new CCodeGenerator();
final TestFileUtilsImpl fileUtils = new TestFileUtilsImpl();
codeGenerator.processTemplate(testMap, "request-templates/InitRequest.ftl", fileUtils.getOutputStream());
final ByteArrayOutputStream bstream = (ByteArrayOutputStream) fileUtils.getOutputStream();
final String output = new String(bstream.toByteArray());
final String expectedOutput = "ds3_request* ds3_init_initiate_multi_part_upload(const char *const bucket_name, const char *const object_name, const uint64_t length) {" + "\n" + " struct _ds3_request* request = _common_request_init(HTTP_POST, _build_path(\"/\", bucket_name, object_name));" + "\n" + " request->length = length;" + "\n" + "\n" + " return (ds3_request*) request;" + "\n" + "}\n";
assertEquals(expectedOutput, output);
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Request in project ds3_autogen by SpectraLogic.
the class HeadResponseGenerator_Test method getStatusCodes_HeadBucket_Test.
@Test
public void getStatusCodes_HeadBucket_Test() {
final Ds3Request headBucket = getHeadBucketRequest();
final ImmutableList<Integer> result = generator.getStatusCodes(headBucket.getDs3ResponseCodes(), headBucket.getName());
assertThat(result.size(), is(3));
assertThat(result, hasItem(200));
assertThat(result, hasItem(403));
assertThat(result, hasItem(404));
}
Aggregations