@@ -12,6 +12,9 @@ import org.codehaus.jackson.map.ObjectMapper
12
12
import org.grails.web.converters.marshaller.json.CollectionMarshaller
13
13
import org.grails.web.converters.marshaller.json.MapMarshaller
14
14
15
+ import java.time.format.DateTimeTextProvider
16
+ import java.time.temporal.TemporalField
17
+
15
18
import static grails.async.Promises.waitAll
16
19
/**
17
20
* Tests for the ParatooService.
@@ -33,6 +36,10 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest<ParatooSer
33
36
static Map DUMMY_POLYGON = [type : ' Polygon' , coordinates : [[[1 , 2 ], [2 , 2 ], [2 , 1 ], [1 , 1 ], [1 , 2 ]]]]
34
37
static Map DUMMY_PLOT = [' type' :' Point' , coordinates : [1 ,2 ]]
35
38
39
+ // The am/pm in the formatted time is local dependent and this appears to be easiest way to determine the value.
40
+ String am = DateUtil . formatAsDisplayDateTime(" 2024-05-14T00:00:00Z" )[-2 .. -1 ]
41
+ String pm = am == " AM" ? " PM" : " pm"
42
+
36
43
def setup () {
37
44
38
45
deleteAll()
@@ -156,7 +163,7 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest<ParatooSer
156
163
assert dataSet. protocol == collectionId. protocolId
157
164
assert dataSet. grantId == " g1"
158
165
assert dataSet. progress == ' planned'
159
- assert dataSet. name == " aParatooForm 1 - ${ DateUtil.formatAsDisplayDateTime(collectionId.eventTime)} (Project 1) "
166
+ assert dataSet. name == " aParatooForm 1 - ${ DateUtil.formatAsDisplayDateTime(collectionId.eventTime)} "
160
167
161
168
[status : ' ok' ]
162
169
}
@@ -182,7 +189,7 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest<ParatooSer
182
189
Map dataSet = [dataSetId :' d1' , grantId :' g1' , surveyId :paratooCollectionId. toMap(), activityId : " 123" ]
183
190
dataSet. surveyId. survey_metadata. orgMintedUUID = orgMintedId
184
191
Map expectedDataSetSync = dataSet + [progress : Activity . STARTED ]
185
- Map expectedDataSetAsync = dataSet + [progress : Activity . STARTED , startDate : " 2023-09-01T00:00:00Z" , endDate : " 2023-09-01T00:00:00Z" , areSpeciesRecorded : false , activityId : ' 123' , siteId : null , format : " Database Table" , sizeUnknown : true , name : " aParatooForm 1 - 2023-09-01 10:00 am " ]
192
+ Map expectedDataSetAsync = dataSet + [progress : Activity . STARTED , startDate : " 2023-09-01T00:00:00Z" , endDate : " 2023-09-01T00:00:00Z" , areSpeciesRecorded : false , activityId : ' 123' , siteId : null , format : " Database Table" , sizeUnknown : true , name : " aParatooForm 1 - 2023-09-01 10:00 ${ am } " ]
186
193
ParatooProject project = new ParatooProject (id : projectId, project : new Project (projectId : projectId, custom : [dataSets : [dataSet]]))
187
194
188
195
when :
@@ -1339,10 +1346,11 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest<ParatooSer
1339
1346
1340
1347
def " The data set name will be updated after the callback to Monitor core and be created from available information" () {
1341
1348
expect :
1342
- ParatooService . buildUpdatedDataSetSummaryName(" site" , " 2024-05-14T00:00:00Z" , " 2024-05-14T10:00:00Z" , " Protocol 1" , null ) == " Protocol 1 (site) - 2024-05-14 10:00 am to 2024-05-14 8:00 pm"
1343
- ParatooService . buildUpdatedDataSetSummaryName(" site" , " 2024-05-14T00:00:00Z" , null , " Protocol 1" , null ) == " Protocol 1 (site) - 2024-05-14 10:00 am"
1344
- ParatooService . buildUpdatedDataSetSummaryName(null , " 2024-05-14T00:00:00Z" , null , " Protocol 1" , null ) == " Protocol 1 - 2024-05-14 10:00 am"
1345
- ParatooService . buildUpdatedDataSetSummaryName(null , null , null , " Protocol 1" , new ParatooCollectionId (eventTime :DateUtil . parse(" 2024-05-14T00:00:00Z" ))) == " Protocol 1 - 2024-05-14 10:00 am"
1349
+ ParatooService . buildUpdatedDataSetSummaryName(" site" , " 2024-05-14T00:00:00Z" , " 2024-05-14T10:00:00Z" , " Protocol 1" , null ) == " Protocol 1 (site) - 2024-05-14 10:00 ${ am} to 2024-05-14 8:00 ${ pm} "
1350
+ ParatooService . buildUpdatedDataSetSummaryName(" site" , " 2024-05-14T00:00:00Z" , null , " Protocol 1" , null ) == " Protocol 1 (site) - 2024-05-14 10:00 ${ am} "
1351
+ ParatooService . buildUpdatedDataSetSummaryName(null , " 2024-05-14T00:00:00Z" , null , " Protocol 1" , null ) == " Protocol 1 - 2024-05-14 10:00 ${ am} "
1352
+ ParatooService . buildUpdatedDataSetSummaryName(null , null , null , " Protocol 1" , new ParatooCollectionId (eventTime :DateUtil . parse(" 2024-05-14T00:00:00Z" ))) == " Protocol 1 - 2024-05-14 10:00 ${ am} "
1353
+
1346
1354
1347
1355
}
1348
1356
0 commit comments