Search in sources :

Example 6 with Ds3Request

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

the class JavaCodeGenerator method generateAllRequests.

/**
     * Generates the Request Handler, Response Handler, and Response Parser
     * for all specified requests
     * @throws IOException
     * @throws TemplateException
     */
private void generateAllRequests(final ImmutableList<Ds3Request> requests, final Ds3DocSpec docSpec) throws IOException, TemplateException {
    if (isEmpty(requests)) {
        LOG.info("There were no requests to generate");
        return;
    }
    for (final Ds3Request request : requests) {
        generateRequest(request, docSpec);
        generateResponse(request);
        generateResponseParser(request);
    }
}
Also used : Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request)

Example 7 with Ds3Request

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

the class BaseRequestGenerator method generate.

@Override
public Request generate(final Ds3Request ds3Request, final String packageName, final Ds3DocSpec docSpec) {
    final Ds3Request updatedRequest = updateDs3RequestParamTypes(ds3Request);
    final String requestName = removePath(updatedRequest.getName());
    final String requestPath = getRequestPath(updatedRequest);
    final String parentClass = getParentClass(ds3Request);
    final ImmutableList<Arguments> optionalArguments = splitAllUuidOptionalArguments(toOptionalArgumentsList(updatedRequest.getOptionalQueryParams()));
    final ImmutableList<RequestConstructor> constructors = splitAllUuidConstructors(toConstructorList(updatedRequest, requestName, docSpec));
    final ImmutableList<Variable> classVariableArguments = convertAllUuidClassVariables(toClassVariableArguments(updatedRequest));
    final ImmutableList<String> imports = getAllImports(updatedRequest, packageName);
    final ImmutableList<String> withConstructors = toWithConstructorList(optionalArguments, requestName, docSpec);
    return new Request(packageName, requestName, parentClass, updatedRequest.getHttpVerb(), requestPath, updatedRequest.getOperation(), updatedRequest.getAction(), optionalArguments, constructors, classVariableArguments, imports, withConstructors);
}
Also used : Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Helper.removeVoidArguments(com.spectralogic.ds3autogen.utils.Helper.removeVoidArguments) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) Ds3RequestClassificationUtil.isNotificationRequest(com.spectralogic.ds3autogen.utils.Ds3RequestClassificationUtil.isNotificationRequest) Ds3RequestClassificationUtil.supportsPaginationRequest(com.spectralogic.ds3autogen.utils.Ds3RequestClassificationUtil.supportsPaginationRequest)

Example 8 with Ds3Request

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

the class BaseRequestGenerator_Test method updateDs3RequestParamTypes_Test.

@Test
public void updateDs3RequestParamTypes_Test() {
    final ImmutableList<Ds3Param> params = ImmutableList.of(new Ds3Param("Arg1", "String", false), new Ds3Param("Arg2", "java.util.UUID", false), new Ds3Param("BucketId", "java.util.UUID", false));
    final Ds3Request request = createDs3RequestTestData(false, params, params);
    final Ds3Request result = updateDs3RequestParamTypes(request);
    final ImmutableList<Ds3Param> requiredParams = result.getRequiredQueryParams();
    assertThat(requiredParams.size(), is(3));
    assertThat(requiredParams.get(0).getName(), is("Arg1"));
    assertThat(requiredParams.get(0).getType(), is("String"));
    assertThat(requiredParams.get(1).getName(), is("Arg2"));
    assertThat(requiredParams.get(1).getType(), is("java.util.UUID"));
    assertThat(requiredParams.get(2).getName(), is("BucketId"));
    assertThat(requiredParams.get(2).getType(), is("String"));
    final ImmutableList<Ds3Param> optionalParams = result.getOptionalQueryParams();
    assertThat(optionalParams.size(), is(3));
    assertThat(optionalParams.get(0).getName(), is("Arg1"));
    assertThat(optionalParams.get(0).getType(), is("String"));
    assertThat(optionalParams.get(1).getName(), is("Arg2"));
    assertThat(optionalParams.get(1).getType(), is("java.util.UUID"));
    assertThat(optionalParams.get(2).getName(), is("BucketId"));
    assertThat(optionalParams.get(2).getType(), is("String"));
}
Also used : Ds3Param(com.spectralogic.ds3autogen.api.models.apispec.Ds3Param) RequestGeneratorTestHelper.createSimpleTestDs3Request(com.spectralogic.ds3autogen.java.test.helpers.RequestGeneratorTestHelper.createSimpleTestDs3Request) Ds3ModelPartialDataFixture.createEmptyDs3Request(com.spectralogic.ds3autogen.testutil.Ds3ModelPartialDataFixture.createEmptyDs3Request) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) Test(org.junit.Test)

