@@ -26,8 +26,7 @@ public class IndividualTest {
2626 private Transaction mockTransaction ;
2727 private Query mockQuery ;
2828
29- @ BeforeEach
30- public void setUp () {
29+ @ BeforeEach public void setUp () {
3130 // Create mock PersistenceManager and stub critical nested methods
3231 mockTransaction = mock (Transaction .class , RETURNS_DEEP_STUBS );
3332 mockQuery = mock (Query .class , RETURNS_DEEP_STUBS );
@@ -42,18 +41,17 @@ public void setUp() {
4241 // Open the static mock for ShepherdPMF
4342 mockedShepherdPMF = mockStatic (ShepherdPMF .class );
4443 // Configure the behavior for static getPMF()
45- mockedShepherdPMF .when (() -> ShepherdPMF .getPMF (anyString ()))
46- .thenReturn (mockPMF );
44+ mockedShepherdPMF .when (() -> ShepherdPMF .getPMF (anyString (), any () ))
45+ .thenReturn (mockPMF );
4746 }
4847
49- @ AfterEach
50- public void tearDown () {
48+ @ AfterEach public void tearDown () {
5149 // Ensure that the static mock is closed after each test
5250 mockedShepherdPMF .close ();
5351 }
52+
5453 // creation
55- @ Test
56- public void testStoreNewMarkedIndividual () {
54+ @ Test public void testStoreNewMarkedIndividual () {
5755 when (mockTransaction .isActive ()).thenReturn (false );
5856 Shepherd testShepherd = spy (new Shepherd ("testContext" ));
5957 // should a null MarkedIndividual "work" here?
@@ -67,8 +65,7 @@ public void testStoreNewMarkedIndividual() {
6765 }
6866
6967 // behavior should be the same as inactive trans
70- @ Test
71- public void testStoreNewMarkedIndividualWithActiveTransaction () {
68+ @ Test public void testStoreNewMarkedIndividualWithActiveTransaction () {
7269 when (mockTransaction .isActive ()).thenReturn (true );
7370 Shepherd testShepherd = spy (new Shepherd ("testContext" ));
7471 // should a null MarkedIndividual "work" here?
@@ -81,13 +78,11 @@ public void testStoreNewMarkedIndividualWithActiveTransaction() {
8178 assertTrue (returnValue );
8279 }
8380
84- @ Test
85- public void testStoreNewMarkedIndividualWithException () {
81+ @ Test public void testStoreNewMarkedIndividualWithException () {
8682 when (mockTransaction .isActive ()).thenReturn (true );
8783 when (mockPM .makePersistent (any ())).thenThrow (IllegalStateException .class );
8884 Shepherd testShepherd = spy (new Shepherd ("testContext" ));
8985 MarkedIndividual markedIndividual = null ;
90-
9186 boolean returnValue = testShepherd .storeNewMarkedIndividual (markedIndividual );
9287
9388 assertThrows (IllegalStateException .class , () -> mockPM .makePersistent (any ()));
@@ -96,13 +91,13 @@ public void testStoreNewMarkedIndividualWithException() {
9691 assertFalse (returnValue );
9792 }
9893
99- @ Test
100- public void testStoreNewScheduledIndividualMerge () {
94+ @ Test public void testStoreNewScheduledIndividualMerge () {
10195 when (mockTransaction .isActive ()).thenReturn (false );
10296 Shepherd testShepherd = spy (new Shepherd ("testContext" ));
10397 // should a null ScheduledIndividualMerge "work" here?
10498 ScheduledIndividualMerge scheduledIndividualMerge = null ;
105- boolean returnValue = testShepherd .storeNewScheduledIndividualMerge (scheduledIndividualMerge );
99+ boolean returnValue = testShepherd .storeNewScheduledIndividualMerge (
100+ scheduledIndividualMerge );
106101
107102 verify (testShepherd , times (1 )).beginDBTransaction ();
108103 verify (mockPM , times (1 )).makePersistent (scheduledIndividualMerge );
@@ -111,55 +106,51 @@ public void testStoreNewScheduledIndividualMerge() {
111106 }
112107
113108 // deletion
114- @ Test
115- public void testThrowAwayMarkedIndividual () {
109+ @ Test public void testThrowAwayMarkedIndividual () {
116110 MarkedIndividual markedIndividual = spy (new MarkedIndividual ());
117111 Shepherd testShepherd = new Shepherd ("testContext" );
112+
118113 testShepherd .throwAwayMarkedIndividual (markedIndividual );
119114 verify (mockPM , times (1 )).deletePersistent (markedIndividual );
120115 verify (markedIndividual , times (1 )).opensearchUnindexQuiet ();
121116 }
122117
123118 // utilities
124- @ Test
125- public void testIsMarkedIndividualWithString () {
119+ @ Test public void testIsMarkedIndividualWithString () {
126120 when (mockPM .getObjectById (any (), anyBoolean ())).thenReturn (new MarkedIndividual ());
127121 Shepherd testShepherd = spy (new Shepherd ("testContext" ));
128122 assertTrue (testShepherd .isMarkedIndividual ("testIndividual" ));
129123 }
130124
131125 // perhaps the edge case of an empty string should be handled?
132- @ Test
133- public void testIsMarkedIndividualWithEmptyString () {
126+ @ Test public void testIsMarkedIndividualWithEmptyString () {
134127 when (mockPM .getObjectById (any (), anyBoolean ())).thenReturn (new MarkedIndividual ());
135128 Shepherd testShepherd = spy (new Shepherd ("testContext" ));
136129 assertTrue (testShepherd .isMarkedIndividual ("" ));
137130 }
138131
139- @ Test
140- public void testIsMarkedIndividualWithStringWithException () {
132+ @ Test public void testIsMarkedIndividualWithStringWithException () {
141133 when (mockPM .getObjectById (any (), anyBoolean ())).thenThrow (JDONullIdentityException .class );
142134 Shepherd testShepherd = spy (new Shepherd ("testContext" ));
143135 assertFalse (testShepherd .isMarkedIndividual ("" ));
144136 }
145137
146- @ Test
147- public void testIsMarkedIndividualWithMIisFalseWithNull () {
138+ @ Test public void testIsMarkedIndividualWithMIisFalseWithNull () {
148139 Shepherd testShepherd = spy (new Shepherd ("testContext" ));
149140 MarkedIndividual markedIndividual = null ;
141+
150142 assertFalse (testShepherd .isMarkedIndividual (markedIndividual ));
151143 }
152144
153145 // getters
154- @ Test
155- public void testGetMarkedIndividualQuiet () {
146+ @ Test public void testGetMarkedIndividualQuiet () {
156147 when (mockPM .getObjectById (any (), anyBoolean ())).thenReturn (new MarkedIndividual ());
157148 Shepherd testShepherd = spy (new Shepherd ("testContext" ));
158- assertInstanceOf (MarkedIndividual .class , testShepherd .getMarkedIndividualQuiet ("some individual" ));
149+ assertInstanceOf (MarkedIndividual .class ,
150+ testShepherd .getMarkedIndividualQuiet ("some individual" ));
159151 }
160152
161- @ Test
162- public void testGetMarkedIndividualByProject () {
153+ @ Test public void testGetMarkedIndividualByProject () {
163154 // null project returns empty list?
164155 Project testProject = null ;
165156 List <MarkedIndividual > expected = new ArrayList <>();
@@ -170,29 +161,28 @@ public void testGetMarkedIndividualByProject() {
170161 assertEquals (expected , testShepherd .getMarkedIndividualsFromProject (testProject ));
171162 }
172163
173- @ Test
174- public void testGetMarkedIndividualByNullEncounter () {
164+ @ Test public void testGetMarkedIndividualByNullEncounter () {
175165 Shepherd testShepherd = new Shepherd ("testContext" );
176166 Encounter testEncounter = null ;
167+
177168 assertNull (testShepherd .getMarkedIndividual (testEncounter ));
178169 }
179170
180- @ Test
181- public void testGetMarkedIndividualByEmptyEncounter () {
171+ @ Test public void testGetMarkedIndividualByEmptyEncounter () {
182172 Encounter mockEncounter ;
183-
184173 Shepherd testShepherd = new Shepherd ("testContext" );
174+
185175 mockEncounter = mock (Encounter .class );
186176 when (mockEncounter .getIndividualID ()).thenReturn ("" );
187177 assertNull (testShepherd .getMarkedIndividual (mockEncounter ));
188178 }
189179
190180 /*
191- // todo: verify these are removed or refactored after Shepherd method cleanup.
192- @Test
193- public void testGetMarkedIndividualThumbnails() {} // one usage ...
181+ // todo: verify these are removed or refactored after Shepherd method cleanup.
182+ @Test
183+ public void testGetMarkedIndividualThumbnails() {} // one usage ...
194184
195- @Test
196- public void testGetMarkedIndividualHard() {} // deprecated
197- */
185+ @Test
186+ public void testGetMarkedIndividualHard() {} // deprecated
187+ */
198188}
0 commit comments