Search in sources :

Example 6 with TestGeneratedModelCode

use of com.spectralogic.ds3autogen.java.utils.TestGeneratedModelCode in project ds3_autogen by SpectraLogic.

the class JavaFunctionalModels_Test method requestType.

@Test
public void requestType() 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/requestType.xml");
    final String modelGeneratedCode = testGeneratedModelCode.getModelGeneratedCode();
    CODE_LOGGER.logFile(modelGeneratedCode, FileTypeToLog.MODEL);
    assertTrue(hasCopyright(modelGeneratedCode));
    assertTrue(isOfPackage("com.spectralogic.ds3client.models", modelGeneratedCode));
    assertTrue(TestHelper.isEnumClass(modelName, modelGeneratedCode));
    assertTrue(TestHelper.enumContainsValue("DELETE", modelGeneratedCode));
    assertTrue(TestHelper.enumContainsValue("GET", modelGeneratedCode));
    assertTrue(TestHelper.enumContainsValue("HEAD", modelGeneratedCode));
    assertTrue(TestHelper.enumContainsValue("POST", modelGeneratedCode));
    assertTrue(TestHelper.enumContainsValue("PUT", modelGeneratedCode));
}
Also used : FileUtils(com.spectralogic.ds3autogen.api.FileUtils) TestGeneratedModelCode(com.spectralogic.ds3autogen.java.utils.TestGeneratedModelCode) Test(org.junit.Test)

Example 7 with TestGeneratedModelCode

use of com.spectralogic.ds3autogen.java.utils.TestGeneratedModelCode in project ds3_autogen by SpectraLogic.

the class JavaFunctionalModels_Test method physicalPlacementApiBeanModel.

@Test
public void physicalPlacementApiBeanModel() throws IOException, TemplateModelException {
    final String modelName = "PhysicalPlacement";
    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/PhysicalPlacementApiBeanType.xml");
    final String modelGeneratedCode = testGeneratedModelCode.getModelGeneratedCode();
    CODE_LOGGER.logFile(modelGeneratedCode, FileTypeToLog.MODEL);
    assertTrue(hasCopyright(modelGeneratedCode));
    assertTrue(isOfPackage("com.spectralogic.ds3client.models", modelGeneratedCode));
    assertTrue(hasModelVariable("Pools", "Pools", "List<Pool>", true, modelGeneratedCode));
    assertTrue(hasModelVariable("Tapes", "Tapes", "List<Tape>", true, modelGeneratedCode));
    assertTrue(hasImport("com.fasterxml.jackson.annotation.JsonProperty", modelGeneratedCode));
    assertTrue(hasImport("com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper", modelGeneratedCode));
    assertFalse(hasImport("com.spectralogic.ds3client.models.Pool", modelGeneratedCode));
    assertFalse(hasImport("com.spectralogic.ds3client.models.Tape", modelGeneratedCode));
    assertTrue(hasImport("java.util.List", modelGeneratedCode));
    final ImmutableList<Element> constructorArgs = ImmutableList.of(new Element("Pools", "array", "Pool"), new Element("Tapes", "array", "Tape"));
    assertFalse(hasModelConstructor(modelName, constructorArgs, modelGeneratedCode));
    assertTrue(hasModelConstructor(modelName, ImmutableList.<Element>of(), modelGeneratedCode));
}
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 8 with TestGeneratedModelCode

use of com.spectralogic.ds3autogen.java.utils.TestGeneratedModelCode in project ds3_autogen by SpectraLogic.

the class JavaFunctionalModels_Test method blobStoreTaskPriority.

@Test
public void blobStoreTaskPriority() throws IOException, TemplateModelException {
    final String modelName = "Priority";
    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/BlobStoreTaskPriorityType.xml");
    final String modelGeneratedCode = testGeneratedModelCode.getModelGeneratedCode();
    CODE_LOGGER.logFile(modelGeneratedCode, FileTypeToLog.MODEL);
    assertTrue(hasCopyright(modelGeneratedCode));
    assertTrue(isOfPackage("com.spectralogic.ds3client.models", modelGeneratedCode));
    assertTrue(TestHelper.isEnumClass(modelName, modelGeneratedCode));
    assertTrue(TestHelper.enumContainsValue("CRITICAL", modelGeneratedCode));
    assertTrue(TestHelper.enumContainsValue("URGENT", modelGeneratedCode));
    assertTrue(TestHelper.enumContainsValue("HIGH", modelGeneratedCode));
    assertTrue(TestHelper.enumContainsValue("NORMAL", modelGeneratedCode));
    assertTrue(TestHelper.enumContainsValue("LOW", modelGeneratedCode));
    assertTrue(TestHelper.enumContainsValue("BACKGROUND", modelGeneratedCode));
}
Also used : FileUtils(com.spectralogic.ds3autogen.api.FileUtils) TestGeneratedModelCode(com.spectralogic.ds3autogen.java.utils.TestGeneratedModelCode) Test(org.junit.Test)

