View Javadoc
1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.creadur.whisker.model;
20  
21  import java.util.ArrayList;
22  import java.util.Collection;
23  import java.util.Collections;
24  import java.util.HashMap;
25  import java.util.Map;
26  
27  import junit.framework.TestCase;
28  
29  public class TestDescriptorRequiredNoticesNoThirdPartyNotices extends TestCase {
30  
31      License primaryLicense = new License(false, "This is the license text", Collections.<String> emptyList(), "example.org", "http://example.org", "Example License");
32      String primaryOrg = "example.org";
33      String primaryNotice = "The primary notice.";
34      Collection<WithinDirectory> contents = new ArrayList<WithinDirectory>();
35      Map<String, License> licenses = new HashMap<String, License>();
36      Map<String, String> notices = new HashMap<String, String>();
37      Map<String, Organisation> organisations = new HashMap<String, Organisation>();
38      
39      Descriptor subject;
40      
41      protected void setUp() throws Exception {
42          super.setUp();
43          primaryLicense.storeIn(licenses);
44      }
45  
46      protected void tearDown() throws Exception {
47          super.tearDown();
48      }
49  
50      public void testNoticeRequiredWhenPrimaryNoticeExists() throws Exception {
51          subject = 
52                  new Descriptor(primaryLicense, primaryOrg,  primaryNotice, 
53                          licenses, notices, organisations, contents);
54          assertTrue("When primary notices exists, even if there are not other notices display is required", subject.isNoticeRequired());        
55      }
56  
57      public void testNoticeNotRequiredWhenPrimaryNoticeIsNullAndNoNotices() throws Exception {
58          subject = 
59                  new Descriptor(primaryLicense, primaryOrg,  null, 
60                          licenses, notices, organisations, contents);
61          assertFalse("When no other notices exist and no primary notice, display is not required", 
62                  subject.isNoticeRequired());        
63      }
64  
65      public void testNoticeNotRequiredWhenPrimaryNoticeIsEmptyAndNoNotices() throws Exception {
66          subject = 
67                  new Descriptor(primaryLicense, primaryOrg,  "", 
68                          licenses, notices, organisations, contents);
69          assertFalse("When no other notices exist and no primary notice, display is not required", 
70                  subject.isNoticeRequired());        
71      }
72  
73      public void testNoticeNotRequiredWhenPrimaryNoticeIsWhitespaceAndNoNotices() throws Exception {
74          subject = 
75                  new Descriptor(primaryLicense, primaryOrg,  "   ", 
76                          licenses, notices, organisations, contents);
77          assertFalse("When no other notices exist and no primary notice, display is not required", 
78                  subject.isNoticeRequired());        
79      }
80  }