-
Notifications
You must be signed in to change notification settings - Fork 24
/
OccurrenceStatusTest.scala
82 lines (61 loc) · 2.7 KB
/
OccurrenceStatusTest.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package au.org.ala.biocache
import au.org.ala.biocache.model.{QualityAssertion, FullRecord}
import au.org.ala.biocache.processor.MiscellaneousProcessor
import au.org.ala.biocache.vocab.AssertionCodes
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import scala.collection.mutable.ArrayBuffer
@RunWith(classOf[JUnitRunner])
class OccurrenceStatusTest extends ConfigFunSuite {
test("present value supplied"){
val raw = new FullRecord
raw.occurrence.occurrenceStatus = "Present"
val processed = new FullRecord
val assertions = new ArrayBuffer[QualityAssertion]()
val mp = new MiscellaneousProcessor
mp.processOccurrenceStatus(raw, processed, assertions)
expectResult(true){ assertions.isEmpty }
expectResult(true){ processed.occurrence.occurrenceStatus == "present" }
}
test("absent value supplied"){
val raw = new FullRecord
raw.occurrence.occurrenceStatus = "Absent"
val processed = new FullRecord
val assertions = new ArrayBuffer[QualityAssertion]()
val mp = new MiscellaneousProcessor
mp.processOccurrenceStatus(raw, processed, assertions)
expectResult(true){ assertions.isEmpty }
expectResult(true){ processed.occurrence.occurrenceStatus == "absent" }
}
test("absence value supplied"){
val raw = new FullRecord
raw.occurrence.occurrenceStatus = "Absence"
val processed = new FullRecord
val assertions = new ArrayBuffer[QualityAssertion]()
val mp = new MiscellaneousProcessor
mp.processOccurrenceStatus(raw, processed, assertions)
expectResult(true){ assertions.isEmpty }
expectResult(true){ processed.occurrence.occurrenceStatus == "absent" }
}
test("no value supplied - assume present, add a warning"){
val raw = new FullRecord
val processed = new FullRecord
val assertions = new ArrayBuffer[QualityAssertion]()
val mp = new MiscellaneousProcessor
mp.processOccurrenceStatus(raw, processed, assertions)
expectResult(true){ assertions.size == 1 }
expectResult(true){ processed.occurrence.occurrenceStatus == "present" }
expectResult(AssertionCodes.ASSUMED_PRESENT_OCCURRENCE_STATUS.code){ assertions(0).code}
}
test("unrecognised value supplied - set to unknown, add a warning"){
val raw = new FullRecord
raw.occurrence.occurrenceStatus = "12321321321"
val processed = new FullRecord
val assertions = new ArrayBuffer[QualityAssertion]()
val mp = new MiscellaneousProcessor
mp.processOccurrenceStatus(raw, processed, assertions)
expectResult(true){ processed.occurrence.occurrenceStatus == "unknown" }
expectResult(true){ assertions.size == 1 }
expectResult( AssertionCodes.UNRECOGNISED_OCCURRENCE_STATUS.code){ assertions(0).code}
}
}