use of com.spectralogic.ds3autogen.java.models.Element 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()"));
}
use of com.spectralogic.ds3autogen.java.models.Element 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)"));
}
use of com.spectralogic.ds3autogen.java.models.Element in project ds3_autogen by SpectraLogic.
the class ResponseAndParserUtil_Test method convertType_Exception_Test.
@Test(expected = IllegalArgumentException.class)
public void convertType_Exception_Test() {
final Element compositeElement = new Element("Tapes", "map", "com.spectralogic.s3.common.dao.domain.tape.Tape");
convertType(compositeElement);
}
use of com.spectralogic.ds3autogen.java.models.Element in project ds3_autogen by SpectraLogic.
the class JavaHelper_Test method getModelVariable_SimpleType_AsAttribute_Test.
@Test
public void getModelVariable_SimpleType_AsAttribute_Test() {
final String expectedResult = " @JacksonXmlProperty(isAttribute = true, localName = \"xmlName\")\n" + " private testType testName;";
final Element element = new Element("testName", "xmlName", true, false, "testType", null);
final String result = getModelVariable(element);
assertThat(result, is(expectedResult));
}
use of com.spectralogic.ds3autogen.java.models.Element in project ds3_autogen by SpectraLogic.
the class JavaHelper_Test method getModelVariable_SimpleType_Test.
@Test
public void getModelVariable_SimpleType_Test() {
final String expectedResult = " @JsonProperty(\"XmlName\")\n" + " private testType testName;";
final Element element = new Element("testName", "xmlName", false, false, "testType", null);
final String result = getModelVariable(element);
assertThat(result, is(expectedResult));
}
Aggregations