//Case 1599: 1.1.06.22_ImportDir_MoveCopyOption_N02 public void Run_Import_ImportDir_MoveCopyOption_Case1599() { int runCount = 0; foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), "Move Copy Check for importdir"); CheckPoint pimp = new CheckPoint("ImportDirMoveCopy", "Move Copy Check for importdir"); r.CheckPoints.Add(pimp); string moveflag = ids.InputParameters.GetParameter("move" + runCount.ToString()).Value; string flag = ids.InputParameters.GetParameter("flag" + runCount.ToString()).Value; string kdis6_path = ids.InputParameters.GetParameter("kdis6_path" + runCount.ToString()).Value; PatientService ps = new PatientService(); XMLParameter cInputPatient = new XMLParameter("patient"); cInputPatient.AddParameter("first_name", "test"); cInputPatient.AddParameter("last_name", "importdir_move"); XMLResult rslcreate = ps.createPatient(cInputPatient); if (rslcreate.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("create patient", "fail", rslcreate.Message); SaveRound(r); continue; } string patientid = rslcreate.SingleResult; try { ImportService imps = new ImportService(); Utility.SetCSDMConfig(CSDMConfigSection.remote, "moveWhenPostImport", moveflag); Utility.RestartCSDM(20000); XMLResult rslimp = imps.importDir(patientid, kdis6_path, flag); if (rslimp.Code != 800) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("import dir", "fail", rslimp.Message); SaveRound(r); ps.deletePatient(patientid); continue; } System.Threading.Thread.Sleep(2000); int expectfilenum = int.Parse(ids.ExpectedValues.GetParameter("expectfilenum" + runCount.ToString()).Value); int filenum = Utility.getFileNumOfDirectory(kdis6_path); if (filenum != expectfilenum) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("import dir", "fail", "File Number not correct"); SaveRound(r); ps.deletePatient(patientid); continue; } pimp.Result = TestResult.Pass; pimp.Outputs.AddParameter("import dir_move", "success", "OK"); SaveRound(r); ps.deletePatient(patientid); } catch (Exception e) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("import dir_move", "exception caught", e.Message); SaveRound(r); ps.deletePatient(patientid); continue; } } Output(); }
//Case 1598: 1.1.06.21_ImportDir_MainDirectory_N01 public void Run_Import_ImportDir_MainDirectory_Case1598() { int runCount = 0; NotificationSim.ReceiveNotification rn = new ReceiveNotification(); System.Collections.Generic.List<string> topics = new System.Collections.Generic.List<string>(); topics.Add("topic.postImportCompleted"); string stopTopic = "teststop"; string stopContent = "teststop"; rn.startListon(topics, stopTopic, stopContent); foreach (InputDataSet ids in this.Input.DataSets) { runCount++; Round r = this.NewRound(runCount.ToString(), "ImportMainDir"); CheckPoint pimp = new CheckPoint("ImportDir", "Import Additional Dir"); r.CheckPoints.Add(pimp); //create patient for import PatientService ps = new PatientService(); XMLParameter cInputPatient = new XMLParameter("patient"); cInputPatient.AddParameter("first_name", "test"); cInputPatient.AddParameter("last_name", "importmaindir"); XMLResult rslCreate = ps.createPatient(cInputPatient); if (rslCreate.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "Create Patient Fail", rslCreate.Message); SaveRound(r); continue; } string patientid = rslCreate.SingleResult; try { string kdis6dir = ids.InputParameters.GetParameter("kdis6_dir").Value; int retrynum = int.Parse(ids.InputParameters.GetParameter("retrynum").Value); string flag = "import"; ImportService imps = new ImportService(); XMLResult rslimport = imps.importDir(patientid, kdis6dir, flag); if (rslimport.Code != 800) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "Import Fail", rslimport.Message); SaveRound(r); ps.deletePatient(patientid); continue; } int n = 0; while (rn.getRecievedNumber() == 0) { n++; if (n < retrynum) { System.Threading.Thread.Sleep(5000); } else { break; } } if (n == retrynum) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "Notification Fail", "No notification recieved after retry " + n.ToString() + " times."); SaveRound(r); ps.deletePatient(patientid); continue; } ApplicationService app = new ApplicationService(); app.sendGenericNotification(stopTopic, stopContent); System.Threading.Thread.Sleep(1000); System.Collections.Generic.List<string> mmm = rn.getNotificationContent(); System.Collections.Generic.List<string> imageids = PAS.AutoTest.TestUtility.Utility.parsePostImportResult("Image", mmm[0]); System.Collections.Generic.List<string> fmsids = PAS.AutoTest.TestUtility.Utility.parsePostImportResult("FMS", mmm[0]); System.Collections.Generic.List<string> analysisids = PAS.AutoTest.TestUtility.Utility.parsePostImportResult("Analysis", mmm[0]); int expectedimgcount = int.Parse(ids.ExpectedValues.GetParameter("imgnum").Value); int expectedfmscount = int.Parse(ids.ExpectedValues.GetParameter("fmsnum").Value); int expectedanalysiscount = int.Parse(ids.ExpectedValues.GetParameter("analysisnum").Value); //check counts if (imageids.Count != expectedimgcount) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "Image Count is not correct", "Actual:" + imageids.Count.ToString() + ",Expected:" + expectedimgcount.ToString()); SaveRound(r); ps.deletePatient(patientid); continue; } if (fmsids.Count != expectedfmscount) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "FMS Count is not correct", "Actual:" + fmsids.Count.ToString() + ",Expected:" + expectedfmscount.ToString()); SaveRound(r); ps.deletePatient(patientid); continue; } if (analysisids.Count != expectedanalysiscount) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "Analysis Count is not correct", "Actual:" + analysisids.Count.ToString() + ",Expected:" + expectedanalysiscount.ToString()); SaveRound(r); ps.deletePatient(patientid); continue; } //get image info ImageService imgs = new ImageService(); foreach (string imgid in imageids) { XMLParameter cInputImage = new XMLParameter("image"); cInputImage.AddParameter("internal_id", imgid); XMLResult rslget = imgs.getImageInfo(cInputImage); if (rslget.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "GetImage Fail", rslget.Message); SaveRound(r); ps.deletePatient(patientid); goto error; } } //get FMS info FMSService fmss = new FMSService(); foreach (string fmsid in fmsids) { XMLResult rslget = fmss.getFMSInfo(fmsid); if (rslget.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "GetFMS Fail", rslget.Message); SaveRound(r); ps.deletePatient(patientid); goto error; } rslget = fmss.getFMSDescription(fmsid); if (rslget.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "GetFMS Fail", rslget.Message); SaveRound(r); ps.deletePatient(patientid); goto error; } } //get Analysis info AnalysisService anas = new AnalysisService(); foreach (string analysisid in analysisids) { XMLResult rslget = anas.getAnalysisInfo(analysisid); if (rslget.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "GetAnalysis Fail", rslget.Message); SaveRound(r); ps.deletePatient(patientid); goto error; } rslget = anas.getAnalysisDescription(analysisid); if (rslget.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "GetAnalysis Fail", rslget.Message); SaveRound(r); ps.deletePatient(patientid); goto error; } } //check list object NewPatientService nps = new NewPatientService(); PatientListObjectsRequestType request = new PatientListObjectsRequestType(); request.currentSpecified = true; request.current = true; request.patientInternalId = patientid; request.type = PatientListObjectsType.all; PatientListObjectsResponseType response = nps.listObjects(request); //to refresh code 800 to 0 response = nps.listObjects(request); if (!nps.LastReturnXMLValidateResult.isValid) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "list object fail", "Response is not complied with schema"); SaveRound(r); ps.deletePatient(patientid); continue; } if (response.status.code != 0) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "list object fail,message: ", response.status.message); SaveRound(r); ps.deletePatient(patientid); continue; } int expectedcurrentps = int.Parse(ids.ExpectedValues.GetParameter("curpsnum").Value); int expectedcurrentfms = int.Parse(ids.ExpectedValues.GetParameter("curfmsnum").Value); int expectedcurrentanalysis = int.Parse(ids.ExpectedValues.GetParameter("curanalysisnum").Value); if (response.presentationStates.Length != expectedcurrentps) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "list object fail,current image count not correct: ", "actural:" + response.presentationStates.Length.ToString() + " expect:" + expectedcurrentps.ToString()); SaveRound(r); ps.deletePatient(patientid); continue; } //get PS PresentationStateService pss = new PresentationStateService(); foreach (PresentationStateType pst in response.presentationStates) { XMLResult rslget = pss.getPresentationState(pst.uid); if (rslget.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "get PS fail: ", rslget.Message); SaveRound(r); ps.deletePatient(patientid); goto error; } } if (response.analysiss != null) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "list object fail,current analysis count not correct: ", "Expect no analysis will be returned"); SaveRound(r); ps.deletePatient(patientid); continue; } if (response.fmss.Length != expectedcurrentfms) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "list object fail,current fms count not correct: ", "actural:" + response.fmss.Length.ToString() + " expect:" + expectedcurrentfms.ToString()); SaveRound(r); ps.deletePatient(patientid); continue; } //list noncurrent objects request.currentSpecified = true; request.current = false; request.patientInternalId = patientid; request.type = PatientListObjectsType.all; response = nps.listObjects(request); int expectednoncurrentps = int.Parse(ids.ExpectedValues.GetParameter("noncurpsnum").Value); int expectednoncurrentfms = int.Parse(ids.ExpectedValues.GetParameter("noncurfmsnum").Value); int expectednoncurrentanalysis = int.Parse(ids.ExpectedValues.GetParameter("noncuranalysisnum").Value); if (response.presentationStates.Length != expectednoncurrentps) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "list object fail, non current ps count not correct: ", "actual:" + response.presentationStates.Length.ToString() + " expect:" + expectednoncurrentanalysis.ToString()); SaveRound(r); ps.deletePatient(patientid); continue; } //get PS foreach (PresentationStateType pst in response.presentationStates) { XMLResult rslget = pss.getPresentationState(pst.uid); if (rslget.IsErrorOccured) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "get PS fail: ", rslget.Message); SaveRound(r); ps.deletePatient(patientid); goto error; } } //check 3d object if (response.volumes.Length != int.Parse(ids.ExpectedValues.GetParameter("expect3dnum").Value)) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "Import 3d objects fail: ", "Count is " + response.volumes.Length.ToString() + ",expect:" + ids.ExpectedValues.GetParameter("expect3dnum").Value); SaveRound(r); ps.deletePatient(patientid); continue; } if (response.analysiss.Length != expectednoncurrentanalysis) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "list object fail,non current analysis count not correct: ", "actual:" + response.analysiss.Length.ToString() + " expect:" + expectednoncurrentanalysis.ToString()); SaveRound(r); ps.deletePatient(patientid); continue; } if (response.fmss.Length != expectednoncurrentfms) { pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "list object fail,non current fms count not correct: ", "actual:" + response.fmss.Length.ToString() + " expect:" + expectednoncurrentfms.ToString()); SaveRound(r); ps.deletePatient(patientid); continue; } //Finally the test success pimp.Result = TestResult.Pass; pimp.Outputs.AddParameter("Import Main Dir", "Success", "OK"); SaveRound(r); ps.deletePatient(patientid); } catch (Exception e) { ps.deletePatient(patientid); pimp.Result = TestResult.Fail; pimp.Outputs.AddParameter("Import Main Dir", "Fail", "Exception caught,message:" + e.Message); SaveRound(r); } } error: Output(); }