Search in sources :

Example 11 with RequestConstructor

use of com.spectralogic.ds3autogen.java.models.RequestConstructor in project ds3_autogen by SpectraLogic.

the class CreateNotificationRequestGenerator_Test method toConstructorList_Test.

@Test
public void toConstructorList_Test() {
    final ImmutableList.Builder<Ds3Param> builder = ImmutableList.builder();
    builder.addAll(createTestDs3ParamList());
    builder.add(new Ds3Param("NotificationEndPoint", "String", false));
    final Ds3Request request = createDs3RequestTestData(true, null, builder.build());
    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(4));
    assertThat(constructorParams.get(0).getName(), is("MaxUploadSize"));
    assertThat(constructorParams.get(1).getName(), is("Name"));
    assertThat(constructorParams.get(2).getName(), is("Priority"));
    assertThat(constructorParams.get(3).getName(), is("NotificationEndPoint"));
    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) ImmutableList(com.google.common.collect.ImmutableList) 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)

Example 12 with RequestConstructor

use of com.spectralogic.ds3autogen.java.models.RequestConstructor in project ds3_autogen by SpectraLogic.

the class MultiFileDeleteRequestGenerator method createIterableConstructor.

/**
     * Creates the Multi File Delete constructor that uses Iterables
     */
protected static RequestConstructor createIterableConstructor(final ImmutableList<Arguments> constructorArgs, final ImmutableList<QueryParam> queryParams, final String requestName, final Ds3DocSpec docSpec) {
    final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();
    if (hasContent(constructorArgs)) {
        constructorArgs.stream().filter(arg -> !arg.getName().equalsIgnoreCase("Delete")).forEach(builder::add);
    }
    builder.add(new Arguments("Iterable<Contents>", "Objs"));
    final ImmutableList<String> additionalLines = ImmutableList.of("this.objects = contentsToString(objs);");
    final ImmutableList<String> argNames = builder.build().stream().map(Arguments::getName).collect(GuavaCollectors.immutableList());
    return new RequestConstructor(false, additionalLines, builder.build(), constructorArgs, queryParams, toConstructorDocs(requestName, argNames, docSpec, 1));
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) GuavaCollectors(com.spectralogic.ds3autogen.utils.collections.GuavaCollectors) ImmutableList(com.google.common.collect.ImmutableList) JavaDocGenerator.toConstructorDocs(com.spectralogic.ds3autogen.java.utils.JavaDocGenerator.toConstructorDocs) Ds3DocSpec(com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec) QueryParam(com.spectralogic.ds3autogen.java.models.QueryParam) RequestConstructor(com.spectralogic.ds3autogen.java.models.RequestConstructor) ConverterUtil.hasContent(com.spectralogic.ds3autogen.utils.ConverterUtil.hasContent) ImmutableList(com.google.common.collect.ImmutableList) Arguments(com.spectralogic.ds3autogen.api.models.Arguments) RequestConstructor(com.spectralogic.ds3autogen.java.models.RequestConstructor)

Example 13 with RequestConstructor

use of com.spectralogic.ds3autogen.java.models.RequestConstructor in project ds3_autogen by SpectraLogic.

the class CreateObjectRequestGenerator method createDeprecatedConstructor.

/**
     * Creates the create deprecated object request constructor that
     * uses the Channel parameter
     */
