Search in sources :

Example 86 with Arguments

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

the class GeneratorUtils method getRequiredArgs.

/**
     * Retrieves a list of arguments from the Ds3Request, including converting the required
     * parameters to arguments, and retrieving the arguments from the request header info
     */
public static ImmutableList<Arguments> getRequiredArgs(final Ds3Request ds3Request) {
    final ImmutableList.Builder<Arguments> requiredArgs = ImmutableList.builder();
    requiredArgs.addAll(RequestConverterUtil.getRequiredArgsFromRequestHeader(ds3Request));
    requiredArgs.addAll(getArgsFromParamList(ds3Request.getRequiredQueryParams()));
    if (ds3Request.getIncludeInPath() && isResourceNotification(ds3Request.getResource())) {
        requiredArgs.add(new Arguments("Guid", "NotificationId"));
    }
    return requiredArgs.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) Arguments(com.spectralogic.ds3autogen.api.models.Arguments)

Example 87 with Arguments

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

the class BaseRequestGenerator method toConstructorList.

/**
     * Creates the request constructors. There will be multiple constructors if there are
     * constructor parameters of type Guid
     */
@Override
public ImmutableList<RequestConstructor> toConstructorList(final Ds3Request ds3Request, final String requestName, final Ds3DocSpec docSpec) {
    final ImmutableList<Arguments> constructorArgs = Helper.removeVoidArguments(toConstructorArgsList(ds3Request));
    final ImmutableList<Arguments> queryParams = toQueryParamsList(ds3Request);
    final RequestConstructor standardConstructor = new RequestConstructor(constructorArgs, queryParams, ds3Request.getOperation(), toConstructorDocs(requestName, constructorArgs.stream().map(Arguments::getName).collect(GuavaCollectors.immutableList()), docSpec, 2));
    return splitGuidConstructor(standardConstructor);
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) RequestConstructor(com.spectralogic.ds3autogen.net.model.request.RequestConstructor)

Example 88 with Arguments

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

the class WithConstructorUtil_Test method putQueryParamLine_IntArguments_Test.

@Test
public void putQueryParamLine_IntArguments_Test() {
    final String expected = "this.getQueryParams().put(\"arg_name\", Integer.toString(argName));";
    final String result = putQueryParamLine(new Arguments("int", "ArgName"));
    assertThat(result, is(expected));
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Test(org.junit.Test)

Example 89 with Arguments

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

the class WithConstructorUtil_Test method putQueryParamLine_ArgInput_Test.

@Test
public void putQueryParamLine_ArgInput_Test() {
    final Arguments delimiter = new Arguments("java.lang.String", "Delimiter");
    assertThat(putQueryParamLine(delimiter), is("this.getQueryParams().put(\"delimiter\", delimiter);"));
    final Arguments bucketId = new Arguments("java.lang.String", "BucketId");
    assertThat(putQueryParamLine(bucketId), is("this.getQueryParams().put(\"bucket_id\", bucketId);"));
    final Arguments bucketName = new Arguments("java.lang.String", "BucketName");
    assertThat(putQueryParamLine(bucketName), is("this.getQueryParams().put(\"bucket_id\", bucketName);"));
    final Arguments stringTest = new Arguments("java.lang.String", "StringTest");
    assertThat(putQueryParamLine(stringTest), is("this.getQueryParams().put(\"string_test\", UrlEscapers.urlFragmentEscaper().escape(stringTest).replace(\"+\", \"%2B\"));"));
    final Arguments intTest = new Arguments("int", "IntTest");
    assertThat(putQueryParamLine(intTest), is("this.getQueryParams().put(\"int_test\", Integer.toString(intTest));"));
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Test(org.junit.Test)

Example 90 with Arguments

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

the class WithConstructorUtil_Test method withConstructorFirstLine_Test.

@Test
public void withConstructorFirstLine_Test() {
    final String expected = "    public TestRequest withArgName(final ArgType argName) {\n";
    final String result = withConstructorFirstLine(new Arguments("ArgType", "ArgName"), "TestRequest");
    assertThat(result, is(expected));
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) 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