@@ -3,7 +3,6 @@ package hmda.persistence.institutions
3
3
import akka .testkit .TestProbe
4
4
import hmda .model .fi ._
5
5
import hmda .persistence .messages .CommonMessages .GetState
6
- import hmda .persistence .demo .DemoData
7
6
import hmda .persistence .institutions .FilingPersistence ._
8
7
import hmda .persistence .model .ActorSpec
9
8
@@ -26,15 +25,6 @@ class FilingPersistenceSpec extends ActorSpec {
26
25
probe.send(filingsActor, GetState )
27
26
probe.expectMsg(filings.reverse)
28
27
}
29
- " be able to change their status" in {
30
- val filing = DemoData .testFilings.head
31
- val modified = filing.copy(status = Cancelled )
32
- probe.send(filingsActor, UpdateFilingStatus (modified))
33
- probe.expectMsg(Some (modified))
34
- probe.send(filingsActor, GetFilingByPeriod (filing.period))
35
- probe.expectMsg(modified)
36
- }
37
-
38
28
" return None when persisting a filing period that already exists" in {
39
29
val f1 = Filing (" 2018" , " 12345" , Completed , true , 1483287071000L , 1514736671000L )
40
30
probe.send(filingsActor, CreateFiling (f1))
@@ -44,12 +34,34 @@ class FilingPersistenceSpec extends ActorSpec {
44
34
probe.send(filingsActor, CreateFiling (f2))
45
35
probe.expectMsg(None )
46
36
}
37
+ }
47
38
48
- " return None for nonexistent period" in {
49
- val f = Filing (" 2006" , " 12345" , Cancelled , false , 1483287071000L , 1514736671000L )
50
- probe.send(filingsActor, UpdateFilingStatus (f))
39
+ " UpdateFilingStatus" must {
40
+ " update status of filing for given period" in {
41
+ val expected = sample1.copy(status = Cancelled )
42
+ probe.send(filingsActor, UpdateFilingStatus (" 2016" , Cancelled ))
43
+ probe.expectMsg(Some (expected))
44
+ probe.send(filingsActor, GetFilingByPeriod (" 2016" ))
45
+ probe.expectMsg(expected)
46
+ }
47
+ " return None for nonexistent filing period" in {
48
+ probe.send(filingsActor, UpdateFilingStatus (" 2006" , InProgress ))
51
49
probe.expectMsg(None )
52
50
}
51
+ " update start and end timestamp, if necessary" in {
52
+ probe.send(filingsActor, UpdateFilingStatus (" 2017" , InProgress ))
53
+ val inProg = probe.expectMsgType[Option [Filing ]].get
54
+ inProg.status mustBe InProgress
55
+ val startTime = inProg.start
56
+ startTime must be > 0L
57
+ inProg.end mustBe 0L
58
+
59
+ probe.send(filingsActor, UpdateFilingStatus (" 2017" , Completed ))
60
+ val comp = probe.expectMsgType[Option [Filing ]].get
61
+ comp.status mustBe Completed
62
+ comp.start mustBe startTime
63
+ comp.end must be > 0L
64
+ }
53
65
}
54
66
55
67
}
0 commit comments