Search in sources :

Example 1 with Element

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()"));
}
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 2 with Element

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)"));
}
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 3 with Element

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);
}
Also used : Element(com.spectralogic.ds3autogen.java.models.Element) Test(org.junit.Test)

Example 4 with Element

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));
}
Also used : Element(com.spectralogic.ds3autogen.java.models.Element) Test(org.junit.Test)

Example 5 with Element

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));
}
Also used : Element(com.spectralogic.ds3autogen.java.models.Element) Test(org.junit.Test)

Aggregations

Element (com.spectralogic.ds3autogen.java.models.Element)19 Test (org.junit.Test)18 Ds3Element (com.spectralogic.ds3autogen.api.models.apispec.Ds3Element)6 FileUtils (com.spectralogic.ds3autogen.api.FileUtils)4 TestGeneratedModelCode (com.spectralogic.ds3autogen.java.utils.TestGeneratedModelCode)4 Ds3Annotation (com.spectralogic.ds3autogen.api.models.apispec.Ds3Annotation)2 Ds3AnnotationElement (com.spectralogic.ds3autogen.api.models.apispec.Ds3AnnotationElement)2 ImmutableList (com.google.common.collect.ImmutableList)1