View Javadoc
1   /**
2    * Copyright 2004-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.kpme.edo.reviewernote;
17  
18  import static org.junit.Assert.assertEquals;
19  import static org.junit.Assert.assertNotNull;
20  
21  import java.util.List;
22  
23  import org.joda.time.LocalDate;
24  import org.junit.After;
25  import org.junit.Before;
26  import org.junit.Test;
27  import org.kuali.kpme.core.IntegrationTest;
28  import org.kuali.kpme.edo.EdoUnitTestBase;
29  import org.kuali.kpme.edo.api.reviewernote.EdoReviewerNote;
30  import org.kuali.kpme.edo.service.EdoServiceLocator;
31  
32  @IntegrationTest
33  public class EdoReviewerNoteServiceTest extends EdoUnitTestBase {
34  
35  	private final String edoReviewerNoteId = "1000"; 
36  	LocalDate asOfDate = new LocalDate(2012,1,1);
37  
38  	@Before
39  	public void setUp() throws Exception {
40  	super.setUp();
41  	
42  	}
43  	
44  	@After
45  	public void tearDown() throws Exception {
46  		super.tearDown();
47  	}
48  	
49  	@Test
50  	public void testGetReviewerNoteById() throws Exception {
51  
52  		EdoReviewerNote edoReviewerNote = EdoServiceLocator.getEdoReviewerNoteService().getReviewerNoteById(edoReviewerNoteId);
53  		assertEquals("1000", edoReviewerNote.getEdoReviewerNoteId());
54  	}
55  	
56  
57  	@Test
58  	public void testGetReviewerNotesByDossierId() throws Exception {
59  
60  		List<EdoReviewerNote> edoReviewerNotes = EdoServiceLocator.getEdoReviewerNoteService().getReviewerNotesByDossierId("1000");
61  		assertEquals("returned the correct number of results", 4, edoReviewerNotes.size());
62  	}
63  
64  	@Test
65  	public void testGetReviewerNotesByUserPrincipalId() throws Exception {
66  
67  		List<EdoReviewerNote> edoReviewerNotes = EdoServiceLocator.getEdoReviewerNoteService().getReviewerNotesByUserPrincipalId("reviewChair");
68  		assertEquals("returned the correct number of results", 2, edoReviewerNotes.size());
69  	}
70  
71  	@Test
72  	public void testSaveOrUpdate() throws Exception {
73  		// get original bo
74  		EdoReviewerNote edoReviewerNote = EdoServiceLocator.getEdoReviewerNoteService().getReviewerNoteById(edoReviewerNoteId);
75  		assertEquals("reviewer note1", edoReviewerNote.getNote());
76  		// modify the retrieved bo
77  		EdoReviewerNoteBo edoReviewerNoteBo = EdoReviewerNoteBo.from(edoReviewerNote);
78  		edoReviewerNoteBo.setNote("Revised Reviewer note1");
79  		EdoServiceLocator.getEdoReviewerNoteService().saveOrUpdate(EdoReviewerNoteBo.to(edoReviewerNoteBo));
80  		// check if the bo has been updated
81  		edoReviewerNote = EdoServiceLocator.getEdoReviewerNoteService().getReviewerNoteById(edoReviewerNoteId);
82  		assertEquals("Revised Reviewer note1", edoReviewerNote.getNote());
83  	}
84  	
85  }