Example 9 with Ds3Request

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

the class CreateObjectRequestGenerator_Test method toConstructorArgumentsList_Test.

@Test
public void toConstructorArgumentsList_Test() {
    final Ds3Request request = createSimpleTestDs3Request();
    final ImmutableList<Arguments> result = generator.toConstructorArgumentsList(request);
    assertThat(result.size(), is(6));
    assertThat(result.get(0).getName(), is("BucketName"));
    assertThat(result.get(1).getName(), is("ObjectName"));
    assertThat(result.get(2).getName(), is("JobId"));
    assertThat(result.get(3).getName(), is("Priority"));
    assertThat(result.get(4).getName(), is("NotificationEndPoint"));
    assertThat(result.get(5).getName(), is("Size"));
    assertThat(result.get(5).getType(), is("long"));
}
Also used : 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) Test(org.junit.Test)

Example 10 with Ds3Request

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

the class CreateObjectRequestGenerator_Test method toConstructorList_Test.

@Test
public void toConstructorList_Test() {
    final Ds3Request request = getRequestCreateObject();
    final ImmutableList<RequestConstructor> result = generator.toConstructorList(request, "", new Ds3DocSpecEmptyImpl());
    assertThat(result.size(), is(3));
    //Deprecated Constructor
    final RequestConstructor constructor1 = result.get(0);
    assertThat(constructor1.isDeprecated(), is(true));
    assertThat(constructor1.getAdditionalLines().size(), is(1));
    assertThat(constructor1.getAdditionalLines().get(0), is("this.stream = new SeekableByteChannelInputStream(channel);"));
    final ImmutableList<Arguments> constructorParams1 = constructor1.getParameters();
    assertThat(constructorParams1.size(), is(4));
    assertThat(constructorParams1.get(0).getName(), is("BucketName"));
    assertThat(constructorParams1.get(1).getName(), is("ObjectName"));
    assertThat(constructorParams1.get(2).getName(), is("Size"));
    assertThat(constructorParams1.get(3).getName(), is("Channel"));
    final ImmutableList<Arguments> constructorAssignments1 = constructor1.getAssignments();
    assertThat(constructorAssignments1.size(), is(4));
    assertThat(constructorAssignments1.get(0).getName(), is("BucketName"));
    assertThat(constructorAssignments1.get(1).getName(), is("ObjectName"));
    assertThat(constructorAssignments1.get(2).getName(), is("Size"));
    assertThat(constructorAssignments1.get(3).getName(), is("Channel"));
    final ImmutableList<QueryParam> queryParams1 = constructor1.getQueryParams();
    assertThat(queryParams1.size(), is(0));
    //Channel Constructor
    final RequestConstructor constructor2 = result.get(1);
    assertThat(constructor2.isDeprecated(), is(false));
    assertThat(constructor2.getAdditionalLines().size(), is(1));
    assertThat(constructor2.getAdditionalLines().get(0), is("this.stream = new SeekableByteChannelInputStream(channel);"));
    final ImmutableList<Arguments> constructorParams2 = constructor2.getParameters();
    assertThat(constructorParams2.size(), is(6));
    assertThat(constructorParams2.get(0).getName(), is("BucketName"));
    assertThat(constructorParams2.get(1).getName(), is("ObjectName"));
    assertThat(constructorParams2.get(2).getName(), is("Size"));
    assertThat(constructorParams2.get(3).getName(), is("Job"));
    assertThat(constructorParams2.get(4).getName(), is("Offset"));
    assertThat(constructorParams2.get(5).getName(), is("Channel"));
    final ImmutableList<Arguments> constructorAssignments2 = constructor2.getAssignments();
    assertThat(constructorAssignments2.size(), is(6));
    assertThat(constructorAssignments2.get(0).getName(), is("BucketName"));
    assertThat(constructorAssignments2.get(1).getName(), is("ObjectName"));
    assertThat(constructorAssignments2.get(2).getName(), is("Size"));
    assertThat(constructorAssignments2.get(3).getName(), is("Job"));
    assertThat(constructorAssignments2.get(4).getName(), is("Offset"));
    assertThat(constructorAssignments2.get(5).getName(), is("Channel"));
    final ImmutableList<QueryParam> queryParams2 = constructor2.getQueryParams();
    assertThat(queryParams2.size(), is(2));
    assertThat(queryParams2.get(0).getName(), is("Job"));
    assertThat(queryParams2.get(1).getName(), is("Offset"));
    //Stream Constructor
    final RequestConstructor constructor3 = result.get(2);
    assertThat(constructor3.isDeprecated(), is(false));
    assertThat(constructor3.getAdditionalLines().size(), is(0));
    final ImmutableList<Arguments> constructorParams3 = constructor3.getParameters();
    assertThat(constructorParams3.size(), is(6));
    assertThat(constructorParams3.get(0).getName(), is("BucketName"));
    assertThat(constructorParams3.get(1).getName(), is("ObjectName"));
    assertThat(constructorParams3.get(2).getName(), is("Size"));
    assertThat(constructorParams3.get(3).getName(), is("Job"));
    assertThat(constructorParams3.get(4).getName(), is("Offset"));
    assertThat(constructorParams3.get(5).getName(), is("Stream"));
    final ImmutableList<Arguments> constructorAssignments3 = constructor3.getAssignments();
    assertThat(constructorAssignments3.size(), is(6));
    assertThat(constructorAssignments3.get(0).getName(), is("BucketName"));
    assertThat(constructorAssignments3.get(1).getName(), is("ObjectName"));
    assertThat(constructorAssignments3.get(2).getName(), is("Size"));
    assertThat(constructorAssignments3.get(3).getName(), is("Job"));
    assertThat(constructorAssignments3.get(4).getName(), is("Offset"));
    assertThat(constructorAssignments3.get(5).getName(), is("Stream"));
    final ImmutableList<QueryParam> queryParams3 = constructor3.getQueryParams();
    assertThat(queryParams3.size(), is(2));
    assertThat(queryParams3.get(0).getName(), is("Job"));
    assertThat(queryParams3.get(1).getName(), is("Offset"));
}
Also used : QueryParam(com.spectralogic.ds3autogen.java.models.QueryParam) 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)

