Skip to content

Commit 725ee77

Browse files
committed
20230420 update: add test data and xml controller.
1 parent eff1abf commit 725ee77

File tree

7 files changed

+296
-14
lines changed

7 files changed

+296
-14
lines changed

TestData/Template.xlsx

9.58 KB
Binary file not shown.

TestData/data.xml

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "asposecellscloud",
3-
"version": "23.3",
3+
"version": "23.4",
44
"description": "Aspose.Cells Cloud SDK for Node.js",
55
"keywords": [
66
"Aspose",
@@ -19,7 +19,7 @@
1919
"main": "dist/api.js",
2020
"types": "dist/api.d.ts",
2121
"scripts": {
22-
"test": "cross-env JUNIT_REPORT_PATH=integration_tests_result.xml mocha -r ts-node/register test/**/*.ts --timeout 250000 --reporter mocha-jenkins-reporter",
22+
"test": "cross-env JUNIT_REPORT_PATH=integration_tests_result.xml mocha -r ts-node/register test/Api/tests_one.ts --timeout 250000 --reporter mocha-jenkins-reporter",
2323
"test-jenkins": "cross-env JUNIT_REPORT_PATH=reports/integration_tests_result.xml mocha -r ts-node/register test/**/*.ts --timeout 250000 --reporter mocha-jenkins-reporter",
2424
"lint": "tslint src/{,**/}*.ts test/{,**/}*.ts -t verbose --project ./tsconfig.json",
2525
"cucumber": "cucumber-js ./bdd/features -r ./dist/bdd/steps",

src/api.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4550,6 +4550,35 @@ export class CellsApi {
45504550
const result = ObjectSerializer.deserialize(response.body, "CellsCloudResponse");
45514551
return Promise.resolve({body: result, response});
45524552
}
4553+
/// <summary>
4554+
/// </summary>
4555+
/// <param name="request">Request. <see cref="PostWorkbookExportXMLRequest" /></param>
4556+
public async postWorkbookExportXML(requestObj:model.PostWorkbookExportXMLRequest ): Promise<{response: http.ClientResponse, body: Buffer}>
4557+
{
4558+
if (requestObj === null || requestObj === undefined) {
4559+
throw new Error('Required parameter "requestObj" was null or undefined when calling postWorkbookExportXML.');
4560+
}
4561+
4562+
const requestOptions = await requestObj.createRequestOptions(this.configuration);
4563+
const response = await invokeApiMethod(requestOptions, this.configuration);
4564+
const result = ObjectSerializer.deserialize(response.body, "Buffer");
4565+
return Promise.resolve({body: result, response});
4566+
}
4567+
4568+
/// <summary>
4569+
/// </summary>
4570+
/// <param name="request">Request. <see cref="PostWorkbookImportXMLRequest" /></param>
4571+
public async postWorkbookImportXML(requestObj:model.PostWorkbookImportXMLRequest ): Promise<{response: http.ClientResponse, body: Buffer}>
4572+
{
4573+
if (requestObj === null || requestObj === undefined) {
4574+
throw new Error('Required parameter "requestObj" was null or undefined when calling postWorkbookImportXML.');
4575+
}
4576+
4577+
const requestOptions = await requestObj.createRequestOptions(this.configuration);
4578+
const response = await invokeApiMethod(requestOptions, this.configuration);
4579+
const result = ObjectSerializer.deserialize(response.body, "Buffer");
4580+
return Promise.resolve({body: result, response});
4581+
}
45534582

45544583
/// <summary>
45554584
/// </summary>

src/model/model.ts

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3695,6 +3695,79 @@ export class PageSection {
36953695
}
36963696
}
36973697

3698+
3699+
export class ImportPosition {
3700+
/**
3701+
* Attribute type map
3702+
*/
3703+
public static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
3704+
{
3705+
name: "sheetName",
3706+
baseName: "SheetName",
3707+
type: "string",
3708+
},
3709+
{
3710+
name: "rowIndex",
3711+
baseName: "RowIndex",
3712+
type: "number",
3713+
},
3714+
{
3715+
name: "columnIndex",
3716+
baseName: "ColumnIndex",
3717+
type: "number",
3718+
}
3719+
];
3720+
/**
3721+
* Returns attribute type map
3722+
*/
3723+
public static getAttributeTypeMap() {
3724+
return ImportPosition.attributeTypeMap;
3725+
3726+
}
3727+
3728+
public sheetName: string;
3729+
public rowIndex: number;
3730+
public columnIndex: number;
3731+
3732+
public constructor(init?: Partial< ImportPosition >) {
3733+
3734+
Object.assign(this, init);
3735+
}
3736+
}
3737+
3738+
export class ImportXMLRequest {
3739+
/**
3740+
* Attribute type map
3741+
*/
3742+
public static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
3743+
{
3744+
name: "xMLFileSource",
3745+
baseName: "XMLFileSource",
3746+
type: "FileSource",
3747+
},
3748+
{
3749+
name: "importPosition",
3750+
baseName: "ImportPosition",
3751+
type: "ImportPosition",
3752+
}
3753+
];
3754+
/**
3755+
* Returns attribute type map
3756+
*/
3757+
public static getAttributeTypeMap() {
3758+
return ImportXMLRequest.attributeTypeMap;
3759+
3760+
}
3761+
3762+
public xMLFileSource: FileSource;
3763+
public importPosition: ImportPosition;
3764+
3765+
public constructor(init?: Partial< ImportXMLRequest >) {
3766+
3767+
Object.assign(this, init);
3768+
}
3769+
}
3770+
36983771
/**
36993772
* Used for password data transfer.
37003773
*/
@@ -16685,6 +16758,7 @@ const typeMap = {
1668516758
Link,
1668616759
LinkElement,
1668716760
ListColumn,
16761+
ImportXMLRequest,
1668816762
MatchConditionRequest,
1668916763
MultipleFilter,
1669016764
MultipleFilters,
@@ -16795,6 +16869,7 @@ const typeMap = {
1679516869
ImportDoubleArrayOption,
1679616870
ImportIntArrayOption,
1679716871
ImportPictureOption,
16872+
ImportPosition,
1679816873
ImportStringArrayOption,
1679916874
JsonSaveOptions,
1680016875
LegendResponse,
@@ -40577,6 +40652,102 @@ export class DeleteWorksheetValidationsRequest {
4057740652
}
4057840653

4057940654
}
40655+
40656+
export class PostWorkbookExportXMLRequest {
40657+
40658+
public name: string;
40659+
40660+
public password: string;
40661+
40662+
public folder: string;
40663+
40664+
public storageName: string;
40665+
40666+
public outPath: string;
40667+
40668+
public outStorageName: string;
40669+
40670+
public checkExcelRestriction: boolean;
40671+
40672+
public constructor(init?: Partial< PostWorkbookExportXMLRequest >) {
40673+
Object.assign(this, init);
40674+
}
40675+
40676+
public async createRequestOptions(configuration: Configuration) : Promise<request.Options> {
40677+
40678+
let localVarPath = configuration.getApiBaseUrl() + "/cells/{name}/exportxml".replace("{" + "name" + "}", String(this.name));
40679+
const queryParameters: any = {};
40680+
localVarPath = addQueryParameterToUrl(localVarPath, queryParameters, "password", this.password);
40681+
localVarPath = addQueryParameterToUrl(localVarPath, queryParameters, "folder", this.folder);
40682+
localVarPath = addQueryParameterToUrl(localVarPath, queryParameters, "storageName", this.storageName);
40683+
localVarPath = addQueryParameterToUrl(localVarPath, queryParameters, "outPath", this.outPath);
40684+
localVarPath = addQueryParameterToUrl(localVarPath, queryParameters, "outStorageName", this.outStorageName);
40685+
localVarPath = addQueryParameterToUrl(localVarPath, queryParameters, "checkExcelRestriction", this.checkExcelRestriction);
40686+
40687+
40688+
const bodyParameter = null;
40689+
40690+
const requestOptions: request.Options = {
40691+
method: "POST",
40692+
qs: queryParameters,
40693+
uri: localVarPath,
40694+
json: true,
40695+
};
40696+
40697+
return Promise.resolve(requestOptions);
40698+
40699+
}
40700+
40701+
}
40702+
40703+
export class PostWorkbookImportXMLRequest {
40704+
40705+
public name: string;
40706+
40707+
public importXMLRequest: ImportXMLRequest;
40708+
40709+
public password: string;
40710+
40711+
public folder: string;
40712+
40713+
public storageName: string;
40714+
40715+
public outPath: string;
40716+
40717+
public outStorageName: string;
40718+
40719+
public checkExcelRestriction: boolean;
40720+
40721+
public constructor(init?: Partial< PostWorkbookImportXMLRequest >) {
40722+
Object.assign(this, init);
40723+
}
40724+
40725+
public async createRequestOptions(configuration: Configuration) : Promise<request.Options> {
40726+
40727+
let localVarPath = configuration.getApiBaseUrl() + "/cells/{name}/importxml".replace("{" + "name" + "}", String(this.name));
40728+
const queryParameters: any = {};
40729+
localVarPath = addQueryParameterToUrl(localVarPath, queryParameters, "password", this.password);
40730+
localVarPath = addQueryParameterToUrl(localVarPath, queryParameters, "folder", this.folder);
40731+
localVarPath = addQueryParameterToUrl(localVarPath, queryParameters, "storageName", this.storageName);
40732+
localVarPath = addQueryParameterToUrl(localVarPath, queryParameters, "outPath", this.outPath);
40733+
localVarPath = addQueryParameterToUrl(localVarPath, queryParameters, "outStorageName", this.outStorageName);
40734+
localVarPath = addQueryParameterToUrl(localVarPath, queryParameters, "checkExcelRestriction", this.checkExcelRestriction);
40735+
40736+
40737+
const bodyParameter = (this.importXMLRequest == null) ? null : ObjectSerializer.serialize( this.importXMLRequest,this.importXMLRequest.constructor.name);
40738+
const requestOptions: request.Options = {
40739+
method: "POST",
40740+
qs: queryParameters,
40741+
uri: localVarPath,
40742+
json: true,
40743+
body:bodyParameter,
40744+
};
40745+
40746+
return Promise.resolve(requestOptions);
40747+
40748+
}
40749+
40750+
}
4058040751

4058140752
export class DownloadFileRequest {
4058240753

test/Api/tests_one.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ var assert = require('assert');
1717
describe('PicturesController test', function() {
1818
this.timeout(200000);
1919
const cellsApi = new api.CellsApi(clientId, clientSecret,"v3.0",ApiURL);
20-
describe('post_update_worksheet_range_style test', function(){
21-
it("should call PostUpdateWorksheetRangeStyle successfully" , function(){
20+
describe('post_worksheet_chart_title test', function(){
21+
it("should call PostWorksheetChartTitle successfully" , function(){
2222
var remoteFolder = "TestData/In"
2323

2424
var localName = "Book1.xlsx"
@@ -30,21 +30,19 @@ describe('PicturesController test', function() {
3030
localNameRequest.storageName ="";
3131
cellsApi.uploadFile(localNameRequest );
3232

33-
var styleFont = new model.Font();
34-
styleFont.size = 16 ;
35-
var style = new model.Style();
36-
style.font = styleFont ;
33+
var title = new model.Title();
34+
title.isVisible = true ;
3735

38-
var request = new model.PostUpdateWorksheetRangeStyleRequest();
36+
var request = new model.PostWorksheetChartTitleRequest();
3937
request.name = remoteName;
40-
request.sheetName = "Sheet1";
41-
request.range = "A1:C10";
42-
request.style = style;
38+
request.sheetName = "Sheet4";
39+
request.chartIndex = 0;
40+
request.title = title;
4341
request.folder = remoteFolder;
4442
request.storageName = "";
45-
return cellsApi.postUpdateWorksheetRangeStyle(request).then((result) => {
43+
return cellsApi.postWorksheetChartTitle(request).then((result) => {
4644
expect(result.response.statusCode).to.equal(200);
4745
});
4846
});
49-
});
47+
});
5048
});

test/Api/tests_xml_controller.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import { expect } from "chai";
2+
import "mocha";
3+
4+
import * as model from "../../src/model/model";
5+
import * as api from "../../src/api";
6+
const clientId = process.env.CellsCloudTestClientId;
7+
const clientSecret = process.env.CellsCloudTestClientSecret;
8+
const ApiURL = process.env.CellsCloudTestApiBaseUrl;
9+
10+
const localPath = "TestData/";
11+
12+
var fs = require('fs');
13+
var path = require('path');
14+
var assert = require('assert');
15+
16+
17+
describe('XmlController test', function() {
18+
this.timeout(200000);
19+
const cellsApi = new api.CellsApi(clientId, clientSecret,"v3.0",ApiURL);
20+
21+
describe('post_workbook_export_xml test', function(){
22+
it("should call PostWorkbookExportXML successfully" , function(){
23+
var remoteFolder = "TestData/In"
24+
25+
var localName = "Template.xlsx"
26+
var remoteName = "Template.xlsx"
27+
28+
var localNameRequest = new model.UploadFileRequest();
29+
localNameRequest.uploadFiles ={localName:fs.createReadStream(localPath + localName)};
30+
localNameRequest.path = remoteFolder + "/" + remoteName ;
31+
localNameRequest.storageName ="";
32+
cellsApi.uploadFile(localNameRequest );
33+
34+
35+
var request = new model.PostWorkbookExportXMLRequest();
36+
request.name = remoteName;
37+
request.folder = remoteFolder;
38+
request.storageName = "";
39+
return cellsApi.postWorkbookExportXML(request).then((result) => {
40+
expect(result.response.statusCode).to.equal(200);
41+
});
42+
});
43+
});
44+
describe('post_workbook_import_xml test', function(){
45+
it("should call PostWorkbookImportXML successfully" , function(){
46+
var remoteFolder = "TestData/In"
47+
48+
var localName = "Template.xlsx"
49+
var dataXML = "data.xml"
50+
var remoteName = "Template.xlsx"
51+
52+
var localNameRequest = new model.UploadFileRequest();
53+
localNameRequest.uploadFiles ={localName:fs.createReadStream(localPath + localName)};
54+
localNameRequest.path = remoteFolder + "/" + remoteName ;
55+
localNameRequest.storageName ="";
56+
cellsApi.uploadFile(localNameRequest );
57+
var dataXMLRequest = new model.UploadFileRequest();
58+
dataXMLRequest.uploadFiles ={dataXML:fs.createReadStream(localPath + dataXML)};
59+
dataXMLRequest.path = remoteFolder + "/data.xml" ;
60+
dataXMLRequest.storageName ="";
61+
cellsApi.uploadFile(dataXMLRequest );
62+
63+
var importXMLRequestXMLFileSource = new model.FileSource();
64+
importXMLRequestXMLFileSource.fileSourceType = "CloudFileSystem" ;
65+
importXMLRequestXMLFileSource.filePath = remoteFolder + "/data.xml" ;
66+
var importXMLRequestImportPosition = new model.ImportPosition();
67+
importXMLRequestImportPosition.sheetName = "Sheet1" ;
68+
importXMLRequestImportPosition.rowIndex = 3 ;
69+
importXMLRequestImportPosition.columnIndex = 4 ;
70+
var importXMLRequest = new model.ImportXMLRequest();
71+
importXMLRequest.xMLFileSource = importXMLRequestXMLFileSource ;
72+
importXMLRequest.importPosition = importXMLRequestImportPosition ;
73+
74+
var request = new model.PostWorkbookImportXMLRequest();
75+
request.name = remoteName;
76+
request.folder = remoteFolder;
77+
request.storageName = "";
78+
return cellsApi.postWorkbookImportXML(request).then((result) => {
79+
expect(result.response.statusCode).to.equal(200);
80+
});
81+
});
82+
});
83+
});

0 commit comments

Comments
 (0)