11require ( '../../../src/common/iServer/InterpolationAnalystService' ) ;
2+ require ( '../../../src/common/util/FetchRequest' ) ;
23var request = require ( 'request' ) ;
34
45var serviceFailedEventArgsSystem = null ;
@@ -32,10 +33,11 @@ describe('InterpolationAnalystService', function () {
3233 jasmine . DEFAULT_TIMEOUT_INTERVAL = originalTimeout ;
3334 } ) ;
3435
35- var resultDataset_RBFByDS = "Interpolation_RBFByDS_commonTest" ;
3636 //数据集 样条插值(径向基函数插值法)分析
3737 it ( 'InterpolationRBFAnalyst_dataset' , function ( done ) {
38- var interpolationAnalystService = initInterpolationAnalystService ( ) ;
38+ var url = "http://supermapiserver:8090/iserver/services/spatialanalyst-sample/restjsr/spatialanalyst" ;
39+ var resultDataset_RBFByDS = "Interpolation_RBFByDS_commonTest" ;
40+ var interpolationAnalystService = new SuperMap . InterpolationAnalystService ( url , options ) ;
3941 expect ( interpolationAnalystService ) . not . toBeNull ( ) ;
4042 expect ( interpolationAnalystService . url ) . toEqual ( url ) ;
4143 var interpolationRBFAnalystParameters = new SuperMap . InterpolationRBFAnalystParameters ( {
@@ -53,39 +55,32 @@ describe('InterpolationAnalystService', function () {
5355 } ,
5456 outputDatasetName : resultDataset_RBFByDS
5557 } ) ;
56- interpolationAnalystService . processAsync ( interpolationRBFAnalystParameters ) ;
58+ var FetchRequest = SuperMap . FetchRequest ;
59+ spyOn ( FetchRequest , 'commit' ) . and . callFake ( function ( ) {
60+ var escapedJson = "{\"succeed\":true,\"recordset\":null,\"message\":null,\"dataset\":\"Interpolation_RBFByDS_commonTest@Interpolation\"}" ;
61+ return Promise . resolve ( new Response ( escapedJson ) ) ;
62+ } ) ;
5763 interpolationAnalystService . events . on ( { "processCompleted" : analyzeCompleted } ) ;
64+ interpolationAnalystService . processAsync ( interpolationRBFAnalystParameters ) ;
5865 setTimeout ( function ( ) {
59- try {
60- expect ( analystEventArgsSystem . type ) . toEqual ( "processCompleted" ) ;
61- var serviceResult = analystEventArgsSystem . result ;
62- expect ( serviceResult ) . not . toBeNull ( ) ;
63- expect ( serviceResult . succeed ) . toBeTruthy ( ) ;
64- expect ( serviceResult . dataset ) . toContain ( resultDataset_RBFByDS ) ;
65- expect ( serviceResult . dataset ) . toContain ( "@Interpolation" ) ;
66- interpolationAnalystService . destroy ( ) ;
67- interpolationRBFAnalystParameters . destroy ( ) ;
68- done ( ) ;
69- } catch ( e ) {
70- expect ( false ) . toBeTruthy ( ) ;
71- console . log ( "InterpolationRBFAnalyst_dataset" + e . name + ":" + e . message ) ;
72- interpolationAnalystService . destroy ( ) ;
73- interpolationRBFAnalystParameters . destroy ( ) ;
74- done ( ) ;
75- }
76- } , 10000 ) ;
77- } ) ;
78- // 删除测试过程中产生的数据集
79- it ( 'delete test resources_RBFByDS' , function ( done ) {
80- var testResult_RBFByDS = GlobeParameter . dataspatialAnalystURL + resultDataset_RBFByDS ;
81- request . delete ( testResult_RBFByDS ) ;
82- done ( ) ;
66+ expect ( analystEventArgsSystem . type ) . toEqual ( "processCompleted" ) ;
67+ var serviceResult = analystEventArgsSystem . result ;
68+ expect ( serviceResult ) . not . toBeNull ( ) ;
69+ expect ( serviceResult . succeed ) . toBeTruthy ( ) ;
70+ expect ( serviceResult . recordset ) . toBeNull ( ) ;
71+ expect ( serviceResult . dataset ) . toContain ( resultDataset_RBFByDS ) ;
72+ expect ( serviceResult . dataset ) . toContain ( "@Interpolation" ) ;
73+ interpolationAnalystService . destroy ( ) ;
74+ interpolationRBFAnalystParameters . destroy ( ) ;
75+ done ( ) ;
76+ } , 1000 ) ;
8377 } ) ;
8478
85- var resultDataset_densityByDS = "Interpolation_densityByDS_commonTest" ;
8679 //数据集 点密度插值分析
8780 it ( 'InterpolationDensityAnalyst_dataset' , function ( done ) {
88- var interpolationAnalystService = initInterpolationAnalystService ( ) ;
81+ var url = "http://supermapiserver:8090/iserver/services/spatialanalyst-sample/restjsr/spatialanalyst" ;
82+ var resultDataset_densityByDS = "Interpolation_densityByDS_commonTest" ;
83+ var interpolationAnalystService = new SuperMap . InterpolationAnalystService ( url , options ) ;
8984 expect ( interpolationAnalystService ) . not . toBeNull ( ) ;
9085 expect ( interpolationAnalystService . url ) . toEqual ( url ) ;
9186 var interpolationDensityAnalystParameters = new SuperMap . InterpolationDensityAnalystParameters ( {
@@ -99,35 +94,28 @@ describe('InterpolationAnalystService', function () {
9994 } ,
10095 outputDatasetName : resultDataset_densityByDS
10196 } ) ;
102- interpolationAnalystService . processAsync ( interpolationDensityAnalystParameters ) ;
97+ var FetchRequest = SuperMap . FetchRequest ;
98+ spyOn ( FetchRequest , 'commit' ) . and . callFake ( function ( ) {
99+ var escapedJson = "{\"succeed\":true,\"recordset\":null,\"message\":null,\"dataset\":\"Interpolation_densityByDS_commonTest@Interpolation\"}" ;
100+ return Promise . resolve ( new Response ( escapedJson ) ) ;
101+ } ) ;
103102 interpolationAnalystService . events . on ( { "processCompleted" : analyzeCompleted } ) ;
103+ interpolationAnalystService . processAsync ( interpolationDensityAnalystParameters ) ;
104104 setTimeout ( function ( ) {
105- try {
106- expect ( analystEventArgsSystem . type ) . toEqual ( "processCompleted" ) ;
107- var serviceResult = analystEventArgsSystem . result ;
108- expect ( serviceResult ) . not . toBeNull ( ) ;
109- expect ( serviceResult . succeed ) . toBeTruthy ( ) ;
110- expect ( serviceResult . dataset ) . toContain ( resultDataset_densityByDS ) ;
111- expect ( serviceResult . dataset ) . toContain ( "@Interpolation" ) ;
112- interpolationAnalystService . destroy ( ) ;
113- interpolationDensityAnalystParameters . destroy ( ) ;
114- done ( ) ;
115- } catch ( e ) {
116- expect ( false ) . toBeTruthy ( ) ;
117- console . log ( "InterpolationDensityAnalyst_dataset" + e . name + ":" + e . message ) ;
118- interpolationAnalystService . destroy ( ) ;
119- interpolationDensityAnalystParameters . destroy ( ) ;
120- done ( ) ;
121- }
122- } , 10000 ) ;
123- } ) ;
124- // 删除测试过程中产生的数据集
125- it ( 'delete test resources_densityByDS' , function ( done ) {
126- var testResult_densityByDS = GlobeParameter . dataspatialAnalystURL + resultDataset_densityByDS ;
127- request . delete ( testResult_densityByDS ) ;
128- done ( ) ;
105+ expect ( analystEventArgsSystem . type ) . toEqual ( "processCompleted" ) ;
106+ var serviceResult = analystEventArgsSystem . result ;
107+ expect ( serviceResult ) . not . toBeNull ( ) ;
108+ expect ( serviceResult . succeed ) . toBeTruthy ( ) ;
109+ expect ( serviceResult . recordset ) . toBeNull ( ) ;
110+ expect ( serviceResult . dataset ) . toContain ( resultDataset_densityByDS ) ;
111+ expect ( serviceResult . dataset ) . toContain ( "@Interpolation" ) ;
112+ interpolationAnalystService . destroy ( ) ;
113+ interpolationDensityAnalystParameters . destroy ( ) ;
114+ done ( ) ;
115+ } , 1000 ) ;
129116 } ) ;
130117
118+
131119 var resultDataset_IDWByDS = "Interpolation_IDWByDS_commonTest" ;
132120 //数据集 反距离加权插值(IDW)分析
133121 it ( 'InterpolationIDWAnalyst_dataset' , function ( done ) {
0 commit comments