use of com.spectralogic.ds3autogen.java.utils.TestGeneratedCode in project ds3_autogen by SpectraLogic.
the class JavaFunctionalTests method verifyPhysicalPlacementForObjectsRequestHandler_FullDetails.
@Test
public void verifyPhysicalPlacementForObjectsRequestHandler_FullDetails() throws IOException, TemplateModelException {
final String requestName = "VerifyPhysicalPlacementForObjectsWithFullDetailsSpectraS3Request";
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/verifyPhysicalPlacementFullDetailsRequest.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("Objects", "List<Ds3Object>", requestName, requestGeneratedCode, false));
assertTrue(isOptParamOfType("StorageDomainId", "String", requestName, requestGeneratedCode, false));
assertTrue(hasMethod("getStream", "InputStream", Scope.PUBLIC, requestGeneratedCode));
assertTrue(requestGeneratedCode.contains("this.getQueryParams().put(\"full_details\", null)"));
assertFalse(doesConstructorContainParam("FullDetails", "void", requestName, requestGeneratedCode));
assertFalse(isReqVariable("FullDetails", "void", requestGeneratedCode));
assertFalse(hasGetter("FullDetails", "void", requestGeneratedCode));
assertTrue(hasImport("com.spectralogic.ds3client.networking.HttpVerb", requestGeneratedCode));
assertTrue(hasImport("java.util.UUID", requestGeneratedCode));
assertTrue(hasImport("java.util.List", requestGeneratedCode));
assertTrue(hasImport("com.spectralogic.ds3client.models.bulk.Ds3Object", requestGeneratedCode));
assertTrue(hasImport("com.spectralogic.ds3client.models.bulk.Ds3ObjectList", requestGeneratedCode));
assertTrue(hasImport("com.spectralogic.ds3client.serializer.XmlOutput", requestGeneratedCode));
assertTrue(hasImport("java.io.ByteArrayInputStream", requestGeneratedCode));
assertTrue(hasImport("java.io.InputStream", requestGeneratedCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.interfaces.AbstractRequest", requestGeneratedCode));
assertTrue(hasImport("java.nio.charset.Charset", requestGeneratedCode));
assertTrue(isOfPackage("com.spectralogic.ds3client.commands.spectrads3", requestGeneratedCode));
assertFalse(requestGeneratedCode.contains("RestOperationType"));
assertTrue(hasOperation(Operation.VERIFY_PHYSICAL_PLACEMENT, requestGeneratedCode));
assertTrue(hasCopyright(requestGeneratedCode));
assertTrue(hasPath("\"/_rest_/bucket/\" + this.bucketName", requestGeneratedCode));
final ImmutableList<Arguments> constructorArgs = ImmutableList.of(new Arguments("String", "BucketName"), new Arguments("List<Ds3Object>", "Objects"));
assertTrue(hasConstructor(requestName, constructorArgs, 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", responseGeneratedCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.interfaces.AbstractResponse", responseGeneratedCode));
assertTrue(hasImport("com.spectralogic.ds3client.models.BulkObjectList", responseGeneratedCode));
assertTrue(isReqParamOfType("bulkObjectListResult", "BulkObjectList", responseName, responseGeneratedCode, false));
//Test the Ds3Client
final String ds3ClientGeneratedCode = testGeneratedCode.getDs3ClientGeneratedCode();
CODE_LOGGER.logFile(ds3ClientGeneratedCode, FileTypeToLog.CLIENT);
testDs3Client(requestName, ds3ClientGeneratedCode);
assertTrue(ds3ClientGeneratedCode.contains("@ResponsePayloadModel(\"BulkObjectList\")"));
assertTrue(ds3ClientGeneratedCode.contains("@Action(\"SHOW\")"));
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.BulkObjectList", 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, "BulkObjectList");
assertTrue(responseParserCode.contains(expectedParsing.toJavaCode()));
assertTrue(responseParserCode.contains("private final int[] expectedStatusCodes = new int[]{200};"));
}
use of com.spectralogic.ds3autogen.java.utils.TestGeneratedCode 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.utils.TestGeneratedCode in project ds3_autogen by SpectraLogic.
the class JavaFunctionalTests method headObjectRequest.
@Test
public void headObjectRequest() throws IOException, TemplateModelException {
final String requestName = "HeadObjectRequest";
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/headObjectRequest.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));
assertFalse(hasImport("com.spectralogic.ds3client.commands.AbstractRequest", requestGeneratedCode));
assertTrue(hasImport("com.spectralogic.ds3client.networking.HttpVerb", requestGeneratedCode));
assertTrue(doesNotHaveOperation(requestGeneratedCode));
assertTrue(hasPath("\"/\" + this.bucketName + \"/\" + this.objectName", requestGeneratedCode));
final ImmutableList<Arguments> constructorArgs = ImmutableList.of(new Arguments("String", "BucketName"), new Arguments("String", "ObjectName"));
assertTrue(hasConstructor(requestName, constructorArgs, 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));
assertTrue(hasImport("com.spectralogic.ds3client.networking.Metadata", responseGeneratedCode));
assertTrue(isReqParamOfType("metadata", "Metadata", responseName, responseGeneratedCode, false));
assertTrue(isReqParamOfType("objectSize", "long", responseName, responseGeneratedCode, false));
assertTrue(isReqParamOfType("status", "Status", responseName, responseGeneratedCode, false));
assertTrue(responseGeneratedCode.contains("public enum Status { EXISTS, DOESNTEXIST, UNKNOWN }"));
//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." + responseName, responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.parsers.utils.ResponseParserUtils", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.interfaces.MetadataImpl", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.networking.Metadata", responseParserCode));
assertTrue(responseParserCode.contains("import static com.spectralogic.ds3client.commands.parsers.utils.ResponseParserUtils.getSizeFromHeaders;"));
assertTrue(responseParserCode.contains("return new HeadObjectResponse(metadata, objectSize, HeadObjectResponse.Status.EXISTS, this.getChecksum(), this.getChecksumType());"));
assertTrue(responseParserCode.contains("return new HeadObjectResponse(metadata, objectSize, HeadObjectResponse.Status.DOESNTEXIST, this.getChecksum(), this.getChecksumType());"));
assertTrue(responseParserCode.contains("private final int[] expectedStatusCodes = new int[]{200, 404};"));
}
use of com.spectralogic.ds3autogen.java.utils.TestGeneratedCode in project ds3_autogen by SpectraLogic.
the class JavaFunctionalTests method getObjectRequestHandler.
@Test
public void getObjectRequestHandler() 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/getObjectRequestHandler.xml");
final String requestGeneratedCode = testGeneratedCode.getRequestGeneratedCode();
CODE_LOGGER.logFile(requestGeneratedCode, FileTypeToLog.REQUEST);
assertTrue(extendsClass(requestName, "AbstractRequest", requestGeneratedCode));
assertTrue(hasStaticMethod("buildRangeHeaderText", "String", Scope.PRIVATE, requestGeneratedCode));
assertTrue(isOptParamOfType("Job", "String", requestName, requestGeneratedCode, false));
assertTrue(isOptParamOfType("Offset", "long", requestName, requestGeneratedCode, false));
assertTrue(isOptParamOfType("ByteRanges", "Collection<Range>", requestName, requestGeneratedCode, true));
assertTrue(isReqParamOfType("BucketName", "String", requestName, requestGeneratedCode, false));
assertTrue(isReqParamOfType("ObjectName", "String", requestName, requestGeneratedCode, false));
assertTrue(isReqParamOfType("Channel", "WritableByteChannel", requestName, requestGeneratedCode, false));
assertTrue(hasImport("com.google.common.base.Joiner", requestGeneratedCode));
assertTrue(hasImport("com.google.common.collect.ImmutableCollection", requestGeneratedCode));
assertTrue(hasImport("com.google.common.collect.ImmutableList", requestGeneratedCode));
assertTrue(hasImport("com.spectralogic.ds3client.networking.HttpVerb", requestGeneratedCode));
assertTrue(hasImport("com.spectralogic.ds3client.models.common.Range", requestGeneratedCode));
assertTrue(hasImport("org.apache.http.entity.ContentType", requestGeneratedCode));
assertTrue(hasImport("java.io.OutputStream", requestGeneratedCode));
assertTrue(hasImport("java.nio.channels.Channels", requestGeneratedCode));
assertTrue(hasImport("java.nio.channels.WritableByteChannel", requestGeneratedCode));
assertTrue(hasImport("java.util.Collection", requestGeneratedCode));
assertTrue(hasImport("java.util.UUID", requestGeneratedCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.interfaces.AbstractRequest", 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> constructorArgs = ImmutableList.of(new Arguments("String", "BucketName"), new Arguments("String", "ObjectName"), new Arguments("WritableByteChannel", "Channel"));
assertTrue(hasConstructor(requestName, constructorArgs, requestGeneratedCode));
final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();
builder.addAll(constructorArgs);
builder.add(new Arguments("UUID", "Job"));
builder.add(new Arguments("long", "Offset"));
assertTrue(hasConstructor(requestName, builder.build(), requestGeneratedCode));
assertTrue(hasConstructor(requestName, modifyType(builder.build(), "UUID", "String"), requestGeneratedCode));
final ImmutableList<Arguments> streamConstructorArgs = ImmutableList.of(new Arguments("String", "BucketName"), new Arguments("String", "ObjectName"), new Arguments("OutputStream", "Stream"), new Arguments("UUID", "Job"), new Arguments("long", "Offset"));
assertTrue(hasConstructor(requestName, streamConstructorArgs, requestGeneratedCode));
assertTrue(hasConstructor(requestName, modifyType(streamConstructorArgs, "UUID", "String"), requestGeneratedCode));
assertTrue(requestGeneratedCode.contains("this.getQueryParams().put(\"job\", job.toString())"));
assertTrue(requestGeneratedCode.contains("this.getQueryParams().put(\"offset\", Long.toString(offset))"));
//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));
assertTrue(hasImport("com.spectralogic.ds3client.models.ChecksumType", responseGeneratedCode));
assertTrue(hasImport("com.spectralogic.ds3client.networking.Metadata", responseGeneratedCode));
assertTrue(isReqParamOfType("checksum", "String", responseName, responseGeneratedCode, true));
assertTrue(isReqParamOfType("checksumType", "ChecksumType.Type", responseName, responseGeneratedCode, true));
assertTrue(isReqParamOfType("metadata", "Metadata", responseName, responseGeneratedCode, false));
assertTrue(isReqParamOfType("objectSize", "long", responseName, responseGeneratedCode, false));
//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);
assertTrue(ds3ClientImplGeneratedCode.contains("return new GetObjectResponseParser(\n" + " request.getChannel(),\n" + " this.netClient.getConnectionDetails().getBufferSize(),\n" + " request.getObjectName())\n" + " .response(this.netClient.getResponse(request));"));
//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.GetObjectResponse", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.interfaces.MetadataImpl", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.parsers.interfaces.AbstractResponseParser", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.commands.parsers.utils.ResponseParserUtils", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.exceptions.ContentLengthNotMatchException", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.networking.Metadata", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.networking.WebResponse", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.utils.IOUtils", responseParserCode));
assertTrue(hasImport("com.spectralogic.ds3client.utils.PerformanceUtils", responseParserCode));
assertTrue(hasImport("java.io.IOException", responseParserCode));
assertTrue(hasImport("java.io.InputStream", responseParserCode));
assertTrue(hasImport("java.nio.channels.WritableByteChannel", responseParserCode));
assertTrue(responseParserCode.contains("private final int[] expectedStatusCodes = new int[]{200, 206};"));
}
use of com.spectralogic.ds3autogen.java.utils.TestGeneratedCode 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};"));
}
Aggregations