View Javadoc
1   /*
2    * Copyright 2009 the original author or authors.
3    * 
4    * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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.openehealth.ipf.commons.ihe.xds.core.metadata;
17  
18  import org.junit.Before;
19  import org.junit.Test;
20  import org.openehealth.ipf.commons.ihe.xds.core.transform.ebxml.DocumentEntryTransformerTestBase;
21  
22  import java.util.Collections;
23  
24  import static org.junit.Assert.assertEquals;
25  
26  /**
27   * Tests for {@link DocumentEntry}.
28   * Note that most of the accessors of {@code DocumentEntry} are tested via
29   * the tests of its transformer {@link DocumentEntryTransformerTestBase}.
30   */
31  public class DocumentEntryTest {
32      private Author author1;
33      private Author author2;
34      private Author author3;
35      private DocumentEntry docEntry;
36  
37      @Before
38      public void setUp() {
39          author1 = new Author();
40          author2 = new Author();
41          author3 = new Author();
42          docEntry = new DocumentEntry();
43      }
44  
45      @Test
46      public void testSetAuthorResetsAuthorList() {
47          docEntry.getAuthors().add(author1);
48          docEntry.getAuthors().add(author2);
49          docEntry.setAuthor(author3);
50          assertEquals(Collections.singletonList(author3), docEntry.getAuthors());
51      }
52  
53      @Test
54      public void testGetAuthorOnEmptyAuthorList() {
55          assertEquals(null, docEntry.getAuthor());
56      }
57      
58      @Test
59      public void testGetAuthorOnAuthorListContainingMultipleAuthors() {
60          docEntry.getAuthors().add(author1);
61          docEntry.getAuthors().add(author2);
62          assertEquals(author1, docEntry.getAuthor());
63      }
64  }
65