Search in sources :

Example 21 with QueryParam

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

the class BaseRequestGenerator_Test method modifyQueryParamType_FullList_Test.

@Test
public void modifyQueryParamType_FullList_Test() {
    final ImmutableList<QueryParam> params = ImmutableList.of(new QueryParam("CurType", "Name"));
    final ImmutableList<QueryParam> result = modifyQueryParamType(params, "CurType", "NewType");
    assertThat(result.size(), is(1));
    assertThat(result.get(0).getName(), is("Name"));
    assertThat(result.get(0).getType(), is("NewType"));
}
Also used : QueryParam(com.spectralogic.ds3autogen.java.models.QueryParam) Test(org.junit.Test)

Example 22 with QueryParam

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

the class CreateObjectRequestGenerator method toConstructorList.

/**
     * Gets the list of constructor models from a Ds3Request. This includes the
     * Create Object deprecated constructor, a constructor that uses the parameter
     * Channel, and a constructor that has an InputStream parameter
     */
@Override
public ImmutableList<RequestConstructor> toConstructorList(final Ds3Request ds3Request, final String requestName, final Ds3DocSpec docSpec) {
    final ImmutableList<Arguments> constructorArgs = toConstructorArgumentsList(ds3Request);
    final ImmutableList<Arguments> optionalArgs = toArgumentsList(ds3Request.getOptionalQueryParams());
    final ImmutableList<QueryParam> queryParams = toQueryParamsList(ds3Request);
    final RequestConstructor depreciatedConstructor = createDeprecatedConstructor(constructorArgs, requestName, docSpec);
    final RequestConstructor channelConstructor = getChannelConstructor(constructorArgs, optionalArgs, queryParams, requestName, docSpec);
    final RequestConstructor inputStreamConstructor = getInputStreamConstructor(constructorArgs, optionalArgs, queryParams, requestName, docSpec);
    return ImmutableList.of(depreciatedConstructor, channelConstructor, inputStreamConstructor);
}
Also used : QueryParam(com.spectralogic.ds3autogen.java.models.QueryParam) Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Helper.removeVoidArguments(com.spectralogic.ds3autogen.utils.Helper.removeVoidArguments) RequestConstructor(com.spectralogic.ds3autogen.java.models.RequestConstructor)

Example 23 with QueryParam

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

the class GetObjectRequestGenerator method createOutputStreamConstructor.

/**
     * Creates the constructor for the get object request that uses OutputStream
     */
protected static RequestConstructor createOutputStreamConstructor(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("OutputStream", "Stream"));
    final ImmutableList.Builder<QueryParam> queryParamsBuilder = ImmutableList.builder();
    queryParamsBuilder.addAll(queryParams);
    queryParamsBuilder.addAll(argsToQueryParams(optionalArgs));
    final ImmutableList.Builder<Arguments> assignmentsBuilder = ImmutableList.builder();
    assignmentsBuilder.addAll(constructorArgs);
    assignmentsBuilder.addAll(optionalArgs);
    final ImmutableList<Arguments> updatedConstructorArgs = constructorArgBuilder.build();
    final ImmutableList<String> argNames = updatedConstructorArgs.stream().map(Arguments::getName).collect(GuavaCollectors.immutableList());
    final ImmutableList<String> additionalLines = ImmutableList.of("this.channel = Channels.newChannel(stream);");
    return new RequestConstructor(false, additionalLines, updatedConstructorArgs, assignmentsBuilder.build(), 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)

Aggregations

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