use of com.spectralogic.ds3autogen.api.FileUtils in project ds3_autogen by SpectraLogic.
the class JavaFunctionalTests method singleRequestHandler.
@Test
public void singleRequestHandler() throws IOException, TemplateModelException {
final String requestName = "GetObjectRequest";
final FileUtils fileUtils = mock(FileUtils.class);
final TestGeneratedCode testGeneratedCode = new TestGeneratedCode(fileUtils, requestName, "./ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/");
testGeneratedCode.generateCode(fileUtils, "/input/singleRequestHandler.xml");
final String requestGeneratedCode = testGeneratedCode.getRequestGeneratedCode();
CODE_LOGGER.logFile(requestGeneratedCode, FileTypeToLog.REQUEST);
assertTrue(extendsClass(requestName, "AbstractRequest", requestGeneratedCode));
final String responseGeneratedCode = testGeneratedCode.getResponseGeneratedCode();
CODE_LOGGER.logFile(responseGeneratedCode, FileTypeToLog.RESPONSE);
final String responseName = requestName.replace("Request", "Response");
assertTrue(extendsClass(responseName, "AbstractResponse", responseGeneratedCode));
final String ds3ClientGeneratedCode = testGeneratedCode.getDs3ClientGeneratedCode();
CODE_LOGGER.logFile(ds3ClientGeneratedCode, FileTypeToLog.CLIENT);
testDs3Client(requestName, ds3ClientGeneratedCode);
final String ds3ClientImplGeneratedCode = testGeneratedCode.getDs3ClientImplGeneratedCode();
CODE_LOGGER.logFile(ds3ClientImplGeneratedCode, FileTypeToLog.CLIENT);
testDs3ClientImpl(requestName, ds3ClientImplGeneratedCode);
final String responseParserCode = testGeneratedCode.getResponseParserGeneratedCode();
CODE_LOGGER.logFile(responseParserCode, FileTypeToLog.PARSER);
assertTrue(isOfPackage("com.spectralogic.ds3client.commands.parsers", responseParserCode));
}
use of com.spectralogic.ds3autogen.api.FileUtils in project ds3_autogen by SpectraLogic.
the class JavaFunctionalTests method getBucketsSpectraS3_Test.
@Test
public void getBucketsSpectraS3_Test() throws IOException, TemplateModelException {
final String requestName = "GetBucketsSpectraS3Request";
final FileUtils fileUtils = mock(FileUtils.class);
final TestGeneratedComponentResponseCode testGeneratedCode = new TestGeneratedComponentResponseCode(fileUtils, requestName, "./ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/spectrads3/", "./ds3-sdk/src/main/java/com/spectralogic/ds3client/models/BucketList.java");
testGeneratedCode.generateCode(fileUtils, "/input/getBucketsSpectraS3.xml");
final String requestGeneratedCode = testGeneratedCode.getRequestGeneratedCode();
CODE_LOGGER.logFile(requestGeneratedCode, FileTypeToLog.REQUEST);
//Verify that name mapped from GetBuckets to GetService
assertTrue(extendsClass(requestName, "AbstractPaginationRequest", requestGeneratedCode));
//Test the generated response
final String responseGeneratedCode = testGeneratedCode.getResponseGeneratedCode();
CODE_LOGGER.logFile(responseGeneratedCode, FileTypeToLog.RESPONSE);
final String responseName = requestName.replace("Request", "Response");
assertTrue(extendsClass(responseName, "AbstractPaginationResponse", responseGeneratedCode));
assertTrue(isReqParamOfType("bucketListResult", "BucketList", responseName, responseGeneratedCode, false));
assertTrue(isReqParamOfType("pagingTotalResultCount", "Integer", responseName, responseGeneratedCode, true));
assertTrue(isReqParamOfType("pagingTruncated", "Integer", responseName, responseGeneratedCode, true));
//Test the Ds3Client
final String ds3ClientGeneratedCode = testGeneratedCode.getDs3ClientGeneratedCode();
CODE_LOGGER.logFile(ds3ClientGeneratedCode, FileTypeToLog.CLIENT);
testDs3Client(requestName, ds3ClientGeneratedCode);
assertTrue(ds3ClientGeneratedCode.contains("@ResponsePayloadModel(\"BucketList\")"));
assertTrue(ds3ClientGeneratedCode.contains("@Action(\"LIST\")"));
assertTrue(ds3ClientGeneratedCode.contains("@Resource(\"BUCKET\")"));
final String ds3ClientImplGeneratedCode = testGeneratedCode.getDs3ClientImplGeneratedCode();
CODE_LOGGER.logFile(ds3ClientImplGeneratedCode, FileTypeToLog.CLIENT);
testDs3ClientImpl(requestName, ds3ClientImplGeneratedCode);
//Test the response parser
final String responseParserCode = testGeneratedCode.getResponseParserGeneratedCode();
CODE_LOGGER.logFile(responseParserCode, FileTypeToLog.PARSER);
assertTrue(isOfPackage("com.spectralogic.ds3client.commands.parsers", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.spectrads3." + responseName, responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.parsers.interfaces.AbstractResponseParser", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.models.BucketList", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.networking.WebResponse", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.serializer.XmlOutput", responseParserCode));
assertTrue(hasImport("java.io.IOException", responseParserCode));
assertTrue(hasImport("java.io.InputStream", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.parsers.utils.ResponseParserUtils", responseParserCode));
final BaseParseResponse expectedParsing = new BaseParseResponse(responseName, "BucketList", true);
assertTrue(responseParserCode.contains(expectedParsing.toJavaCode()));
assertTrue(responseParserCode.contains("private final int[] expectedStatusCodes = new int[]{200};"));
}
use of com.spectralogic.ds3autogen.api.FileUtils 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));
}
use of com.spectralogic.ds3autogen.api.FileUtils 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));
}
use of com.spectralogic.ds3autogen.api.FileUtils 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()"));
}
Aggregations