Search in sources :

Example 16 with Ds3DocSpecEmptyImpl

use of com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl in project ds3_autogen by SpectraLogic.

the class BulkRequestGenerator_Test method toWithConstructor_Test.

@Test
public void toWithConstructor_Test() {
    final String expectedResult = "    public GetBucketRequestHandler withDelimiter(final String delimiter) {\n" + "        this.delimiter = delimiter;\n" + "        this.updateQueryParam(\"delimiter\", delimiter);\n" + "        return this;\n" + "    }\n";
    final Arguments arg = new Arguments("String", "Delimiter");
    final String result = generator.toWithConstructor(arg, "GetBucketRequestHandler", new Ds3DocSpecEmptyImpl());
    assertThat(result, is(expectedResult));
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Ds3DocSpecEmptyImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl) Test(org.junit.Test)

Example 17 with Ds3DocSpecEmptyImpl

use of com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl in project ds3_autogen by SpectraLogic.

the class StreamRequestPayloadGenerator_Test method toConstructorList_Test.

@Test
public void toConstructorList_Test() {
    final ImmutableList<RequestConstructor> result = generator.toConstructorList(getCreateMultiPartUploadPart(), "", new Ds3DocSpecEmptyImpl());
    assertThat(result.size(), is(2));
    assertThat(result.get(0).getParameters().size(), is(6));
    assertThat(result.get(0).getParameters().get(0).getName(), is("BucketName"));
    assertThat(result.get(0).getParameters().get(1).getName(), is("ObjectName"));
    assertThat(result.get(0).getParameters().get(2).getName(), is("PartNumber"));
    assertThat(result.get(0).getParameters().get(3).getName(), is("UploadId"));
    assertThat(result.get(0).getParameters().get(4).getName(), is("Size"));
    assertThat(result.get(0).getParameters().get(5).getName(), is("Channel"));
    assertThat(result.get(1).getParameters().size(), is(6));
    assertThat(result.get(1).getParameters().get(0).getName(), is("BucketName"));
    assertThat(result.get(1).getParameters().get(1).getName(), is("ObjectName"));
    assertThat(result.get(1).getParameters().get(2).getName(), is("PartNumber"));
    assertThat(result.get(1).getParameters().get(3).getName(), is("UploadId"));
    assertThat(result.get(1).getParameters().get(4).getName(), is("Size"));
    assertThat(result.get(1).getParameters().get(5).getName(), is("Stream"));
}
Also used : Ds3DocSpecEmptyImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl) RequestConstructor(com.spectralogic.ds3autogen.java.models.RequestConstructor) Test(org.junit.Test)

Example 18 with Ds3DocSpecEmptyImpl

use of com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl in project ds3_autogen by SpectraLogic.

the class BaseRequestGenerator_Test method toConstructorList_Test.

@Test
public void toConstructorList_Test() {
    final ImmutableList<Ds3Param> params = createTestDs3ParamList();
    final Ds3Request request = createDs3RequestTestData(true, null, params);
    final ImmutableList<RequestConstructor> result = generator.toConstructorList(request, "", new Ds3DocSpecEmptyImpl());
    assertThat(result.size(), is(1));
    final RequestConstructor constructor = result.get(0);
    assertThat(constructor.getAdditionalLines().size(), is(0));
    assertThat(constructor.isDeprecated(), is(false));
    final ImmutableList<Arguments> constructorParams = constructor.getParameters();
    assertThat(constructorParams.size(), is(3));
    assertThat(constructorParams.get(0).getName(), is("MaxUploadSize"));
    assertThat(constructorParams.get(1).getName(), is("Name"));
    assertThat(constructorParams.get(2).getName(), is("Priority"));
    final ImmutableList<Arguments> constructorAssignments = constructor.getAssignments();
    assertThat(constructorAssignments.size(), is(3));
    assertThat(constructorAssignments.get(0).getName(), is("MaxUploadSize"));
    assertThat(constructorAssignments.get(1).getName(), is("Name"));
    assertThat(constructorAssignments.get(2).getName(), is("Priority"));
    final ImmutableList<QueryParam> queryParams = constructor.getQueryParams();
    assertThat(queryParams.size(), is(4));
    assertThat(queryParams.get(0).getName(), is("IgnoreNamingConflicts"));
    assertThat(queryParams.get(1).getName(), is("MaxUploadSize"));
    assertThat(queryParams.get(2).getName(), is("Name"));
    assertThat(queryParams.get(3).getName(), is("Priority"));
}
Also used : Ds3Param(com.spectralogic.ds3autogen.api.models.apispec.Ds3Param) QueryParam(com.spectralogic.ds3autogen.java.models.QueryParam) RequestGeneratorTestHelper.createSimpleTestDs3Request(com.spectralogic.ds3autogen.java.test.helpers.RequestGeneratorTestHelper.createSimpleTestDs3Request) Ds3ModelPartialDataFixture.createEmptyDs3Request(com.spectralogic.ds3autogen.testutil.Ds3ModelPartialDataFixture.createEmptyDs3Request) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Ds3DocSpecEmptyImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl) RequestConstructor(com.spectralogic.ds3autogen.java.models.RequestConstructor) Test(org.junit.Test)

