Search in sources :

Example 41 with FileUtils

use of com.spectralogic.ds3autogen.api.FileUtils in project ds3_autogen by SpectraLogic.

the class JavaFunctionalModels_Test method bulkObject_Test.

@Test
public void bulkObject_Test() throws IOException, TemplateModelException {
    final String modelName = "BulkObject";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestGeneratedModelCode testGeneratedModelCode = new TestGeneratedModelCode(fileUtils, modelName, "./ds3-sdk/src/main/java/com/spectralogic/ds3client/models/");
    testGeneratedModelCode.generateCode(fileUtils, "/input/bulkObjectType.xml");
    final String modelGeneratedCode = testGeneratedModelCode.getModelGeneratedCode();
    CODE_LOGGER.logFile(modelGeneratedCode, FileTypeToLog.MODEL);
    assertTrue(hasCopyright(modelGeneratedCode));
    assertTrue(isOfPackage("com.spectralogic.ds3client.models", modelGeneratedCode));
    assertTrue(hasParamAttribute("InCache", "Boolean", modelGeneratedCode));
    assertTrue(hasParamAttribute("Latest", "boolean", modelGeneratedCode));
    assertTrue(hasParamAttribute("Length", "long", modelGeneratedCode));
    assertTrue(hasParamAttribute("Name", "String", modelGeneratedCode));
    assertTrue(hasParamAttribute("Offset", "long", modelGeneratedCode));
    assertTrue(hasModelVariable("PhysicalPlacement", "PhysicalPlacement", modelGeneratedCode));
    assertTrue(hasParamAttribute("Version", "long", modelGeneratedCode));
    assertTrue(hasImport("com.fasterxml.jackson.annotation.JsonProperty", modelGeneratedCode));
    assertTrue(hasImport("com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement", modelGeneratedCode));
    assertTrue(hasImport("com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty", modelGeneratedCode));
    assertTrue(hasModelConstructor(modelName, ImmutableList.<Element>of(), modelGeneratedCode));
    assertTrue(modelGeneratedCode.contains("public int hashCode()"));
    assertTrue(modelGeneratedCode.contains("public boolean equals(final Object obj)"));
    assertTrue(modelGeneratedCode.contains("public String toString()"));
}
Also used : FileUtils(com.spectralogic.ds3autogen.api.FileUtils) TestGeneratedModelCode(com.spectralogic.ds3autogen.java.utils.TestGeneratedModelCode) Element(com.spectralogic.ds3autogen.java.models.Element) Test(org.junit.Test)

Example 42 with FileUtils

use of com.spectralogic.ds3autogen.api.FileUtils in project ds3_autogen by SpectraLogic.

the class JavaFunctionalModels_Test method NamedDetailedTapeList_Test.

@Test
public void NamedDetailedTapeList_Test() throws IOException, TemplateModelException {
    final String requestName = "PlaceHolderRequest";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestGeneratedComponentResponseCode testGeneratedCode = new TestGeneratedComponentResponseCode(fileUtils, requestName, "./ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/", "./ds3-sdk/src/main/java/com/spectralogic/ds3client/models/NamedDetailedTapeList.java");
    testGeneratedCode.generateCode(fileUtils, "/input/namedDetailedTapeList.xml");
    final String modelCode = testGeneratedCode.getEncapsulatingTypeGeneratedCode();
    CODE_LOGGER.logFile(modelCode, FileTypeToLog.MODEL);
    assertFalse(modelCode.contains("@JacksonXmlRootElement(namespace = "));
    assertFalse(modelCode.contains("@JsonProperty(\"NamedDetailedTape\")"));
    assertTrue(modelCode.contains("@JsonProperty(\"Tape\")"));
}
Also used : TestGeneratedComponentResponseCode(com.spectralogic.ds3autogen.java.utils.TestGeneratedComponentResponseCode) FileUtils(com.spectralogic.ds3autogen.api.FileUtils) Test(org.junit.Test)

Example 43 with FileUtils

use of com.spectralogic.ds3autogen.api.FileUtils in project ds3_autogen by SpectraLogic.

the class JavaFunctionalModels_Test method unusedType.

@Test
public void unusedType() throws IOException, TemplateModelException {
    final String modelName = "RequestType";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestGeneratedModelCode testGeneratedModelCode = new TestGeneratedModelCode(fileUtils, modelName, "./ds3-sdk/src/main/java/com/spectralogic/ds3client/models/");
    testGeneratedModelCode.generateCode(fileUtils, "/input/unusedType.xml");
    final String modelGeneratedCode = testGeneratedModelCode.getModelGeneratedCode();
    CODE_LOGGER.logFile(modelGeneratedCode, FileTypeToLog.MODEL);
    assertTrue(modelGeneratedCode.isEmpty());
}
Also used : FileUtils(com.spectralogic.ds3autogen.api.FileUtils) TestGeneratedModelCode(com.spectralogic.ds3autogen.java.utils.TestGeneratedModelCode) Test(org.junit.Test)

Example 44 with FileUtils

use of com.spectralogic.ds3autogen.api.FileUtils in project ds3_autogen by SpectraLogic.

the class JavaFunctionalModels_Test method s3Object_Test.

