Search in sources :

Example 6 with Arguments

use of com.spectralogic.ds3autogen.api.models.Arguments in project ds3_autogen by SpectraLogic.

the class MultipartUploadPayloadGenerator_Test method getPayloadConstructorArgTest.

@Test
public void getPayloadConstructorArgTest() {
    final Arguments result = generator.getPayloadConstructorArg();
    assertThat(result.getName(), is("parts"));
    assertThat(result.getType(), is("[]Part"));
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Test(org.junit.Test)

Example 7 with Arguments

use of com.spectralogic.ds3autogen.api.models.Arguments in project ds3_autogen by SpectraLogic.

the class BaseRequestGenerator_Test method splitGuidConstructor_WithOutUuid_Test.

@Test
public void splitGuidConstructor_WithOutUuid_Test() {
    final ImmutableList<Arguments> args = ImmutableList.of(new Arguments("int", "IntArg"));
    final RequestConstructor constructor = new RequestConstructor(args, args, Operation.ALLOCATE, "My Documentation");
    final ImmutableList<RequestConstructor> result = splitGuidConstructor(constructor);
    assertThat(result.size(), is(1));
    assertTrue(containsType(result.get(0).getConstructorArgs(), "int"));
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) RequestConstructor(com.spectralogic.ds3autogen.net.model.request.RequestConstructor) Test(org.junit.Test)

Example 8 with Arguments

use of com.spectralogic.ds3autogen.api.models.Arguments in project ds3_autogen by SpectraLogic.

the class BaseRequestGenerator_Test method splitGuidConstructor_WithUuid_Test.

@Test
public void splitGuidConstructor_WithUuid_Test() {
    final ImmutableList<Arguments> args = ImmutableList.of(new Arguments("UUID", "UuidArg"));
    final RequestConstructor constructor = new RequestConstructor(args, args, Operation.ALLOCATE, "My Documentation");
    final ImmutableList<RequestConstructor> result = splitGuidConstructor(constructor);
    assertThat(result.size(), is(2));
    assertTrue(containsType(result.get(0).getConstructorArgs(), "UUID"));
    assertFalse(containsType(result.get(1).getConstructorArgs(), "UUID"));
    assertTrue(containsType(result.get(1).getConstructorArgs(), "String"));
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) RequestConstructor(com.spectralogic.ds3autogen.net.model.request.RequestConstructor) Test(org.junit.Test)

Example 9 with Arguments

use of com.spectralogic.ds3autogen.api.models.Arguments in project ds3_autogen by SpectraLogic.

the class NetCodeGenerator_Test method getJobChunksReadyForClientProcessingRequest_Test.

@Test
public void getJobChunksReadyForClientProcessingRequest_Test() throws IOException, TemplateModelException {
    final String requestName = "GetJobChunksReadyForClientProcessingSpectraS3Request";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestGenerateCode codeGenerator = new TestGenerateCode(fileUtils, requestName, "./Ds3/Calls/", "MasterObjectList");
    codeGenerator.generateCode(fileUtils, "/input/getJobChunksRequest.xml");
    final String requestCode = codeGenerator.getRequestCode();
    CODE_LOGGER.logFile(requestCode, FileTypeToLog.REQUEST);
    assertTrue(TestHelper.extendsClass(requestName, "Ds3Request", requestCode));
    assertTrue(TestHelper.hasProperty("Verb", "HttpVerb", requestCode));
    assertTrue(TestHelper.hasProperty("Path", "string", requestCode));
    assertTrue(TestHelper.hasRequiredParam("Job", "string", requestCode));
    final ImmutableList<Arguments> constructorArgs = ImmutableList.of(new Arguments("Guid", "Job"));
    assertTrue(TestHelper.hasConstructor(requestName, constructorArgs, requestCode));
    assertTrue(TestHelper.hasConstructor(requestName, modifyType(constructorArgs, "Guid", "string"), requestCode));
    //Generate Client code
    final String commandName = requestName.replace("Request", "");
    final String clientCode = codeGenerator.getClientCode();
    CODE_LOGGER.logFile(clientCode, FileTypeToLog.CLIENT);
    assertTrue(TestHelper.hasPayloadCommand(commandName, clientCode));
    final String idsClientCode = codeGenerator.getIdsClientCode();
    CODE_LOGGER.logFile(idsClientCode, FileTypeToLog.CLIENT);
    assertTrue(TestHelper.hasIDsCommand(commandName, idsClientCode));
    //Generate Responses
    final String responseCode = codeGenerator.getResponseCode();
    CODE_LOGGER.logFile(responseCode, FileTypeToLog.RESPONSE);
    final String responsePayloadType = "Objects";
    assertFalse(TestHelper.hasRequiredParam("ResponsePayload", responsePayloadType, responseCode));
    //Generate Parser
    final String parserCode = codeGenerator.getParserCode();
    CODE_LOGGER.logFile(parserCode, FileTypeToLog.PARSER);
    assertTrue(hasContent(parserCode));
    assertFalse(parserHasResponseCode(200, parserCode));
    assertTrue(parserHasPayload("MasterObjectList", "MasterObjectList", parserCode));
}
Also used : TestGenerateCode(com.spectralogic.ds3autogen.net.utils.TestGenerateCode) FileUtils(com.spectralogic.ds3autogen.api.FileUtils) Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Test(org.junit.Test)

Example 10 with Arguments

use of com.spectralogic.ds3autogen.api.models.Arguments in project ds3_autogen by SpectraLogic.

the class NetCodeGenerator_Test method CreatePutJobRequest_Test.

@Test
public void CreatePutJobRequest_Test() throws IOException, TemplateModelException {
    final String requestName = "PutBulkJobSpectraS3Request";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestGenerateCode codeGenerator = new TestGenerateCode(fileUtils, requestName, "./Ds3/Calls/", "MasterObjectList");
    codeGenerator.generateCode(fileUtils, "/input/createPutJobRequest.xml");
    //Generate Request code
    final String requestCode = codeGenerator.getRequestCode();
    CODE_LOGGER.logFile(requestCode, FileTypeToLog.REQUEST);
    assertTrue(TestHelper.extendsClass(requestName, "Ds3Request", requestCode));
    assertTrue(TestHelper.hasProperty("Verb", "HttpVerb", requestCode));
    assertTrue(TestHelper.hasProperty("Path", "string", requestCode));
    assertTrue(TestHelper.hasRequiredParam("BucketName", "string", requestCode));
    assertTrue(TestHelper.hasRequiredParam("Objects", "IEnumerable<Ds3Object>", requestCode));
    assertTrue(TestHelper.hasRequiredParam("MaxUploadSize", "long?", requestCode));
    final ImmutableList<Arguments> constructorArgs = ImmutableList.of(new Arguments("String", "BucketName"), new Arguments("IEnumerable<Ds3Object>", "Objects"));
    assertTrue(TestHelper.hasConstructor(requestName, constructorArgs, requestCode));
    assertTrue(requestCode.contains("this.QueryParams.Add(\"operation\", \"start_bulk_put\");"));
    //Generate Client code
    final String commandName = requestName.replace("Request", "");
    final String clientCode = codeGenerator.getClientCode();
    CODE_LOGGER.logFile(clientCode, FileTypeToLog.CLIENT);
    assertTrue(TestHelper.hasPayloadCommand(commandName, clientCode));
    final String idsClientCode = codeGenerator.getIdsClientCode();
    CODE_LOGGER.logFile(idsClientCode, FileTypeToLog.CLIENT);
    assertTrue(TestHelper.hasIDsCommand(commandName, idsClientCode));
    //Generate Responses
    final String responseCode = codeGenerator.getResponseCode();
    CODE_LOGGER.logFile(responseCode, FileTypeToLog.RESPONSE);
    final String responseName = NormalizingContractNamesUtil.toResponseName(requestName);
    final String responsePayloadType = "MasterObjectList";
    assertTrue(TestHelper.hasConstructor(responseName, ImmutableList.of(new Arguments(responsePayloadType, "ResponsePayload")), responseCode));
    assertTrue(TestHelper.hasRequiredParam("ResponsePayload", responsePayloadType, responseCode));
    //Generate Parser
    final String parserCode = codeGenerator.getParserCode();
    CODE_LOGGER.logFile(parserCode, FileTypeToLog.PARSER);
    assertTrue(parserCode.contains("ResponseParseUtilities.HandleStatusCode(response, (HttpStatusCode)200, HttpStatusCode.ServiceUnavailable)"));
    assertTrue(parserHasPayload("MasterObjectList", "MasterObjectList", parserCode));
}
Also used : TestGenerateCode(com.spectralogic.ds3autogen.net.utils.TestGenerateCode) FileUtils(com.spectralogic.ds3autogen.api.FileUtils) Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Test(org.junit.Test)

Aggregations

Arguments (com.spectralogic.ds3autogen.api.models.Arguments)188 Test (org.junit.Test)144 FileUtils (com.spectralogic.ds3autogen.api.FileUtils)46 ImmutableList (com.google.common.collect.ImmutableList)40 RequestConstructor (com.spectralogic.ds3autogen.java.models.RequestConstructor)33 Ds3Request (com.spectralogic.ds3autogen.api.models.apispec.Ds3Request)25 Ds3DocSpecEmptyImpl (com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl)25 TestGeneratedCode (com.spectralogic.ds3autogen.java.utils.TestGeneratedCode)25 TestGenerateCode (com.spectralogic.ds3autogen.net.utils.TestGenerateCode)21 QueryParam (com.spectralogic.ds3autogen.java.models.QueryParam)19 Helper.removeVoidArguments (com.spectralogic.ds3autogen.utils.Helper.removeVoidArguments)15 BaseParseResponse (com.spectralogic.ds3autogen.java.models.parseresponse.BaseParseResponse)14 RequestGeneratorTestHelper.createSimpleTestDs3Request (com.spectralogic.ds3autogen.java.test.helpers.RequestGeneratorTestHelper.createSimpleTestDs3Request)13 Ds3Param (com.spectralogic.ds3autogen.api.models.apispec.Ds3Param)9 GuavaCollectors (com.spectralogic.ds3autogen.utils.collections.GuavaCollectors)8 CustomArgumentComparator (com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator)8 ConstructorParam (com.spectralogic.ds3autogen.python.model.request.ConstructorParam)7 Helper.camelToUnderscore (com.spectralogic.ds3autogen.utils.Helper.camelToUnderscore)7 RequestConverterUtil.getNonVoidArgsFromParamList (com.spectralogic.ds3autogen.utils.RequestConverterUtil.getNonVoidArgsFromParamList)6 Ds3ResponseType (com.spectralogic.ds3autogen.api.models.apispec.Ds3ResponseType)5