001: /*
002: * Copyright 2005-2007 The Kuali Foundation.
003: *
004: *
005: * Licensed under the Educational Community License, Version 1.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.opensource.org/licenses/ecl1.php
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package edu.iu.uis.eden.notes;
018:
019: import java.util.Iterator;
020: import java.util.List;
021:
022: import org.junit.Test;
023: import org.kuali.workflow.test.WorkflowTestCase;
024:
025: import edu.iu.uis.eden.clientapp.WorkflowDocument;
026: import edu.iu.uis.eden.clientapp.vo.NetworkIdVO;
027: import edu.iu.uis.eden.clientapp.vo.NoteVO;
028:
029: public class NoteWebServiceTest extends WorkflowTestCase {
030:
031: @Test
032: public void testNotesClient() throws Exception {
033: NoteVO testNoteVO;
034: WorkflowDocument doc = new WorkflowDocument(new NetworkIdVO(
035: "rkirkend"), "TestDocumentType");
036: //Test add notes
037: testNoteVO = new NoteVO();
038: testNoteVO.setNoteAuthorWorkflowId("andlee");
039: testNoteVO.setNoteText("first added note");
040: doc.updateNote(testNoteVO);
041:
042: testNoteVO = new NoteVO();
043: testNoteVO.setNoteAuthorWorkflowId("rou");
044: testNoteVO.setNoteText("second added note");
045: doc.updateNote(testNoteVO);
046:
047: List notesList = doc.getNoteList();
048:
049: assertEquals("Two notes are added.", 2, notesList.size());
050: /* int i = 0;
051: for (Iterator it= notesList.iterator(); it.hasNext();){
052: NoteVO displayNoteVO = (NoteVO)it.next();
053: System.out.println("i=" + i);
054: System.out.println(displayNoteVO.getNoteAuthorWorkflowId());
055: System.out.println(displayNoteVO.getNoteText());
056: if (i ==0){
057: assertEquals("The first note Text is equals 'first added note", "first added note", displayNoteVO.getNoteText());
058: }
059: i++;
060: }*/
061:
062: doc.saveRoutingData();
063:
064: int i = 0;
065: notesList = doc.getNoteList();
066: assertEquals("Note List size changed", 2, notesList.size());
067: for (Iterator iter = notesList.iterator(); iter.hasNext();) {
068: NoteVO noteVO = (NoteVO) iter.next();
069: assertNotNull("Note saved through workflow document",
070: noteVO.getNoteId());
071: System.out.println("Note ID is:" + noteVO.getNoteId());
072: i++;
073: if (i == 1) {
074: assertEquals("text altered during save",
075: "first added note", noteVO.getNoteText());
076: assertEquals("note user associated with saved note",
077: "andlee", noteVO.getNoteAuthorWorkflowId());
078: }
079: if (i == 2) {
080: assertEquals("text altered during save",
081: "second added note", noteVO.getNoteText());
082: assertEquals("note user associated with saved note",
083: "rou", noteVO.getNoteAuthorWorkflowId());
084: }
085:
086: }
087:
088: /*List notesFromDB = SpringServiceLocator.getNoteService().getNotesByRouteHeaderId(doc.getRouteHeaderId());
089: for (Iterator iter = notesFromDB.iterator(); iter.hasNext();) {
090: Note note = (Note) iter.next();
091: System.out.println(note.getNoteText());
092: }*/
093:
094: notesList = doc.getNoteList();
095: testNoteVO = (NoteVO) notesList.get(0);
096: doc.deleteNote(testNoteVO);
097:
098: testNoteVO = (NoteVO) notesList.get(1);
099: testNoteVO.setNoteText("Update second note text");
100: doc.updateNote(testNoteVO);
101:
102: doc.saveRoutingData();
103: i = 0;
104: notesList = doc.getNoteList();
105: assertEquals("Note List size changed", 1, notesList.size());
106: for (Iterator iter = notesList.iterator(); iter.hasNext();) {
107: NoteVO noteVO = (NoteVO) iter.next();
108: assertNotNull("Note saved through workflow document",
109: noteVO.getNoteId());
110: System.out.println("Note ID is:" + noteVO.getNoteId());
111: i++;
112: if (i == 1) {
113: assertEquals("text altered during save",
114: "Update second note text", noteVO.getNoteText());
115: assertEquals("note user associated with saved note",
116: "rou", noteVO.getNoteAuthorWorkflowId());
117: }
118: }
119:
120: }
121: }
|