Search in sources :

Example 21 with Ds3DocSpec

use of com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec in project ds3_autogen by SpectraLogic.

the class BaseRequestGenerator_Test method toDocumentation_Test.

@Test
public void toDocumentation_Test() {
    final String expected = "'''\n" + "  This is how you use test one request\n" + "  `param_one` This is how you use param one\n" + "  `does_not_exist` \n" + "  '''\n";
    final Ds3DocSpec docSpec = new Ds3DocSpecImpl(ImmutableMap.of("TestOneRequest", "This is how you use test one request"), ImmutableMap.of("ParamOne", "This is how you use param one"));
    final ImmutableList<String> params = ImmutableList.of("param_one", "does_not_exist");
    final String result = toDocumentation("TestOneRequest", params, docSpec);
    assertThat(result, is(expected));
}
Also used : Ds3DocSpec(com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec) Ds3DocSpecImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecImpl) Test(org.junit.Test)

Example 22 with Ds3DocSpec

use of com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec in project ds3_autogen by SpectraLogic.

the class BaseRequestGenerator_Test method toWithConstructor_Test.

@Test
public void toWithConstructor_Test() {
    final String expectedDoc = "/// <summary>\n" + "        /// This is how you use Test Request\n" + "        /// </summary>\n" + "        /// <param name=\"TestParam\">This is how you use Test Param</param>\n";
    final String requestName = "TestRequest";
    final String paramName = "TestParam";
    final Ds3DocSpec docSpec = new Ds3DocSpecImpl(ImmutableMap.of(requestName, "This is how you use Test Request"), ImmutableMap.of(paramName, "This is how you use Test Param"));
    final NetNullableVariable netVar = new NetNullableVariable(paramName, "int", true, true);
    final WithConstructorVariable result = toWithConstructor(netVar, requestName, docSpec);
    assertThat(result.getName(), is(netVar.getName()));
    assertThat(result.getType(), is(netVar.getType()));
    assertThat(result.getNetType(), is(netVar.getNetType()));
    assertThat(result.getDocumentation(), is(expectedDoc));
}
Also used : NetNullableVariable(com.spectralogic.ds3autogen.net.model.common.NetNullableVariable) WithConstructorVariable(com.spectralogic.ds3autogen.net.model.request.WithConstructorVariable) Ds3DocSpec(com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec) Ds3DocSpecImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecImpl) Test(org.junit.Test)

Example 23 with Ds3DocSpec

use of com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec in project ds3_autogen by SpectraLogic.

the class JavaFunctionalDocs_Test method getBucketRequest_Test.

@Test
public void getBucketRequest_Test() throws IOException, TemplateModelException {
    final String requestName = "GetBucketRequest";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestGeneratedCode codeGenerator = new TestGeneratedCode(fileUtils, requestName, "./ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/");
    final Ds3DocSpec docSpec = new Ds3DocSpecImpl(ImmutableMap.of(requestName, "This is how you use the request"), ImmutableMap.of("Delimiter", "This is how you use delimiter", "Marker", "This is how you use marker", "MaxKeys", "This is how you use max keys", "Prefix", "This is how you use prefix", "BucketName", "This is how you use bucket name"));
    codeGenerator.generateCode(fileUtils, "/input/getBucketRequestHandler.xml", docSpec);
    //Generate Request code
    final String requestCode = codeGenerator.getRequestGeneratedCode();
    CODE_LOGGER.logFile(requestCode, FileTypeToLog.REQUEST);
    assertTrue(requestCode.contains(toConstructorDocs(requestName, ImmutableList.of("Delimiter"), docSpec, 1)));
    assertTrue(requestCode.contains(toConstructorDocs(requestName, ImmutableList.of("Marker"), docSpec, 1)));
    assertTrue(requestCode.contains(toConstructorDocs(requestName, ImmutableList.of("MaxKeys"), docSpec, 1)));
    assertTrue(requestCode.contains(toConstructorDocs(requestName, ImmutableList.of("Prefix"), docSpec, 1)));
    assertTrue(requestCode.contains(toConstructorDocs(requestName, ImmutableList.of("BucketName"), docSpec, 1)));
    //Generate Client code
    final String ds3ClientCode = codeGenerator.getDs3ClientGeneratedCode();
    CODE_LOGGER.logFile(ds3ClientCode, FileTypeToLog.CLIENT);
    final Pattern expectedCommandDoc = Pattern.compile("\\s+/\\*\\*" + "\\s+\\* This is how you use the request" + "\\s+\\*/" + "\\s+GetBucketResponse getBucket\\(final GetBucketRequest request\\)", Pattern.MULTILINE | Pattern.UNIX_LINES);
    assertTrue(expectedCommandDoc.matcher(ds3ClientCode).find());
}
Also used : Pattern(java.util.regex.Pattern) FileUtils(com.spectralogic.ds3autogen.api.FileUtils) Ds3DocSpec(com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec) Ds3DocSpecImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecImpl) Test(org.junit.Test)

Aggregations

Ds3DocSpec (com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec)23 Test (org.junit.Test)20 Ds3DocSpecParser (com.spectralogic.ds3autogen.api.Ds3DocSpecParser)7 NameMapper (com.spectralogic.ds3autogen.NameMapper)6 Ds3DocSpecImpl (com.spectralogic.ds3autogen.docspec.Ds3DocSpecImpl)5 Ds3SpecParserImpl (com.spectralogic.ds3autogen.Ds3SpecParserImpl)4 Ds3SpecParser (com.spectralogic.ds3autogen.api.Ds3SpecParser)4 FileUtils (com.spectralogic.ds3autogen.api.FileUtils)4 Ds3ApiSpec (com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec)4 Ds3DocSpecParserImpl (com.spectralogic.ds3autogen.docspec.Ds3DocSpecParserImpl)4 Enum (com.spectralogic.ds3autogen.c.models.Enum)3 Ds3DocSpecEmptyImpl (com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 CodeGenerator (com.spectralogic.ds3autogen.api.CodeGenerator)2 GoCodeGenerator (com.spectralogic.ds3autogen.go.GoCodeGenerator)2 TestFileUtilsImpl (com.spectralogic.ds3autogen.utils.TestFileUtilsImpl)2 InputStream (java.io.InputStream)2 Pattern (java.util.regex.Pattern)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1