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.SubmissionSetTransformerTestBase;
21  
22  import java.util.Collections;
23  
24  import static org.junit.Assert.assertEquals;
25  import static org.junit.Assert.assertTrue;
26  
27  /**
28   * Tests for {@link SubmissionSet}.
29   * Note that most of the accessors of {@code SubmissionSet} are tested via
30   * the tests of its transformer {@link SubmissionSetTransformerTestBase}.
31   */
32  public class SubmissionSetTest {
33      private Author author1;
34      private Author author2;
35      private Author author3;
36      private SubmissionSet submissionSet;
37  
38      @Before
39      public void setUp() {
40          author1 = new Author();
41          author2 = new Author();
42          author3 = new Author();
43          submissionSet = new SubmissionSet();
44      }
45  
46      @Test
47      public void testSetAuthorResetsAuthorList() {
48          submissionSet.getAuthors().add(author1);
49          submissionSet.getAuthors().add(author2);
50          submissionSet.setAuthor(author3);
51          assertEquals(Collections.singletonList(author3), submissionSet.getAuthors());
52      }
53  
54      @Test
55      public void testGetAuthorOnEmptyAuthorList() {
56          assertTrue(null, submissionSet.getAuthors().isEmpty());
57      }
58  
59      @Test
60      public void testGetAuthorOnAuthorListContainingMultipleAuthors() {
61          submissionSet.getAuthors().add(author1);
62          submissionSet.getAuthors().add(author2);
63          assertEquals(2, submissionSet.getAuthors().size());
64          assertEquals(author1, submissionSet.getAuthors().get(0));
65          assertEquals(author2, submissionSet.getAuthors().get(1));
66      }
67  }