use of com.spectralogic.ds3autogen.api.FileUtils in project ds3_autogen by SpectraLogic.
the class NetCodeGenerator_Types_Test method testElementsType.
@Test
public void testElementsType() throws IOException, TemplateModelException {
final String typeName = "TestElementsType";
final FileUtils fileUtils = mock(FileUtils.class);
final TestGenerateCode codeGenerator = new TestGenerateCode(fileUtils, PLACEHOLDER_REQUEST_NAME, "./Ds3/Calls/", typeName);
final ImmutableList<String> ignorableFiles = ImmutableList.of("./Ds3/Models/ChecksumType.cs");
codeGenerator.withIgnorableFiles(fileUtils, ignorableFiles);
codeGenerator.generateCode(fileUtils, "/input/types/testElementsType.xml");
final String typeCode = codeGenerator.getTypeCode();
LOG.info("Generated code:\n" + typeCode);
assertTrue(typeCode.contains("public class " + typeName));
assertTrue(typeCode.contains("public IEnumerable<Pool> Pools { get; set; }"));
assertTrue(typeCode.contains("public long ByteOffset { get; set; }"));
assertTrue(typeCode.contains("public string Checksum { get; set; }"));
assertTrue(typeCode.contains("public ChecksumType.Type? ChecksumType { get; set; }"));
assertTrue(typeCode.contains("public Guid Id { get; set; }"));
assertTrue(typeCode.contains("public long Length { get; set; }"));
assertTrue(typeCode.contains("public Guid ObjectId { get; set; }"));
}
use of com.spectralogic.ds3autogen.api.FileUtils in project ds3_autogen by SpectraLogic.
the class NetCodeGenerator_Types_Test method bucket_Test.
@Test
public void bucket_Test() throws TemplateModelException, IOException {
final String typeName = "Bucket";
final FileUtils fileUtils = mock(FileUtils.class);
final TestGenerateCode codeGenerator = new TestGenerateCode(fileUtils, PLACEHOLDER_REQUEST_NAME, "./Ds3/Calls/", typeName);
codeGenerator.generateCode(fileUtils, "/input/types/bucket.xml");
final String typeCode = codeGenerator.getTypeCode();
LOG.info("Generated code:\n" + typeCode);
assertTrue(typeCode.contains("public DateTime CreationDate { get; set; }"));
assertTrue(typeCode.contains("public Guid DataPolicyId { get; set; }"));
assertTrue(typeCode.contains("public Guid Id { get; set; }"));
assertTrue(typeCode.contains("public long? LastPreferredChunkSizeInBytes { get; set; }"));
assertTrue(typeCode.contains("public long? LogicalUsedCapacity { get; set; }"));
assertTrue(typeCode.contains("public string Name { get; set; }"));
assertTrue(typeCode.contains("public Guid UserId { get; set; }"));
}
use of com.spectralogic.ds3autogen.api.FileUtils in project ds3_autogen by SpectraLogic.
the class NetCodeGenerator_Types_Test method databasePhysicalSpaceState.
@Test
public void databasePhysicalSpaceState() throws IOException, TemplateModelException {
final String typeName = "DatabasePhysicalSpaceState";
final FileUtils fileUtils = mock(FileUtils.class);
final TestGenerateCode codeGenerator = new TestGenerateCode(fileUtils, PLACEHOLDER_REQUEST_NAME, "./Ds3/Calls/", typeName);
codeGenerator.generateCode(fileUtils, "/input/types/databasePhysicalSpaceState.xml");
final String typeCode = codeGenerator.getTypeCode();
LOG.info("Generated code:\n" + typeCode);
assertTrue(typeCode.contains("public enum " + typeName));
assertTrue(typeCode.contains("CRITICAL,"));
assertTrue(typeCode.contains("LOW,"));
assertTrue(typeCode.contains("NEAR_LOW,"));
assertTrue(typeCode.contains("NORMAL"));
}
use of com.spectralogic.ds3autogen.api.FileUtils in project ds3_autogen by SpectraLogic.
the class NetCodeGenerator_Types_Test method checksumType.
@Test
public void checksumType() throws IOException, TemplateModelException {
final String typeName = "ChecksumType";
final FileUtils fileUtils = mock(FileUtils.class);
final TestGenerateCode codeGenerator = new TestGenerateCode(fileUtils, PLACEHOLDER_REQUEST_NAME, "./Ds3/Calls/", typeName);
codeGenerator.generateCode(fileUtils, "/input/types/checksumType.xml");
final String typeCode = codeGenerator.getTypeCode();
LOG.info("Generated code:\n" + typeCode);
assertTrue(typeCode.contains("public abstract class " + typeName));
assertTrue(typeCode.contains("CRC_32,"));
assertTrue(typeCode.contains("CRC_32C,"));
assertTrue(typeCode.contains("MD5,"));
assertTrue(typeCode.contains("SHA_256,"));
assertTrue(typeCode.contains("SHA_512,"));
assertTrue(typeCode.contains("NONE"));
}
use of com.spectralogic.ds3autogen.api.FileUtils in project ds3_autogen by SpectraLogic.
the class NetCodeGenerator_Test method createObjectRequest.
@Test
public void createObjectRequest() throws IOException, TemplateModelException {
final String requestName = "PutObjectRequest";
final FileUtils fileUtils = mock(FileUtils.class);
final TestGenerateCode codeGenerator = new TestGenerateCode(fileUtils, requestName, "./Ds3/Calls/");
codeGenerator.generateCode(fileUtils, "/input/createObjectRequest.xml");
final String requestCode = codeGenerator.getRequestCode();
CODE_LOGGER.logFile(requestCode, FileTypeToLog.REQUEST);
assertTrue(TestHelper.extendsClass(requestName, "Ds3Request", requestCode));
assertTrue(TestHelper.hasProperty("Verb", "HttpVerb", requestCode));
assertTrue(TestHelper.hasProperty("Path", "string", requestCode));
assertTrue(TestHelper.hasRequiredParam("BucketName", "string", requestCode));
assertTrue(TestHelper.hasRequiredParam("ObjectName", "string", requestCode));
assertTrue(TestHelper.hasOptionalParam(requestName, "Job", "Guid", requestCode));
assertTrue(TestHelper.hasOptionalParam(requestName, "Offset", "long", requestCode));
assertTrue(requestCode.contains("private readonly Stream RequestPayload;"));
assertTrue(requestCode.contains("internal override Stream GetContentStream()"));
assertTrue(hasOptionalChecksum(requestName, requestCode));
assertTrue(hasOptionalMetadata(requestName, requestCode));
final ImmutableList.Builder<Arguments> constructorArgs = ImmutableList.builder();
constructorArgs.add(new Arguments("String", "BucketName"));
constructorArgs.add(new Arguments("String", "ObjectName"));
constructorArgs.add(new Arguments("Stream", "RequestPayload"));
assertTrue(TestHelper.hasConstructor(requestName, constructorArgs.build(), requestCode));
constructorArgs.add(new Arguments("long", "Length"));
assertTrue(TestHelper.hasConstructor(requestName, constructorArgs.build(), requestCode));
//Generate Client code
final String commandName = requestName.replace("Request", "");
final String clientCode = codeGenerator.getClientCode();
CODE_LOGGER.logFile(clientCode, FileTypeToLog.CLIENT);
assertTrue(TestHelper.hasVoidCommand(commandName, clientCode));
final String idsClientCode = codeGenerator.getIdsClientCode();
CODE_LOGGER.logFile(idsClientCode, FileTypeToLog.CLIENT);
assertTrue(TestHelper.hasIDsCommand(commandName, idsClientCode));
//Generate Responses (should be empty due to no response payload)
final String responseCode = codeGenerator.getResponseCode();
assertTrue(isEmpty(responseCode));
//Generate Parser
final String parserCode = codeGenerator.getParserCode();
CODE_LOGGER.logFile(parserCode, FileTypeToLog.PARSER);
assertTrue(isEmpty(parserCode));
}
Aggregations