Search in sources :

Example 1 with Ds3DocSpecImpl

use of com.spectralogic.ds3autogen.docspec.Ds3DocSpecImpl in project ds3_autogen by SpectraLogic.

the class NetCodeGenerator_Docs_Test method getBucketRequest_Test.

@Test
public void getBucketRequest_Test() throws IOException, TemplateModelException {
    final String requestName = "GetBucketRequest";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestGenerateCode codeGenerator = new TestGenerateCode(fileUtils, requestName, "./Ds3/Calls/", "ListBucketResult");
    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/getBucketRequest.xml", docSpec);
    //Generate Request code
    final String requestCode = codeGenerator.getRequestCode();
    CODE_LOGGER.logFile(requestCode, FileTypeToLog.REQUEST);
    assertTrue(requestCode.contains(toConstructorDocs(requestName, ImmutableList.of("Delimiter"), docSpec, 2)));
    assertTrue(requestCode.contains(toConstructorDocs(requestName, ImmutableList.of("Marker"), docSpec, 2)));
    assertTrue(requestCode.contains(toConstructorDocs(requestName, ImmutableList.of("MaxKeys"), docSpec, 2)));
    assertTrue(requestCode.contains(toConstructorDocs(requestName, ImmutableList.of("Prefix"), docSpec, 2)));
    assertTrue(requestCode.contains(toConstructorDocs(requestName, ImmutableList.of("BucketName"), docSpec, 2)));
    //Generate Client code
    final String idsClientCode = codeGenerator.getIdsClientCode();
    CODE_LOGGER.logFile(idsClientCode, FileTypeToLog.CLIENT);
    final String expectedCommandDoc = "/// <summary>\n" + "        /// This is how you use the request\n" + "        /// </summary>\n" + "        /// <param name=\"request\"></param>\n" + "        /// <returns></returns>";
    assertTrue(idsClientCode.contains(expectedCommandDoc));
}
Also used : TestGenerateCode(com.spectralogic.ds3autogen.net.utils.TestGenerateCode) FileUtils(com.spectralogic.ds3autogen.api.FileUtils) Ds3DocSpec(com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec) Ds3DocSpecImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecImpl) Test(org.junit.Test)

Example 2 with Ds3DocSpecImpl

use of com.spectralogic.ds3autogen.docspec.Ds3DocSpecImpl in project ds3_autogen by SpectraLogic.

the class PythonFunctionalDocs_Test method getBucketRequest_Test.

@Test
public void getBucketRequest_Test() throws IOException, TemplateModelException {
    final String requestName = "GetBucketRequest";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestPythonGeneratedCode codeGenerator = new TestPythonGeneratedCode(fileUtils);
    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/requests/getBucketRequest.xml", docSpec);
    //Test Request code
    final String ds3Code = codeGenerator.getDs3Code();
    CODE_LOGGER.logFile(ds3Code, FileTypeToLog.REQUEST);
    final Pattern expectedConstructorDocs = Pattern.compile("'''\\s+" + "This is how you use the request\\s+" + "`bucket_name` This is how you use bucket name\\s+" + "`delimiter` This is how you use delimiter\\s+" + "`marker` This is how you use marker\\s+" + "`max_keys` This is how you use max keys\\s+" + "`prefix` This is how you use prefix\\s+" + "'''\\s+" + "def __init__\\(self, bucket_name, delimiter=None, marker=None, max_keys=None, prefix=None\\):", Pattern.MULTILINE | Pattern.UNIX_LINES);
    assertTrue(expectedConstructorDocs.matcher(ds3Code).find());
    //Test Client code
    final Pattern expectedCommandDoc = Pattern.compile("'''\\s+" + "This is how you use the request\\s+" + "'''\\s+" + "def get_bucket\\(self, request\\):", Pattern.MULTILINE | Pattern.UNIX_LINES);
    assertTrue(expectedCommandDoc.matcher(ds3Code).find());
}
Also used : Pattern(java.util.regex.Pattern) FileUtils(com.spectralogic.ds3autogen.api.FileUtils) Ds3DocSpec(com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec) TestPythonGeneratedCode(com.spectralogic.ds3autogen.python.utils.TestPythonGeneratedCode) Ds3DocSpecImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecImpl) Test(org.junit.Test)

Example 3 with Ds3DocSpecImpl

use of com.spectralogic.ds3autogen.docspec.Ds3DocSpecImpl 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 4 with Ds3DocSpecImpl

use of com.spectralogic.ds3autogen.docspec.Ds3DocSpecImpl 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 5 with Ds3DocSpecImpl

use of com.spectralogic.ds3autogen.docspec.Ds3DocSpecImpl 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)5 Ds3DocSpecImpl (com.spectralogic.ds3autogen.docspec.Ds3DocSpecImpl)5 Test (org.junit.Test)5 FileUtils (com.spectralogic.ds3autogen.api.FileUtils)3 Pattern (java.util.regex.Pattern)2 NetNullableVariable (com.spectralogic.ds3autogen.net.model.common.NetNullableVariable)1 WithConstructorVariable (com.spectralogic.ds3autogen.net.model.request.WithConstructorVariable)1 TestGenerateCode (com.spectralogic.ds3autogen.net.utils.TestGenerateCode)1 TestPythonGeneratedCode (com.spectralogic.ds3autogen.python.utils.TestPythonGeneratedCode)1