Example 9 with TestGeneratedModelCode

use of com.spectralogic.ds3autogen.java.utils.TestGeneratedModelCode in project ds3_autogen by SpectraLogic.

the class JavaFunctionalModels_Test method httpErrorResultApiBean_Test.

@Test
public void httpErrorResultApiBean_Test() throws IOException, TemplateModelException {
    final String modelName = "Error";
    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/httpErrorResultApiBean.xml");
    final String modelGeneratedCode = testGeneratedModelCode.getModelGeneratedCode();
    CODE_LOGGER.logFile(modelGeneratedCode, FileTypeToLog.MODEL);
    assertTrue(hasCopyright(modelGeneratedCode));
    assertTrue(isOfPackage("com.spectralogic.ds3client.models", modelGeneratedCode));
    assertTrue(hasModelVariable("Code", "String", modelGeneratedCode));
    assertTrue(hasModelVariable("HttpErrorCode", "int", modelGeneratedCode));
    assertTrue(hasModelVariable("Message", "String", modelGeneratedCode));
    assertTrue(hasModelVariable("Resource", "String", modelGeneratedCode));
    assertTrue(hasModelVariable("ResourceId", "long", modelGeneratedCode));
    assertTrue(hasImport("com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement", modelGeneratedCode));
    assertTrue(hasImport("com.fasterxml.jackson.annotation.JsonProperty", modelGeneratedCode));
    assertTrue(hasImport("com.fasterxml.jackson.annotation.JsonIgnoreProperties", modelGeneratedCode));
    assertTrue(modelGeneratedCode.contains("@JsonIgnoreProperties(ignoreUnknown = true)"));
    assertTrue(modelGeneratedCode.contains("public String toString()"));
}
Also used : FileUtils(com.spectralogic.ds3autogen.api.FileUtils) TestGeneratedModelCode(com.spectralogic.ds3autogen.java.utils.TestGeneratedModelCode) Test(org.junit.Test)

Example 10 with TestGeneratedModelCode

use of com.spectralogic.ds3autogen.java.utils.TestGeneratedModelCode in project ds3_autogen by SpectraLogic.

the class JavaFunctionalModels_Test method bucketAclType.

@Test
public void bucketAclType() throws IOException, TemplateModelException {
    final String modelName = "BucketAcl";
    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/BucketAclType.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("GroupId", "UUID", modelGeneratedCode));
    assertTrue(hasModelVariable("Id", "UUID", modelGeneratedCode));
    assertTrue(hasModelVariable("Permission", "BucketAclPermission", modelGeneratedCode));
    assertTrue(hasModelVariable("UserId", "UUID", modelGeneratedCode));
    assertTrue(hasImport("com.fasterxml.jackson.annotation.JsonProperty", modelGeneratedCode));
    assertTrue(hasImport("java.util.UUID", modelGeneratedCode));
    assertFalse(hasImport("com.spectralogic.ds3client.models.BucketAclPermission", modelGeneratedCode));
    assertFalse(hasImport("java.util.List", modelGeneratedCode));
    final ImmutableList<Element> constructorArgs = ImmutableList.of(new Element("BucketId", "UUID", ""), new Element("GroupId", "UUID", ""), new Element("Id", "UUID", ""), new Element("Permission", "BucketAclPermission", ""), new Element("UserId", "UUID", ""));
    assertFalse(hasModelConstructor(modelName, constructorArgs, modelGeneratedCode));
    assertTrue(hasModelConstructor(modelName, ImmutableList.<Element>of(), modelGeneratedCode));
}
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)

Aggregations

FileUtils (com.spectralogic.ds3autogen.api.FileUtils)11 TestGeneratedModelCode (com.spectralogic.ds3autogen.java.utils.TestGeneratedModelCode)11 Test (org.junit.Test)11 Element (com.spectralogic.ds3autogen.java.models.Element)4