@Test
public void s3Object_Test() throws IOException, TemplateModelException {
    final String modelName = "S3Object";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestGeneratedModelCode testGeneratedModelCode = new TestGeneratedModelCode(fileUtils, modelName, "./ds3-sdk/src/main/java/com/spectralogic/ds3client/models/");
    testGeneratedModelCode.generateCode(fileUtils, "/input/s3objectType.xml");
    final String modelGeneratedCode = testGeneratedModelCode.getModelGeneratedCode();
    CODE_LOGGER.logFile(modelGeneratedCode, FileTypeToLog.MODEL);
    assertTrue(hasCopyright(modelGeneratedCode));
    assertTrue(isOfPackage("com.spectralogic.ds3client.models", modelGeneratedCode));
    assertTrue(hasModelVariable("BucketId", "UUID", modelGeneratedCode));
    assertTrue(hasModelVariable("CreationDate", "Date", modelGeneratedCode));
    assertTrue(hasModelVariable("Id", "UUID", modelGeneratedCode));
    assertTrue(hasModelVariable("Latest", "boolean", modelGeneratedCode));
    assertTrue(hasModelVariable("Name", "String", modelGeneratedCode));
    assertTrue(hasModelVariable("Type", "S3ObjectType", modelGeneratedCode));
    assertTrue(hasModelVariable("Version", "long", modelGeneratedCode));
    assertTrue(hasImport("com.fasterxml.jackson.annotation.JsonProperty", modelGeneratedCode));
    assertTrue(hasImport("com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement", modelGeneratedCode));
    assertTrue(hasImport("java.util.Objects", modelGeneratedCode));
    assertTrue(hasImport("java.util.UUID", modelGeneratedCode));
    assertTrue(hasImport("java.util.Date", modelGeneratedCode));
    assertTrue(hasModelConstructor(modelName, ImmutableList.<Element>of(), modelGeneratedCode));
    assertTrue(modelGeneratedCode.contains("public int hashCode()"));
    assertTrue(modelGeneratedCode.contains("public boolean equals(final Object obj)"));
}
Also used : FileUtils(com.spectralogic.ds3autogen.api.FileUtils) TestGeneratedModelCode(com.spectralogic.ds3autogen.java.utils.TestGeneratedModelCode) Element(com.spectralogic.ds3autogen.java.models.Element) Test(org.junit.Test)

Example 45 with FileUtils

use of com.spectralogic.ds3autogen.api.FileUtils in project ds3_autogen by SpectraLogic.

the class JavaFunctionalModels_Test method JobsApiBean_Test.

@Test
public void JobsApiBean_Test() throws IOException, TemplateModelException {
    //This Type is special cased AND renamed: generation relies on name detection in isJobsApiBean within JavaCodeGenerator
    final String modelName = "JobList";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestGeneratedModelCode testGeneratedModelCode = new TestGeneratedModelCode(fileUtils, modelName, "./ds3-sdk/src/main/java/com/spectralogic/ds3client/models/");
    testGeneratedModelCode.generateCode(fileUtils, "/input/jobsApiBean.xml");
    final String modelGeneratedCode = testGeneratedModelCode.getModelGeneratedCode();
    CODE_LOGGER.logFile(modelGeneratedCode, FileTypeToLog.MODEL);
    assertTrue(hasCopyright(modelGeneratedCode));
    assertTrue(isOfPackage("com.spectralogic.ds3client.models", modelGeneratedCode));
    assertTrue(modelGeneratedCode.contains("@JacksonXmlRootElement(namespace = \"Jobs\")"));
    assertTrue(modelGeneratedCode.contains("public class JobList {"));
    assertTrue(modelGeneratedCode.contains("@JsonProperty(\"Job\")"));
    assertTrue(modelGeneratedCode.contains("@JacksonXmlElementWrapper(useWrapping = false)"));
    assertTrue(modelGeneratedCode.contains("private List<Job> jobs = new ArrayList<>();"));
}
Also used : FileUtils(com.spectralogic.ds3autogen.api.FileUtils) TestGeneratedModelCode(com.spectralogic.ds3autogen.java.utils.TestGeneratedModelCode) Test(org.junit.Test)

Aggregations

FileUtils (com.spectralogic.ds3autogen.api.FileUtils)113 Test (org.junit.Test)112 Arguments (com.spectralogic.ds3autogen.api.models.Arguments)46 TestGenerateCode (com.spectralogic.ds3autogen.net.utils.TestGenerateCode)34 TestGeneratedCode (com.spectralogic.ds3autogen.java.utils.TestGeneratedCode)30 GoTestCodeUtil (com.spectralogic.ds3autogen.go.utils.GoTestCodeUtil)19 BaseParseResponse (com.spectralogic.ds3autogen.java.models.parseresponse.BaseParseResponse)18 TestGeneratedModelCode (com.spectralogic.ds3autogen.java.utils.TestGeneratedModelCode)11 TestPythonGeneratedCode (com.spectralogic.ds3autogen.python.utils.TestPythonGeneratedCode)10 EmptyParseResponse (com.spectralogic.ds3autogen.java.models.parseresponse.EmptyParseResponse)5 TypeContent (com.spectralogic.ds3autogen.python.model.type.TypeContent)5 TypeElementList (com.spectralogic.ds3autogen.python.model.type.TypeElementList)5 ImmutableList (com.google.common.collect.ImmutableList)4 Ds3DocSpec (com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec)4 Element (com.spectralogic.ds3autogen.java.models.Element)4 TestGeneratedComponentResponseCode (com.spectralogic.ds3autogen.java.utils.TestGeneratedComponentResponseCode)4 Ds3DocSpecImpl (com.spectralogic.ds3autogen.docspec.Ds3DocSpecImpl)3 TypeElement (com.spectralogic.ds3autogen.python.model.type.TypeElement)3 Ds3SpecParserImpl (com.spectralogic.ds3autogen.Ds3SpecParserImpl)2 CodeGenerator (com.spectralogic.ds3autogen.api.CodeGenerator)2