Search in sources :

Example 61 with Ds3Request

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

the class RequestGeneratorUtil_Test method getGoArgFromResource_Test.

@Test
public void getGoArgFromResource_Test() {
    final ImmutableList<Arguments> expectedArgs = ImmutableList.of(new Arguments("String", "notificationId"), new Arguments("String", "bucketId"), new Arguments("UUID", "jobId"), new Arguments("String", "activeJob"));
    final ImmutableList<Ds3Request> requests = ImmutableList.of(createTestRequest(Resource.DS3_TARGET_FAILURE_NOTIFICATION_REGISTRATION, true), createTestRequest(Resource.BUCKET, true), createTestRequest(Resource.JOB, true), createTestRequest(Resource.ACTIVE_JOB, true));
    assertThat(requests.size(), is(expectedArgs.size()));
    for (int i = 0; i > requests.size(); i++) {
        final Arguments result = getGoArgFromResource(requests.get(i));
        assertThat(result.getName(), is(expectedArgs.get(i).getName()));
        assertThat(result.getType(), is(expectedArgs.get(i).getType()));
    }
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) Test(org.junit.Test)

Example 62 with Ds3Request

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

the class BaseClientGenerator_Test method toCommandList_HttpRedirectTrue_Test.

@Test
public void toCommandList_HttpRedirectTrue_Test() {
    final ImmutableList<Command> expected = ImmutableList.of(new Command("GetBucketsHandler"), new Command("GetObjectsHandler"));
    final ImmutableList<Ds3Request> requests = ImmutableList.of(getBucketsRequest(), deleteBucketRequest(), getObjectsDetailsRequest(), getRequestBulkGet());
    final ImmutableList<Command> result = generator.toCommandList(requests, true);
    assertThat(result.size(), is(expected.size()));
    expected.forEach(cmd -> assertThat(result, hasItem(cmd)));
}
Also used : Command(com.spectralogic.ds3autogen.go.models.client.Command) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) Test(org.junit.Test)

Example 63 with Ds3Request

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

the class BaseRequestGenerator_Test method toImportSet_NoStrconv_Test.

@Test
public void toImportSet_NoStrconv_Test() {
    final Ds3Request ds3Request = createDs3RequestTestData(false, PARAMS_NOT_REQURING_STRCONV, PARAMS_NOT_REQURING_STRCONV);
    final ImmutableSet<String> result = generator.toImportSet(ds3Request);
    assertThat(result.size(), is(0));
}
Also used : Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) Test(org.junit.Test)

Example 64 with Ds3Request

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

the class BaseRequestGenerator_Test method toImportSet_WithStrconv_Test.

@Test
public void toImportSet_WithStrconv_Test() {
    final ImmutableSet<String> expectedImports = ImmutableSet.of("strconv");
    final Ds3Request ds3Request = createDs3RequestTestData(false, PARAMS_NOT_REQURING_STRCONV, PARAMS_REQUIRING_STRCONV);
    final ImmutableSet<String> result = generator.toImportSet(ds3Request);
    assertThat(result.size(), is(expectedImports.size()));
    expectedImports.forEach(expected -> assertThat(result, hasItem(expected)));
}
Also used : Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) Test(org.junit.Test)

Example 65 with Ds3Request

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

the class JavaCodeGenerator method generateRequest.

/**
     * Generates the code for the Request handler described in a Ds3Request
     * @param ds3Request A Ds3Request
     * @throws IOException
     * @throws TemplateException
     */
private void generateRequest(final Ds3Request ds3Request, final Ds3DocSpec docSpec) throws IOException, TemplateException {
    final Template tmpl = getRequestTemplate(ds3Request);
    final Request request = toRequest(ds3Request, docSpec);
    final Path requestPath = getPathFromPackage(ds3Request, request.getName());
    LOG.info("Getting outputstream for file: {}", requestPath.toString());
    try (final OutputStream outStream = fileUtils.getOutputFile(requestPath);
        final Writer writer = new OutputStreamWriter(outStream)) {
        tmpl.process(request, writer);
    }
}
Also used : Path(java.nio.file.Path) OutputStream(java.io.OutputStream) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) OutputStreamWriter(java.io.OutputStreamWriter) OutputStreamWriter(java.io.OutputStreamWriter) Writer(java.io.Writer)

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