diff --git a/src/main/java/org/spdx/core/CoreModelObject.java b/src/main/java/org/spdx/core/CoreModelObject.java index 2e881ad..e36a0df 100644 --- a/src/main/java/org/spdx/core/CoreModelObject.java +++ b/src/main/java/org/spdx/core/CoreModelObject.java @@ -38,7 +38,6 @@ import org.spdx.storage.IModelStore.ModelUpdate; /** - * @author Gary O'Neall * * Superclass for all SPDX model objects * @@ -70,12 +69,16 @@ * * This class also handles the conversion of a CoreModelObject to and from a TypeValue for storage in the ModelStore. * + * @author Gary O'Neall + * */ public abstract class CoreModelObject { static final Logger logger = LoggerFactory.getLogger(CoreModelObject.class); static final String PROPERTY_MSG = "Property "; + + private static final String ATTEMPTING_EXTERNAL_MSG = "Attempting to set {0} for an external model object"; protected IModelStore modelStore; protected String objectUri; protected String specVersion; @@ -340,7 +343,7 @@ public void setPropertyValue(PropertyDescriptor propertyDescriptor, @Nullable Ob throw new InvalidSPDXAnalysisException("Can not set a property for the literal value "+((IndividualUriValue)this).getIndividualURI()); } if (isExternal()) { - logger.warn("Attempting to set "+propertyDescriptor+" for an external model object"); + logger.warn(ATTEMPTING_EXTERNAL_MSG, propertyDescriptor); return; } ModelObjectHelper.setPropertyValue(this.modelStore, objectUri, propertyDescriptor, value, @@ -461,7 +464,7 @@ public Optional getBooleanPropertyValue(PropertyDescriptor propertyDesc */ public void removeProperty(PropertyDescriptor propertyDescriptor) throws InvalidSPDXAnalysisException { if (isExternal()) { - logger.warn("Attempting to set "+propertyDescriptor+" for an external model object"); + logger.warn(ATTEMPTING_EXTERNAL_MSG, propertyDescriptor); return; } ModelObjectHelper.removeProperty(modelStore, objectUri, propertyDescriptor); @@ -484,7 +487,7 @@ public ModelUpdate updateRemoveProperty(PropertyDescriptor propertyDescriptor) { */ public void clearValueCollection(PropertyDescriptor propertyDescriptor) throws InvalidSPDXAnalysisException { if (isExternal()) { - logger.warn("Attempting to set "+propertyDescriptor+" for an external model object"); + logger.warn(ATTEMPTING_EXTERNAL_MSG, propertyDescriptor); return; } ModelObjectHelper.clearValueCollection(modelStore, objectUri, propertyDescriptor); @@ -510,7 +513,7 @@ public ModelUpdate updateClearValueCollection(PropertyDescriptor propertyDescrip */ public void addPropertyValueToCollection(PropertyDescriptor propertyDescriptor, Object value) throws InvalidSPDXAnalysisException { if (isExternal()) { - logger.warn("Attempting to set "+propertyDescriptor+" for an external model object"); + logger.warn(ATTEMPTING_EXTERNAL_MSG, propertyDescriptor); return; } ModelObjectHelper.addValueToCollection(modelStore, objectUri, propertyDescriptor, value, @@ -539,7 +542,7 @@ public ModelUpdate updateAddPropertyValueToCollection(PropertyDescriptor propert */ public void removePropertyValueFromCollection(PropertyDescriptor propertyDescriptor, Object value) throws InvalidSPDXAnalysisException { if (isExternal()) { - logger.warn("Attempting to set "+propertyDescriptor+" for an external model object"); + logger.warn(ATTEMPTING_EXTERNAL_MSG, propertyDescriptor); return; } ModelObjectHelper.removePropertyValueFromCollection(modelStore, objectUri, propertyDescriptor, value); diff --git a/src/main/java/org/spdx/core/DefaultModelStore.java b/src/main/java/org/spdx/core/DefaultModelStore.java index 6162bee..257c7f7 100644 --- a/src/main/java/org/spdx/core/DefaultModelStore.java +++ b/src/main/java/org/spdx/core/DefaultModelStore.java @@ -24,11 +24,11 @@ import org.spdx.storage.IModelStore; /** - * @author Gary O'Neall - * * Singleton class to hold a default model store used when no model store is provided * * WARNING: The model store is in memory and will continue to grow as it is utilized. There is NO garbage collection. + * + * @author Gary O'Neall * */ public class DefaultModelStore { diff --git a/src/main/java/org/spdx/core/DefaultStoreNotInitialized.java b/src/main/java/org/spdx/core/DefaultStoreNotInitialized.java index b4175b1..e496a5f 100644 --- a/src/main/java/org/spdx/core/DefaultStoreNotInitialized.java +++ b/src/main/java/org/spdx/core/DefaultStoreNotInitialized.java @@ -5,9 +5,9 @@ package org.spdx.core; /** - * @author Gary O'Neall - * * Exception where the default store is used before it has been initialized + * + * @author Gary O'Neall * */ public class DefaultStoreNotInitialized extends InvalidSPDXAnalysisException { diff --git a/src/main/java/org/spdx/core/DuplicateSpdxIdException.java b/src/main/java/org/spdx/core/DuplicateSpdxIdException.java index f42b835..ba761db 100644 --- a/src/main/java/org/spdx/core/DuplicateSpdxIdException.java +++ b/src/main/java/org/spdx/core/DuplicateSpdxIdException.java @@ -18,8 +18,9 @@ package org.spdx.core; /** - * @author gary - * + * Exception for duplicate SPDX ID creations + * + * @author Gary O'Neall */ public class DuplicateSpdxIdException extends InvalidSPDXAnalysisException { diff --git a/src/main/java/org/spdx/core/IExternalElementInfo.java b/src/main/java/org/spdx/core/IExternalElementInfo.java index f3c75d1..3a62618 100644 --- a/src/main/java/org/spdx/core/IExternalElementInfo.java +++ b/src/main/java/org/spdx/core/IExternalElementInfo.java @@ -5,12 +5,11 @@ package org.spdx.core; /** - * @author Gary O'Neall - * * Information about an Element which is external to the collection or store * * The information stored is version dependent and implemented in the models - * + * + * @author Gary O'Neall */ public interface IExternalElementInfo { diff --git a/src/main/java/org/spdx/core/IModelCopyManager.java b/src/main/java/org/spdx/core/IModelCopyManager.java index 722d6af..3af7034 100644 --- a/src/main/java/org/spdx/core/IModelCopyManager.java +++ b/src/main/java/org/spdx/core/IModelCopyManager.java @@ -9,8 +9,6 @@ import org.spdx.storage.IModelStore; /** - * @author Gary O'Neall - * * Implementation classes of this interface helps facilitate copying objects from one model to another. * * In addition to the copy functions (methods), these objects keeps track of @@ -18,7 +16,7 @@ * * These objects can be passed into the constructor for ModelObjects to allow the objects to be copied. * - * + * @author Gary O'Neall */ public interface IModelCopyManager { diff --git a/src/main/java/org/spdx/core/ISpdxModelInfo.java b/src/main/java/org/spdx/core/ISpdxModelInfo.java index fe70d7f..0d6947d 100644 --- a/src/main/java/org/spdx/core/ISpdxModelInfo.java +++ b/src/main/java/org/spdx/core/ISpdxModelInfo.java @@ -12,10 +12,9 @@ import org.spdx.storage.IModelStore; /** - * @author Gary O'Neall - * * Interface for SPDX model information - * + * + * @author Gary O'Neall */ public interface ISpdxModelInfo { diff --git a/src/main/java/org/spdx/core/InvalidSPDXAnalysisException.java b/src/main/java/org/spdx/core/InvalidSPDXAnalysisException.java index f41fb5a..1712587 100644 --- a/src/main/java/org/spdx/core/InvalidSPDXAnalysisException.java +++ b/src/main/java/org/spdx/core/InvalidSPDXAnalysisException.java @@ -18,9 +18,9 @@ package org.spdx.core; /** - * @author Gary O'Neall - * * Exception for invalid SPDX Documents + * + * @author Gary O'Neall * */ public class InvalidSPDXAnalysisException extends Exception { diff --git a/src/main/java/org/spdx/core/InvalidSpdxPropertyException.java b/src/main/java/org/spdx/core/InvalidSpdxPropertyException.java index 6a9d5d4..5e7c83c 100644 --- a/src/main/java/org/spdx/core/InvalidSpdxPropertyException.java +++ b/src/main/java/org/spdx/core/InvalidSpdxPropertyException.java @@ -18,9 +18,9 @@ package org.spdx.core; /** - * @author Gary O'Neall - * * Invalid property name or value for an SPDX item + * + * @author Gary O'Neall * */ public class InvalidSpdxPropertyException extends InvalidSPDXAnalysisException { diff --git a/src/main/java/org/spdx/core/ModelCollection.java b/src/main/java/org/spdx/core/ModelCollection.java index 48f8559..66387a3 100644 --- a/src/main/java/org/spdx/core/ModelCollection.java +++ b/src/main/java/org/spdx/core/ModelCollection.java @@ -54,9 +54,7 @@ public class ModelCollection implements Collection { */ protected Map externalMap; private Class type; - //TODO: See if this boolean is needed before deleting the comments -// private boolean licensePrimitiveAssignable; // If true, NONE and NOASSERTION should be converted to NoneLicense and NoAssertionLicense - + /** * @author Gary O'Neall * @@ -111,13 +109,9 @@ public ModelCollection(IModelStore modelStore, String objectUri, PropertyDescrip } if (Objects.nonNull(type)) { this.type = type; - // TODO: make sure the following commented logic is not needed -// licensePrimitiveAssignable = type.isAssignableFrom(SpdxNoneLicense.class) || type.isAssignableFrom(SpdxNoAssertionLicense.class); if (!modelStore.isCollectionMembersAssignableTo(objectUri, propertyDescriptor, type)) { throw new SpdxInvalidTypeException("Incompatible type for property "+propertyDescriptor+": "+type.toString()); } -// } else { -// licensePrimitiveAssignable = false; } } diff --git a/src/main/java/org/spdx/core/ModelRegistry.java b/src/main/java/org/spdx/core/ModelRegistry.java index 748e89a..7c0150e 100644 --- a/src/main/java/org/spdx/core/ModelRegistry.java +++ b/src/main/java/org/spdx/core/ModelRegistry.java @@ -18,13 +18,13 @@ import org.spdx.storage.IModelStore; /** - * @author Gary O'Neall - * + * Singleton class which contains a registry of SPDX model versions * * Each model version implements a model interface ISpdxModelInfo which * supports inflating an SPDX type specific to that version - * s + * + * @author Gary O'Neall */ public class ModelRegistry { diff --git a/src/main/java/org/spdx/core/ModelRegistryException.java b/src/main/java/org/spdx/core/ModelRegistryException.java index 05822b0..1a82c51 100644 --- a/src/main/java/org/spdx/core/ModelRegistryException.java +++ b/src/main/java/org/spdx/core/ModelRegistryException.java @@ -5,8 +5,9 @@ package org.spdx.core; /** - * @author gary + * Exceptions related to a model registry * + * @author Gary O'Neall */ public class ModelRegistryException extends InvalidSPDXAnalysisException { diff --git a/src/main/java/org/spdx/core/NotEquivalentReason.java b/src/main/java/org/spdx/core/NotEquivalentReason.java index f32694d..47a7267 100644 --- a/src/main/java/org/spdx/core/NotEquivalentReason.java +++ b/src/main/java/org/spdx/core/NotEquivalentReason.java @@ -20,11 +20,10 @@ import org.spdx.storage.PropertyDescriptor; /** - * @author Gary O'Neall - * * Primarily used for debugging. Records details when two model objects are compared and are determined to not * be equivalent - * + * + * @author Gary O'Neall */ public class NotEquivalentReason { diff --git a/src/main/java/org/spdx/core/SimpleUriValue.java b/src/main/java/org/spdx/core/SimpleUriValue.java index 561de77..1bfbcf3 100644 --- a/src/main/java/org/spdx/core/SimpleUriValue.java +++ b/src/main/java/org/spdx/core/SimpleUriValue.java @@ -113,7 +113,7 @@ public Object toModelObject(IModelStore store, IModelCopyManager copyManager, } else { retval = ModelRegistry.getModelRegistry().getExternalElement(store, uri, copyManager, type, specVersion); if (Objects.isNull(retval)) { - logger.warn(this.getIndividualURI() + " does not match an enum, individual, or external pattern"); + logger.warn("{0} does not match an enum, individual, or external pattern", this.getIndividualURI()); retval = this; } } diff --git a/src/main/java/org/spdx/core/SpdxCoreConstants.java b/src/main/java/org/spdx/core/SpdxCoreConstants.java index b29add1..f04ff2f 100644 --- a/src/main/java/org/spdx/core/SpdxCoreConstants.java +++ b/src/main/java/org/spdx/core/SpdxCoreConstants.java @@ -5,10 +5,9 @@ package org.spdx.core; /** - * @author Gary O'Neall - * * Common constants used in the SPDX core library * + * @author Gary O'Neall */ public class SpdxCoreConstants { diff --git a/src/main/java/org/spdx/core/SpdxIdInUseException.java b/src/main/java/org/spdx/core/SpdxIdInUseException.java index d1ac4f6..29a2307 100644 --- a/src/main/java/org/spdx/core/SpdxIdInUseException.java +++ b/src/main/java/org/spdx/core/SpdxIdInUseException.java @@ -19,6 +19,7 @@ /** * Exception when an SPDX element is in use (e.g. exception thrown when attempting to delete) + * * @author Gary O'Neall * */ diff --git a/src/main/java/org/spdx/core/SpdxIdNotFoundException.java b/src/main/java/org/spdx/core/SpdxIdNotFoundException.java index 5c34d2e..7446787 100644 --- a/src/main/java/org/spdx/core/SpdxIdNotFoundException.java +++ b/src/main/java/org/spdx/core/SpdxIdNotFoundException.java @@ -18,9 +18,9 @@ package org.spdx.core; /** - * @author Gary O'Neall - * * Exception for no SPDX identifier found + * + * @author Gary O'Neall * */ public class SpdxIdNotFoundException extends InvalidSPDXAnalysisException { diff --git a/src/main/java/org/spdx/core/SpdxInvalidIdException.java b/src/main/java/org/spdx/core/SpdxInvalidIdException.java index b7ca16e..a482235 100644 --- a/src/main/java/org/spdx/core/SpdxInvalidIdException.java +++ b/src/main/java/org/spdx/core/SpdxInvalidIdException.java @@ -18,9 +18,9 @@ package org.spdx.core; /** - * @author Gary O'Neall + * Invalid SPDX identifier * - * Ivalid SPDX identifier + * @author Gary O'Neall * */ public class SpdxInvalidIdException extends InvalidSPDXAnalysisException { diff --git a/src/main/java/org/spdx/core/SpdxInvalidTypeException.java b/src/main/java/org/spdx/core/SpdxInvalidTypeException.java index fee4b9c..de3739d 100644 --- a/src/main/java/org/spdx/core/SpdxInvalidTypeException.java +++ b/src/main/java/org/spdx/core/SpdxInvalidTypeException.java @@ -18,9 +18,9 @@ package org.spdx.core; /** - * @author Gary O'Neall - * * Invalid type for an SPDX property + * + * @author Gary O'Neall * */ public class SpdxInvalidTypeException extends InvalidSPDXAnalysisException { diff --git a/src/main/java/org/spdx/core/SpdxObjectNotInStoreException.java b/src/main/java/org/spdx/core/SpdxObjectNotInStoreException.java index 99f3629..1358c49 100644 --- a/src/main/java/org/spdx/core/SpdxObjectNotInStoreException.java +++ b/src/main/java/org/spdx/core/SpdxObjectNotInStoreException.java @@ -19,6 +19,7 @@ /** * Exception when an SDPX ID or object was not found in a model store + * * @author Gary O'Neall * */ diff --git a/src/main/java/org/spdx/core/package-info.java b/src/main/java/org/spdx/core/package-info.java index 3b69fce..7a7c4c6 100644 --- a/src/main/java/org/spdx/core/package-info.java +++ b/src/main/java/org/spdx/core/package-info.java @@ -3,9 +3,8 @@ * Copyright (c) 2024 Source Auditor Inc. */ /** - * @author Gary O'Neall - * * Common classes used by the SPDX model and library * + * @author Gary O'Neall */ package org.spdx.core; \ No newline at end of file diff --git a/src/main/java/org/spdx/licenseTemplate/LicenseTextHelper.java b/src/main/java/org/spdx/licenseTemplate/LicenseTextHelper.java index cb00bea..ca25971 100644 --- a/src/main/java/org/spdx/licenseTemplate/LicenseTextHelper.java +++ b/src/main/java/org/spdx/licenseTemplate/LicenseTextHelper.java @@ -19,9 +19,9 @@ import java.util.regex.Pattern; /** - * @author Gary O'Neall - * * Static helper class for comparing license text + * + * @author Gary O'Neall * */ public class LicenseTextHelper { @@ -101,7 +101,7 @@ public class LicenseTextHelper { private LicenseTextHelper() { // static class - }; + } /** * Returns true if two sets of license text is considered a match per @@ -271,11 +271,7 @@ public static boolean canSkip(String token) { */ public static boolean tokensEquivalent(String tokenA, String tokenB) { if (tokenA == null) { - if (tokenB == null) { - return true; - } else { - return false; - } + return tokenB == null; } else if (tokenB == null) { return false; } else { @@ -349,12 +345,12 @@ public static String replaceMultWord(String s) { public static String normalizeText(String s) { // First normalize single quotes, then normalize two single quotes to a double quote, normalize double quotes // then normalize non-breaking spaces to spaces - return s.replaceAll("‘|’|‛|‚|`", "'") // Take care of single quotes first - .replaceAll("http://", "https://") // Normalize the http protocol scheme - .replaceAll("''","\"") // This way, we can change doulbe single quotes to a single double cquote - .replaceAll("“|”|‟|„", "\"") // Now we can normalize the double quotes + return s.replaceAll("[‘’‛‚`]", "'") // Take care of single quotes first + .replace("http://", "https://") // Normalize the http protocol scheme + .replace("''","\"") // This way, we can change doulbe single quotes to a single double cquote + .replaceAll("[“”‟„]", "\"") // Now we can normalize the double quotes .replaceAll("\\u00A0", " ") // replace non-breaking spaces with spaces since Java does not handle the former well - .replaceAll("—|–","-") // replace em dash, en dash with simple dash + .replaceAll("[—–]","-") // replace em dash, en dash with simple dash .replaceAll("\\u2028", "\n"); // replace line separator with newline since Java does not handle the former well } @@ -363,6 +359,6 @@ public static String normalizeText(String s) { * @return s without any line separators (---, ***, ===) */ public static String removeLineSeparators(String s) { - return s.replaceAll("(-|=|\\*){3,}\\s*$", ""); // Remove ----, ***, and ==== + return s.replaceAll("[-=*]{3,}\\s*$", ""); // Remove ----, ***, and ==== } } diff --git a/src/main/java/org/spdx/licenseTemplate/package-info.java b/src/main/java/org/spdx/licenseTemplate/package-info.java index 517795d..1ccc179 100644 --- a/src/main/java/org/spdx/licenseTemplate/package-info.java +++ b/src/main/java/org/spdx/licenseTemplate/package-info.java @@ -16,9 +16,9 @@ * limitations under the License. */ /** - * @author Gary O'Neall - * * License template are used for matching licenses. + * + * @author Gary O'Neall * */ package org.spdx.licenseTemplate; \ No newline at end of file diff --git a/src/main/java/org/spdx/storage/CompatibleModelStoreWrapper.java b/src/main/java/org/spdx/storage/CompatibleModelStoreWrapper.java deleted file mode 100644 index c9beca7..0000000 --- a/src/main/java/org/spdx/storage/CompatibleModelStoreWrapper.java +++ /dev/null @@ -1,590 +0,0 @@ -/** - * Copyright (c) 2023 Source Auditor Inc. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed 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.spdx.storage; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import java.util.stream.StreamSupport; - -import org.spdx.core.InvalidSPDXAnalysisException; -import org.spdx.core.ModelRegistryException; -import org.spdx.core.SpdxCoreConstants; -import org.spdx.core.SpdxInvalidIdException; -import org.spdx.core.SpdxInvalidTypeException; -import org.spdx.core.TypedValue; - -/** - * Wraps a model store providing a compatible interface to the 1.X version of the SPDX Java Library - * - * @author Gary O'Neall - * - */ -public class CompatibleModelStoreWrapper implements IModelStore { - - //TODO: Move this to the SPDX 2.X library - - public static class TypedValueCompatV2 { - String id; - String type; - - public TypedValueCompatV2(String id, String type) { - this.id = id; - this.type = type; - } - } - - public static final String LATEST_SPDX_2X_VERSION = "SPDX-2.3"; - - // Namespaces - public static final String RDF_NAMESPACE = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; - public static final String RDFS_NAMESPACE = "http://www.w3.org/2000/01/rdf-schema#"; - public static final String SPDX_NAMESPACE = "http://spdx.org/rdf/terms#"; - public static final String DOAP_NAMESPACE = "http://usefulinc.com/ns/doap#"; - public static final String OWL_NAMESPACE = "http://www.w3.org/2002/07/owl#"; - public static final String RDF_POINTER_NAMESPACE = "http://www.w3.org/2009/pointers#"; - public static final String XML_SCHEMA_NAMESPACE = "http://www.w3.org/2001/XMLSchema#"; - - static final Map PROP_NAME_TO_NON_SPDX_NS; - - static { - Map nameToNS = new HashMap<>(); - nameToNS.put("type", RDF_NAMESPACE); - nameToNS.put("resource", RDF_NAMESPACE); - nameToNS.put("sameAs", OWL_NAMESPACE); - nameToNS.put("comment", RDFS_NAMESPACE); - nameToNS.put("label", RDFS_NAMESPACE); - nameToNS.put("seeAlso", RDFS_NAMESPACE); - nameToNS.put("homepage", DOAP_NAMESPACE); - nameToNS.put("startPointer", RDF_POINTER_NAMESPACE); - nameToNS.put("endPointer", RDF_POINTER_NAMESPACE); - nameToNS.put("reference", RDF_POINTER_NAMESPACE); - nameToNS.put("offset", RDF_POINTER_NAMESPACE); - nameToNS.put("lineNumber", RDF_POINTER_NAMESPACE); - - PROP_NAME_TO_NON_SPDX_NS = Collections.unmodifiableMap(nameToNS); - } - - private IModelStore baseStore; - - public CompatibleModelStoreWrapper(IModelStore baseStore) { - Objects.requireNonNull(baseStore, "A base store must be provided for the CompatibileModelStoreWrapper"); - this.baseStore = baseStore; - } - - public static PropertyDescriptor propNameToPropDescriptor(String propName) { - return new PropertyDescriptor(propName, - PROP_NAME_TO_NON_SPDX_NS.getOrDefault(propName, SPDX_NAMESPACE)); - } - - @Override - public void close() throws Exception { - baseStore.close(); - } - - /** - * @param documentUri a nameSpace for the ID - * @param id unique ID within the SPDX document - * @return true if the objectUri already exists for the documentUri - */ - public boolean exists(String documentUri, String id) { - return exists(documentUriIdToUri(documentUri, id, baseStore)); - } - - /** - * @param documentUri SPDX v2 Document URI - * @param id ID consistent with SPDX v2 spec - * @param store store used for the Document URI - * @return true if the objectUri already exists for the documentUri - */ - public static String documentUriIdToUri(String documentUri, String id, IModelStore store) { - return documentUriIdToUri(documentUri, id, store.isAnon(id)); - } - - public static String documentUriToNamespace(String documentUri) { - if (documentUri.contains("://spdx.org/licenses/")) { - return documentUri; - } else { - return documentUri + "#"; - } - } - - /** - * @param documentUri SPDX v2 Document URI - * @param id ID consistent with SPDX v2 spec - * @param anonymous true of this is an anonymous ID - * @return a URI based on the document URI and ID - if anonymous is true, the ID is returned - */ - public static String documentUriIdToUri(String documentUri, String id, boolean anonymous) { - return anonymous ? id : documentUriToNamespace(documentUri) + id; - } - - /** - * Convenience method to convert an SPDX 2.X style typed value to the current TypedValue - * @param documentUri SPDX v2 Document URI - * @param id ID consistent with SPDX v2 spec - * @param anonymous true of this is an anonymous ID - * @param type SPDX type - * @return TypedValue with the proper Object URI formed by the documentUri and ID - * @throws SpdxInvalidIdException if the ID is not valid - * @throws SpdxInvalidTypeException if the type is not valid - * @throws ModelRegistryException if there is no model registered for the spec version - */ - public static TypedValue typedValueFromDocUri(String documentUri, String id, boolean anonymous, String type) throws SpdxInvalidIdException, SpdxInvalidTypeException, ModelRegistryException { - return new TypedValue(documentUriIdToUri(documentUri, id, anonymous), type, LATEST_SPDX_2X_VERSION); - } - - /** - * Convenience method to convert an SPDX 2.X style typed value to the current TypedValue - * @param documentUri SPDX v2 Document URI - * @param id ID consistent with SPDX v2 spec - * @param store store used - * @param type SPDX type - * @return TypedValue with the proper Object URI formed by the documentUri and ID - * @throws SpdxInvalidIdException if the ID is not valid - * @throws SpdxInvalidTypeException if the type is not valid - * @throws ModelRegistryException if there is no model registered for the spec version - */ - public static TypedValue typedValueFromDocUri(String documentUri, String id, IModelStore store, String type) throws SpdxInvalidIdException, SpdxInvalidTypeException, ModelRegistryException { - return new TypedValue(documentUriIdToUri(documentUri, id, store), type, LATEST_SPDX_2X_VERSION); - } - - /** - * @param store Store storing the objet URI - * @param objectUri Object URI - * @param documentUri SPDX 2 document URI for the ID - * @return the SPDX 2 compatible ID - * @throws InvalidSPDXAnalysisException - */ - public static String objectUriToId(IModelStore store, String objectUri, String documentUri) throws InvalidSPDXAnalysisException { - return objectUriToId(store.isAnon(objectUri), objectUri, documentUri); - } - - /** - * @param anon true if the ID type is anonymous - * @param objectUri Object URI - * @param documentUri SPDX 2 document URI for the ID - * @return the SPDX 2 compatible ID - * @throws InvalidSPDXAnalysisException on any SPDX exception - */ - public static String objectUriToId(boolean anon, String objectUri, String documentUri) throws InvalidSPDXAnalysisException { - Objects.requireNonNull(objectUri, "Object URI can not be null"); - if (anon) { - return objectUri; - } - if (objectUri.startsWith(SpdxCoreConstants.LISTED_LICENSE_URL)) { - return objectUri.substring(SpdxCoreConstants.LISTED_LICENSE_URL.length()); - } - if (objectUri.startsWith(SpdxCoreConstants.LISTED_LICENSE_NAMESPACE_PREFIX)) { - return objectUri.substring(SpdxCoreConstants.LISTED_LICENSE_NAMESPACE_PREFIX.length()); - } - if ("http://spdx.org/rdf/terms#noassertion".equals(objectUri)) { - return "NOASSERTION"; - } - if ("http://spdx.org/rdf/terms#none".equals(objectUri)) { - return "NONE"; - } - Objects.requireNonNull(documentUri, "Document URI can not be null"); - String nameSpace = documentUri + "#"; - if (!objectUri.startsWith(nameSpace)) { - throw new InvalidSPDXAnalysisException("Object URI must start with document URI + #. DocumentUri: " + - documentUri + ", Object URI: "+objectUri); - } - return objectUri.substring(nameSpace.length()); - } - - @Override - public boolean exists(String uri) { - return baseStore.exists(uri); - } - - /** - * @param documentUri SPDX v2 spec document URI - * @param id SPDX ID - * @param type type - * @throws InvalidSPDXAnalysisException on any SPDX exception - */ - public void create(String documentUri, String id, String type) - throws InvalidSPDXAnalysisException { - baseStore.create( - new TypedValue(documentUriIdToUri(documentUri, id, this), type, LATEST_SPDX_2X_VERSION)); - } - - @Override - public void create(TypedValue typedValue) throws InvalidSPDXAnalysisException { - baseStore.create(typedValue); - } - - @Override - public List getPropertyValueDescriptors( - String objectUri) throws InvalidSPDXAnalysisException { - return baseStore.getPropertyValueDescriptors(objectUri); - } - - public List getPropertyValueDescriptors( - String documentUri, String id) throws InvalidSPDXAnalysisException { - return getPropertyValueDescriptors(documentUriIdToUri(documentUri, id, baseStore)); - } - - /** - * @param objectUri URI for the item - * @return all property names stored for the Object URI - * @throws InvalidSPDXAnalysisException on any SPDX exception - */ - public Collection getPropertyValueNames( - String objectUri) throws InvalidSPDXAnalysisException { - return StreamSupport.stream(getPropertyValueDescriptors(objectUri).spliterator(), false) - .map(descriptor -> descriptor.getName()) - .collect(Collectors.toList()); - } - - /** - * @param documentUri document URI - * @param id ID for the item - * @return all property names stored for the documentUri#id - * @throws InvalidSPDXAnalysisException on any SPDX exception - */ - public Collection getPropertyValueNames( - String documentUri, String id) throws InvalidSPDXAnalysisException { - return getPropertyValueNames(documentUriIdToUri(documentUri, id, baseStore)); - } - - @Override - public void setValue(String objectUri, - PropertyDescriptor propertyDescriptor, Object value) - throws InvalidSPDXAnalysisException { - baseStore.setValue(objectUri, propertyDescriptor, value); - } - - public void setValue(String documentUri, String id, - PropertyDescriptor propertyDescriptor, Object value) - throws InvalidSPDXAnalysisException { - setValue(documentUriIdToUri(documentUri, id, baseStore), propertyDescriptor, value); - } - - public void setValue(String documentUri, String id, - String propertyName, Object value) - throws InvalidSPDXAnalysisException { - setValue(documentUriIdToUri(documentUri, id, baseStore), propNameToPropDescriptor(propertyName), value); - } - - @Override - public Optional getValue(String objectUri, - PropertyDescriptor propertyDescriptor) - throws InvalidSPDXAnalysisException { - return baseStore.getValue(objectUri, propertyDescriptor); - } - - public Optional getValue(String documentUri, String id, - PropertyDescriptor propertyDescriptor) - throws InvalidSPDXAnalysisException { - return getValue(documentUriIdToUri(documentUri, id, baseStore), propertyDescriptor); - } - - public Optional getValue(String documentUri, String id, - String propertyName) - throws InvalidSPDXAnalysisException { - return getValue(documentUriIdToUri(documentUri, id, baseStore), propNameToPropDescriptor(propertyName)); - } - - public String getNextId(IdType idType, String documentUri) - throws InvalidSPDXAnalysisException { - Objects.requireNonNull(documentUri, "SPDX V2 requires a namespace for generating next ID's"); - return baseStore.getNextId(idType); - } - - @Override - public String getNextId(IdType idType) - throws InvalidSPDXAnalysisException { - return baseStore.getNextId(idType); - } - - @Override - public void removeProperty(String objectUri, - PropertyDescriptor propertyDescriptor) - throws InvalidSPDXAnalysisException { - baseStore.removeProperty(objectUri, propertyDescriptor); - } - - public void removeProperty(String documentUri, String id, - PropertyDescriptor propertyDescriptor) - throws InvalidSPDXAnalysisException { - removeProperty(documentUriIdToUri(documentUri, id, baseStore), propertyDescriptor); - } - - public void removeProperty(String documentUri, String id, - String propertyName) - throws InvalidSPDXAnalysisException { - removeProperty(documentUriIdToUri(documentUri, id, baseStore), propNameToPropDescriptor(propertyName)); - } - - @Override - public Stream getAllItems(String nameSpace, String typeFilter) - throws InvalidSPDXAnalysisException { - return baseStore.getAllItems(nameSpace, typeFilter); - } - - @Override - public IModelStoreLock enterCriticalSection(boolean readLockRequested) throws InvalidSPDXAnalysisException { - return baseStore.enterCriticalSection(readLockRequested); - } - - public IModelStoreLock enterCriticalSection(String documentUri, - boolean readLockRequested) throws InvalidSPDXAnalysisException { - return enterCriticalSection(readLockRequested); - } - - @Override - public void leaveCriticalSection(IModelStoreLock lock) { - baseStore.leaveCriticalSection(lock); - } - - @Override - public boolean removeValueFromCollection(String objectUri, - PropertyDescriptor propertyDescriptor, Object value) - throws InvalidSPDXAnalysisException { - return baseStore.removeValueFromCollection(objectUri, propertyDescriptor, value); - } - - public boolean removeValueFromCollection(String documentUri, String id, - PropertyDescriptor propertyDescriptor, Object value) - throws InvalidSPDXAnalysisException { - return removeValueFromCollection(documentUriIdToUri(documentUri, id, baseStore), propertyDescriptor, value); - } - - public boolean removeValueFromCollection(String documentUri, String id, - String propertyName, Object value) - throws InvalidSPDXAnalysisException { - return removeValueFromCollection(documentUriIdToUri(documentUri, id, baseStore), propNameToPropDescriptor(propertyName), value); - } - - @Override - public int collectionSize(String objectUri, - PropertyDescriptor propertyDescriptor) - throws InvalidSPDXAnalysisException { - return baseStore.collectionSize(objectUri, propertyDescriptor); - } - - public int collectionSize(String documentUri, String id, - PropertyDescriptor propertyDescriptor) - throws InvalidSPDXAnalysisException { - return collectionSize(documentUriIdToUri(documentUri, id, baseStore), propertyDescriptor); - } - - public int collectionSize(String documentUri, String id, - String propertyName) - throws InvalidSPDXAnalysisException { - return collectionSize(documentUriIdToUri(documentUri, id, baseStore), propNameToPropDescriptor(propertyName)); - } - - @Override - public boolean collectionContains(String objectUri, - PropertyDescriptor propertyDescriptor, Object value) - throws InvalidSPDXAnalysisException { - return baseStore.collectionContains(objectUri, propertyDescriptor, value); - } - - public boolean collectionContains(String documentUri, String id, - PropertyDescriptor propertyDescriptor, Object value) - throws InvalidSPDXAnalysisException { - return collectionContains(documentUriIdToUri(documentUri, id, baseStore), propertyDescriptor, value); - } - - public boolean collectionContains(String documentUri, String id, - String propertyName, Object value) - throws InvalidSPDXAnalysisException { - return collectionContains(documentUriIdToUri(documentUri, id, baseStore), propNameToPropDescriptor(propertyName), value); - } - - @Override - public void clearValueCollection(String objectUri, - PropertyDescriptor propertyDescriptor) - throws InvalidSPDXAnalysisException { - baseStore.clearValueCollection(objectUri, propertyDescriptor); - } - - public void clearValueCollection(String documentUri, String id, - PropertyDescriptor propertyDescriptor) - throws InvalidSPDXAnalysisException { - clearValueCollection(documentUriIdToUri(documentUri, id, baseStore), propertyDescriptor); - } - - public void clearValueCollection(String documentUri, String id, - String propertyName) - throws InvalidSPDXAnalysisException { - clearValueCollection(documentUriIdToUri(documentUri, id, baseStore), propNameToPropDescriptor(propertyName)); - } - - @Override - public boolean addValueToCollection(String objectUri, - PropertyDescriptor propertyDescriptor, Object value) - throws InvalidSPDXAnalysisException { - return baseStore.addValueToCollection(objectUri, propertyDescriptor, value); - } - - public boolean addValueToCollection(String documentUri, String id, - PropertyDescriptor propertyDescriptor, Object value) - throws InvalidSPDXAnalysisException { - return addValueToCollection(documentUriIdToUri(documentUri, id, baseStore), propertyDescriptor, value); - } - - public boolean addValueToCollection(String documentUri, String id, - String propertyName, Object value) - throws InvalidSPDXAnalysisException { - return addValueToCollection(documentUriIdToUri(documentUri, id, baseStore), propNameToPropDescriptor(propertyName), value); - } - - @Override - public Iterator listValues(String objectUri, - PropertyDescriptor propertyDescriptor) - throws InvalidSPDXAnalysisException { - return baseStore.listValues(objectUri, propertyDescriptor); - } - - public Iterator listValues(String documentUri, String id, - PropertyDescriptor propertyDescriptor) - throws InvalidSPDXAnalysisException { - return listValues(documentUriIdToUri(documentUri, id, baseStore), propertyDescriptor); - } - - public Iterator listValues(String documentUri, String id, - String propertyName) - throws InvalidSPDXAnalysisException { - return listValues(documentUriIdToUri(documentUri, id, baseStore), propNameToPropDescriptor(propertyName)); - } - @Override - public boolean isCollectionMembersAssignableTo(String objectUri, - PropertyDescriptor propertyDescriptor, Class clazz) - throws InvalidSPDXAnalysisException { - return baseStore.isCollectionMembersAssignableTo(objectUri, propertyDescriptor, clazz); - } - - public boolean isCollectionMembersAssignableTo(String documentUri, - String id, PropertyDescriptor propertyDescriptor, Class clazz) - throws InvalidSPDXAnalysisException { - return isCollectionMembersAssignableTo(documentUriIdToUri(documentUri, id, baseStore), propertyDescriptor, clazz); - } - - public boolean isCollectionMembersAssignableTo(String documentUri, - String id, String propertyName, Class clazz) - throws InvalidSPDXAnalysisException { - return isCollectionMembersAssignableTo(documentUriIdToUri(documentUri, id, baseStore), propNameToPropDescriptor(propertyName), clazz); - } - @Override - public boolean isPropertyValueAssignableTo(String objectUri, - PropertyDescriptor propertyDescriptor, Class clazz, String specVersion) - throws InvalidSPDXAnalysisException { - return baseStore.isPropertyValueAssignableTo(objectUri, propertyDescriptor, clazz, specVersion); - } - - public boolean isPropertyValueAssignableTo(String documentUri, String id, - PropertyDescriptor propertyDescriptor, Class clazz) - throws InvalidSPDXAnalysisException { - return isPropertyValueAssignableTo(documentUriIdToUri(documentUri, id, baseStore), propertyDescriptor, - clazz, LATEST_SPDX_2X_VERSION); - } - - public boolean isPropertyValueAssignableTo(String documentUri, String id, - String propertyName, Class clazz) - throws InvalidSPDXAnalysisException { - return isPropertyValueAssignableTo(documentUriIdToUri(documentUri, id, baseStore), propNameToPropDescriptor(propertyName), - clazz, LATEST_SPDX_2X_VERSION); - } - - @Override - public boolean isCollectionProperty(String objectUri, - PropertyDescriptor propertyDescriptor) - throws InvalidSPDXAnalysisException { - return baseStore.isCollectionProperty(objectUri, propertyDescriptor); - } - - public boolean isCollectionProperty(String documentUri, String id, - PropertyDescriptor propertyDescriptor) - throws InvalidSPDXAnalysisException { - return isCollectionProperty(documentUriIdToUri(documentUri, id, baseStore), propertyDescriptor); - } - - public boolean isCollectionProperty(String documentUri, String id, - String propertyName) - throws InvalidSPDXAnalysisException { - return isCollectionProperty(documentUriIdToUri(documentUri, id, baseStore), propNameToPropDescriptor(propertyName)); - } - - @Override - public IdType getIdType(String objectUri) { - return baseStore.getIdType(objectUri); - } - - @Override - public Optional getCaseSensisitiveId(String documentUri, - String caseInsensisitiveId) { - return baseStore.getCaseSensisitiveId(documentUri, caseInsensisitiveId); - } - - @Override - public Optional getTypedValue(String objectUri) - throws InvalidSPDXAnalysisException { - return baseStore.getTypedValue(objectUri); - } - - public Optional getTypedValue(String documentUri, String id) - throws InvalidSPDXAnalysisException { - return getTypedValue(documentUriIdToUri(documentUri, id, baseStore)); - } - - @Override - public void delete(String documentUri) - throws InvalidSPDXAnalysisException { - baseStore.delete(documentUri); - } - - public void delete(String documentUri, String id) - throws InvalidSPDXAnalysisException { - delete(documentUriIdToUri(documentUri, id, baseStore)); - } - - /** - * @return the store this store wraps - */ - public IModelStore getBaseModelStore() { - return this.baseStore; - } - - @Override - public boolean equals(Object comp) { - return comp instanceof CompatibleModelStoreWrapper && getBaseModelStore().equals(((CompatibleModelStoreWrapper)comp).getBaseModelStore()); - // TODO: Return true if the base is equal since this contains no properties - } - - @Override - public int hashCode() { - return 11 ^ super.hashCode(); - } - - @Override - public boolean isAnon(String objectUri) { - return baseStore.isAnon(objectUri); - } -} diff --git a/src/main/java/org/spdx/storage/NullModelStore.java b/src/main/java/org/spdx/storage/NullModelStore.java index fbaf6df..6fff00c 100644 --- a/src/main/java/org/spdx/storage/NullModelStore.java +++ b/src/main/java/org/spdx/storage/NullModelStore.java @@ -14,13 +14,15 @@ import org.spdx.core.TypedValue; /** - * @author Gary O'Neall - * * Null model store to be used with constants and individuals + * + * @author Gary O'Neall * */ public class NullModelStore implements IModelStore { + private static final String NULL_MODEL_MSG = "Null model store - can only be used with constants and individuals"; + @Override public void close() throws Exception { // Nothing to close @@ -34,7 +36,7 @@ public boolean exists(String objectUri) { @Override public void create(TypedValue typedValue) throws InvalidSPDXAnalysisException { - throw new InvalidSPDXAnalysisException("Null model store - can only be used with constants and individuals"); + throw new InvalidSPDXAnalysisException(NULL_MODEL_MSG); } @Override @@ -47,7 +49,7 @@ public List getPropertyValueDescriptors( public void setValue(String objectUri, PropertyDescriptor propertyDescriptor, Object value) throws InvalidSPDXAnalysisException { - throw new InvalidSPDXAnalysisException("Null model store - can only be used with constants and individuals"); + throw new InvalidSPDXAnalysisException(NULL_MODEL_MSG); } @Override @@ -59,14 +61,14 @@ public Optional getValue(String objectUri, @Override public String getNextId(IdType idType) throws InvalidSPDXAnalysisException { - throw new InvalidSPDXAnalysisException("Null model store - can only be used with constants and individuals"); + throw new InvalidSPDXAnalysisException(NULL_MODEL_MSG); } @Override public void removeProperty(String objectUri, PropertyDescriptor propertyDescriptor) throws InvalidSPDXAnalysisException { - throw new InvalidSPDXAnalysisException("Null model store - can only be used with constants and individuals"); + throw new InvalidSPDXAnalysisException(NULL_MODEL_MSG); } @Override @@ -97,35 +99,35 @@ public void leaveCriticalSection(IModelStoreLock lock) { public boolean removeValueFromCollection(String objectUri, PropertyDescriptor propertyDescriptor, Object value) throws InvalidSPDXAnalysisException { - throw new InvalidSPDXAnalysisException("Null model store - can only be used with constants and individuals"); + throw new InvalidSPDXAnalysisException(NULL_MODEL_MSG); } @Override public int collectionSize(String objectUri, PropertyDescriptor propertyDescriptor) throws InvalidSPDXAnalysisException { - throw new InvalidSPDXAnalysisException("Null model store - can only be used with constants and individuals"); + throw new InvalidSPDXAnalysisException(NULL_MODEL_MSG); } @Override public boolean collectionContains(String objectUri, PropertyDescriptor propertyDescriptor, Object value) throws InvalidSPDXAnalysisException { - throw new InvalidSPDXAnalysisException("Null model store - can only be used with constants and individuals"); + throw new InvalidSPDXAnalysisException(NULL_MODEL_MSG); } @Override public void clearValueCollection(String objectUri, PropertyDescriptor propertyDescriptor) throws InvalidSPDXAnalysisException { - throw new InvalidSPDXAnalysisException("Null model store - can only be used with constants and individuals"); + throw new InvalidSPDXAnalysisException(NULL_MODEL_MSG); } @Override public boolean addValueToCollection(String objectUri, PropertyDescriptor propertyDescriptor, Object value) throws InvalidSPDXAnalysisException { - throw new InvalidSPDXAnalysisException("Null model store - can only be used with constants and individuals"); + throw new InvalidSPDXAnalysisException(NULL_MODEL_MSG); } @Override @@ -139,21 +141,21 @@ public Iterator listValues(String objectUri, public boolean isCollectionMembersAssignableTo(String objectUri, PropertyDescriptor propertyDescriptor, Class clazz) throws InvalidSPDXAnalysisException { - throw new InvalidSPDXAnalysisException("Null model store - can only be used with constants and individuals"); + throw new InvalidSPDXAnalysisException(NULL_MODEL_MSG); } @Override public boolean isPropertyValueAssignableTo(String objectUri, PropertyDescriptor propertyDescriptor, Class clazz, String specVersion) throws InvalidSPDXAnalysisException { - throw new InvalidSPDXAnalysisException("Null model store - can only be used with constants and individuals"); + throw new InvalidSPDXAnalysisException(NULL_MODEL_MSG); } @Override public boolean isCollectionProperty(String objectUri, PropertyDescriptor propertyDescriptor) throws InvalidSPDXAnalysisException { - throw new InvalidSPDXAnalysisException("Null model store - can only be used with constants and individuals"); + throw new InvalidSPDXAnalysisException(NULL_MODEL_MSG); } @Override @@ -175,7 +177,7 @@ public Optional getTypedValue(String objectUri) @Override public void delete(String objectUri) throws InvalidSPDXAnalysisException { - throw new InvalidSPDXAnalysisException("Null model store - can only be used with constants and individuals"); + throw new InvalidSPDXAnalysisException(NULL_MODEL_MSG); } @Override diff --git a/src/test/java/org/spdx/core/TestCoreModelObject.java b/src/test/java/org/spdx/core/TestCoreModelObject.java index d8864b2..c9c5b92 100644 --- a/src/test/java/org/spdx/core/TestCoreModelObject.java +++ b/src/test/java/org/spdx/core/TestCoreModelObject.java @@ -62,6 +62,7 @@ public void setUp() throws Exception { */ @After public void tearDown() throws Exception { + // Nothing to tear down (yet) } /** diff --git a/src/test/java/org/spdx/core/TestModelObjectHelper.java b/src/test/java/org/spdx/core/TestModelObjectHelper.java index b7080a9..f153ead 100644 --- a/src/test/java/org/spdx/core/TestModelObjectHelper.java +++ b/src/test/java/org/spdx/core/TestModelObjectHelper.java @@ -58,6 +58,7 @@ public void setUp() throws Exception { */ @After public void tearDown() throws Exception { + // Nothing to tear down (yet) } /** diff --git a/src/test/java/org/spdx/licenseTemplate/LicenseTextHelperTest.java b/src/test/java/org/spdx/licenseTemplate/LicenseTextHelperTest.java index a026cdf..65e02a5 100644 --- a/src/test/java/org/spdx/licenseTemplate/LicenseTextHelperTest.java +++ b/src/test/java/org/spdx/licenseTemplate/LicenseTextHelperTest.java @@ -35,6 +35,7 @@ public class LicenseTextHelperTest extends TestCase { /** * @throws java.lang.Exception */ + @Override public void setUp() throws Exception { super.setUp(); } @@ -42,6 +43,7 @@ public void setUp() throws Exception { /** * @throws java.lang.Exception */ + @Override public void tearDown() throws Exception { super.tearDown(); } diff --git a/src/test/java/org/spdx/licenseTemplate/TestHtmlTemplateOutputHandler.java b/src/test/java/org/spdx/licenseTemplate/TestHtmlTemplateOutputHandler.java index 4339029..1d68fcb 100644 --- a/src/test/java/org/spdx/licenseTemplate/TestHtmlTemplateOutputHandler.java +++ b/src/test/java/org/spdx/licenseTemplate/TestHtmlTemplateOutputHandler.java @@ -18,10 +18,6 @@ import static org.junit.Assert.*; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import org.spdx.licenseTemplate.LicenseTemplateRule.RuleType; @@ -31,34 +27,6 @@ */ public class TestHtmlTemplateOutputHandler { - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception { - } - - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception { - } - /** * Test method for {@link org.spdx.licenseTemplate.HtmlTemplateOutputHandler#normalText(java.lang.String)}. */ diff --git a/src/test/java/org/spdx/licenseTemplate/TestTextTemplateOutputHandler.java b/src/test/java/org/spdx/licenseTemplate/TestTextTemplateOutputHandler.java index aa50a67..99f89b4 100644 --- a/src/test/java/org/spdx/licenseTemplate/TestTextTemplateOutputHandler.java +++ b/src/test/java/org/spdx/licenseTemplate/TestTextTemplateOutputHandler.java @@ -18,10 +18,6 @@ import static org.junit.Assert.*; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import org.spdx.licenseTemplate.LicenseTemplateRule.RuleType; @@ -31,34 +27,6 @@ */ public class TestTextTemplateOutputHandler { - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception { - } - - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception { - } - /** * Test method for {@link org.spdx.licenseTemplate.TextTemplateOutputHandler#normalText(java.lang.String)}. */ diff --git a/src/test/java/org/spdx/storage/TestCompatibleModelStoreWrapper.java b/src/test/java/org/spdx/storage/TestCompatibleModelStoreWrapper.java deleted file mode 100644 index bc7057d..0000000 --- a/src/test/java/org/spdx/storage/TestCompatibleModelStoreWrapper.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * SPDX-License-Identifier: Apache-2.0 - * Copyright (c) 2024 Source Auditor Inc. - */ -package org.spdx.storage; - -import static org.junit.Assert.*; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.spdx.core.InvalidSPDXAnalysisException; -import org.spdx.core.MockModelInfo; -import org.spdx.core.ModelRegistry; -import org.spdx.core.ModelRegistryException; -import org.spdx.core.SpdxInvalidIdException; -import org.spdx.core.SpdxInvalidTypeException; -import org.spdx.core.TypedValue; - -/** - * @author Gary O'Neall - * - */ -public class TestCompatibleModelStoreWrapper { - - static final String DOC_DOC_URI = "https://this/is/a/namespace"; - static final String DOC_NAMESPACE = DOC_DOC_URI + "#"; - static final String LICENSE_DOC_URI = "https://spdx.org/licenses/"; - static final String LICENSE_DOC_URI2 = "http://spdx.org/licenses/"; - static final String ANON_ID = "__anon__"; - static final String ID = "SPDXID_15"; - static final String OBJECT_URI = DOC_NAMESPACE + ID; - - IModelStore modelStore; - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() { - modelStore = new MockModelStore(); - ModelRegistry.getModelRegistry().registerModel(new MockModelInfo()); - } - - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception { - } - - /** - * Test method for {@link org.spdx.storage.CompatibleModelStoreWrapper#documentUriIdToUri(java.lang.String, java.lang.String, org.spdx.storage.IModelStore)}. - */ - @Test - public void testDocumentUriIdToUriStringStringIModelStore() { - assertEquals(OBJECT_URI, CompatibleModelStoreWrapper.documentUriIdToUri(DOC_DOC_URI, ID, modelStore)); - assertEquals(ANON_ID, CompatibleModelStoreWrapper.documentUriIdToUri(DOC_DOC_URI, ANON_ID, modelStore)); - } - - /** - * Test method for {@link org.spdx.storage.CompatibleModelStoreWrapper#documentUriToNamespace(java.lang.String, boolean)}. - */ - @Test - public void testDocumentUriToNamespace() { - - assertEquals(DOC_DOC_URI + "#", CompatibleModelStoreWrapper.documentUriToNamespace(DOC_DOC_URI)); - assertEquals(LICENSE_DOC_URI, CompatibleModelStoreWrapper.documentUriToNamespace(LICENSE_DOC_URI)); - assertEquals(LICENSE_DOC_URI2, CompatibleModelStoreWrapper.documentUriToNamespace(LICENSE_DOC_URI2)); - } - - /** - * Test method for {@link org.spdx.storage.CompatibleModelStoreWrapper#documentUriIdToUri(java.lang.String, java.lang.String, boolean)}. - */ - @Test - public void testDocumentUriIdToUriStringStringBoolean() { - assertEquals(OBJECT_URI, CompatibleModelStoreWrapper.documentUriIdToUri(DOC_DOC_URI, ID, false)); - assertEquals(ANON_ID, CompatibleModelStoreWrapper.documentUriIdToUri(DOC_DOC_URI, ANON_ID, true)); - } - - /** - * Test method for {@link org.spdx.storage.CompatibleModelStoreWrapper#typedValueFromDocUri(java.lang.String, java.lang.String, boolean, java.lang.String)}. - * @throws ModelRegistryException - * @throws SpdxInvalidTypeException - * @throws SpdxInvalidIdException - */ - @Test - public void testTypedValueFromDocUri() throws SpdxInvalidIdException, SpdxInvalidTypeException, ModelRegistryException { - String type = "MockType"; - TypedValue result = CompatibleModelStoreWrapper.typedValueFromDocUri(DOC_DOC_URI, ID, false, type); - assertEquals(type, result.getType()); - assertEquals(OBJECT_URI, result.getObjectUri()); - assertEquals(CompatibleModelStoreWrapper.LATEST_SPDX_2X_VERSION, result.getSpecVersion()); - } - - /** - * Test method for {@link org.spdx.storage.CompatibleModelStoreWrapper#objectUriToId(org.spdx.storage.IModelStore, java.lang.String, java.lang.String)}. - * @throws InvalidSPDXAnalysisException - */ - @Test - public void testObjectUriToIdIModelStoreStringString() throws InvalidSPDXAnalysisException { - assertEquals(ID, CompatibleModelStoreWrapper.objectUriToId(modelStore, OBJECT_URI, DOC_DOC_URI)); - assertEquals(ANON_ID, CompatibleModelStoreWrapper.objectUriToId(modelStore, ANON_ID, DOC_DOC_URI)); - } - - /** - * Test method for {@link org.spdx.storage.CompatibleModelStoreWrapper#objectUriToId(boolean, java.lang.String, java.lang.String)}. - * @throws InvalidSPDXAnalysisException - */ - @Test - public void testObjectUriToIdBooleanStringString() throws InvalidSPDXAnalysisException { - assertEquals(ID, CompatibleModelStoreWrapper.objectUriToId(false, OBJECT_URI, DOC_DOC_URI)); - assertEquals(ANON_ID, CompatibleModelStoreWrapper.objectUriToId(true, ANON_ID, DOC_DOC_URI)); - } - -}