@@ -348,7 +348,7 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest<ParatooSer
348
348
349
349
}
350
350
351
- void " The service will create a new site if ploy layout has been updated or use existing site" () {
351
+ void " The service will create use existing site" () {
352
352
setup :
353
353
String projectId = ' p1'
354
354
String orgMintedId = ' d1'
@@ -377,7 +377,6 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest<ParatooSer
377
377
Map dataSet = [dataSetId :' d1' , grantId :' g1' , surveyId :paratooCollectionId. toMap()]
378
378
ParatooProject project = new ParatooProject (id : projectId, project : new Project (projectId : projectId, custom : [dataSets : [dataSet]]))
379
379
Map surveyData = readSurveyData(' basalAreaDbhReverseLookup' )
380
- Map site
381
380
382
381
when :
383
382
Map result = service. submitCollection(collection, project)
@@ -409,12 +408,48 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest<ParatooSer
409
408
}
410
409
1 * userService. getCurrentUserDetails() >> [userId : userId]
411
410
1 * userService. setCurrentUser(userId)
411
+ }
412
412
413
- when :
413
+ void " The service will create a new site if plot layout has been updated" () {
414
+ setup :
415
+ String projectId = ' p1'
416
+ String orgMintedId = ' d1'
417
+ Date afterSubmissionDate = DateUtil . parseWithMilliseconds(" 2023-09-15T06:00:11.996Z" )
418
+ Date beforeSubmissionDate = DateUtil . parseWithMilliseconds(" 2023-09-14T06:00:11.996Z" )
419
+ Site . withSession { session ->
420
+ new Site (
421
+ name : " SATFLB0001 - Control (100 x 100)" ,
422
+ siteId : " s0" ,
423
+ extent : [geometry : DUMMY_POLYGON ],
424
+ description : " SATFLB0001 - Control (100 x 100)" ,
425
+ notes : " Core monitoring plot some comment" ,
426
+ type : " compound" ,
427
+ externalIds : [new ExternalId (externalId : " 2" , idType : ExternalId.IdType . MONITOR_PLOT_GUID )],
428
+ dateCreated : afterSubmissionDate,
429
+ lastUpdated : afterSubmissionDate
430
+ ). save(flush : true )
431
+ session. flush()
432
+ }
433
+ ParatooProtocolId protocol = new ParatooProtocolId (id : " 1" , version : 1 )
434
+ ParatooCollection collection = new ParatooCollection (
435
+ orgMintedUUID :orgMintedId,
436
+ coreProvenance : [
437
+ " system_core" : " <system-core>" ,
438
+ " version_core" : " <core-version>"
439
+ ]
440
+ )
441
+ ParatooCollectionId paratooCollectionId = buildCollectionId(" mintCollectionIdBasalAreaPayload" ," guid-3" )
442
+ Map dataSet = [dataSetId :' d1' , grantId :' g1' , surveyId :paratooCollectionId. toMap()]
443
+ ParatooProject project = new ParatooProject (id : projectId, project : new Project (projectId : projectId, custom : [dataSets : [dataSet]]))
444
+ Map surveyData = readSurveyData(' basalAreaDbhReverseLookup' )
414
445
String date = DateUtil . format(new Date ())
415
446
date = date. replace(" Z" , " .999Z" )
416
- surveyData[" collections" ][" basal-area-dbh-measure-survey" ][" plot_visit" ][" plot_layout" ][" updatedAt" ] = [date]
417
- result = service. submitCollection(collection, project)
447
+ surveyData. collections. " basal-area-dbh-measure-survey" . " plot_visit" . " plot_layout" . " updatedAt" = date
448
+ Map site
449
+
450
+ when :
451
+ def result = service. submitCollection(collection, project)
452
+ waitAll(result. promise)
418
453
419
454
then :
420
455
1 * webService. doPost(* _) >> [resp : surveyData]
0 commit comments