protected static RequestConstructor createDeprecatedConstructor(final ImmutableList<Arguments> constructorArgs, final String requestName, final Ds3DocSpec docSpec) {
    final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();
    builder.addAll(constructorArgs);
    builder.add(new Arguments("SeekableByteChannel", "Channel"));
    final ImmutableList<String> additionalLines = ImmutableList.of("this.stream = new SeekableByteChannelInputStream(channel);");
    final ImmutableList<Arguments> updatedArgs = builder.build();
    final ImmutableList<String> argNames = updatedArgs.stream().map(Arguments::getName).collect(GuavaCollectors.immutableList());
    return new RequestConstructor(true, additionalLines, updatedArgs, updatedArgs, ImmutableList.of(), toConstructorDocs(requestName, argNames, docSpec, 1));
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Helper.removeVoidArguments(com.spectralogic.ds3autogen.utils.Helper.removeVoidArguments) RequestConstructor(com.spectralogic.ds3autogen.java.models.RequestConstructor)

Example 14 with RequestConstructor

use of com.spectralogic.ds3autogen.java.models.RequestConstructor in project ds3_autogen by SpectraLogic.

the class GetObjectRequestGenerator method createChannelConstructor.

/**
     * Creates the constructor for the get object request that uses WritableByteChannel
     */
protected static RequestConstructor createChannelConstructor(final ImmutableList<Arguments> constructorArgs, final ImmutableList<Arguments> optionalArgs, final ImmutableList<QueryParam> queryParams, final String requestName, final Ds3DocSpec docSpec) {
    final ImmutableList.Builder<Arguments> constructorArgBuilder = ImmutableList.builder();
    constructorArgBuilder.addAll(constructorArgs);
    constructorArgBuilder.addAll(optionalArgs);
    constructorArgBuilder.add(new Arguments("WritableByteChannel", "Channel"));
    final ImmutableList.Builder<QueryParam> queryParamsBuilder = ImmutableList.builder();
    queryParamsBuilder.addAll(queryParams);
    queryParamsBuilder.addAll(argsToQueryParams(optionalArgs));
    final ImmutableList<Arguments> updatedConstructorArgs = constructorArgBuilder.build();
    final ImmutableList<String> argNames = updatedConstructorArgs.stream().map(Arguments::getName).collect(GuavaCollectors.immutableList());
    return new RequestConstructor(updatedConstructorArgs, updatedConstructorArgs, queryParamsBuilder.build(), toConstructorDocs(requestName, argNames, docSpec, 1));
}
Also used : QueryParam(com.spectralogic.ds3autogen.java.models.QueryParam) ImmutableList(com.google.common.collect.ImmutableList) Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Helper.removeVoidArguments(com.spectralogic.ds3autogen.utils.Helper.removeVoidArguments) RequestConstructor(com.spectralogic.ds3autogen.java.models.RequestConstructor)

Example 15 with RequestConstructor

use of com.spectralogic.ds3autogen.java.models.RequestConstructor in project ds3_autogen by SpectraLogic.

the class CommonRequestGeneratorUtils method createInputStreamConstructor.

/**
     * Creates a constructor with the provided parameters in addition to
     * adding the required parameter Stream for parsing a request payload.
     */
public static RequestConstructor createInputStreamConstructor(final ImmutableList<Arguments> parameters, final ImmutableList<QueryParam> queryParams, final String requestName, final Ds3DocSpec docSpec) {
    final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();
    if (hasContent(parameters)) {
        builder.addAll(parameters);
    }
    builder.add(new Arguments("InputStream", "Stream"));
    final ImmutableList<Arguments> updatedParameters = builder.build();
    final ImmutableList<String> argNames = updatedParameters.stream().map(Arguments::getName).collect(GuavaCollectors.immutableList());
    return new RequestConstructor(updatedParameters, updatedParameters, queryParams, toConstructorDocs(requestName, argNames, docSpec, 1));
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) Arguments(com.spectralogic.ds3autogen.api.models.Arguments) RequestConstructor(com.spectralogic.ds3autogen.java.models.RequestConstructor)

Aggregations

RequestConstructor (com.spectralogic.ds3autogen.java.models.RequestConstructor)34 Arguments (com.spectralogic.ds3autogen.api.models.Arguments)33 Test (org.junit.Test)22 Ds3DocSpecEmptyImpl (com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl)18 QueryParam (com.spectralogic.ds3autogen.java.models.QueryParam)18 ImmutableList (com.google.common.collect.ImmutableList)10 Ds3Request (com.spectralogic.ds3autogen.api.models.apispec.Ds3Request)8 RequestGeneratorTestHelper.createSimpleTestDs3Request (com.spectralogic.ds3autogen.java.test.helpers.RequestGeneratorTestHelper.createSimpleTestDs3Request)6 Helper.removeVoidArguments (com.spectralogic.ds3autogen.utils.Helper.removeVoidArguments)5 Ds3Param (com.spectralogic.ds3autogen.api.models.apispec.Ds3Param)3 Ds3DocSpec (com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec)1 JavaDocGenerator.toConstructorDocs (com.spectralogic.ds3autogen.java.utils.JavaDocGenerator.toConstructorDocs)1 Ds3ModelPartialDataFixture.createEmptyDs3Request (com.spectralogic.ds3autogen.testutil.Ds3ModelPartialDataFixture.createEmptyDs3Request)1 ConverterUtil.hasContent (com.spectralogic.ds3autogen.utils.ConverterUtil.hasContent)1 GuavaCollectors (com.spectralogic.ds3autogen.utils.collections.GuavaCollectors)1