@@ -2,7 +2,7 @@ package hmda.query.view.institutions
2
2
3
3
import akka .actor .ActorRef
4
4
import akka .testkit .TestProbe
5
- import hmda .model .institution .InstitutionGenerators
5
+ import hmda .model .institution .{ Institution , InstitutionGenerators }
6
6
import hmda .persistence .messages .CommonMessages .GetState
7
7
import hmda .persistence .messages .events .institutions .InstitutionEvents .{ InstitutionCreated , InstitutionModified }
8
8
import hmda .persistence .model .ActorSpec
@@ -17,6 +17,10 @@ class InstitutionViewSpec extends ActorSpec {
17
17
val i3 = InstitutionGenerators .sampleInstitution
18
18
val i4 = i3.copy(cra = true )
19
19
20
+ val e1 = Institution .empty.copy(id = " 1" , emailDomains = Set (" test.com" , " " , " " ))
21
+ val e2 = Institution .empty.copy(id = " 2" , emailDomains = Set (" " , " " , " " ))
22
+ val e3 = Institution .empty.copy(id = " 3" , emailDomains = Set (" test.com" , " " , " " ))
23
+
20
24
val institutionQuery = createInstitutionView(system)
21
25
22
26
implicit val ec = system.dispatcher
@@ -29,6 +33,9 @@ class InstitutionViewSpec extends ActorSpec {
29
33
institutionQuery ! EventWithSeqNr (2 , InstitutionCreated (i2))
30
34
institutionQuery ! EventWithSeqNr (3 , InstitutionCreated (i3))
31
35
institutionQuery ! EventWithSeqNr (4 , InstitutionModified (i4))
36
+ institutionQuery ! EventWithSeqNr (5 , InstitutionCreated (e1))
37
+ institutionQuery ! EventWithSeqNr (6 , InstitutionCreated (e2))
38
+ institutionQuery ! EventWithSeqNr (7 , InstitutionCreated (e3))
32
39
}
33
40
34
41
" Institutions View" must {
@@ -50,7 +57,7 @@ class InstitutionViewSpec extends ActorSpec {
50
57
}
51
58
" return full list of institutions" in {
52
59
probe.send(institutionQuery, GetState )
53
- probe.expectMsg(Set (i1, i2, i4))
60
+ probe.expectMsg(Set (i1, i2, i4, e1, e2, e3 ))
54
61
}
55
62
" return reference to institution query projector" in {
56
63
probe.send(institutionQuery, GetProjectionActorRef )
@@ -61,6 +68,21 @@ class InstitutionViewSpec extends ActorSpec {
61
68
probe.send(institutionQuery, GetInstitutionByRespondentId (i1.respondentId))
62
69
probe.expectMsg(i1)
63
70
}
71
+
72
+ " return a set of institutions that match a domain" in {
73
+ probe.send(institutionQuery, FindInstitutionByPeriodAndDomain (" test.com" ))
74
+ probe.expectMsg(Set (e1, e3))
75
+ }
76
+
77
+ " return an empty set when requesting a domain that doesn't exist" in {
78
+ probe.send(institutionQuery, FindInstitutionByPeriodAndDomain (" notest.com" ))
79
+ probe.expectMsg(Set ())
80
+ }
81
+
82
+ " return an empty set when requesting a blank domain" in {
83
+ probe.send(institutionQuery, FindInstitutionByPeriodAndDomain (" " ))
84
+ probe.expectMsg(Set ())
85
+ }
64
86
}
65
87
66
88
}
0 commit comments