Search in sources :

Example 1 with FileUtils

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

the class PythonFunctionalTests method deleteJobCreatedNotification.

@Test
public void deleteJobCreatedNotification() throws IOException, TemplateModelException {
    final String requestName = "DeleteJobCreatedNotificationRegistrationSpectraS3Request";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestPythonGeneratedCode codeGenerator = new TestPythonGeneratedCode(fileUtils);
    codeGenerator.generateCode(fileUtils, "/input/requests/deleteJobCreatedNotificationRegistrationRequest.xml");
    final String ds3Code = codeGenerator.getDs3Code();
    CODE_LOGGER.logFile(ds3Code, FileTypeToLog.REQUEST);
    final ImmutableList<String> reqArgs = ImmutableList.of("notification_id");
    hasRequestHandler(requestName, HttpVerb.DELETE, reqArgs, null, null, ds3Code);
    assertTrue(ds3Code.contains("self.path = '/_rest_/job_created_notification_registration/' + notification_id"));
    //Test Client
    hasClient(ImmutableList.of(requestName), ds3Code);
}
Also used : FileUtils(com.spectralogic.ds3autogen.api.FileUtils) TestPythonGeneratedCode(com.spectralogic.ds3autogen.python.utils.TestPythonGeneratedCode) Test(org.junit.Test)

Example 2 with FileUtils

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

the class PythonFunctionalTests method headObjectRequest.

@Test
public void headObjectRequest() throws TemplateModelException, IOException {
    final String requestName = "HeadObjectRequest";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestPythonGeneratedCode codeGenerator = new TestPythonGeneratedCode(fileUtils);
    codeGenerator.generateCode(fileUtils, "/input/requests/headObjectRequest.xml");
    final String ds3Code = codeGenerator.getDs3Code();
    CODE_LOGGER.logFile(ds3Code, FileTypeToLog.REQUEST);
    final ImmutableList<String> reqArgs = ImmutableList.of("bucket_name", "object_name");
    hasRequestHandler(requestName, HttpVerb.GET, reqArgs, ImmutableList.of(), ImmutableList.of(), ds3Code);
    hasOperation(Operation.START_BULK_PUT, ds3Code);
    assertTrue(ds3Code.contains("self.__check_status_codes__([200, 403, 404])"));
    assertTrue(ds3Code.contains("self.status_code = self.response.status\n" + "    if self.response.status == 200:\n" + "      self.result = HeadRequestStatus.EXISTS\n" + "    elif self.response.status == 403:\n" + "      self.result = HeadRequestStatus.NOTAUTHORIZED\n" + "    elif self.response.status == 404:\n" + "      self.result = HeadRequestStatus.DOESNTEXIST\n" + "    else:\n" + "      self.result = HeadRequestStatus.UNKNOWN"));
    assertTrue(ds3Code.contains("class HeadRequestStatus(object):"));
    //Test Client
    hasClient(ImmutableList.of(requestName), ds3Code);
}
Also used : FileUtils(com.spectralogic.ds3autogen.api.FileUtils) TestPythonGeneratedCode(com.spectralogic.ds3autogen.python.utils.TestPythonGeneratedCode) Test(org.junit.Test)

Example 3 with FileUtils

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

the class PythonFunctionalTests method jobsApiBean.

@Test
public void jobsApiBean() throws IOException, TemplateModelException {
    final String modelDescriptorName = "JobList";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestPythonGeneratedCode codeGenerator = new TestPythonGeneratedCode(fileUtils);
    codeGenerator.generateCode(fileUtils, "/input/types/jobsApiBean.xml");
    final String ds3Code = codeGenerator.getDs3Code();
    CODE_LOGGER.logFile(ds3Code, FileTypeToLog.MODEL_PARSERS);
    assertTrue(hasContent(ds3Code));
    final ImmutableList<TypeContent> modelContents = ImmutableList.of(new TypeElementList("Job", "None", "Job"));
    hasModelDescriptor(modelDescriptorName, modelContents, ds3Code);
}
Also used : FileUtils(com.spectralogic.ds3autogen.api.FileUtils) TypeContent(com.spectralogic.ds3autogen.python.model.type.TypeContent) TestPythonGeneratedCode(com.spectralogic.ds3autogen.python.utils.TestPythonGeneratedCode) TypeElementList(com.spectralogic.ds3autogen.python.model.type.TypeElementList) Test(org.junit.Test)

Example 4 with FileUtils

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

the class NetCodeGenerator_ModelParsers_Test method jobChunkApiBean_Test.

