@@ -672,6 +672,54 @@ public void shortenedStackTrace_shouldRemoveSpringframeworkAndReflectionRelatedL
672
672
assertEquals (expected , OpenmrsUtil .shortenedStackTrace (test ), "stack trace was not shortened properly" );
673
673
}
674
674
675
+ /**
676
+ * @see OpenmrsUtil#formattedStackTrace(String)
677
+ */
678
+ @ Test
679
+ public void formattedStackTrace_shouldReturnTheErrorAndCauseAfterFormattingIfNotInDevMode () {
680
+ Properties props = Context .getRuntimeProperties ();
681
+ props .setProperty (OpenmrsConstants .DEVELOPMENT_MODE_RUNTIME_PROPERTY , "false" );
682
+ Context .setRuntimeProperties (props );
683
+
684
+ String test = "ca.uhn.hl7v2.HL7Exception: Error while processing HL7 message: ORU_R01\n "
685
+ + "\t at org.openmrs.hl7.impl.HL7ServiceImpl.processHL7Message(HL7ServiceImpl.java:752)\n "
686
+ + "Caused by: ca.uhn.hl7v2.app.ApplicationException: ca.uhn.hl7v2.HL7Exception: Could not resolve patient by identifier\n "
687
+ + "\t at org.openmrs.hl7.handler.ORUR01Handler.processMessage(ORUR01Handler.java:132)\n "
688
+ + "Caused by: ca.uhn.hl7v2.HL7Exception: Could not resolve patient by identifier\n "
689
+ + "\t at org.openmrs.hl7.handler.ORUR01Handler.getPatientByIdentifier(ORUR01Handler.java:998)" ;
690
+
691
+ String expected = "Error (HL7): ca.uhn.hl7v2.HL7Exception: Error while processing HL7 message: ORU_R01\n "
692
+ + "Caused by: ca.uhn.hl7v2.app.ApplicationException: ca.uhn.hl7v2.HL7Exception: Could not resolve patient by identifier" ;
693
+
694
+ assertEquals (expected , OpenmrsUtil .formattedStackTrace (test ), "stack trace was not formatted properly" );
695
+ }
696
+
697
+ /**
698
+ * @see OpenmrsUtil#formattedStackTrace(String)
699
+ */
700
+ @ Test
701
+ public void formattedStackTrace_shouldReturnTheUnFormattedStackTraceIfInDevMode () {
702
+ Properties props = Context .getRuntimeProperties ();
703
+ props .setProperty (OpenmrsConstants .DEVELOPMENT_MODE_RUNTIME_PROPERTY , "true" );
704
+ Context .setRuntimeProperties (props );
705
+
706
+ String test = "ca.uhn.hl7v2.HL7Exception: Error while processing HL7 message: ORU_R01\n "
707
+ + "\t at org.openmrs.hl7.impl.HL7ServiceImpl.processHL7Message(HL7ServiceImpl.java:752)\n "
708
+ + "Caused by: ca.uhn.hl7v2.app.ApplicationException: ca.uhn.hl7v2.HL7Exception: Could not resolve patient by identifier\n "
709
+ + "\t at org.openmrs.hl7.handler.ORUR01Handler.processMessage(ORUR01Handler.java:132)\n "
710
+ + "Caused by: ca.uhn.hl7v2.HL7Exception: Could not resolve patient by identifier\n "
711
+ + "\t at org.openmrs.hl7.handler.ORUR01Handler.getPatientByIdentifier(ORUR01Handler.java:998)" ;
712
+
713
+ String expected = "ca.uhn.hl7v2.HL7Exception: Error while processing HL7 message: ORU_R01\n "
714
+ + "\t at org.openmrs.hl7.impl.HL7ServiceImpl.processHL7Message(HL7ServiceImpl.java:752)\n "
715
+ + "Caused by: ca.uhn.hl7v2.app.ApplicationException: ca.uhn.hl7v2.HL7Exception: Could not resolve patient by identifier\n "
716
+ + "\t at org.openmrs.hl7.handler.ORUR01Handler.processMessage(ORUR01Handler.java:132)\n "
717
+ + "Caused by: ca.uhn.hl7v2.HL7Exception: Could not resolve patient by identifier\n "
718
+ + "\t at org.openmrs.hl7.handler.ORUR01Handler.getPatientByIdentifier(ORUR01Handler.java:998)" ;
719
+
720
+ assertEquals (expected , OpenmrsUtil .formattedStackTrace (test ), "stack trace was not returned properly" );
721
+ }
722
+
675
723
/**
676
724
* @see OpenmrsUtil#shortenedStackTrace(String)
677
725
*/
0 commit comments