use of com.spectralogic.ds3autogen.java.utils.TestGeneratedModelCode 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.utils.TestGeneratedModelCode 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());
}
use of com.spectralogic.ds3autogen.java.utils.TestGeneratedModelCode 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.utils.TestGeneratedModelCode 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<>();"));
}
use of com.spectralogic.ds3autogen.java.utils.TestGeneratedModelCode in project ds3_autogen by SpectraLogic.
the class JavaFunctionalModels_Test method emptyType.
@Test(expected = IllegalArgumentException.class)
public void emptyType() throws IOException, TemplateModelException {
final String modelName = "EmptyType";
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/emptyType.xml");
}
Aggregations