Search in sources :

Example 46 with Arguments

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

the class BaseRequestGenerator_Test method toWithConstructorList_Test.

@Test
public void toWithConstructorList_Test() {
    final String expected = "    public TestRequest withArgOne(final TypeOne argOne) {\n" + "        this.argOne = argOne;\n" + "        this.updateQueryParam(\"arg_one\", argOne);\n" + "        return this;\n" + "    }\n";
    final String voidExpected = "    public TestRequest withVoidArg(final boolean voidArg) {\n" + "        this.voidArg = voidArg;\n" + "        if (this.voidArg) {\n" + "            this.getQueryParams().put(\"void_arg\", null);\n" + "        } else {\n" + "            this.getQueryParams().remove(\"void_arg\");\n" + "        }\n" + "        return this;\n" + "    }\n";
    final ImmutableList<Arguments> optionalParams = ImmutableList.of(new Arguments("TypeOne", "ArgOne"), new Arguments("void", "VoidArg"));
    final ImmutableList<String> result = generator.toWithConstructorList(optionalParams, "TestRequest", new Ds3DocSpecEmptyImpl());
    assertThat(result.size(), is(2));
    assertThat(result.get(0), is(expected));
    assertThat(result.get(1), is(voidExpected));
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Ds3DocSpecEmptyImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl) Test(org.junit.Test)

Example 47 with Arguments

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

the class BaseRequestGenerator_Test method splitAllUuidOptionalArguments_FullList_Test.

@Test
public void splitAllUuidOptionalArguments_FullList_Test() {
    final ImmutableList<Arguments> variables = ImmutableList.of(new Arguments("UUID", "Var1"), new Arguments("Integer", "Var2"));
    final ImmutableList<Arguments> result = splitAllUuidOptionalArguments(variables);
    assertThat(result.size(), is(3));
    assertThat(result.get(0).getName(), is("Var1"));
    assertThat(result.get(0).getType(), is("UUID"));
    assertThat(result.get(1).getName(), is("Var1"));
    assertThat(result.get(1).getType(), is("String"));
    assertThat(result.get(2).getName(), is("Var2"));
    assertThat(result.get(2).getType(), is("Integer"));
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Test(org.junit.Test)

Example 48 with Arguments

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

the class CreateObjectRequestGenerator_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("Size"));
    assertThat(result.get(5).getType(), is("long"));
}
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 49 with Arguments

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

the class CreateObjectRequestGenerator_Test method createInputStreamConstructor_Test.

@Test
public void createInputStreamConstructor_Test() {
    final RequestConstructor result = getInputStreamConstructor(ImmutableList.of(new Arguments("Type", "Arg1")), ImmutableList.of(new Arguments("Type", "Arg2")), ImmutableList.of(new QueryParam("Type", "Arg3")), "", new Ds3DocSpecEmptyImpl());
    assertThat(result.isDeprecated(), is(false));
    assertThat(result.getAdditionalLines().size(), is(0));
    final ImmutableList<Arguments> params = result.getParameters();
    assertThat(params.size(), is(3));
    assertThat(params.get(0).getName(), is("Arg1"));
    assertThat(params.get(1).getName(), is("Arg2"));
    assertThat(params.get(2).getName(), is("Stream"));
    final ImmutableList<Arguments> assignments = result.getAssignments();
    assertThat(assignments.size(), is(3));
    assertThat(assignments.get(0).getName(), is("Arg1"));
    assertThat(assignments.get(1).getName(), is("Arg2"));
    assertThat(assignments.get(2).getName(), is("Stream"));
    final ImmutableList<QueryParam> queryParams = result.getQueryParams();
    assertThat(queryParams.size(), is(1));
    assertThat(queryParams.get(0).getName(), is("Arg3"));
}
Also used : QueryParam(com.spectralogic.ds3autogen.java.models.QueryParam) 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 50 with Arguments

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

the class CreateObjectRequestGenerator_Test method toConstructorList_Test.