Aggregations

Ds3Request (com.spectralogic.ds3autogen.api.models.apispec.Ds3Request)92 Test (org.junit.Test)76 RequestGeneratorTestHelper.createSimpleTestDs3Request (com.spectralogic.ds3autogen.java.test.helpers.RequestGeneratorTestHelper.createSimpleTestDs3Request)37 Arguments (com.spectralogic.ds3autogen.api.models.Arguments)24 Ds3ModelPartialDataFixture.createEmptyDs3Request (com.spectralogic.ds3autogen.testutil.Ds3ModelPartialDataFixture.createEmptyDs3Request)17 ImmutableList (com.google.common.collect.ImmutableList)11 Ds3Param (com.spectralogic.ds3autogen.api.models.apispec.Ds3Param)11 Ds3DocSpecEmptyImpl (com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl)9 QueryParam (com.spectralogic.ds3autogen.java.models.QueryParam)9 GuavaCollectors (com.spectralogic.ds3autogen.utils.collections.GuavaCollectors)8 RequestConstructor (com.spectralogic.ds3autogen.java.models.RequestConstructor)7 ConstructorParam (com.spectralogic.ds3autogen.python.model.request.ConstructorParam)7 Helper.camelToUnderscore (com.spectralogic.ds3autogen.utils.Helper.camelToUnderscore)7 CustomArgumentComparator (com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator)7 RequestConverterUtil.getNonVoidArgsFromParamList (com.spectralogic.ds3autogen.utils.RequestConverterUtil.getNonVoidArgsFromParamList)6 Ds3ApiSpec (com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec)5 PythonHelper.pythonIndent (com.spectralogic.ds3autogen.python.helpers.PythonHelper.pythonIndent)5 Variable (com.spectralogic.ds3autogen.java.models.Variable)3 Ds3RequestClassificationUtil (com.spectralogic.ds3autogen.utils.Ds3RequestClassificationUtil)3 OutputStream (java.io.OutputStream)3