Skip to content

Commit 55254b6

Browse files
committed
- fixes broken test
1 parent 93ad03d commit 55254b6

File tree

1 file changed

+40
-5
lines changed

1 file changed

+40
-5
lines changed

src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy

+40-5
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest<ParatooSer
348348

349349
}
350350

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" () {
352352
setup:
353353
String projectId = 'p1'
354354
String orgMintedId = 'd1'
@@ -377,7 +377,6 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest<ParatooSer
377377
Map dataSet = [dataSetId:'d1', grantId:'g1', surveyId:paratooCollectionId.toMap()]
378378
ParatooProject project = new ParatooProject(id: projectId, project: new Project(projectId: projectId, custom: [dataSets: [dataSet]]))
379379
Map surveyData = readSurveyData('basalAreaDbhReverseLookup')
380-
Map site
381380

382381
when:
383382
Map result = service.submitCollection(collection, project)
@@ -409,12 +408,48 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest<ParatooSer
409408
}
410409
1 * userService.getCurrentUserDetails() >> [userId: userId]
411410
1 * userService.setCurrentUser(userId)
411+
}
412412

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')
414445
String date = DateUtil.format(new Date())
415446
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)
418453

419454
then:
420455
1 * webService.doPost(*_) >> [resp: surveyData]

0 commit comments

Comments
 (0)