@Test
public void toConstructorList_Test() {
    final Ds3Request request = getRequestCreateObject();
    final ImmutableList<RequestConstructor> result = generator.toConstructorList(request, "", new Ds3DocSpecEmptyImpl());
    assertThat(result.size(), is(3));
    //Deprecated Constructor
    final RequestConstructor constructor1 = result.get(0);
    assertThat(constructor1.isDeprecated(), is(true));
    assertThat(constructor1.getAdditionalLines().size(), is(1));
    assertThat(constructor1.getAdditionalLines().get(0), is("this.stream = new SeekableByteChannelInputStream(channel);"));
    final ImmutableList<Arguments> constructorParams1 = constructor1.getParameters();
    assertThat(constructorParams1.size(), is(4));
    assertThat(constructorParams1.get(0).getName(), is("BucketName"));
    assertThat(constructorParams1.get(1).getName(), is("ObjectName"));
    assertThat(constructorParams1.get(2).getName(), is("Size"));
    assertThat(constructorParams1.get(3).getName(), is("Channel"));
    final ImmutableList<Arguments> constructorAssignments1 = constructor1.getAssignments();
    assertThat(constructorAssignments1.size(), is(4));
    assertThat(constructorAssignments1.get(0).getName(), is("BucketName"));
    assertThat(constructorAssignments1.get(1).getName(), is("ObjectName"));
    assertThat(constructorAssignments1.get(2).getName(), is("Size"));
    assertThat(constructorAssignments1.get(3).getName(), is("Channel"));
    final ImmutableList<QueryParam> queryParams1 = constructor1.getQueryParams();
    assertThat(queryParams1.size(), is(0));
    //Channel Constructor
    final RequestConstructor constructor2 = result.get(1);
    assertThat(constructor2.isDeprecated(), is(false));
    assertThat(constructor2.getAdditionalLines().size(), is(1));
    assertThat(constructor2.getAdditionalLines().get(0), is("this.stream = new SeekableByteChannelInputStream(channel);"));
    final ImmutableList<Arguments> constructorParams2 = constructor2.getParameters();
    assertThat(constructorParams2.size(), is(6));
    assertThat(constructorParams2.get(0).getName(), is("BucketName"));
    assertThat(constructorParams2.get(1).getName(), is("ObjectName"));
    assertThat(constructorParams2.get(2).getName(), is("Size"));
    assertThat(constructorParams2.get(3).getName(), is("Job"));
    assertThat(constructorParams2.get(4).getName(), is("Offset"));
    assertThat(constructorParams2.get(5).getName(), is("Channel"));
    final ImmutableList<Arguments> constructorAssignments2 = constructor2.getAssignments();
    assertThat(constructorAssignments2.size(), is(6));
    assertThat(constructorAssignments2.get(0).getName(), is("BucketName"));
    assertThat(constructorAssignments2.get(1).getName(), is("ObjectName"));
    assertThat(constructorAssignments2.get(2).getName(), is("Size"));
    assertThat(constructorAssignments2.get(3).getName(), is("Job"));
    assertThat(constructorAssignments2.get(4).getName(), is("Offset"));
    assertThat(constructorAssignments2.get(5).getName(), is("Channel"));
    final ImmutableList<QueryParam> queryParams2 = constructor2.getQueryParams();
    assertThat(queryParams2.size(), is(2));
    assertThat(queryParams2.get(0).getName(), is("Job"));
    assertThat(queryParams2.get(1).getName(), is("Offset"));
    //Stream Constructor
    final RequestConstructor constructor3 = result.get(2);
    assertThat(constructor3.isDeprecated(), is(false));
    assertThat(constructor3.getAdditionalLines().size(), is(0));
    final ImmutableList<Arguments> constructorParams3 = constructor3.getParameters();
    assertThat(constructorParams3.size(), is(6));
    assertThat(constructorParams3.get(0).getName(), is("BucketName"));
    assertThat(constructorParams3.get(1).getName(), is("ObjectName"));
    assertThat(constructorParams3.get(2).getName(), is("Size"));
    assertThat(constructorParams3.get(3).getName(), is("Job"));
    assertThat(constructorParams3.get(4).getName(), is("Offset"));
    assertThat(constructorParams3.get(5).getName(), is("Stream"));
    final ImmutableList<Arguments> constructorAssignments3 = constructor3.getAssignments();
    assertThat(constructorAssignments3.size(), is(6));
    assertThat(constructorAssignments3.get(0).getName(), is("BucketName"));
    assertThat(constructorAssignments3.get(1).getName(), is("ObjectName"));
    assertThat(constructorAssignments3.get(2).getName(), is("Size"));
    assertThat(constructorAssignments3.get(3).getName(), is("Job"));
    assertThat(constructorAssignments3.get(4).getName(), is("Offset"));
    assertThat(constructorAssignments3.get(5).getName(), is("Stream"));
    final ImmutableList<QueryParam> queryParams3 = constructor3.getQueryParams();
    assertThat(queryParams3.size(), is(2));
    assertThat(queryParams3.get(0).getName(), is("Job"));
    assertThat(queryParams3.get(1).getName(), is("Offset"));
}
Also used : QueryParam(com.spectralogic.ds3autogen.java.models.QueryParam) 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) Ds3DocSpecEmptyImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl) RequestConstructor(com.spectralogic.ds3autogen.java.models.RequestConstructor) 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