Search in sources :

Example 21 with Arguments

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

the class BaseRequestGenerator_Test method splitUuidOptionalArgument_UUID_Test.

@Test
public void splitUuidOptionalArgument_UUID_Test() {
    final ImmutableList<Arguments> result = splitUuidOptionalArgument(new Arguments("UUID", "Arg"));
    assertThat(result.size(), is(2));
    assertThat(result.get(0).getType(), is("UUID"));
    assertThat(result.get(1).getType(), is("String"));
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Test(org.junit.Test)

Example 22 with Arguments

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

the class BaseRequestGenerator_Test method convertUuidConstructorToStringConstructor_Test.

@Test
public void convertUuidConstructorToStringConstructor_Test() {
    final ImmutableList<Arguments> args = ImmutableList.of(new Arguments("String", "StringArg"), new Arguments("UUID", "UuidArg"), new Arguments("int", "IntArg"));
    final RequestConstructor constructor = new RequestConstructor(args, args, argsToQueryParams(args), "");
    final RequestConstructor result = convertUuidConstructorToStringConstructor(constructor);
    assertThat(getAllArgumentTypes(result.getParameters()), not(hasItem("UUID")));
    assertThat(getQueryParamTypes(result.getQueryParams()), not(hasItem("UUID")));
    assertThat(getAllArgumentTypes(result.getAssignments()), not(hasItem("UUID")));
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) RequestConstructor(com.spectralogic.ds3autogen.java.models.RequestConstructor) Test(org.junit.Test)

Example 23 with Arguments

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

the class BulkRequestGenerator_Test method toConstructorArgumentsList_Test.

@Test
public void toConstructorArgumentsList_Test() {
    final Ds3Request request = createSimpleTestDs3Request();
    final ImmutableList<Arguments> result = generator.toConstructorArgumentsList(request);
    assertThat(result.size(), is(6));
    assertThat(result.get(0).getName(), is("BucketName"));
    assertThat(result.get(1).getName(), is("ObjectName"));
    assertThat(result.get(2).getName(), is("JobId"));
    assertThat(result.get(3).getName(), is("Priority"));
    assertThat(result.get(4).getName(), is("NotificationEndPoint"));
    assertThat(result.get(5).getName(), is("Objects"));
    assertThat(result.get(5).getType(), is("Iterable<Ds3Object>"));
}
Also used : RequestGeneratorTestHelper.createSimpleTestDs3Request(com.spectralogic.ds3autogen.java.test.helpers.RequestGeneratorTestHelper.createSimpleTestDs3Request) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Test(org.junit.Test)

Example 24 with Arguments

use of com.spectralogic.ds3autogen.api.models.Arguments 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 25 with Arguments

use of com.spectralogic.ds3autogen.api.models.Arguments 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

Arguments (com.spectralogic.ds3autogen.api.models.Arguments)188 Test (org.junit.Test)144 FileUtils (com.spectralogic.ds3autogen.api.FileUtils)46 ImmutableList (com.google.common.collect.ImmutableList)40 RequestConstructor (com.spectralogic.ds3autogen.java.models.RequestConstructor)33 Ds3Request (com.spectralogic.ds3autogen.api.models.apispec.Ds3Request)25 Ds3DocSpecEmptyImpl (com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl)25 TestGeneratedCode (com.spectralogic.ds3autogen.java.utils.TestGeneratedCode)25 TestGenerateCode (com.spectralogic.ds3autogen.net.utils.TestGenerateCode)21 QueryParam (com.spectralogic.ds3autogen.java.models.QueryParam)19 Helper.removeVoidArguments (com.spectralogic.ds3autogen.utils.Helper.removeVoidArguments)15 BaseParseResponse (com.spectralogic.ds3autogen.java.models.parseresponse.BaseParseResponse)14 RequestGeneratorTestHelper.createSimpleTestDs3Request (com.spectralogic.ds3autogen.java.test.helpers.RequestGeneratorTestHelper.createSimpleTestDs3Request)13 Ds3Param (com.spectralogic.ds3autogen.api.models.apispec.Ds3Param)9 GuavaCollectors (com.spectralogic.ds3autogen.utils.collections.GuavaCollectors)8 CustomArgumentComparator (com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator)8 ConstructorParam (com.spectralogic.ds3autogen.python.model.request.ConstructorParam)7 Helper.camelToUnderscore (com.spectralogic.ds3autogen.utils.Helper.camelToUnderscore)7 RequestConverterUtil.getNonVoidArgsFromParamList (com.spectralogic.ds3autogen.utils.RequestConverterUtil.getNonVoidArgsFromParamList)6 Ds3ResponseType (com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType)5