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 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 }