WHISKER-6 isOnlyPrimary should exclude cases when a different copyright notice has been set

git-svn-id: https://svn.apache.org/repos/asf/creadur/whisker/trunk@1403538 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/apache-whisker-model/src/main/java/org/apache/creadur/whisker/model/Descriptor.java b/apache-whisker-model/src/main/java/org/apache/creadur/whisker/model/Descriptor.java
index c647e62..f817cf2 100644
--- a/apache-whisker-model/src/main/java/org/apache/creadur/whisker/model/Descriptor.java
+++ b/apache-whisker-model/src/main/java/org/apache/creadur/whisker/model/Descriptor.java
@@ -243,10 +243,13 @@
      *         by the primary organisation
      */
     public boolean isOnlyPrimary(final ContentElement contentElement) {
+        final NoCopyrightNoticeVerifier verifier = new NoCopyrightNoticeVerifier();
         final LicenseAndOrganisationCollator collator = new LicenseAndOrganisationCollator();
         contentElement.accept(collator);
+        contentElement.accept(verifier);
         return collator.isOnlyLicense(getPrimaryLicense())
-                && collator.isOnlyOrganisation(this.primaryOrganisationId);
+                && collator.isOnlyOrganisation(this.primaryOrganisationId)
+                && !verifier.isCopyrightNoticePresent();
     }
 
     /**
diff --git a/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/DescriptorBuilderForTesting.java b/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/DescriptorBuilderForTesting.java
index 3386389..d18f9ab 100644
--- a/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/DescriptorBuilderForTesting.java
+++ b/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/DescriptorBuilderForTesting.java
@@ -30,6 +30,7 @@
 public class DescriptorBuilderForTesting {
 
     public static final String DEFAULT_PRIMARY_COPYRIGHT_NOTICE = "Copyright (c) Primary";
+    public static final String DEFAULT_SUBSIDARY_COPYRIGHT_NOTICE = "Copyright (c) Secondary";
 
     License primaryLicense = defaultPrimaryLicense();
     String primaryCopyrightNotice = DEFAULT_PRIMARY_COPYRIGHT_NOTICE;
@@ -40,6 +41,8 @@
     Map<String, String> notices = new HashMap<String, String>();
     Map<String, Organisation> organisations = new HashMap<String, Organisation>();
 
+    String subsidaryCopyrightNotice;
+
     public Descriptor build() {
         primaryLicense.storeIn(licenses);
         primaryOrg.storeIn(organisations);
@@ -54,6 +57,15 @@
             contents);
     }
 
+    public DescriptorBuilderForTesting withSubsidaryCopyrightNotice() {
+        return withSubsidaryCopyrightNotice(DEFAULT_SUBSIDARY_COPYRIGHT_NOTICE);
+    }
+
+    public DescriptorBuilderForTesting withSubsidaryCopyrightNotice(String subsidaryCopyrightNotice) {
+        this.subsidaryCopyrightNotice = subsidaryCopyrightNotice;
+        return this;
+    }
+
     public DescriptorBuilderForTesting withThirdParty(
             OrganisationBuilderForTesting builder) {
         builder.build().storeIn(organisations);
@@ -90,9 +102,8 @@
         byOrgs.add(new ByOrganisation(org, resources));
 
         Collection<WithLicense> withLicenses = new ArrayList<WithLicense>();
-        String copyright = "Copyright Blah";
         Map<String, String> params = Collections.emptyMap();
-        withLicenses.add(new WithLicense(license, copyright, params, byOrgs));
+        withLicenses.add(new WithLicense(license, subsidaryCopyrightNotice, params, byOrgs));
 
         Collection<ByOrganisation> publicDomain = Collections.emptyList();
 
diff --git a/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/TestDescriptorOnlyPrimary.java b/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/TestDescriptorOnlyPrimary.java
new file mode 100644
index 0000000..4763148
--- /dev/null
+++ b/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/TestDescriptorOnlyPrimary.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.creadur.whisker.model;
+
+import junit.framework.TestCase;
+
+public class TestDescriptorOnlyPrimary extends TestCase {
+
+    DescriptorBuilderForTesting builder;
+    Descriptor subject;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        builder = new DescriptorBuilderForTesting();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testIsOnlyPrimaryWithSubsidaryCopyrightNotice() throws Exception {
+        builder.withSubsidaryCopyrightNotice().withThirdParty().withDirectory(".");
+        subject = builder.build();
+        assertFalse("Work is not only primary when subsidary copyright notices exist.",
+                subject.isOnlyPrimary(builder.contents.iterator().next()));
+    }
+}