Search in sources :

Example 31 with Ds3Request

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

the class BaseResponseGenerator_Test method getParsePayload_NoNameToMarshal_Test.

@Test
public void getParsePayload_NoNameToMarshal_Test() {
    final Ds3Request request = getBucketRequest();
    assertThat(getParsePayload(request), instanceOf(BaseParsePayload.class));
}
Also used : BaseParsePayload(com.spectralogic.ds3autogen.python.model.response.BaseParsePayload) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) Test(org.junit.Test)

Example 32 with Ds3Request

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

the class BaseResponseGenerator_Test method getStatusCodes_Test.

@Test
public void getStatusCodes_Test() {
    final Ds3Request request = getRequestAmazonS3GetObject();
    final ImmutableList<Integer> result = generator.getStatusCodes(request.getDs3ResponseCodes(), request.getName());
    assertThat(result, hasItem(200));
    assertThat(result, hasItem(206));
}
Also used : Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) Test(org.junit.Test)

Example 33 with Ds3Request

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

the class BaseResponseGenerator_Test method getParsePayload_NoPayload_Test.

@Test
public void getParsePayload_NoPayload_Test() {
    final Ds3Request emptyRequest = createDs3RequestTestData("com.test.Request", Classification.amazons3);
    assertThat(getParsePayload(emptyRequest), instanceOf(NoPayload.class));
}
Also used : Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) NoPayload(com.spectralogic.ds3autogen.python.model.response.NoPayload) Test(org.junit.Test)

Example 34 with Ds3Request

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

the class CCodeGeneratorAmazonS3InitRequests_Test method testGenerateInitAmazonS3WithOptionalQueryParams.

@Test
public void testGenerateInitAmazonS3WithOptionalQueryParams() 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.CreateObjectRequestHandler", HttpVerb.PUT, 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_create_object(const char *const bucket_name, const char *const object_name, const uint64_t length) {" + "\n" + "    struct _ds3_request* request = _common_request_init(HTTP_PUT, _build_path(\"/\", bucket_name, object_name));" + "\n" + "    request->length = length;" + "\n" + "\n" + "    return (ds3_request*) request;" + "\n" + "}\n";
    assertEquals(expectedOutput, output);
}
Also used : Ds3Param(com.spectralogic.ds3autogen.api.models.apispec.Ds3Param) TestFileUtilsImpl(com.spectralogic.ds3autogen.utils.TestFileUtilsImpl) HashMap(java.util.HashMap) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) Request(com.spectralogic.ds3autogen.c.models.Request) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) Ds3DocSpecEmptyImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 35 with Ds3Request

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

the class GetObjectParserGenerator_Test method toImportList_Test.

@Test
public void toImportList_Test() {
    final Ds3Request request = getRequestAmazonS3GetObject();
    final ImmutableSet<String> result = generator.toImportList("GetObjectResponse", request, request.getDs3ResponseCodes());
    assertThat(result.size(), is(12));
    assertThat(result, hasItem("com.spectralogic.ds3client.commands.GetObjectResponse"));
    assertThat(result, hasItem("com.spectralogic.ds3client.commands.interfaces.MetadataImpl"));
    assertThat(result, hasItem("com.spectralogic.ds3client.commands.parsers.interfaces.AbstractResponseParser"));
    assertThat(result, hasItem("com.spectralogic.ds3client.commands.parsers.utils.ResponseParserUtils"));
    assertThat(result, hasItem("com.spectralogic.ds3client.exceptions.ContentLengthNotMatchException"));
    assertThat(result, hasItem("com.spectralogic.ds3client.networking.Metadata"));
    assertThat(result, hasItem("com.spectralogic.ds3client.networking.WebResponse"));
    assertThat(result, hasItem("com.spectralogic.ds3client.utils.IOUtils"));
    assertThat(result, hasItem("com.spectralogic.ds3client.utils.PerformanceUtils"));
    assertThat(result, hasItem("java.io.IOException"));
    assertThat(result, hasItem("java.io.InputStream"));
    assertThat(result, hasItem("java.nio.channels.WritableByteChannel"));
}
Also used : Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) Test(org.junit.Test)

Aggregations

Ds3Request (com.spectralogic.ds3autogen.api.models.apispec.Ds3Request)92 Test (org.junit.Test)76 RequestGeneratorTestHelper.createSimpleTestDs3Request (com.spectralogic.ds3autogen.java.test.helpers.RequestGeneratorTestHelper.createSimpleTestDs3Request)37 Arguments (com.spectralogic.ds3autogen.api.models.Arguments)24 Ds3ModelPartialDataFixture.createEmptyDs3Request (com.spectralogic.ds3autogen.testutil.Ds3ModelPartialDataFixture.createEmptyDs3Request)17 ImmutableList (com.google.common.collect.ImmutableList)11 Ds3Param (com.spectralogic.ds3autogen.api.models.apispec.Ds3Param)11 Ds3DocSpecEmptyImpl (com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl)9 QueryParam (com.spectralogic.ds3autogen.java.models.QueryParam)9 GuavaCollectors (com.spectralogic.ds3autogen.utils.collections.GuavaCollectors)8 RequestConstructor (com.spectralogic.ds3autogen.java.models.RequestConstructor)7 ConstructorParam (com.spectralogic.ds3autogen.python.model.request.ConstructorParam)7 Helper.camelToUnderscore (com.spectralogic.ds3autogen.utils.Helper.camelToUnderscore)7 CustomArgumentComparator (com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator)7 RequestConverterUtil.getNonVoidArgsFromParamList (com.spectralogic.ds3autogen.utils.RequestConverterUtil.getNonVoidArgsFromParamList)6 Ds3ApiSpec (com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec)5 PythonHelper.pythonIndent (com.spectralogic.ds3autogen.python.helpers.PythonHelper.pythonIndent)5 Variable (com.spectralogic.ds3autogen.java.models.Variable)3 Ds3RequestClassificationUtil (com.spectralogic.ds3autogen.utils.Ds3RequestClassificationUtil)3 OutputStream (java.io.OutputStream)3