[1227] | 1 | package gov.va.med.edp.pt.demog.control {
|
---|
| 2 | import mx.rpc.IResponder;
|
---|
| 3 | import gov.va.med.edp.pt.demog.IPatientChecksDao;
|
---|
| 4 | import gov.va.med.edp.pt.demog.model.PatientSelectVO;
|
---|
| 5 | import gov.va.med.edp.pt.demog.model.PatientCheckVO;
|
---|
| 6 | import gov.va.med.edp.pt.demog.model.PatientChecksModel;
|
---|
| 7 |
|
---|
| 8 | import flexunit.framework.TestCase;
|
---|
| 9 |
|
---|
| 10 | public class TestPatientChecksController extends TestCase implements IPatientChecksDao {
|
---|
| 11 |
|
---|
| 12 | private var loadCalledWithThisPt:PatientSelectVO;
|
---|
| 13 | private var logAccessCalledWithThisDfn:String;
|
---|
| 14 |
|
---|
| 15 | public function testResetPatientChecks():void {
|
---|
| 16 | var model:PatientChecksModel = new PatientChecksModel();
|
---|
| 17 | model.patientChecks = new PatientCheckVO();
|
---|
| 18 | model.patientChecksReady = true;
|
---|
| 19 |
|
---|
| 20 | var c:PatientChecksController = new PatientChecksController();
|
---|
| 21 | c.model = model;
|
---|
| 22 |
|
---|
| 23 | c.resetPatientChecks();
|
---|
| 24 |
|
---|
| 25 | assertNull(model.patientChecks);
|
---|
| 26 | assertFalse(model.patientChecksReady);
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | public function testLoadPatientChecks():void {
|
---|
| 30 | var model:PatientChecksModel = new PatientChecksModel();
|
---|
| 31 | var c:PatientChecksController = new PatientChecksController();
|
---|
| 32 | c.model = model;
|
---|
| 33 | c.dao = this;
|
---|
| 34 |
|
---|
| 35 | var pt:PatientSelectVO = new PatientSelectVO();
|
---|
| 36 | pt.dfn = "FOO";
|
---|
| 37 | pt.name = "BAR";
|
---|
| 38 |
|
---|
| 39 | c.loadPatientChecks(pt);
|
---|
| 40 |
|
---|
| 41 | assertEquals(PatientChecksModel.STATE_LOADING, model.checkState);
|
---|
| 42 | assertFalse(model.patientChecksReady);
|
---|
| 43 | assertTrue(pt === loadCalledWithThisPt);
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | public function testLogSensitivePatientAccess():void {
|
---|
| 47 | var model:PatientChecksModel = new PatientChecksModel();
|
---|
| 48 | model.checkState = PatientChecksModel.STATE_LOADING;
|
---|
| 49 | model.patientChecks = new PatientCheckVO();
|
---|
| 50 | model.patientChecks.dfn = "foobar";
|
---|
| 51 | model.patientChecks.sensitive = true;
|
---|
| 52 | model.patientChecks.warningText = "Patient FOO,BAR is sensitive. Continue";
|
---|
| 53 | model.patientChecks.logAccess = true;
|
---|
| 54 | model.patientChecksReady = true;
|
---|
| 55 |
|
---|
| 56 | var c:PatientChecksController = new PatientChecksController();
|
---|
| 57 | c.model = model;
|
---|
| 58 | c.dao = this;
|
---|
| 59 |
|
---|
| 60 | c.forwardPatientCheck();
|
---|
| 61 | assertEquals(PatientChecksModel.STATE_SENSITIVE, model.checkState);
|
---|
| 62 |
|
---|
| 63 | c.forwardPatientCheck();
|
---|
| 64 | assertEquals("foobar", logAccessCalledWithThisDfn);
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | //
|
---|
| 68 | // methods to mock the patient checks DAO
|
---|
| 69 | //
|
---|
| 70 | public function loadPatientChecks(responder:IResponder, pt:PatientSelectVO):void {
|
---|
| 71 | loadCalledWithThisPt = pt;
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | public function logPatientAccess(responder:IResponder, dfn:String):void {
|
---|
| 75 | logAccessCalledWithThisDfn = dfn;
|
---|
| 76 | }
|
---|
| 77 | }
|
---|
| 78 | }
|
---|