Search in sources :

Example 21 with RequestConstructor

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

the class CreateObjectRequestGenerator_Test method createChannelConstructor_Test.

@Test
public void createChannelConstructor_Test() {
    final RequestConstructor result = getChannelConstructor(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(1));
    assertThat(result.getAdditionalLines().get(0), is("this.stream = new SeekableByteChannelInputStream(channel);"));
    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("Channel"));
    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("Channel"));
    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 22 with RequestConstructor

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

the class GetObjectRequestGenerator_Test method createOutputStreamConstructor_Test.

@Test
public void createOutputStreamConstructor_Test() {
    final RequestConstructor result = createOutputStreamConstructor(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(1));
    assertThat(result.getAdditionalLines().get(0), is("this.channel = Channels.newChannel(stream);"));
    final ImmutableList<Arguments> constructorParams = result.getParameters();
    assertThat(constructorParams.size(), is(3));
    assertThat(constructorParams.get(0).getName(), is("Arg1"));
    assertThat(constructorParams.get(1).getName(), is("Arg2"));
    assertThat(constructorParams.get(2).getName(), is("Stream"));
    final ImmutableList<Arguments> constructorAssignments = result.getAssignments();
    assertThat(constructorAssignments.size(), is(2));
    assertThat(constructorAssignments.get(0).getName(), is("Arg1"));
    assertThat(constructorAssignments.get(1).getName(), is("Arg2"));
    final ImmutableList<QueryParam> queryParams = result.getQueryParams();
    assertThat(queryParams.size(), is(2));
    assertThat(queryParams.get(0).getName(), is("Arg3"));
    assertThat(queryParams.get(1).getName(), is("Arg2"));
}
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 23 with RequestConstructor

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

the class BaseRequestGenerator_Test method splitUuidConstructor_NoUuid_Test.

@Test
public void splitUuidConstructor_NoUuid_Test() {
    final ImmutableList<Arguments> args = ImmutableList.of(new Arguments("String", "StringArg"), new Arguments("int", "IntArg"));
    final RequestConstructor constructor = new RequestConstructor(args, args, argsToQueryParams(args), "");
    final ImmutableList<RequestConstructor> result = splitUuidConstructor(constructor);
    assertThat(result.size(), is(1));
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) RequestConstructor(com.spectralogic.ds3autogen.java.models.RequestConstructor) Test(org.junit.Test)

Example 24 with RequestConstructor

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

the class BaseRequestGenerator_Test method splitAllUuidConstructors_Test.

@Test
public void splitAllUuidConstructors_Test() {
    final ImmutableList<Arguments> args = ImmutableList.of(new Arguments("String", "StringArg"), new Arguments("UUID", "UuidArg"), new Arguments("int", "IntArg"));
    final RequestConstructor constructor = new RequestConstructor(args, args, argsToQueryParams(args), "");
    final ImmutableList<RequestConstructor> result = splitAllUuidConstructors(ImmutableList.of(constructor));
    assertThat(result.size(), is(2));
    assertThat(getAllArgumentTypes(result.get(0).getParameters()), hasItem("UUID"));
    assertThat(getQueryParamTypes(result.get(0).getQueryParams()), hasItem("UUID"));
    assertThat(getAllArgumentTypes(result.get(0).getAssignments()), hasItem("UUID"));
    assertThat(getAllArgumentTypes(result.get(1).getParameters()), not(hasItem("UUID")));
    assertThat(getQueryParamTypes(result.get(1).getQueryParams()), not(hasItem("UUID")));
    assertThat(getAllArgumentTypes(result.get(1).getAssignments()), not(hasItem("UUID")));
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) RequestConstructor(com.spectralogic.ds3autogen.java.models.RequestConstructor) Test(org.junit.Test)

Example 25 with RequestConstructor

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

the class NotificationRequestGenerator_Test method toConstructorList_Test.

@Test
public void toConstructorList_Test() {
    final Ds3Request request = getRequestDeleteNotification();
    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(1));
    assertThat(constructorParams.get(0).getName(), is("NotificationId"));
    assertThat(constructor.getAssignments().size(), is(0));
    assertThat(constructor.getQueryParams().size(), is(0));
}
Also used : Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) RequestGeneratorTestHelper.createSimpleTestDs3Request(com.spectralogic.ds3autogen.java.test.helpers.RequestGeneratorTestHelper.createSimpleTestDs3Request) 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

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