Search in sources :

Example 1 with TestGeneratedComponentResponseCode

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

the class JavaFunctionalTests method getObjectsDetailsRequest_Test.

@Test
public void getObjectsDetailsRequest_Test() throws IOException, TemplateModelException {
    final String requestName = "GetObjectsDetailsSpectraS3Request";
    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/S3ObjectList.java");
    testGeneratedCode.generateCode(fileUtils, "/input/getObjectsDetailsRequestHandler.xml");
    final String requestGeneratedCode = testGeneratedCode.getRequestGeneratedCode();
    CODE_LOGGER.logFile(requestGeneratedCode, FileTypeToLog.REQUEST);
    //Verify that name mapped from GetObjects to GetObjectsDetailsSpectraS3
    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(hasImport("com.spectralogic.ds3client.commands.interfaces.AbstractPaginationResponse", responseGeneratedCode));
    assertTrue(isReqParamOfType("s3ObjectListResult", "S3ObjectList", 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(\"S3ObjectList\")"));
    assertTrue(ds3ClientGeneratedCode.contains("@Action(\"LIST\")"));
    assertTrue(ds3ClientGeneratedCode.contains("@Resource(\"OBJECT\")"));
    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.S3ObjectList", 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, "S3ObjectList", true);
    assertTrue(responseParserCode.contains(expectedParsing.toJavaCode()));
    assertTrue(responseParserCode.contains("private final int[] expectedStatusCodes = new int[]{200};"));
}
Also used : TestGeneratedComponentResponseCode(com.spectralogic.ds3autogen.java.utils.TestGeneratedComponentResponseCode) FileUtils(com.spectralogic.ds3autogen.api.FileUtils) BaseParseResponse(com.spectralogic.ds3autogen.java.models.parseresponse.BaseParseResponse) Test(org.junit.Test)

Example 2 with TestGeneratedComponentResponseCode

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

the class JavaFunctionalTests method getJobCompletedNotificationRegistrationsRequestHandler.

@Test
public void getJobCompletedNotificationRegistrationsRequestHandler() throws IOException, TemplateModelException {
    final String requestName = "GetJobCompletedNotificationRegistrationsSpectraS3Request";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestGeneratedComponentResponseCode testGeneratedCode = new TestGeneratedComponentResponseCode(fileUtils, requestName, "./ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/spectrads3/notifications/", "./ds3-sdk/src/main/java/com/spectralogic/ds3client/models/JobCompletedNotificationRegistrationList.java");
    testGeneratedCode.generateCode(fileUtils, "/input/getJobCompletedNotificationRegistrationsRequestHandler.xml");
    final String requestGeneratedCode = testGeneratedCode.getRequestGeneratedCode();
    CODE_LOGGER.logFile(requestGeneratedCode, FileTypeToLog.REQUEST);
    assertTrue(extendsClass(requestName, "AbstractPaginationRequest", requestGeneratedCode));
    assertTrue(hasPath("\"/_rest_/job_completed_notification_registration\"", requestGeneratedCode));
    assertTrue(isOfPackage("com.spectralogic.ds3client.commands.spectrads3.notifications", requestGeneratedCode));
    assertTrue(hasImport("java.util.UUID", requestGeneratedCode));
    assertTrue(hasImport("com.spectralogic.ds3client.commands.interfaces.AbstractPaginationRequest", requestGeneratedCode));
    assertTrue(isOptParamOfType("LastPage", "boolean", requestName, requestGeneratedCode, false));
    assertTrue(isOptParamOfType("PageLength", "int", requestName, requestGeneratedCode, false));
    assertTrue(isOptParamOfType("PageOffset", "int", requestName, requestGeneratedCode, false));
    assertTrue(isOptParamOfType("PageStartMarker", "String", requestName, requestGeneratedCode, false));
    assertTrue(isOptParamOfType("UserId", "String", requestName, requestGeneratedCode, false));
    assertTrue(hasCopyright(requestGeneratedCode));
    assertFalse(doesConstructorContainParam("Test", "boolean", requestName, requestGeneratedCode));
    assertFalse(isReqVariable("Test", "boolean", requestGeneratedCode));
    assertFalse(hasGetter("Test", "boolean", requestGeneratedCode));
    assertTrue(hasConstructor(requestName, ImmutableList.of(), 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(isOfPackage("com.spectralogic.ds3client.commands.spectrads3.notifications", responseGeneratedCode));
    assertTrue(hasImport("com.spectralogic.ds3client.commands.interfaces.AbstractPaginationResponse", responseGeneratedCode));
    assertTrue(hasImport("com.spectralogic.ds3client.models.JobCompletedNotificationRegistrationList", responseGeneratedCode));
    assertTrue(isReqParamOfType("jobCompletedNotificationRegistrationListResult", "JobCompletedNotificationRegistrationList", 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(\"JobCompletedNotificationRegistrationList\")"));
    assertTrue(ds3ClientGeneratedCode.contains("@Action(\"LIST\")"));
    assertTrue(ds3ClientGeneratedCode.contains("@Resource(\"JOB_COMPLETED_NOTIFICATION_REGISTRATION\")"));
    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.models.JobCompletedNotificationRegistrationList", 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, "JobCompletedNotificationRegistrationList", true);
    assertTrue(responseParserCode.contains(expectedParsing.toJavaCode()));
    assertTrue(responseParserCode.contains("private final int[] expectedStatusCodes = new int[]{200};"));
}
Also used : TestGeneratedComponentResponseCode(com.spectralogic.ds3autogen.java.utils.TestGeneratedComponentResponseCode) FileUtils(com.spectralogic.ds3autogen.api.FileUtils) BaseParseResponse(com.spectralogic.ds3autogen.java.models.parseresponse.BaseParseResponse) Test(org.junit.Test)

Example 3 with TestGeneratedComponentResponseCode

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

the class JavaFunctionalModels_Test method NamedDetailedTapeList_Test.

@Test
public void NamedDetailedTapeList_Test() throws IOException, TemplateModelException {
    final String requestName = "PlaceHolderRequest";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestGeneratedComponentResponseCode testGeneratedCode = new TestGeneratedComponentResponseCode(fileUtils, requestName, "./ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/", "./ds3-sdk/src/main/java/com/spectralogic/ds3client/models/NamedDetailedTapeList.java");
    testGeneratedCode.generateCode(fileUtils, "/input/namedDetailedTapeList.xml");
    final String modelCode = testGeneratedCode.getEncapsulatingTypeGeneratedCode();
    CODE_LOGGER.logFile(modelCode, FileTypeToLog.MODEL);
    assertFalse(modelCode.contains("@JacksonXmlRootElement(namespace = "));
    assertFalse(modelCode.contains("@JsonProperty(\"NamedDetailedTape\")"));
    assertTrue(modelCode.contains("@JsonProperty(\"Tape\")"));
}
Also used : TestGeneratedComponentResponseCode(com.spectralogic.ds3autogen.java.utils.TestGeneratedComponentResponseCode) FileUtils(com.spectralogic.ds3autogen.api.FileUtils) Test(org.junit.Test)

Example 4 with TestGeneratedComponentResponseCode

use of com.spectralogic.ds3autogen.java.utils.TestGeneratedComponentResponseCode 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};"));
}
Also used : TestGeneratedComponentResponseCode(com.spectralogic.ds3autogen.java.utils.TestGeneratedComponentResponseCode) FileUtils(com.spectralogic.ds3autogen.api.FileUtils) BaseParseResponse(com.spectralogic.ds3autogen.java.models.parseresponse.BaseParseResponse) Test(org.junit.Test)

Aggregations

FileUtils (com.spectralogic.ds3autogen.api.FileUtils)4 TestGeneratedComponentResponseCode (com.spectralogic.ds3autogen.java.utils.TestGeneratedComponentResponseCode)4 Test (org.junit.Test)4 BaseParseResponse (com.spectralogic.ds3autogen.java.models.parseresponse.BaseParseResponse)3