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));
}
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));
}
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());
}
Aggregations