Search in sources :

Example 1 with BaseRequest

use of com.spectralogic.ds3autogen.python.model.request.BaseRequest in project ds3_autogen by SpectraLogic.

the class PythonCodeGenerator_Test method toRequestModelList_NullList_Test.

@Test
public void toRequestModelList_NullList_Test() {
    final ImmutableList<BaseRequest> result = generator.toRequestModelList(null, new Ds3DocSpecEmptyImpl());
    assertThat(result.size(), is(0));
}
Also used : BaseRequest(com.spectralogic.ds3autogen.python.model.request.BaseRequest) Ds3DocSpecEmptyImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl) Test(org.junit.Test)

Example 2 with BaseRequest

use of com.spectralogic.ds3autogen.python.model.request.BaseRequest in project ds3_autogen by SpectraLogic.

the class PythonCodeGenerator method generateCommands.

/**
     * Generates the ds3.py python code which includes: request handlers, response handlers,
     * response payload descriptors, and the client
     */
@Override
public void generateCommands(final ImmutableList<Ds3Request> ds3Requests, final ImmutableMap<String, Ds3Type> typeMap, final Ds3DocSpec docSpec) throws IOException, TemplateException {
    if (isEmpty(ds3Requests)) {
        LOG.info("There are no requests to generate");
        return;
    }
    final ImmutableList<BaseRequest> baseRequests = toRequestModelList(ds3Requests, docSpec);
    final ImmutableList<BaseResponse> baseResponses = toResponseModelList(ds3Requests);
    final ImmutableList<TypeDescriptor> baseTypes = toTypeDescriptorList(typeMap);
    final ImmutableList<BaseClient> clientCommands = toClientCommands(ds3Requests, docSpec);
    final CommandSet commandSet = new CommandSet(baseRequests, baseResponses, baseTypes, clientCommands);
    final Template tmpl = getCommandTemplate(config);
    final Path path = toBaseProjectPath("ds3.py");
    LOG.info("Getting OutputStream for file: " + path.toString());
    try (final OutputStream outStream = fileUtils.getOutputFile(path);
        final Writer writer = new OutputStreamWriter(outStream)) {
        tmpl.process(commandSet, writer);
    }
}
Also used : Path(java.nio.file.Path) OutputStream(java.io.OutputStream) BaseClient(com.spectralogic.ds3autogen.python.model.client.BaseClient) BaseResponse(com.spectralogic.ds3autogen.python.model.response.BaseResponse) TypeDescriptor(com.spectralogic.ds3autogen.python.model.type.TypeDescriptor) BaseRequest(com.spectralogic.ds3autogen.python.model.request.BaseRequest) CommandSet(com.spectralogic.ds3autogen.python.model.commands.CommandSet) OutputStreamWriter(java.io.OutputStreamWriter) OutputStreamWriter(java.io.OutputStreamWriter) Writer(java.io.Writer)

Example 3 with BaseRequest

use of com.spectralogic.ds3autogen.python.model.request.BaseRequest in project ds3_autogen by SpectraLogic.

the class PythonCodeGenerator_Test method toRequestModelList_EmptyList_Test.

@Test
public void toRequestModelList_EmptyList_Test() {
    final ImmutableList<BaseRequest> result = generator.toRequestModelList(ImmutableList.of(), new Ds3DocSpecEmptyImpl());
    assertThat(result.size(), is(0));
}
Also used : BaseRequest(com.spectralogic.ds3autogen.python.model.request.BaseRequest) Ds3DocSpecEmptyImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl) Test(org.junit.Test)

Example 4 with BaseRequest

use of com.spectralogic.ds3autogen.python.model.request.BaseRequest in project ds3_autogen by SpectraLogic.

the class PythonCodeGenerator_Test method toRequestModel_Test.

@Test
public void toRequestModel_Test() {
    final BaseRequest result = generator.toRequestModel(getRequestCreateNotification(), getTestDocSpec());
    assertThat(result.getName(), is("CreateJobCreatedNotificationRegistrationRequestHandler"));
    assertThat(result.getPath(), is("'/_rest_/job_created_notification_registration'"));
    assertThat(result.getHttpVerb(), is(HttpVerb.POST.toString()));
    assertThat(result.getAdditionalContent(), is(nullValue()));
    assertThat(result.getAssignments().size(), is(0));
    assertThat(result.getConstructorParams().size(), is(4));
    assertThat(result.getOptionalArgs().size(), is(3));
    assertThat(result.getQueryParams().size(), is(1));
    assertThat(result.getQueryParams().get(0).getName(), is("notification_end_point"));
    assertThat(result.getQueryParams().get(0).getAssignment(), is("notification_end_point"));
}
Also used : BaseRequest(com.spectralogic.ds3autogen.python.model.request.BaseRequest) Test(org.junit.Test)

Aggregations

BaseRequest (com.spectralogic.ds3autogen.python.model.request.BaseRequest)4 Test (org.junit.Test)3 Ds3DocSpecEmptyImpl (com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl)2 BaseClient (com.spectralogic.ds3autogen.python.model.client.BaseClient)1 CommandSet (com.spectralogic.ds3autogen.python.model.commands.CommandSet)1 BaseResponse (com.spectralogic.ds3autogen.python.model.response.BaseResponse)1 TypeDescriptor (com.spectralogic.ds3autogen.python.model.type.TypeDescriptor)1 OutputStream (java.io.OutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 Path (java.nio.file.Path)1