1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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 }