Search in sources :

Example 71 with FileUtils

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

the class GoFunctionalTypeTests method jobList.

@Test
public void jobList() throws IOException, TemplateModelException {
    final String typeName = "JobList";
    final FileUtils fileUtils = mock(FileUtils.class);
    final GoTestCodeUtil codeGenerator = new GoTestCodeUtil(fileUtils, requestName, typeName);
    codeGenerator.generateCode(fileUtils, "/input/jobListType.xml");
    // Verify response payload type file was generated
    final String typeCode = codeGenerator.getTypeCode();
    CODE_LOGGER.logFile(typeCode, FileTypeToLog.MODEL);
    assertTrue(hasContent(typeCode));
    assertTrue(typeCode.contains("Jobs []Job `xml:\"Job\"`"));
}
Also used : FileUtils(com.spectralogic.ds3autogen.api.FileUtils) GoTestCodeUtil(com.spectralogic.ds3autogen.go.utils.GoTestCodeUtil) Test(org.junit.Test)

Example 72 with FileUtils

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

the class GoFunctionalTypeTests method jobType.

@Test
public void jobType() throws IOException, TemplateModelException {
    final String typeName = "Job";
    final FileUtils fileUtils = mock(FileUtils.class);
    final GoTestCodeUtil codeGenerator = new GoTestCodeUtil(fileUtils, requestName, typeName);
    codeGenerator.generateCode(fileUtils, "/input/jobType.xml");
    // Verify response payload type file was generated
    final String typeCode = codeGenerator.getTypeCode();
    CODE_LOGGER.logFile(typeCode, FileTypeToLog.MODEL);
    assertTrue(hasContent(typeCode));
    assertTrue(typeCode.contains("Aggregating bool `xml:\"Aggregating,attr\"`"));
    assertTrue(typeCode.contains("BucketName *string `xml:\"BucketName,attr\"`"));
    assertTrue(typeCode.contains("CachedSizeInBytes int64 `xml:\"CachedSizeInBytes,attr\"`"));
    assertTrue(typeCode.contains("ChunkClientProcessingOrderGuarantee JobChunkClientProcessingOrderGuarantee `xml:\"ChunkClientProcessingOrderGuarantee,attr\"`"));
    assertTrue(typeCode.contains("CompletedSizeInBytes int64 `xml:\"CompletedSizeInBytes,attr\"`"));
    assertTrue(typeCode.contains("EntirelyInCache bool `xml:\"EntirelyInCache,attr\"`"));
    assertTrue(typeCode.contains("JobId string `xml:\"JobId,attr\"`"));
    assertTrue(typeCode.contains("Naked bool `xml:\"Naked,attr\"`"));
    assertTrue(typeCode.contains("Name *string `xml:\"Name,attr\"`"));
    assertTrue(typeCode.contains("Nodes []JobNode `xml:\"Nodes>Node\"`"));
    assertTrue(typeCode.contains("OriginalSizeInBytes int64 `xml:\"OriginalSizeInBytes,attr\"`"));
    assertTrue(typeCode.contains("Priority Priority `xml:\"Priority,attr\"`"));
    assertTrue(typeCode.contains("RequestType JobRequestType `xml:\"RequestType,attr\"`"));
    assertTrue(typeCode.contains("StartDate string `xml:\"StartDate,attr\"`"));
    assertTrue(typeCode.contains("Status JobStatus `xml:\"Status,attr\"`"));
    assertTrue(typeCode.contains("UserId string `xml:\"UserId,attr\"`"));
    assertTrue(typeCode.contains("UserName *string `xml:\"UserName,attr\"`"));
}
Also used : FileUtils(com.spectralogic.ds3autogen.api.FileUtils) GoTestCodeUtil(com.spectralogic.ds3autogen.go.utils.GoTestCodeUtil) Test(org.junit.Test)

Example 73 with FileUtils

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

the class PythonFunctionalTests method simpleRequest.

@Test
public void simpleRequest() throws IOException, TemplateModelException {
    final String requestName = "SimpleTestRequest";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestPythonGeneratedCode codeGenerator = new TestPythonGeneratedCode(fileUtils);
    codeGenerator.generateCode(fileUtils, "/input/requests/simpleRequest.xml");
    final String ds3Code = codeGenerator.getDs3Code();
    CODE_LOGGER.logFile(ds3Code, FileTypeToLog.REQUEST);
    final ImmutableList<String> reqArgs = ImmutableList.of("bucket_name");
    final ImmutableList<String> optArgs = ImmutableList.of("delimiter", "marker", "max_keys", "prefix");
    final ImmutableList<String> voidArgs = ImmutableList.of("test_void_param");
    hasRequestHandler(requestName, HttpVerb.GET, reqArgs, optArgs, voidArgs, "object_list", ds3Code);
    hasOperation(Operation.START_BULK_PUT, ds3Code);
    //Test Client
    hasClient(ImmutableList.of(requestName), ds3Code);
    //Test static functions present
    assertTrue(ds3Code.contains("def createClientFromEnv():"));
}
Also used : FileUtils(com.spectralogic.ds3autogen.api.FileUtils) TestPythonGeneratedCode(com.spectralogic.ds3autogen.python.utils.TestPythonGeneratedCode) Test(org.junit.Test)

Example 74 with FileUtils

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

the class PythonFunctionalTests method headBucketRequest.

@Test
public void headBucketRequest() throws TemplateModelException, IOException {
    final String requestName = "HeadBucketRequest";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestPythonGeneratedCode codeGenerator = new TestPythonGeneratedCode(fileUtils);
    codeGenerator.generateCode(fileUtils, "/input/requests/headBucketRequest.xml");
    final String ds3Code = codeGenerator.getDs3Code();
    CODE_LOGGER.logFile(ds3Code, FileTypeToLog.REQUEST);
    final ImmutableList<String> reqArgs = ImmutableList.of("bucket_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 75 with FileUtils

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

the class PythonFunctionalTests method namedDetailedTapeList.

@Test
public void namedDetailedTapeList() throws TemplateModelException, IOException {
    final String modelDescriptorName = "NamedDetailedTapeList";
    final FileUtils fileUtils = mock(FileUtils.class);
    final TestPythonGeneratedCode codeGenerator = new TestPythonGeneratedCode(fileUtils);
    codeGenerator.generateCode(fileUtils, "/input/types/namedDetailedTapeList.xml");
    final String ds3Code = codeGenerator.getDs3Code();
    CODE_LOGGER.logFile(ds3Code, FileTypeToLog.MODEL_PARSERS);
    assertTrue(hasContent(ds3Code));
    final ImmutableList<TypeContent> modelContents = ImmutableList.of(new TypeElementList("Tape", "None", "NamedDetailedTape"));
    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)

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