use of com.spectralogic.ds3autogen.java.models.parseresponse.EmptyParseResponse in project ds3_autogen by SpectraLogic.
the class JavaFunctionalTests method createObjectRequestHandler.
@Test
public void createObjectRequestHandler() throws IOException, TemplateModelException {
final String requestName = "PutObjectRequest";
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/createObjectRequestHandler.xml");
final String requestGeneratedCode = testGeneratedCode.getRequestGeneratedCode();
CODE_LOGGER.logFile(requestGeneratedCode, FileTypeToLog.REQUEST);
assertFalse(requestGeneratedCode.contains("CreateObjectRequest"));
assertTrue(extendsClass(requestName, "AbstractRequest", requestGeneratedCode));
assertTrue(isOptParamOfType("Job", "String", requestName, requestGeneratedCode, false));
assertTrue(isOptParamOfType("Offset", "long", requestName, requestGeneratedCode, false));
assertTrue(isReqParamOfType("BucketName", "String", requestName, requestGeneratedCode, false));
assertTrue(isReqParamOfType("ObjectName", "String", requestName, requestGeneratedCode, false));
assertTrue(isReqParamOfType("Size", "long", requestName, requestGeneratedCode, false));
assertTrue(hasMethod("withChecksum", requestName, Scope.PUBLIC, requestGeneratedCode));
assertTrue(hasMethod("withMetaData", requestName, Scope.PUBLIC, requestGeneratedCode));
assertTrue(isOptVariable("Channel", "SeekableByteChannel", requestGeneratedCode));
assertTrue(hasGetter("Channel", "SeekableByteChannel", requestGeneratedCode));
assertTrue(hasImport("com.spectralogic.ds3client.networking.HttpVerb", requestGeneratedCode));
assertTrue(hasImport("java.io.InputStream", requestGeneratedCode));
assertTrue(hasImport("java.nio.channels.SeekableByteChannel", requestGeneratedCode));
assertTrue(hasImport("java.util.UUID", requestGeneratedCode));
assertFalse(hasImport("com.spectralogic.ds3client.commands.AbstractRequest", requestGeneratedCode));
assertTrue(hasImport("com.spectralogic.ds3client.utils.SeekableByteChannelInputStream", requestGeneratedCode));
testHasChecksumCode(requestGeneratedCode, requestName);
assertTrue(isOfPackage("com.spectralogic.ds3client.commands", requestGeneratedCode));
assertTrue(doesNotHaveOperation(requestGeneratedCode));
assertTrue(hasCopyright(requestGeneratedCode));
assertTrue(hasPath("\"/\" + this.bucketName + \"/\" + this.objectName", requestGeneratedCode));
final ImmutableList<Arguments> commonConstructorArgs = ImmutableList.of(new Arguments("String", "BucketName"), new Arguments("String", "ObjectName"), new Arguments("long", "Size"));
final ImmutableList.Builder<Arguments> deprecatedBuilder = ImmutableList.builder();
deprecatedBuilder.addAll(commonConstructorArgs);
deprecatedBuilder.add(new Arguments("SeekableByteChannel", "Channel"));
assertTrue(hasConstructor(requestName, deprecatedBuilder.build(), requestGeneratedCode));
final ImmutableList.Builder<Arguments> channelBuilder = ImmutableList.builder();
channelBuilder.addAll(commonConstructorArgs);
channelBuilder.add(new Arguments("UUID", "Job"));
channelBuilder.add(new Arguments("long", "Offset"));
channelBuilder.add(new Arguments("SeekableByteChannel", "Channel"));
assertTrue(hasConstructor(requestName, channelBuilder.build(), requestGeneratedCode));
assertTrue(hasConstructor(requestName, modifyType(channelBuilder.build(), "UUID", "String"), requestGeneratedCode));
final ImmutableList.Builder<Arguments> streamBuilder = ImmutableList.builder();
streamBuilder.addAll(commonConstructorArgs);
streamBuilder.add(new Arguments("UUID", "Job"));
streamBuilder.add(new Arguments("long", "Offset"));
streamBuilder.add(new Arguments("InputStream", "Stream"));
assertTrue(hasConstructor(requestName, streamBuilder.build(), requestGeneratedCode));
assertTrue(hasConstructor(requestName, modifyType(streamBuilder.build(), "UUID", "String"), 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, "AbstractResponse", responseGeneratedCode));
assertTrue(isOfPackage("com.spectralogic.ds3client.commands", responseGeneratedCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.interfaces.AbstractResponse", responseGeneratedCode));
//Test the Ds3Client
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);
//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.parsers.interfaces.AbstractResponseParser", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.networking.WebResponse", responseParserCode));
assertTrue(hasImport("java.io.IOException", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.PutObjectResponse", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.parsers.utils.ResponseParserUtils", responseParserCode));
final EmptyParseResponse expectedParsing = new EmptyParseResponse(responseName);
assertTrue(responseParserCode.contains(expectedParsing.toJavaCode()));
assertTrue(responseParserCode.contains("private final int[] expectedStatusCodes = new int[]{200};"));
}
use of com.spectralogic.ds3autogen.java.models.parseresponse.EmptyParseResponse in project ds3_autogen by SpectraLogic.
the class JavaFunctionalTests method deleteObject_Test.
@Test
public void deleteObject_Test() throws IOException, TemplateModelException {
final String requestName = "DeleteObjectRequest";
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/deleteObject.xml");
final String requestGeneratedCode = testGeneratedCode.getRequestGeneratedCode();
CODE_LOGGER.logFile(requestGeneratedCode, FileTypeToLog.REQUEST);
assertTrue(extendsClass(requestName, "AbstractRequest", requestGeneratedCode));
assertTrue(isReqParamOfType("BucketName", "String", requestName, requestGeneratedCode, false));
assertTrue(isReqParamOfType("ObjectName", "String", requestName, requestGeneratedCode, false));
assertTrue(isOptParamOfType("Replicate", "boolean", requestName, requestGeneratedCode, false));
assertTrue(isOptParamOfType("RollBack", "boolean", requestName, requestGeneratedCode, false));
//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, "AbstractResponse", responseGeneratedCode));
//Test the Ds3Client
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);
//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.parsers.interfaces.AbstractResponseParser", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.networking.WebResponse", responseParserCode));
assertTrue(hasImport("java.io.IOException", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.DeleteObjectResponse", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.parsers.utils.ResponseParserUtils", responseParserCode));
final EmptyParseResponse expectedParsing = new EmptyParseResponse(responseName);
assertTrue(responseParserCode.contains(expectedParsing.toJavaCode()));
assertTrue(responseParserCode.contains("private final int[] expectedStatusCodes = new int[]{204};"));
}
use of com.spectralogic.ds3autogen.java.models.parseresponse.EmptyParseResponse in project ds3_autogen by SpectraLogic.
the class JavaFunctionalTests method createMultiPartUploadPartRequest.
@Test
public void createMultiPartUploadPartRequest() throws IOException, TemplateModelException {
final String requestName = "PutMultiPartUploadPartRequest";
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/createMultiPartUploadPartRequest.xml");
final String requestGeneratedCode = testGeneratedCode.getRequestGeneratedCode();
CODE_LOGGER.logFile(requestGeneratedCode, FileTypeToLog.REQUEST);
assertTrue(extendsClass(requestName, "AbstractRequest", requestGeneratedCode));
assertTrue(isOfPackage("com.spectralogic.ds3client.commands", requestGeneratedCode));
assertTrue(hasCopyright(requestGeneratedCode));
assertTrue(isReqParamOfType("BucketName", "String", requestName, requestGeneratedCode, false));
assertTrue(isReqParamOfType("ObjectName", "String", requestName, requestGeneratedCode, false));
assertTrue(isReqParamOfType("PartNumber", "int", requestName, requestGeneratedCode, false));
assertTrue(isReqParamOfType("UploadId", "String", requestName, requestGeneratedCode, false));
assertTrue(isReqParamOfType("Stream", "InputStream", requestName, requestGeneratedCode, false));
assertTrue(isOptVariable("Channel", "SeekableByteChannel", requestGeneratedCode));
assertTrue(hasGetter("Channel", "SeekableByteChannel", requestGeneratedCode));
assertFalse(hasImport("com.spectralogic.ds3client.commands.AbstractRequest", requestGeneratedCode));
assertTrue(hasImport("com.spectralogic.ds3client.networking.HttpVerb", requestGeneratedCode));
assertTrue(hasImport("java.util.UUID", requestGeneratedCode));
assertTrue(hasImport("com.google.common.net.UrlEscapers", requestGeneratedCode));
assertTrue(hasImport("com.spectralogic.ds3client.utils.SeekableByteChannelInputStream", requestGeneratedCode));
assertTrue(hasImport("java.nio.channels.SeekableByteChannel", requestGeneratedCode));
assertTrue(hasImport("java.io.InputStream", requestGeneratedCode));
assertTrue(doesNotHaveOperation(requestGeneratedCode));
assertTrue(hasPath("\"/\" + this.bucketName + \"/\" + this.objectName", requestGeneratedCode));
final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();
builder.add(new Arguments("String", "BucketName"));
builder.add(new Arguments("String", "ObjectName"));
builder.add(new Arguments("int", "PartNumber"));
builder.add(new Arguments("long", "Size"));
builder.add(new Arguments("UUID", "UploadId"));
final ImmutableList.Builder<Arguments> channelBuilder = ImmutableList.builder();
channelBuilder.addAll(builder.build());
channelBuilder.add(new Arguments("SeekableByteChannel", "Channel"));
assertTrue(hasConstructor(requestName, channelBuilder.build(), requestGeneratedCode));
assertTrue(hasConstructor(requestName, modifyType(channelBuilder.build(), "UUID", "String"), requestGeneratedCode));
final ImmutableList.Builder<Arguments> streamBuilder = ImmutableList.builder();
streamBuilder.addAll(builder.build());
streamBuilder.add(new Arguments("InputStream", "Stream"));
assertTrue(hasConstructor(requestName, channelBuilder.build(), requestGeneratedCode));
assertTrue(hasConstructor(requestName, modifyType(channelBuilder.build(), "UUID", "String"), 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, "AbstractResponse", responseGeneratedCode));
assertTrue(isOfPackage("com.spectralogic.ds3client.commands", responseGeneratedCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.interfaces.AbstractResponse", responseGeneratedCode));
//Test the Ds3Client
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);
//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." + responseName, responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.parsers.interfaces.AbstractResponseParser", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.networking.WebResponse", responseParserCode));
assertTrue(hasImport("java.io.IOException", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.parsers.utils.ResponseParserUtils", responseParserCode));
final EmptyParseResponse expectedParsing = new EmptyParseResponse(responseName);
assertTrue(responseParserCode.contains(expectedParsing.toJavaCode()));
assertTrue(responseParserCode.contains("private final int[] expectedStatusCodes = new int[]{200};"));
}
use of com.spectralogic.ds3autogen.java.models.parseresponse.EmptyParseResponse in project ds3_autogen by SpectraLogic.
the class JavaFunctionalTests method deleteBucket_Test.
@Test
public void deleteBucket_Test() throws IOException, TemplateModelException {
final String requestName = "DeleteBucketSpectraS3Request";
final FileUtils fileUtils = mock(FileUtils.class);
final TestGeneratedCode testGeneratedCode = new TestGeneratedCode(fileUtils, requestName, "./ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/spectrads3/");
testGeneratedCode.generateCode(fileUtils, "/input/deleteBucket.xml");
final String requestGeneratedCode = testGeneratedCode.getRequestGeneratedCode();
CODE_LOGGER.logFile(requestGeneratedCode, FileTypeToLog.REQUEST);
assertTrue(extendsClass(requestName, "AbstractRequest", requestGeneratedCode));
assertTrue(isReqParamOfType("BucketName", "String", requestName, requestGeneratedCode, false));
assertTrue(isOptParamOfType("Replicate", "boolean", requestName, requestGeneratedCode, false));
assertTrue(isOptParamOfType("Force", "boolean", requestName, requestGeneratedCode, false));
//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, "AbstractResponse", responseGeneratedCode));
//Test the Ds3Client
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);
//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.parsers.interfaces.AbstractResponseParser", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.networking.WebResponse", responseParserCode));
assertTrue(hasImport("java.io.IOException", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.spectrads3.DeleteBucketSpectraS3Response", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.parsers.utils.ResponseParserUtils", responseParserCode));
final EmptyParseResponse expectedParsing = new EmptyParseResponse(responseName);
assertTrue(responseParserCode.contains(expectedParsing.toJavaCode()));
assertTrue(responseParserCode.contains("private final int[] expectedStatusCodes = new int[]{204};"));
}
use of com.spectralogic.ds3autogen.java.models.parseresponse.EmptyParseResponse in project ds3_autogen by SpectraLogic.
the class JavaFunctionalTests method deleteJobCreatedNotificationRegistrationRequestHandler.
@Test
public void deleteJobCreatedNotificationRegistrationRequestHandler() throws IOException, TemplateModelException {
final String requestName = "DeleteJobCreatedNotificationRegistrationSpectraS3Request";
final FileUtils fileUtils = mock(FileUtils.class);
final TestGeneratedCode testGeneratedCode = new TestGeneratedCode(fileUtils, requestName, "./ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/spectrads3/notifications/");
testGeneratedCode.generateCode(fileUtils, "/input/deleteJobCreatedNotificationRegistrationRequestHandler.xml");
final String requestGeneratedCode = testGeneratedCode.getRequestGeneratedCode();
CODE_LOGGER.logFile(requestGeneratedCode, FileTypeToLog.REQUEST);
assertTrue(extendsClass(requestName, "AbstractDeleteNotificationRequest", requestGeneratedCode));
assertTrue(hasPath("\"/_rest_/job_created_notification_registration/\" + this.getNotificationId().toString()", requestGeneratedCode));
assertTrue(isOfPackage("com.spectralogic.ds3client.commands.spectrads3.notifications", requestGeneratedCode));
assertTrue(hasImport("java.util.UUID", requestGeneratedCode));
assertTrue(hasCopyright(requestGeneratedCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.interfaces.AbstractDeleteNotificationRequest", requestGeneratedCode));
final ImmutableList<Arguments> constructorArgs = ImmutableList.of(new Arguments("UUID", "NotificationId"));
assertTrue(hasConstructor(requestName, constructorArgs, requestGeneratedCode));
assertTrue(hasConstructor(requestName, modifyType(constructorArgs, "UUID", "String"), 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, "AbstractResponse", responseGeneratedCode));
assertTrue(isOfPackage("com.spectralogic.ds3client.commands.spectrads3.notifications", responseGeneratedCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.interfaces.AbstractResponse", responseGeneratedCode));
//Test the Ds3Client
final String ds3ClientGeneratedCode = testGeneratedCode.getDs3ClientGeneratedCode();
CODE_LOGGER.logFile(ds3ClientGeneratedCode, FileTypeToLog.CLIENT);
testDs3Client(requestName, ds3ClientGeneratedCode);
assertTrue(ds3ClientGeneratedCode.contains("@Action(\"DELETE\")"));
assertTrue(ds3ClientGeneratedCode.contains("@Resource(\"JOB_CREATED_NOTIFICATION_REGISTRATION\")"));
assertFalse(ds3ClientGeneratedCode.contains("@ResponsePayloadModel("));
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.notifications." + responseName, responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.parsers.interfaces.AbstractResponseParser", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.networking.WebResponse", responseParserCode));
assertTrue(hasImport("java.io.IOException", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.parsers.utils.ResponseParserUtils", responseParserCode));
final EmptyParseResponse expectedParsing = new EmptyParseResponse(responseName);
assertTrue(responseParserCode.contains(expectedParsing.toJavaCode()));
assertTrue(responseParserCode.contains("private final int[] expectedStatusCodes = new int[]{204};"));
}
Aggregations