@@ -147,23 +147,23 @@ public void testWeightValidation()
147147 "WARN: Weight above the allowable value of 20.0 kg for Cynomolgus" ,
148148 "INFO: Weight gain of >10%. Last weight 12 kg" )
149149 );
150- getApiHelper ().testValidationMessage (DATA_ADMIN .getEmail (), "study" , "weight" , weightFields , data , expected );
150+ getApiHelper ().testValidationMessage (DATA_ADMIN .getEmail (), "study" , "weight" , getWeightFields () , data , expected );
151151
152152 //expect INFO for +10% diff
153153 data = new Object [][]{
154154 {SUBJECTS [3 ], new Date (), null , null , 20 , EHRQCState .IN_PROGRESS .label , null , null , "recordID" }
155155 };
156156 expected = new HashMap <>();
157157 expected .put ("weight" , Collections .singletonList ("INFO: Weight gain of >10%. Last weight 12 kg" ));
158- getApiHelper ().testValidationMessage (DATA_ADMIN .getEmail (), "study" , "weight" , weightFields , data , expected );
158+ getApiHelper ().testValidationMessage (DATA_ADMIN .getEmail (), "study" , "weight" , getWeightFields () , data , expected );
159159
160160 //expect INFO for -10% diff
161161 data = new Object [][]{
162162 {SUBJECTS [3 ], new Date (), null , null , 5 , EHRQCState .IN_PROGRESS .label , null , null , "recordID" }
163163 };
164164 expected = new HashMap <>();
165165 expected .put ("weight" , Collections .singletonList ("INFO: Weight drop of >10%. Last weight 12 kg" ));
166- getApiHelper ().testValidationMessage (DATA_ADMIN .getEmail (), "study" , "weight" , weightFields , data , expected );
166+ getApiHelper ().testValidationMessage (DATA_ADMIN .getEmail (), "study" , "weight" , getWeightFields () , data , expected );
167167
168168 //TODO: test error threshold
169169 }
@@ -245,10 +245,10 @@ private void testUserAgainstAllStates(@LoggedParam EHRUser user)
245245 _saveRowsTimes = new ArrayList <>();
246246
247247 //test insert
248- Object [][] insertData = {weightData1 };
249- insertData [0 ][Arrays .asList (weightFields ).indexOf (FIELD_OBJECTID )] = null ;
250- insertData [0 ][Arrays .asList (weightFields ).indexOf (FIELD_LSID )] = null ;
251- SimplePostCommand insertCommand = getApiHelper ().prepareInsertCommand ("study" , "Weight" , FIELD_LSID , weightFields , insertData );
248+ Object [][] insertData = {getWeightData1 () };
249+ insertData [0 ][Arrays .asList (getWeightFields () ).indexOf (FIELD_OBJECTID )] = null ;
250+ insertData [0 ][Arrays .asList (getWeightFields () ).indexOf (FIELD_LSID )] = null ;
251+ SimplePostCommand insertCommand = getApiHelper ().prepareInsertCommand ("study" , "Weight" , FIELD_LSID , getWeightFields () , insertData );
252252
253253 for (EHRQCState qc : EHRQCState .values ())
254254 {
@@ -268,34 +268,34 @@ private void testUserAgainstAllStates(@LoggedParam EHRUser user)
268268 {
269269 // first create an initial row as a data admin
270270 UUID objectId = UUID .randomUUID ();
271- Object [][] originalData = {weightData1 };
272- originalData [0 ][Arrays .asList (weightFields ).indexOf (FIELD_QCSTATELABEL )] = originalQc .label ;
271+ Object [][] originalData = {getWeightData1 () };
272+ originalData [0 ][Arrays .asList (getWeightFields () ).indexOf (FIELD_QCSTATELABEL )] = originalQc .label ;
273273 extraContext .put ("targetQC" , originalQc .label );
274- originalData [0 ][Arrays .asList (weightFields ).indexOf (FIELD_OBJECTID )] = objectId .toString ();
275- SimplePostCommand initialInsertCommand = getApiHelper ().prepareInsertCommand ("study" , "Weight" , FIELD_LSID , weightFields , originalData );
274+ originalData [0 ][Arrays .asList (getWeightFields () ).indexOf (FIELD_OBJECTID )] = objectId .toString ();
275+ SimplePostCommand initialInsertCommand = getApiHelper ().prepareInsertCommand ("study" , "Weight" , FIELD_LSID , getWeightFields () , originalData );
276276 log ("Inserting initial record for update test, with initial QCState of: " + originalQc .label );
277277 response = getApiHelper ().doSaveRows (DATA_ADMIN .getEmail (), initialInsertCommand , extraContext );
278278
279279 String lsid = getLsidFromResponse (response );
280- originalData [0 ][Arrays .asList (weightFields ).indexOf (FIELD_LSID )] = lsid ;
280+ originalData [0 ][Arrays .asList (getWeightFields () ).indexOf (FIELD_LSID )] = lsid ;
281281
282282 //then try to update to all other QCStates
283283 for (EHRQCState qc : EHRQCState .values ())
284284 {
285285 boolean successExpected = originalQc .equals (qc ) ? successExpected (user .getRole (), originalQc , "update" ) : successExpected (user .getRole (), originalQc , "update" ) && successExpected (user .getRole (), qc , "insert" );
286286 log ("Testing role: " + user .getRole ().name () + " with update from QCState " + originalQc .label + " to: " + qc .label );
287- originalData [0 ][Arrays .asList (weightFields ).indexOf (FIELD_QCSTATELABEL )] = qc .label ;
288- SimplePostCommand updateCommand = getApiHelper ().prepareUpdateCommand ("study" , "Weight" , FIELD_LSID , weightFields , originalData , null );
287+ originalData [0 ][Arrays .asList (getWeightFields () ).indexOf (FIELD_QCSTATELABEL )] = qc .label ;
288+ SimplePostCommand updateCommand = getApiHelper ().prepareUpdateCommand ("study" , "Weight" , FIELD_LSID , getWeightFields () , originalData , null );
289289 extraContext .put ("targetQC" , qc .label );
290290 if (!successExpected )
291291 getApiHelper ().doSaveRowsExpectingError (user .getEmail (), updateCommand , extraContext );
292292 else
293293 {
294294 getApiHelper ().doSaveRows (user .getEmail (), updateCommand , extraContext );
295295 log ("Resetting QCState of record to: " + originalQc .label );
296- originalData [0 ][Arrays .asList (weightFields ).indexOf (FIELD_QCSTATELABEL )] = originalQc .label ;
296+ originalData [0 ][Arrays .asList (getWeightFields () ).indexOf (FIELD_QCSTATELABEL )] = originalQc .label ;
297297 extraContext .put ("targetQC" , originalQc .label );
298- updateCommand = getApiHelper ().prepareUpdateCommand ("study" , "Weight" , FIELD_LSID , weightFields , originalData , null );
298+ updateCommand = getApiHelper ().prepareUpdateCommand ("study" , "Weight" , FIELD_LSID , getWeightFields () , originalData , null );
299299 getApiHelper ().doSaveRows (DATA_ADMIN .getEmail (), updateCommand , extraContext );
300300 }
301301 }
0 commit comments