creadur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r1403538 - in /creadur/whisker/trunk/apache-whisker-model/src: main/java/org/apache/creadur/whisker/model/ test/java/org/apache/creadur/whisker/model/
Date Mon, 29 Oct 2012 21:25:02 GMT
Author: rdonkin
Date: Mon Oct 29 21:25:01 2012
New Revision: 1403538

URL: http://svn.apache.org/viewvc?rev=1403538&view=rev
Log:
WHISKER-6 isOnlyPrimary should exclude cases when a different copyright notice has been set

Added:
    creadur/whisker/trunk/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/TestDescriptorOnlyPrimary.java
  (with props)
Modified:
    creadur/whisker/trunk/apache-whisker-model/src/main/java/org/apache/creadur/whisker/model/Descriptor.java
    creadur/whisker/trunk/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/DescriptorBuilderForTesting.java

Modified: creadur/whisker/trunk/apache-whisker-model/src/main/java/org/apache/creadur/whisker/model/Descriptor.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-model/src/main/java/org/apache/creadur/whisker/model/Descriptor.java?rev=1403538&r1=1403537&r2=1403538&view=diff
==============================================================================
--- creadur/whisker/trunk/apache-whisker-model/src/main/java/org/apache/creadur/whisker/model/Descriptor.java
(original)
+++ creadur/whisker/trunk/apache-whisker-model/src/main/java/org/apache/creadur/whisker/model/Descriptor.java
Mon Oct 29 21:25:01 2012
@@ -243,10 +243,13 @@ public class Descriptor {
      *         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();
     }
 
     /**

Modified: creadur/whisker/trunk/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/DescriptorBuilderForTesting.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/DescriptorBuilderForTesting.java?rev=1403538&r1=1403537&r2=1403538&view=diff
==============================================================================
--- creadur/whisker/trunk/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/DescriptorBuilderForTesting.java
(original)
+++ creadur/whisker/trunk/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/DescriptorBuilderForTesting.java
Mon Oct 29 21:25:01 2012
@@ -30,6 +30,7 @@ import static org.apache.creadur.whisker
 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 @@ public class DescriptorBuilderForTesting
     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 @@ public class DescriptorBuilderForTesting
             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 @@ public class DescriptorBuilderForTesting
         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();
 

Added: creadur/whisker/trunk/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/TestDescriptorOnlyPrimary.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/TestDescriptorOnlyPrimary.java?rev=1403538&view=auto
==============================================================================
--- creadur/whisker/trunk/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/TestDescriptorOnlyPrimary.java
(added)
+++ creadur/whisker/trunk/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/TestDescriptorOnlyPrimary.java
Mon Oct 29 21:25:01 2012
@@ -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()));
+    }
+}

Propchange: creadur/whisker/trunk/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/TestDescriptorOnlyPrimary.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message