Search in sources :

Example 1 with Ds3DocSpec

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

the class Ds3DocSpecEmptyImpl_Test method getParamDocumentation_Test.

@Test
public void getParamDocumentation_Test() {
    final Ds3DocSpec docSpec = new Ds3DocSpecEmptyImpl();
    assertThat(docSpec.getParamDocumentation(null).isPresent(), is(false));
    assertThat(docSpec.getParamDocumentation("").isPresent(), is(false));
    assertThat(docSpec.getParamDocumentation("SomeParam").isPresent(), is(false));
}
Also used : Ds3DocSpec(com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec) Test(org.junit.Test)

Example 2 with Ds3DocSpec

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

the class Ds3DocSpecImpl_Test method getParamDocumentation_Test.

@Test
public void getParamDocumentation_Test() {
    final Ds3DocSpec docSpec = getTestDocSpec();
    final Optional<String> request1 = docSpec.getParamDocumentation(paramName1);
    assertThat(request1.isPresent(), is(true));
    assertThat(request1.get(), is(paramDescriptor1));
    final Optional<String> request2 = docSpec.getParamDocumentation(paramName2);
    assertThat(request2.isPresent(), is(true));
    assertThat(request2.get(), is(paramDescriptor2));
    assertThat(docSpec.getParamDocumentation(requestName1).isPresent(), is(false));
    assertThat(docSpec.getParamDocumentation(requestName2).isPresent(), is(false));
}
Also used : Ds3DocSpec(com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec) Test(org.junit.Test)

Example 3 with Ds3DocSpec

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

the class Ds3DocSpecParserImpl_Test method getDocSpec_Test.

@Test
public void getDocSpec_Test() throws IOException {
    final InputStream inputStream = Ds3DocSpecParserImpl_Test.class.getResourceAsStream(TEST_COMMAND_DOCS_FILE);
    final NameMapper nameMapper = new NameMapper(TEST_NAME_MAPPER_FILE);
    final Ds3DocSpecParser parser = new Ds3DocSpecParserImpl(nameMapper);
    final Ds3DocSpec result = parser.getDocSpec(inputStream);
    assertThat(result.getParamDocumentation("Param1").get(), is("This is the effect of Param1"));
    assertThat(result.getParamDocumentation("Param2").get(), is("This is the effect of Param2"));
    assertThat(result.getParamDocumentation("Param3").get(), is("This is the effect of Param3"));
    assertThat(result.getRequestDocumentation("Test1Request").get(), is("This is how you use Request1"));
    assertThat(result.getRequestDocumentation("Test2Request").get(), is("This is how you use Request2"));
    assertThat(result.getRequestDocumentation("Test3Request").get(), is("This is how you use Amazon Request3"));
    assertThat(result.getRequestDocumentation("Test3SpectraS3Request").get(), is("This is how you use SpectraS3 Request3"));
}
Also used : InputStream(java.io.InputStream) Ds3DocSpec(com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec) NameMapper(com.spectralogic.ds3autogen.NameMapper) Ds3DocSpecParser(com.spectralogic.ds3autogen.api.Ds3DocSpecParser) Test(org.junit.Test)

Example 4 with Ds3DocSpec

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

the class CCodeGenerator_Test method testRequestDocumentation.

@Test
public void testRequestDocumentation() throws IOException {
    final Ds3DocSpecParser docSpecParser = new Ds3DocSpecParserImpl(new NameMapper());
    final Ds3DocSpec docSpec = docSpecParser.getDocSpec(CCodeGenerator_Test.class.getResourceAsStream("/input/testCommandDocumentation.json"));
    final Optional<String> testRequestHandlerDescription = docSpec.getRequestDocumentation("Test1Request");
    assertTrue(testRequestHandlerDescription.isPresent());
    assertEquals(testRequestHandlerDescription.get(), "This is how you use Request1");
}
Also used : Ds3DocSpecParserImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecParserImpl) Ds3DocSpec(com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec) NameMapper(com.spectralogic.ds3autogen.NameMapper) Ds3DocSpecParser(com.spectralogic.ds3autogen.api.Ds3DocSpecParser) Test(org.junit.Test)

Example 5 with Ds3DocSpec

use of com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec 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)

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