1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.kew.notes;
18
19 import java.util.Iterator;
20 import java.util.List;
21
22 import org.junit.Test;
23 import org.kuali.rice.kew.dto.NetworkIdDTO;
24 import org.kuali.rice.kew.dto.NoteDTO;
25 import org.kuali.rice.kew.service.WorkflowDocument;
26 import org.kuali.rice.kew.test.KEWTestCase;
27
28
29 public class NoteWebServiceTest extends KEWTestCase {
30
31 @Test public void testNotesClient() throws Exception {
32 NoteDTO testNoteVO;
33 WorkflowDocument doc = new WorkflowDocument(new NetworkIdDTO("rkirkend"), "TestDocumentType");
34
35 testNoteVO = new NoteDTO();
36 testNoteVO.setNoteAuthorWorkflowId("andlee");
37 testNoteVO.setNoteText("first added note");
38 doc.updateNote(testNoteVO);
39
40 testNoteVO = new NoteDTO();
41 testNoteVO.setNoteAuthorWorkflowId("rou");
42 testNoteVO.setNoteText("second added note");
43 doc.updateNote(testNoteVO);
44
45 List notesList = doc.getNoteList();
46
47 assertEquals ("Two notes are added.", 2, notesList.size());
48
49
50
51
52
53
54
55
56
57
58
59
60 doc.saveRoutingData();
61
62 int i = 0;
63 notesList = doc.getNoteList();
64 assertEquals("Note List size changed",2,notesList.size());
65 for (Iterator iter = notesList.iterator(); iter.hasNext();) {
66 NoteDTO noteVO = (NoteDTO) iter.next();
67 assertNotNull("Note saved through workflow document", noteVO.getNoteId());
68 System.out.println("Note ID is:" + noteVO.getNoteId());
69 i++;
70 if (i ==1) {
71 assertEquals("text altered during save", "first added note", noteVO.getNoteText());
72 assertEquals("note user associated with saved note", "andlee", noteVO.getNoteAuthorWorkflowId());
73 }
74 if (i ==2) {
75 assertEquals("text altered during save", "second added note", noteVO.getNoteText());
76 assertEquals("note user associated with saved note", "rou", noteVO.getNoteAuthorWorkflowId());
77 }
78
79 }
80
81
82
83
84
85
86
87 notesList = doc.getNoteList();
88 testNoteVO = (NoteDTO)notesList.get(0);
89 doc.deleteNote(testNoteVO);
90
91 testNoteVO = (NoteDTO)notesList.get(1);
92 testNoteVO.setNoteText("Update second note text");
93 doc.updateNote(testNoteVO);
94
95 doc.saveRoutingData();
96 i = 0;
97 notesList = doc.getNoteList();
98 assertEquals("Note List size changed",1,notesList.size());
99 for (Iterator iter = notesList.iterator(); iter.hasNext();) {
100 NoteDTO noteVO = (NoteDTO) iter.next();
101 assertNotNull("Note saved through workflow document", noteVO.getNoteId());
102 System.out.println("Note ID is:" + noteVO.getNoteId());
103 i++;
104 if (i ==1) {
105 assertEquals("text altered during save", "Update second note text", noteVO.getNoteText());
106 assertEquals("note user associated with saved note", "rou", noteVO.getNoteAuthorWorkflowId());
107 }
108 }
109
110 }
111 }