@Test
public void jobChunkApiBean_Test() throws TemplateModelException, IOException {
    final String typeName = "Objects";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestGenerateCode codeGenerator = new TestGenerateCode(fileUtils, "PlaceHolderRequest", "./Ds3/Calls/", typeName);
    codeGenerator.withIgnorableFiles(fileUtils, ImmutableList.of("./Ds3/Models/BulkObject.cs"));
    codeGenerator.generateCode(fileUtils, "/input/types/jobChunkApiBean.xml");
    final String typeParserCode = codeGenerator.getTypeParser();
    CODE_LOGGER.logFile(typeParserCode, FileTypeToLog.MODEL_PARSERS);
    assertTrue(typeParserCode.contains("public static Objects ParseObjects(XElement element)"));
    assertTrue(typeParserCode.contains("public static Objects ParseNullableObjects(XElement element)"));
    assertTrue(typeParserCode.contains("ChunkId = ParseGuid(element.AttributeText(\"ChunkId\"))"));
    assertTrue(typeParserCode.contains("ChunkNumber = ParseInt(element.AttributeText(\"ChunkNumber\"))"));
    assertTrue(typeParserCode.contains("NodeId = ParseNullableGuid(element.AttributeTextOrNull(\"NodeId\"))"));
    assertTrue(typeParserCode.contains("ObjectsList = element.Elements(\"Object\").Select(ParseBulkObject).ToList()"));
}
Also used : TestGenerateCode(com.spectralogic.ds3autogen.net.utils.TestGenerateCode) FileUtils(com.spectralogic.ds3autogen.api.FileUtils) Test(org.junit.Test)

Example 5 with FileUtils

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

the class NetCodeGenerator_ModelParsers_Test method checksumType_Test.

@Test
public void checksumType_Test() throws IOException, TemplateModelException {
    final String enumName = "ChecksumType";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestGenerateCode codeGenerator = new TestGenerateCode(fileUtils, "PlaceHolderRequest", "./Ds3/Calls/", enumName);
    codeGenerator.generateCode(fileUtils, "/input/modelparsing/modelParsingEnumType.xml");
    final String typeParserCode = codeGenerator.getTypeParser();
    CODE_LOGGER.logFile(typeParserCode, FileTypeToLog.MODEL_PARSERS);
    assertFalse(typeParserCode.contains("AlgorithmName"));
    assertFalse(typeParserCode.contains("HttpHeaderName"));
    assertFalse(parseNullableEnumString(enumName, typeParserCode));
    assertFalse(parseEnumString(enumName, typeParserCode));
    assertFalse(parseNullableEnumElement(enumName, typeParserCode));
    assertFalse(parseEnumElement(enumName, typeParserCode));
}
Also used : TestGenerateCode(com.spectralogic.ds3autogen.net.utils.TestGenerateCode) FileUtils(com.spectralogic.ds3autogen.api.FileUtils) Test(org.junit.Test)

Aggregations

FileUtils (com.spectralogic.ds3autogen.api.FileUtils)113 Test (org.junit.Test)112 Arguments (com.spectralogic.ds3autogen.api.models.Arguments)46 TestGenerateCode (com.spectralogic.ds3autogen.net.utils.TestGenerateCode)34 TestGeneratedCode (com.spectralogic.ds3autogen.java.utils.TestGeneratedCode)30 GoTestCodeUtil (com.spectralogic.ds3autogen.go.utils.GoTestCodeUtil)19 BaseParseResponse (com.spectralogic.ds3autogen.java.models.parseresponse.BaseParseResponse)18 TestGeneratedModelCode (com.spectralogic.ds3autogen.java.utils.TestGeneratedModelCode)11 TestPythonGeneratedCode (com.spectralogic.ds3autogen.python.utils.TestPythonGeneratedCode)10 EmptyParseResponse (com.spectralogic.ds3autogen.java.models.parseresponse.EmptyParseResponse)5 TypeContent (com.spectralogic.ds3autogen.python.model.type.TypeContent)5 TypeElementList (com.spectralogic.ds3autogen.python.model.type.TypeElementList)5 ImmutableList (com.google.common.collect.ImmutableList)4 Ds3DocSpec (com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec)4 Element (com.spectralogic.ds3autogen.java.models.Element)4 TestGeneratedComponentResponseCode (com.spectralogic.ds3autogen.java.utils.TestGeneratedComponentResponseCode)4 Ds3DocSpecImpl (com.spectralogic.ds3autogen.docspec.Ds3DocSpecImpl)3 TypeElement (com.spectralogic.ds3autogen.python.model.type.TypeElement)3 Ds3SpecParserImpl (com.spectralogic.ds3autogen.Ds3SpecParserImpl)2 CodeGenerator (com.spectralogic.ds3autogen.api.CodeGenerator)2