use of com.spectralogic.ds3autogen.api.FileUtils in project ds3_autogen by SpectraLogic.
the class JavaFunctionalModels_Test method emptyType.
@Test(expected = IllegalArgumentException.class)
public void emptyType() throws IOException, TemplateModelException {
final String modelName = "EmptyType";
final FileUtils fileUtils = mock(FileUtils.class);
final TestGeneratedModelCode testGeneratedModelCode = new TestGeneratedModelCode(fileUtils, modelName, "./ds3-sdk/src/main/java/com/spectralogic/ds3client/models/");
testGeneratedModelCode.generateCode(fileUtils, "/input/emptyType.xml");
}
use of com.spectralogic.ds3autogen.api.FileUtils in project ds3_autogen by SpectraLogic.
the class JavaFunctionalModels_Test method requestType.
@Test
public void requestType() throws IOException, TemplateModelException {
final String modelName = "RequestType";
final FileUtils fileUtils = mock(FileUtils.class);
final TestGeneratedModelCode testGeneratedModelCode = new TestGeneratedModelCode(fileUtils, modelName, "./ds3-sdk/src/main/java/com/spectralogic/ds3client/models/");
testGeneratedModelCode.generateCode(fileUtils, "/input/requestType.xml");
final String modelGeneratedCode = testGeneratedModelCode.getModelGeneratedCode();
CODE_LOGGER.logFile(modelGeneratedCode, FileTypeToLog.MODEL);
assertTrue(hasCopyright(modelGeneratedCode));
assertTrue(isOfPackage("com.spectralogic.ds3client.models", modelGeneratedCode));
assertTrue(TestHelper.isEnumClass(modelName, modelGeneratedCode));
assertTrue(TestHelper.enumContainsValue("DELETE", modelGeneratedCode));
assertTrue(TestHelper.enumContainsValue("GET", modelGeneratedCode));
assertTrue(TestHelper.enumContainsValue("HEAD", modelGeneratedCode));
assertTrue(TestHelper.enumContainsValue("POST", modelGeneratedCode));
assertTrue(TestHelper.enumContainsValue("PUT", modelGeneratedCode));
}
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);
}
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);
}
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);
}
Aggregations