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 TestDescriptorRequiredNoticesWithThirdPartyNoticesButNoneUsed 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          notices.put("bogus", "some notice chaff");
45      }
46  
47      protected void tearDown() throws Exception {
48          super.tearDown();
49      }
50  
51      public void testNoticeRequiredWhenPrimaryNoticeExists() throws Exception {
52          subject = 
53                  new Descriptor(primaryLicense, primaryOrg,  primaryNotice, 
54                          licenses, notices, organisations, contents);
55          assertTrue("When primary notices exists and third party notices needed then display is required", 
56                  subject.isNoticeRequired());        
57      }
58  
59      public void testNoticeNotRequiredWhenPrimaryNoticeIsNullAndAllThirdPartyNoticesUnused() throws Exception {
60          subject = 
61                  new Descriptor(primaryLicense, primaryOrg,  null, 
62                          licenses, notices, organisations, contents);
63          assertFalse("When no other notices exist and third party notices needed then display is required", 
64                  subject.isNoticeRequired());        
65      }
66  
67      public void testNoticeNotRequiredWhenPrimaryNoticeIsEmptyAndAllThirdPartyNoticesUnused() throws Exception {
68          subject = 
69                  new Descriptor(primaryLicense, primaryOrg,  "", 
70                          licenses, notices, organisations, contents);
71          assertFalse("When no other notices exist and third party notices needed then display is required", 
72                  subject.isNoticeRequired());        
73      }
74  
75      public void testNoticeNotRequiredWhenPrimaryNoticeIsWhitespaceAndAllThirdPartyNoticesUnused() throws Exception {
76          subject = 
77                  new Descriptor(primaryLicense, primaryOrg,  "   ", 
78                          licenses, notices, organisations, contents);
79          assertFalse("When no other notices exist and third party notices needed then display is required", 
80                  subject.isNoticeRequired());        
81      }
82  }