Project

General

Profile

Download (5.69 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
4
* http://www.e-taxonomy.eu
5
* 
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

    
10
package eu.etaxonomy.cdm.model.reference;
11

    
12
import static org.junit.Assert.*;
13

    
14
import java.util.List;
15

    
16
import org.apache.log4j.Logger;
17
import org.junit.After;
18
import org.junit.AfterClass;
19
import org.junit.Before;
20
import org.junit.BeforeClass;
21
import org.junit.Ignore;
22
import org.junit.Test;
23

    
24
/**
25
 * @author a.mueller
26
 * @created 23.03.2009
27
 * @version 1.0
28
 */
29
//@Ignore
30
public class PublicationBaseTest {
31
	@SuppressWarnings("unused")
32
	private static Logger logger = Logger.getLogger(PublicationBaseTest.class);
33

    
34
	private IBook publicationBase;
35
	private IArticle publicationBase2;
36
	private String publisher1;
37
	private String publisher2;
38
	private String place1;
39
	private String place2;
40
	
41
	/**
42
	 * @throws java.lang.Exception
43
	 */
44
	@BeforeClass
45
	public static void setUpBeforeClass() throws Exception {
46
	}
47

    
48
	/**
49
	 * @throws java.lang.Exception
50
	 */
51
	@AfterClass
52
	public static void tearDownAfterClass() throws Exception {
53
	}
54

    
55
	/**
56
	 * @throws java.lang.Exception
57
	 */
58
	@Before
59
	public void setUp() throws Exception {
60
		publisher1 = "publisher1";
61
		publisher2 = "publisher2";
62
		place1 = "place1";
63
		place2 = "place2";
64
		
65
		
66
		publicationBase = ReferenceFactory.newBook();
67
		
68
		publicationBase2 = ReferenceFactory.newArticle();
69
		
70
	}
71

    
72
	/**
73
	 * @throws java.lang.Exception
74
	 */
75
	@After
76
	public void tearDown() throws Exception {
77
	}
78

    
79
	
80
	
81
	/**
82
	 * Test method for {@link eu.etaxonomy.cdm.model.reference.PublicationBase#addPublisher(java.lang.String, java.lang.String)}.
83
	 */
84
	@Test
85
	public void testAddPublisherStringString() {
86
		assertEquals("No publisher is set", null, publicationBase.getPublisher());
87
		publicationBase.setPublisher(publisher1, place1);
88
		assertEquals("The publishers is publisher1", publisher1, publicationBase.getPublisher());
89
		assertEquals("The place is place1", place1, publicationBase.getPlacePublished());
90
		publicationBase.setPublisher(publisher2, place2);
91
		assertEquals("Second publisher must be publisher2", publisher2, publicationBase.getPublisher());
92

    
93
		assertEquals("Second publication place must be place2", place2, publicationBase.getPlacePublished());
94
	}
95
	
96
	@Test
97
	public void testInReferenceValidation(){
98
		IJournal journal = ReferenceFactory.newJournal();
99
		publicationBase2.setInJournal(journal);
100
		//TODO: to validate it, the object has to be saved to the db
101
		IBookSection booksection = ((ReferenceBase)publicationBase2).castReferenceToBookSection();
102
		
103
		
104
	}
105

    
106
	
107
//	/**
108
//	 * Test method for {@link eu.etaxonomy.cdm.model.reference.PublicationBase#addPublisher(java.lang.String, java.lang.String, int)}.
109
//	 */
110
//	@Test(expected=IndexOutOfBoundsException.class)
111
//	public void testAddPublisherStringStringInt() {
112
//		publicationBase.addPublisher(publisher1, place1);
113
//		publicationBase.addPublisher(publisher2, place2);
114
//		assertEquals("Publishers list must contains exactly 2 entry", 2, publicationBase.getPublishers().size());
115
//		String indexPublisher = "indexPublisher";
116
//		String indexPlace = "indexPlace";
117
//		publicationBase.addPublisher(indexPublisher, indexPlace, 1);
118
//		assertEquals("Publisher at position 1 (starting at 0) should be 'indexPublisher'", indexPublisher, publicationBase.getPublishers().get(1).getPublisherName());
119
//		publicationBase.addPublisher(indexPublisher, indexPlace, 5);
120
//	}
121

    
122

    
123
//	/**
124
//	 * Test method for {@link eu.etaxonomy.cdm.model.reference.PublicationBase#getPublisher(java.lang.int}.
125
//	 */
126
//	@Test(expected=IndexOutOfBoundsException.class)
127
//	public void testGetPublisherInt() {
128
//		publicationBase.addPublisher(publisher1, place1);
129
//		publicationBase.addPublisher(publisher2, place2);
130
//		assertEquals("Publishers list must contains exactly 2 entry", 2, publicationBase.getPublishers().size());
131
//		assertEquals("First publisher must be publisher1", publisher1, publicationBase.getPublisher(0).getPublisherName());
132
//		publicationBase.getPublisher(2);
133
//		publicationBase.getPublisher(-1);
134
//	}
135

    
136
//	/**
137
//	 * Test method for {@link eu.etaxonomy.cdm.model.reference.PublicationBase#removePublisher(eu.etaxonomy.cdm.model.reference.Publisher)}.
138
//	 */
139
//	@Test
140
//	public void testRemovePublisher() {
141
//		publicationBase.addPublisher(publisher1, place1);
142
//		publicationBase.addPublisher(publisher2, place2);
143
//		assertEquals("Publishers list must contains exactly 2 entry", 2, publicationBase.getPublishers().size());
144
//		publicationBase.removePublisher(publicationBase.getPublishers().get(0));
145
//		assertEquals("Publishers list must contains exactly 1 entry", 1, publicationBase.getPublishers().size());
146
//		List<Publisher> publishers = publicationBase.getPublishers();
147
//		assertEquals("Only publisher must be publisher2", publisher2, publishers.get(0).getPublisherName());
148
//		assertEquals("only publication place  must be place2", place2, publishers.get(0).getPlace());
149
//	}
150

    
151
//	/**
152
//	 * Test method for {@link eu.etaxonomy.cdm.model.reference.PublicationBase#clone()}.
153
//	 */
154
//	@Test
155
//	public void testClone() {
156
//		publicationBase.addPublisher(publisher1, place1);
157
//		publicationBase.addPublisher(publisher2, place2);
158
//		assertEquals("Publishers list must contains exactly 2 entry", 2, publicationBase.getPublishers().size());
159
//		CdDvd clone = (CdDvd)publicationBase.clone();
160
//		assertEquals("Publisher place must be equal in original publication and cloned publication", place1, clone.getPublisher(0).getPlace());
161
//		assertNotSame(place1, publicationBase.getPublisher(0), clone.getPublisher(0));	
162
//	}
163
}
    (1-1/1)