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"));
}
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));
}
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));
}
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));
}
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));
}
Aggregations