Example 19 with Ds3DocSpecEmptyImpl

use of com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl in project ds3_autogen by SpectraLogic.

the class BulkRequestGenerator_Test method toWithConstructor_VoidParam_Test.

@Test
public void toWithConstructor_VoidParam_Test() {
    final String expectedResult = "    public GetJobsRequestHandler withFullDetails(final boolean fullDetails) {\n" + "        this.fullDetails = fullDetails;\n" + "        if (this.fullDetails) {\n" + "            this.getQueryParams().put(\"full_details\", null);\n" + "        } else {\n" + "            this.getQueryParams().remove(\"full_details\");\n" + "        }\n" + "        return this;\n" + "    }\n";
    final Arguments arg = new Arguments("void", "FullDetails");
    final String result = generator.toWithConstructor(arg, "GetJobsRequestHandler", new Ds3DocSpecEmptyImpl());
    assertThat(result, is(expectedResult));
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Ds3DocSpecEmptyImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl) Test(org.junit.Test)

Example 20 with Ds3DocSpecEmptyImpl

use of com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl in project ds3_autogen by SpectraLogic.

the class BulkRequestGenerator_Test method toWithConstructor_MaxUploadSizeParam_Test.

@Test
public void toWithConstructor_MaxUploadSizeParam_Test() {
    final String expectedResult = "    public CreatePutJobRequestHandler withMaxUploadSize(final long maxUploadSize) {\n" + "        if (maxUploadSize > MIN_UPLOAD_SIZE_IN_BYTES) {\n" + "            this.getQueryParams().put(\"max_upload_size\", Long.toString(maxUploadSize));\n" + "        } else {\n" + "            this.getQueryParams().put(\"max_upload_size\", MAX_UPLOAD_SIZE_IN_BYTES);\n" + "        }\n" + "        return this;\n" + "    }\n";
    final Arguments arg = new Arguments("long", "MaxUploadSize");
    final String result = generator.toWithConstructor(arg, "CreatePutJobRequestHandler", new Ds3DocSpecEmptyImpl());
    assertThat(result, is(expectedResult));
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Ds3DocSpecEmptyImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl) Test(org.junit.Test)

Aggregations

Ds3DocSpecEmptyImpl (com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl)83 Test (org.junit.Test)79 TestFileUtilsImpl (com.spectralogic.ds3autogen.utils.TestFileUtilsImpl)36 ByteArrayOutputStream (java.io.ByteArrayOutputStream)34 Ds3SpecParserImpl (com.spectralogic.ds3autogen.Ds3SpecParserImpl)26 Ds3ApiSpec (com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec)26 Arguments (com.spectralogic.ds3autogen.api.models.Arguments)25 Ds3SpecParser (com.spectralogic.ds3autogen.api.Ds3SpecParser)24 RequestConstructor (com.spectralogic.ds3autogen.java.models.RequestConstructor)18 Request (com.spectralogic.ds3autogen.c.models.Request)16 HashMap (java.util.HashMap)16 QueryParam (com.spectralogic.ds3autogen.java.models.QueryParam)14 Enum (com.spectralogic.ds3autogen.c.models.Enum)13 Ds3Request (com.spectralogic.ds3autogen.api.models.apispec.Ds3Request)10 Source (com.spectralogic.ds3autogen.c.models.Source)9 RequestGeneratorTestHelper.createSimpleTestDs3Request (com.spectralogic.ds3autogen.java.test.helpers.RequestGeneratorTestHelper.createSimpleTestDs3Request)6 Ds3Param (com.spectralogic.ds3autogen.api.models.apispec.Ds3Param)5 Ds3DocSpec (com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec)4 CodeGenerator (com.spectralogic.ds3autogen.api.CodeGenerator)3 JavaCodeGenerator (com.spectralogic.ds3autogen.java.JavaCodeGenerator)3