Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2013
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. here is Note.hbm.xml file
  2.  
  3. <?xml version="1.0"?>
  4. <!DOCTYPE hibernate-mapping PUBLIC
  5. "-//Hibernate/Hibernate Mapping DTD 3.1//EN"
  6. "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
  7.  
  8. <hibernate-mapping package="org.openmrs.module.patientnotes">
  9.  
  10. <class name="Note" table="note">
  11.  
  12. <id name="id" type="int" column="id" unsaved-value="0">
  13. <generator class="native" />
  14. </id>
  15.  
  16. <property name="voided" type="java.lang.Boolean" column="is_voided" not-null="true" length="1" />
  17.  
  18. <property name="dateVoided" type="java.util.Date" column="date_voided" not-null="true" length="19" />
  19.  
  20. <many-to-one name="voided_By" class="org.openmrs.User" not-null="true" />
  21.  
  22. <property name="voidReason" type="java.lang.String"
  23. column="void_reason" length="255" />
  24.  
  25. </class>
  26.  
  27. </hibernate-mapping>
  28. private Boolean voided = Boolean.FALSE;
  29.  
  30. private Date dateVoided;
  31.  
  32. private User voidedBy;
  33.  
  34. private String voidReason;
  35.  
  36.  
  37.  
  38. public Boolean getVoided() {
  39. return voided;
  40. }
  41.  
  42. public void setVoided(Boolean voided) {
  43. this.voided = voided;
  44. }
  45.  
  46. public Date getDateVoided() {
  47. return dateVoided;
  48. }
  49.  
  50. public void setDateVoided(Date dateVoided) {
  51. this.dateVoided = dateVoided;
  52. }
  53.  
  54. public User getVoidedBy() {
  55. return voidedBy;
  56. }
  57.  
  58. public void setVoidedBy(User voidedBy) {
  59. this.voidedBy = voidedBy;
  60. }
  61.  
  62. public String getVoidReason() {
  63. return voidReason;
  64. }
  65.  
  66.  
  67.  
  68. and finnaly in HibernateNoteDAO.java
  69.  
  70. log.info("voiding note because " + reason);
  71. return (Note) sessionFactory.getCurrentSession().get(Note.class, note);
  72. }
  73.  
  74.  
  75.  
  76.  
  77.  
  78. I have written the test case that is yet failing till now
  79.  
  80. that is
  81.  
  82. package org.openmrs.api.db;
  83.  
  84. import static org.junit.Assert.*;
  85.  
  86. import org.junit.Ignore;
  87. import org.junit.Test;
  88. import org.openmrs.PersonName;
  89. import org.openmrs.notification.Note;
  90. import org.openmrs.test.BaseContextSensitiveTest;
  91. import org.openmrs.test.Verifies;
  92.  
  93. public class NoteDAOTest extends BaseContextSensitiveTest{
  94.  
  95. private NoteDAO dao = null;
  96. @Test
  97. public void voidNote_shouldvoidNote() throws Exception {
  98. Note note = new Note();
  99. String reason = null;
  100. assertEquals(dao.voidNote(note, reason), note.getVoided());
  101. }
  102.  
  103. }
  104.  
  105. ___________________________________________________________________________________
  106. added code in
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement