From 923a9943a1d59a9d1e87d24490eea78fa9869de7 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Tue, 19 Mar 2019 01:16:38 +0000 Subject: Use Assertions class from policy-common Change import line in all classes that use the Assertions class, there are a lot of them. Issue-ID: POLICY-1264 Change-Id: I8480264be4e36348b3fc63acf1bc36e9c9dd250b Signed-off-by: liamfallon --- .../model/basicmodel/concepts/AxArtifactKey.java | 5 +- .../apex/model/basicmodel/concepts/AxConcept.java | 5 +- .../basicmodel/concepts/AxConceptGetterImpl.java | 3 +- .../apex/model/basicmodel/concepts/AxKeyInfo.java | 5 +- .../basicmodel/concepts/AxKeyInformation.java | 5 +- .../apex/model/basicmodel/concepts/AxKeyUse.java | 5 +- .../apex/model/basicmodel/concepts/AxModel.java | 5 +- .../model/basicmodel/concepts/AxReferenceKey.java | 9 +- .../basicmodel/concepts/AxValidationMessage.java | 3 +- .../apex/model/basicmodel/dao/ApexDaoFactory.java | 3 +- .../model/basicmodel/handling/ApexModelReader.java | 9 +- .../model/basicmodel/handling/ApexModelSaver.java | 9 +- .../basicmodel/handling/ApexModelStringWriter.java | 9 +- .../model/basicmodel/handling/ApexModelWriter.java | 9 +- .../contextmodel/concepts/AxContextAlbum.java | 13 +- .../contextmodel/concepts/AxContextAlbums.java | 5 +- .../contextmodel/concepts/AxContextModel.java | 5 +- .../contextmodel/concepts/AxContextSchema.java | 7 +- .../contextmodel/concepts/AxContextSchemas.java | 5 +- .../model/enginemodel/concepts/AxEngineModel.java | 13 +- .../model/enginemodel/concepts/AxEngineStats.java | 11 +- .../apex/model/eventmodel/concepts/AxEvent.java | 11 +- .../model/eventmodel/concepts/AxEventModel.java | 5 +- .../apex/model/eventmodel/concepts/AxEvents.java | 5 +- .../apex/model/eventmodel/concepts/AxField.java | 7 +- .../model/modelapi/impl/ContextSchemaFacade.java | 9 +- .../apex/model/modelapi/impl/EventFacade.java | 9 +- .../apex/model/modelapi/impl/ModelFacade.java | 9 +- .../model/modelapi/impl/ModelHandlerFacade.java | 9 +- .../apex/model/modelapi/impl/PolicyFacade.java | 3 +- .../apex/model/modelapi/impl/TaskFacade.java | 9 +- .../apex/model/policymodel/concepts/AxLogic.java | 13 +- .../model/policymodel/concepts/AxPolicies.java | 29 ++-- .../apex/model/policymodel/concepts/AxPolicy.java | 21 +-- .../model/policymodel/concepts/AxPolicyModel.java | 25 +-- .../apex/model/policymodel/concepts/AxState.java | 9 +- .../model/policymodel/concepts/AxStateOutput.java | 13 +- .../policymodel/concepts/AxStateTaskReference.java | 13 +- .../model/policymodel/concepts/AxStateTree.java | 11 +- .../apex/model/policymodel/concepts/AxTask.java | 25 +-- .../policymodel/concepts/AxTaskParameter.java | 11 +- .../apex/model/policymodel/concepts/AxTasks.java | 13 +- .../model/policymodel/handling/PolicyAnalyser.java | 9 +- .../policy/apex/model/utilities/Assertions.java | 191 --------------------- .../apex/model/utilities/AssertionsTest.java | 93 ---------- 45 files changed, 227 insertions(+), 468 deletions(-) delete mode 100644 model/utilities/src/main/java/org/onap/policy/apex/model/utilities/Assertions.java delete mode 100644 model/utilities/src/test/java/org/onap/policy/apex/model/utilities/AssertionsTest.java (limited to 'model') diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxArtifactKey.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxArtifactKey.java index 7e39e5817..9b1dd6293 100644 --- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxArtifactKey.java +++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxArtifactKey.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,13 +33,13 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * An artifact key uniquely identifies every first order entity in the system. Every first order concept in the system * must have an {@link AxArtifactKey} to identify it. Concepts that are wholly contained in another concept are * identified using a {@link AxReferenceKey} key. - * + * *

Key validation checks that the name and version fields match the NAME_REGEXP and VERSION_REGEXP * regular expressions respectively. */ diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConcept.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConcept.java index bb6614715..e9aad675b 100644 --- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConcept.java +++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConcept.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +26,7 @@ import java.util.List; import javax.xml.bind.annotation.XmlType; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * This class is the base class for all Apex concept classes. It enforces implementation of abstract methods and @@ -46,7 +47,7 @@ public abstract class AxConcept implements Serializable, Comparable { /** * Copy constructor. - * + * * @param copyConcept the concept to copy from */ public AxConcept(final AxConcept copyConcept) { diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImpl.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImpl.java index 866de8053..e9c878346 100644 --- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImpl.java +++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImpl.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +25,7 @@ import java.util.NavigableMap; import java.util.Set; import java.util.TreeSet; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * Implements concept getting from navigable maps. diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java index 2c2952df9..5bcd8727e 100644 --- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java +++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,12 +40,12 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; import org.onap.policy.apex.model.basicmodel.dao.converters.CDataConditioner; import org.onap.policy.apex.model.basicmodel.dao.converters.Uuid2String; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * The key information on an {@link AxArtifactKey} key in an Apex policy model. Each {@link AxArtifactKey} must have an * {@link AxKeyInfo} object. THe information held is the key's UUID and it's description. - * + * *

Validation checks that all fields are defined and that the key is valid. It also observes that descriptions are * blank and warns if the UUID is a zero UUID. */ diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInformation.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInformation.java index 9afec9999..2b0594591 100644 --- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInformation.java +++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInformation.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,14 +44,14 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * The Class AxKeyInformation holds a map of the key information for the entire Apex model. All Apex models * {@link AxModel} must have an {@link AxKeyInformation} field. The {@link AxKeyInformation} class implements the helper * methods of the {@link AxConceptGetter} interface to allow {@link AxKeyInfo} instances to be retrieved by calling * methods directly on this class without referencing the contained map. - * + * *

Validation checks that the key is not null, that the key information map is not empty, that each key and value in * the map is defined, that the key in each map entry matches the key if each entry value, and that no duplicate UUIDs * exist. Each key information entry is then validated individually. diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUse.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUse.java index 09170de9b..b37519d41 100644 --- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUse.java +++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUse.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,13 +24,13 @@ package org.onap.policy.apex.model.basicmodel.concepts; import java.util.List; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * This class records a usage of a key in the system. When the list of keys being used by a concept is built using the * getKeys() method of the {@link AxConcept} class, an instance of this class is created for every key occurrence. The * list of keys returned by the getKeys() method is a list of {@link AxKeyUse} objects. - * + * *

Validation checks that each key is valid. */ diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxModel.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxModel.java index 66045db48..1a604a3c4 100644 --- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxModel.java +++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxModel.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,12 +42,12 @@ import javax.xml.bind.annotation.XmlType; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; import org.onap.policy.apex.model.basicmodel.service.ModelService; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * This class is the base class for all models in Apex. All model classes inherit from this model so all models must * have a key and have key information. - * + * *

Validation checks that the model key is valid. It goes on to check for null keys and checks each key for * uniqueness in the model. A check is carried out to ensure that an {@link AxKeyInfo} instance exists for every * {@link AxArtifactKey} key. For each {@link AxReferenceKey} instance, a check is made that its parent and local name diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKey.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKey.java index 57196ade7..04d9e23f6 100644 --- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKey.java +++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKey.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,21 +33,21 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * A reference key identifies entities in the system that are contained in other entities. Every contained concept in * the system must have an {@link AxReferenceKey} to identify it. Non-contained first order concepts are identified * using an {@link AxArtifactKey} key. - * + * *

An {@link AxReferenceKey} contains an {@link AxArtifactKey} key reference to the first order entity that contains * it. The local name of the reference key must uniquely identify the referenced concept among those concepts contained * in the reference key's parent. In other words, if a parent concept has more than one child, the local name in the key * of all its children must be unique. - * + * *

If a reference key's parent is itself a reference key, then the parent's local name must be set in the reference * key. If the parent is a first order concept, then the parent's local name in the key will be set to NULL. - * + * *

Key validation checks that the parent name and parent version fields match the NAME_REGEXP and * VERSION_REGEXP regular expressions respectively and that the local name fields match the * LOCAL_NAME_REGEXP regular expression. diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxValidationMessage.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxValidationMessage.java index 7ca0b2f3c..3e09e1ca8 100644 --- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxValidationMessage.java +++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxValidationMessage.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +22,7 @@ package org.onap.policy.apex.model.basicmodel.concepts; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * A validation message is created for each validation observation observed during validation of a concept. The message diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/ApexDaoFactory.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/ApexDaoFactory.java index 47996d88d..b374ff40a 100644 --- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/ApexDaoFactory.java +++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/ApexDaoFactory.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +22,7 @@ package org.onap.policy.apex.model.basicmodel.dao; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReader.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReader.java index f340f73d4..1f820ef68 100644 --- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReader.java +++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReader.java @@ -1,19 +1,20 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -42,9 +43,9 @@ import org.eclipse.persistence.jaxb.MarshallerProperties; import org.eclipse.persistence.oxm.MediaType; import org.onap.policy.apex.model.basicmodel.concepts.AxConcept; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; -import org.onap.policy.apex.model.utilities.Assertions; import org.onap.policy.apex.model.utilities.TextFileUtils; import org.onap.policy.common.utils.resources.ResourceUtils; +import org.onap.policy.common.utils.validation.Assertions; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaver.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaver.java index 4f3008f04..50e8bb5fa 100644 --- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaver.java +++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaver.java @@ -1,19 +1,20 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -24,7 +25,7 @@ import java.io.File; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.model.basicmodel.concepts.AxModel; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriter.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriter.java index 92a956bde..91e58d663 100644 --- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriter.java +++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriter.java @@ -1,19 +1,20 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -24,7 +25,7 @@ import java.io.ByteArrayOutputStream; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.model.basicmodel.concepts.AxConcept; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriter.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriter.java index eded9fdec..35c458eaa 100644 --- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriter.java +++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriter.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -44,7 +45,7 @@ import org.eclipse.persistence.jaxb.MarshallerProperties; import org.eclipse.persistence.oxm.MediaType; import org.onap.policy.apex.model.basicmodel.concepts.AxConcept; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; import org.w3c.dom.Document; diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java index 3d008e992..e27bf78e8 100644 --- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java +++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,25 +43,25 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxKeyUse; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * This class is used to define an album of context. - * + * *

A context album is a distributed map of context that will be distributed across all process instances that require * access to it. This class defines the schema (structure) of the items in the context album, whether the items on the * context album are writable or not, and what the scope of the context album is. - * + * *

The structure of items (objects) the context album is defined as a schema, which is understood by whatever schema * implementation is being used for the context album. - * + * *

The scope of a context album is a string field, understood by whatever distribution mechanism is being used for * the context album. The distribution mechanism uses the scope of the context album to decide to which executable * entities a given context album is distributed. - * + * *

The writable flag on a context album defines whether users of a context album can write to the context album or * just read objects from the context album. - * + * *

Validation checks that the album key and the context schema key are not null and that the scope field is not * undefined and matches the regular expression SCOPE_REGEXP. */ diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java index cd452cae1..ddf363ed3 100644 --- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java +++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,14 +49,14 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxKey; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * This class is a context album container and holds a map of the context albums for an entire Apex model. All Apex * models that use context albums must have an {@link AxContextAlbums} field. The {@link AxContextAlbums} class * implements the helper methods of the {@link AxConceptGetter} interface to allow {@link AxContextAlbum} instances to * be retrieved by calling methods directly on this class without referencing the contained map. - * + * *

Validation checks that the container key is not null. An observation is issued if no context albums are defined in * the container. If context albums do exist, they are checked to ensure that keys and values are not null and that the * map key matches the key in the map value for all album entries. Each context album entry is then validated diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextModel.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextModel.java index 56983f37b..b2139f893 100644 --- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextModel.java +++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextModel.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,14 +42,14 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation; import org.onap.policy.apex.model.basicmodel.concepts.AxModel; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; import org.onap.policy.apex.model.basicmodel.service.ModelService; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * A container class for an Apex context model. This class is a container class that allows an Apex model to be * constructed that just contains context and the key information for that context. The model contains schema * definitions and the definitions of context albums that use those schemas. In the case where Apex context is being * used without policy or independent of policy, an Apex context model is sufficient to get Apex context working. - * + * *

Validation runs {@link AxModel} validation on the model. In addition, the {@link AxContextSchemas} and * {@link AxContextAlbums} validation is run on the context schemas and albums in the model. */ diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java index 767b1d02e..f2e3dc3cf 100644 --- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java +++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +42,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; import org.onap.policy.apex.model.basicmodel.dao.converters.CDataConditioner; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * This class holds a data schema definition in Apex. A data schema describes the structure of a single atom of data @@ -50,13 +51,13 @@ import org.onap.policy.apex.model.utilities.Assertions; * schema flavour defines the type of schema being defined and the schema itself defines the schema. The schema flavour * is used by Apex to look up and load a plugin class that understands and interprets the schema definition and can * create instances of classes for the schema. - * + * *

An {@link AxContextSchema} is used to define each parameter in Apex events, the messages that enter, exit, and are * passed internally in Apex. In addition, an Apex {@link AxContextAlbum} instances hold a map of * {@link AxContextSchema} instances to represent the context being managed as an {@link AxContextAlbum}. For example, * the state of all cells in a mobile network might be represented as an {@link AxContextAlbum} with its * {@link AxContextSchema} being defined as @code cell} objects. - * + * *

Validation checks that the schema key is not null. It also checks that the schema flavour is defined and matches * the regular expression SCHEMA_FLAVOUR_REGEXP. Finally, validation checks that the defined schema is not a blank or * empty string. diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java index 2b31aa425..b2456bfbf 100644 --- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java +++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,14 +49,14 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxKey; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * This class is a context schema container and holds a map of the context schemas for an entire Apex model. All Apex * models that use context schemas must have an {@link AxContextSchemas} field. The {@link AxContextSchemas} class * implements the helper methods of the {@link AxConceptGetter} interface to allow {@link AxContextSchema} instances to * be retrieved by calling methods directly on this class without referencing the contained map. - * + * *

Validation checks that the container key is not null. An error is issued if no context schemas are defined in the * container. Each context schema entry is checked to ensure that its key and value are not null and that the key * matches the key in the map value. Each context schema entry is then validated individually. diff --git a/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineModel.java b/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineModel.java index 9b015552a..785845532 100644 --- a/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineModel.java +++ b/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineModel.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -46,7 +47,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums; import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel; import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * A container class for an Apex engine model. This class is a container class that allows an Apex @@ -55,7 +56,7 @@ import org.onap.policy.apex.model.utilities.Assertions; * is used by an Apex engine to pass its current execution state to any system that wishes to query * that information. The time stamp of the engine model is the time at which the state and * statistics of the engine were read. - * + * *

Validation checks that the current state {@link AxEngineState} is defined and that the time stamp * is set on the engine model. */ @@ -101,7 +102,7 @@ public class AxEngineModel extends AxContextModel { /** * Copy constructor. - * + * * @param copyConcept the concept to copy from */ public AxEngineModel(final AxEngineModel copyConcept) { diff --git a/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineStats.java b/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineStats.java index 896794ce7..adda0c1f3 100644 --- a/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineStats.java +++ b/model/engine-model/src/main/java/org/onap/policy/apex/model/enginemodel/concepts/AxEngineStats.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -41,7 +42,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * This class is a java bean that is used to record statistics on Apex engines as they execute. @@ -109,7 +110,7 @@ public class AxEngineStats extends AxConcept { /** * Copy constructor. - * + * * @param copyConcept the concept to copy from */ public AxEngineStats(final AxEngineStats copyConcept) { diff --git a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvent.java b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvent.java index 099ee2260..c83b7b86a 100644 --- a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvent.java +++ b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvent.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,24 +48,24 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxKey; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * This class defines an Apex event. An {@link AxEvent} is used to kick off execution of policies in Apex and is emitted * by policies when they completer execution. In addition, Apex uses {@link AxEvent} instances internally to pass * control from one Apex state to the next during execution. - * + * *

The {@link AxArtifactKey} of an event uniquely identifies it in an Apex system and the name field in the key is * the name of the event. - * + * *

Each {@link AxEvent} has a name space, which is usually set to identify the domain of application of an event. For * example a 4G cell power event might have the name space {@code org.onap.radio.4g} and the name {@code PowerEvent}. * The source and target of the event are reserved to hold an identifier that defines the sender and receiver of an * event respectively. The definition and structure of these fields is reserved for future use and their use by * applications is currently not recommended. - * + * *

The parameters that an event has are defined as a map of {@link AxField} instances. - * + * *

Validation checks that the event key is valid. If name space is a blank string, a warning is issued. Blank source * or target fields result in observations being issued. An event may not have any parameters. If it has parameters, the * name and value of each parameter entry is checked to ensure they are not null. Then the local name of each parameter diff --git a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEventModel.java b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEventModel.java index cab46cd39..69ae01acf 100644 --- a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEventModel.java +++ b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEventModel.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,13 +43,13 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxModel; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; import org.onap.policy.apex.model.basicmodel.service.ModelService; import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * A container class for an Apex event model. This class is a container class that allows an Apex model to be * constructed that contains events and context and the key information for those events and context. The model contains * schema definitions and the definitions of events that use those schemas. - * + * *

Validation runs {@link AxModel} validation on the model. In addition, the {@link AxContextSchemas} and * {@link AxEvents} validation is run on the context schemas and events in the model. */ diff --git a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvents.java b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvents.java index e973f2ead..4ec3af3b3 100644 --- a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvents.java +++ b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxEvents.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,14 +49,14 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxKey; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * This class is an event container and holds a map of the events for an entire Apex model. All Apex models that use * events must have an {@link AxEvents} field. The {@link AxEvents} class implements the helper methods of the * {@link AxConceptGetter} interface to allow {@link AxEvents} instances to be retrieved by calling methods directly on * this class without referencing the contained map. - * + * *

Validation checks that the container key is not null. An error is issued if no events are defined in the * container. Each event entry is checked to ensure that its key and value are not null and that the key matches the key * in the map value. Each event entry is then validated individually. diff --git a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxField.java b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxField.java index 6b38ca7a8..300f6beb5 100644 --- a/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxField.java +++ b/model/event-model/src/main/java/org/onap/policy/apex/model/eventmodel/concepts/AxField.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,16 +48,16 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; import org.onap.policy.apex.model.basicmodel.xml.AxReferenceKeyAdapter; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * In Apex, a field is an input or output parameter to or from a concept. For example, the parameters of an event are * fields and the input and output of a task is defined as a collection of fields. - * + * *

A field has an {@link AxReferenceKey} key that defines its name and parent, and a {@link AxArtifactKey} key to a * context schema that defines the structure of the data atom that holds the value of the field. Fields can be specified * as being optional but are mandatory by default. - * + * *

Validation checks that the field key and the field schema reference key are not null. */ @Entity diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ContextSchemaFacade.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ContextSchemaFacade.java index 6bcf8ecbf..8b479ebfd 100644 --- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ContextSchemaFacade.java +++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ContextSchemaFacade.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -29,7 +30,7 @@ import org.onap.policy.apex.model.basicmodel.handling.ApexModelStringWriter; import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema; import org.onap.policy.apex.model.modelapi.ApexApiResult; import org.onap.policy.apex.model.modelapi.ApexModel; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * This class acts as a facade for operations towards a policy model for context schema operations. diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/EventFacade.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/EventFacade.java index 645ad9a08..8df43f99f 100644 --- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/EventFacade.java +++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/EventFacade.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -32,7 +33,7 @@ import org.onap.policy.apex.model.eventmodel.concepts.AxEvent; import org.onap.policy.apex.model.eventmodel.concepts.AxField; import org.onap.policy.apex.model.modelapi.ApexApiResult; import org.onap.policy.apex.model.modelapi.ApexModel; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * This class acts as a facade for operations towards a policy model for event operations diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ModelFacade.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ModelFacade.java index a44032634..cba72018f 100644 --- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ModelFacade.java +++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ModelFacade.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -27,7 +28,7 @@ import org.onap.policy.apex.model.basicmodel.handling.ApexModelStringWriter; import org.onap.policy.apex.model.modelapi.ApexApiResult; import org.onap.policy.apex.model.modelapi.ApexModel; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * This class acts as a facade for operations towards a policy model. diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ModelHandlerFacade.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ModelHandlerFacade.java index 0f6bd0830..db4a9ab08 100644 --- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ModelHandlerFacade.java +++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ModelHandlerFacade.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -54,9 +55,9 @@ import org.onap.policy.apex.model.policymodel.handling.PolicyAnalysisResult; import org.onap.policy.apex.model.policymodel.handling.PolicyModelComparer; import org.onap.policy.apex.model.policymodel.handling.PolicyModelMerger; import org.onap.policy.apex.model.policymodel.handling.PolicyModelSplitter; -import org.onap.policy.apex.model.utilities.Assertions; import org.onap.policy.apex.model.utilities.TextFileUtils; import org.onap.policy.common.utils.resources.ResourceUtils; +import org.onap.policy.common.utils.validation.Assertions; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/PolicyFacade.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/PolicyFacade.java index 8ab4d02d7..b600b152e 100644 --- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/PolicyFacade.java +++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/PolicyFacade.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +44,7 @@ import org.onap.policy.apex.model.policymodel.concepts.AxStateTaskOutputType; import org.onap.policy.apex.model.policymodel.concepts.AxStateTaskReference; import org.onap.policy.apex.model.policymodel.concepts.AxTask; import org.onap.policy.apex.model.policymodel.concepts.AxTaskSelectionLogic; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * This class acts as a facade for operations towards a policy model for policy operations. diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/TaskFacade.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/TaskFacade.java index 77bb22d52..3632e7663 100644 --- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/TaskFacade.java +++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/TaskFacade.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -38,7 +39,7 @@ import org.onap.policy.apex.model.modelapi.ApexModel; import org.onap.policy.apex.model.policymodel.concepts.AxTask; import org.onap.policy.apex.model.policymodel.concepts.AxTaskLogic; import org.onap.policy.apex.model.policymodel.concepts.AxTaskParameter; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * This class acts as a facade for operations towards a policy model for task operations. diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java index ad86fb42c..2fed326f9 100644 --- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java +++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -44,7 +45,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; import org.onap.policy.apex.model.basicmodel.dao.converters.CDataConditioner; import org.onap.policy.apex.model.basicmodel.xml.AxReferenceKeyAdapter; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * This class holds Logic for executing a task or task selection on an Apex policy state. The flavour of the logic @@ -54,7 +55,7 @@ import org.onap.policy.apex.model.utilities.Assertions; * executes it. In the Apex engine, executors are deployed as plugins. Apex also provides the executor with run-time * context, which makes context such as input fields, output fields, and context albums available to the task at * runtime. - * + * *

Validation checks that the logic key is valid, that the logic flavour is defined and is valid when checked against * the {@code LOGIC_FLAVOUR_REGEXP} regular expression, and that the specified logic string is not null or blank. */ @@ -113,7 +114,7 @@ public class AxLogic extends AxConcept { /** * Copy constructor. - * + * * @param copyConcept the concept to copy from */ public AxLogic(final AxLogic copyConcept) { diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicies.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicies.java index 3be3e4a31..493cf79c1 100644 --- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicies.java +++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicies.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -48,14 +49,14 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxKey; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * This class is a policy container and holds a map of the policies for an entire Apex model. All Apex models that use * policies must have an {@link AxPolicies} field. The {@link AxPolicies} class implements the helper methods of the * {@link AxConceptGetter} interface to allow {@link AxPolicy} instances to be retrieved by calling methods directly on * this class without referencing the contained map. - * + * *

Validation checks that the container key is not null. An error is issued if no policies are defined in the * container. Each policy entry is checked to ensure that its key and value are not null and that the key matches the * key in the map value. Each policy entry is then validated individually. @@ -105,7 +106,7 @@ public class AxPolicies extends AxConcept implements AxConceptGetter { /** * Copy constructor. - * + * * @param copyConcept the concept to copy from */ public AxPolicies(final AxPolicies copyConcept) { @@ -146,7 +147,7 @@ public class AxPolicies extends AxConcept implements AxConceptGetter { /* * (non-Javadoc) - * + * * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKey() */ @Override @@ -156,7 +157,7 @@ public class AxPolicies extends AxConcept implements AxConceptGetter { /* * (non-Javadoc) - * + * * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#getKeys() */ @Override @@ -202,7 +203,7 @@ public class AxPolicies extends AxConcept implements AxConceptGetter { /* * (non-Javadoc) - * + * * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#validate(org.onap.policy.apex.model. * basicmodel.concepts.AxValidationResult) */ @@ -250,7 +251,7 @@ public class AxPolicies extends AxConcept implements AxConceptGetter { /* * (non-Javadoc) - * + * * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#clean() */ @Override @@ -264,7 +265,7 @@ public class AxPolicies extends AxConcept implements AxConceptGetter { /* * (non-Javadoc) - * + * * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#toString() */ @Override @@ -307,7 +308,7 @@ public class AxPolicies extends AxConcept implements AxConceptGetter { /* * (non-Javadoc) - * + * * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#hashCode() */ @Override @@ -321,7 +322,7 @@ public class AxPolicies extends AxConcept implements AxConceptGetter { /* * (non-Javadoc) - * + * * @see org.onap.policy.apex.model.basicmodel.concepts.AxConcept#equals(java.lang.Object) */ @Override @@ -346,7 +347,7 @@ public class AxPolicies extends AxConcept implements AxConceptGetter { /* * (non-Javadoc) - * + * * @see java.lang.Comparable#compareTo(java.lang.Object) */ @Override diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java index 3c43c6edd..00db24124 100644 --- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java +++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicy.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -48,7 +49,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; @@ -57,7 +58,7 @@ import org.slf4j.ext.XLoggerFactory; * {@link AxState} instance. The states of a policy are held in a map in the policy. The state tree is built up at * policy design time by a policy editor and each state is connected to its next state by an {@link AxStateOutput} * instance. - * + * *

Execution of a policy is triggered by an event. A policy starts execution from its first state so the trigger * event for the first sate is the trigger event for the entire policy. Execution from that first state can continue to * one or more subsequent states and so on down branches of states. The state output of the final state in a branch has @@ -65,10 +66,10 @@ import org.slf4j.ext.XLoggerFactory; * in the policy are the possible set of output events on the policy. A state may only be used once in the state tree of * a policy and recursive execution of states in the same execution branch is not allowed, so the same state may not * execute more than once on a single execution of a policy. - * + * *

The template of a policy is a string that can be used by policy editors to store meta information on the policy * that can be used at design time. The policy template string is not used during policy execution. - * + * *

During validation of a policy, the validation checks listed below are executed:

  1. The policy key must not * be a null key
  2. The policy key must be valid
  3. If the policy template is not set, an observation is issued
  4. At * least one state must be defined
  5. Keys and values must all be defined, that is not null
  6. The key on each entry @@ -122,7 +123,7 @@ public class AxPolicy extends AxConcept { /** * Copy constructor. - * + * * @param copyConcept the concept to copy from */ public AxPolicy(final AxPolicy copyConcept) { @@ -316,7 +317,7 @@ public class AxPolicy extends AxConcept { /** * Validate a state entry. - * + * * @param stateEntry the state entry to validate * @param result The validation result to append to * @return The result of the validation @@ -363,7 +364,7 @@ public class AxPolicy extends AxConcept { /** * Validate a state tree to ensure there are no circular references in it. - * + * * @param result The validation result to append to * @return The result of the validation */ diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java index 8233a0517..acc2c8e04 100644 --- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java +++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxPolicyModel.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -54,7 +55,7 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas; import org.onap.policy.apex.model.eventmodel.concepts.AxEvent; import org.onap.policy.apex.model.eventmodel.concepts.AxEvents; import org.onap.policy.apex.model.eventmodel.concepts.AxField; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * A container class for an Apex policy model. This class is a container class that allows an Apex @@ -62,18 +63,18 @@ import org.onap.policy.apex.model.utilities.Assertions; * required to run policies in Apex. The model contains schema definitions, definitions of events * and context albums that use those schemas, definitions of tasks for policies and definitions of * the policies themselves. - * + * *

    An Apex policy model is an important artifact in Apex. At editing time, an Apex editor creates * and edits a policy model and a policy model is loaded into and is executed by an Apex engine. * Therefore, an Apex model and the set of policies that it holds is the way that the policy domain * that an Apex engine or a group of Apex engines executes across is expressed, both at design time * and run time. The Apex deployment system is responsible for deploying Apex models to and the * context they need the appropriate engines for execution. - * + * *

    Model registration is carried out by calling the {@code register()} method, which registers the * policy model and all its constituent containers with the model service. The containers for * context schemas, events, context albums, tasks, policies, and key information are all registered. - * + * *

    Once a policy model is composed, the overall structure of the policy model and all its references * can be validated. During validation of a policy model, the validation checks listed below are * executed: @@ -156,7 +157,7 @@ public class AxPolicyModel extends AxModel { /** * Copy constructor. - * + * * @param copyConcept the concept to copy from */ public AxPolicyModel(final AxPolicyModel copyConcept) { @@ -421,7 +422,7 @@ public class AxPolicyModel extends AxModel { /** * Validate all fundamental concepts keyed in tasks exist. - * + * * @param task The task to validate the keys of * @param result the validation result to return * @return the result @@ -468,7 +469,7 @@ public class AxPolicyModel extends AxModel { /** * Validate that the references used on a state are valid. - * + * * @param state The state to check * @param result the validation result to append to */ @@ -519,7 +520,7 @@ public class AxPolicyModel extends AxModel { /** * Validate that the fields on tasks and events that trigger them and are output by them are * compatible for all tasks used on a state. - * + * * @param state The state to check * @param result the validation result to append to */ @@ -546,7 +547,7 @@ public class AxPolicyModel extends AxModel { /** * Validate that the fields on a task of a state output and the events that trigger it are * compatible. - * + * * @param state The state to check * @param task The task to check * @param stateOutput The state output to check diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxState.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxState.java index f25c22827..cb5331f94 100644 --- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxState.java +++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxState.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +58,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * This class holds the definition of a single state in a policy. A state is a single stage in a policy. A state has a @@ -957,9 +958,9 @@ public class AxState extends AxConcept { /** * Compare the object fields on this state to another state. - * + * * @param the other state to compare with - * @return the result of the comparison + * @return the result of the comparison */ private int compareObjectFields(final AxState other) { if (!key.equals(other.key)) { @@ -986,7 +987,7 @@ public class AxState extends AxConcept { if (!taskReferenceMap.equals(other.taskReferenceMap)) { return (taskReferenceMap.hashCode() - other.taskReferenceMap.hashCode()); } - + return 0; } } diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateOutput.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateOutput.java index 6f6117027..67ed4f16a 100644 --- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateOutput.java +++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateOutput.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -43,7 +44,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * This class defines a single output that a state can have. A state can have many outputs with each @@ -52,7 +53,7 @@ import org.onap.policy.apex.model.utilities.Assertions; * state output is selected. If no next state is defined (the next state is a null * {@link AxReferenceKey} key), then this state output outputs its event to an external system and * is an output state for the full policy. - * + * *

    During validation of a state output, the validation checks listed below are executed: *

      *
    1. The state output key must not be a null key and must be valid, see validation in @@ -106,7 +107,7 @@ public class AxStateOutput extends AxConcept { /** * Copy constructor. - * + * * @param copyConcept the concept to copy from */ public AxStateOutput(final AxStateOutput copyConcept) { diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTaskReference.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTaskReference.java index fdf73149f..13c21b65e 100644 --- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTaskReference.java +++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTaskReference.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -44,7 +45,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * This class defines the type of output handling that will be used when a task in a state completes @@ -59,7 +60,7 @@ import org.onap.policy.apex.model.utilities.Assertions; * case of {@link AxStateTaskOutputType#LOGIC} output selection, the output reference key held in * this {@link AxStateTaskReference} instance to an instance of an {@link AxStateFinalizerLogic} * class. See the explanation in the {@link AxState} class for a full description of this handling. - * + * *

      During validation of a state task reference, the validation checks listed below are executed: *

        *
      1. The state task reference key must not be a null key and must be valid, see validation in @@ -111,7 +112,7 @@ public class AxStateTaskReference extends AxConcept { /** * Copy constructor. - * + * * @param copyConcept the concept to copy from */ public AxStateTaskReference(final AxStateTaskReference copyConcept) { diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTree.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTree.java index 0233aa6bf..e68bf9613 100644 --- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTree.java +++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxStateTree.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -27,14 +28,14 @@ import java.util.Set; import java.util.TreeSet; import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * The Class is used to return the tree that represents the state branches or chains in a policy. It * creates a tree that holds the state fan out branches in a policy that starts from the given top * state of the tree. Each branch from a state is held in a set of next states for the top state and * each branch in the state tree is itself a {@link AxStateTree} instance. - * + * *

        Validation checks for recursive state use, in other words validation forbids the use of a given * state more than once in a state tree. */ diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java index cf8f34ce7..bbf749a4a 100644 --- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java +++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTask.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -54,21 +55,21 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat import org.onap.policy.apex.model.eventmodel.concepts.AxField; import org.onap.policy.apex.model.eventmodel.concepts.AxInputField; import org.onap.policy.apex.model.eventmodel.concepts.AxOutputField; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * This class holds the definition of a task in Apex. A task is executed by a state and performs * some domain specific logic to carry out work required to be done by a policy. The Task Logic that * is executed by a task is held in a {@link AxTaskLogic} instance. - * + * *

        A task has a set of input fields and output fields, which are passed to and are emitted from the * task during a task execution cycle. A task may have task parameters {@link AxTaskParameter}, * which are configuration values passed to a task at initialization time. - * + * *

        The Task Logic in a task may use information in context albums to perform their domain specific * work. The context albums that the task uses and that should be made available to the task by Apex * policy distribution are held as a set of references to context albums in the task. - * + * *

        During validation of a task, the validation checks listed below are executed: *

          *
        1. The task key must not be a null key and must be valid, see validation in @@ -138,7 +139,7 @@ public class AxTask extends AxConcept { /** * Copy constructor. - * + * * @param copyConcept the concept to copy from */ public AxTask(final AxTask copyConcept) { @@ -491,7 +492,7 @@ public class AxTask extends AxConcept { /** * Validate a field. - * + * * @param key the key of the field to validate * @param field the field to validate * @param direction The direction of the field @@ -517,7 +518,7 @@ public class AxTask extends AxConcept { /** * Validate a task parameter entry. - * + * * @param taskParameterEntry the task parameter entry to validate * @param result The validation result to append to * @return The result of the validation @@ -541,7 +542,7 @@ public class AxTask extends AxConcept { /** * Validate a context album reference entry. - * + * * @param taskParameterEntry the context album reference entry to validate * @param result The validation result to append to * @return The result of the validation @@ -647,7 +648,7 @@ public class AxTask extends AxConcept { } copy.setContextAlbumReferences(newContextUsage); - copy.setTaskLogic(new AxTaskLogic((AxLogic) taskLogic)); + copy.setTaskLogic(new AxTaskLogic(taskLogic)); return copy; } diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskParameter.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskParameter.java index 236956020..4846c59cf 100644 --- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskParameter.java +++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTaskParameter.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -38,7 +39,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * This class is used to specify the configuration parameters that may be passed to a task @@ -77,7 +78,7 @@ public class AxTaskParameter extends AxConcept { /** * Copy constructor. - * + * * @param copyConcept the concept to copy from */ public AxTaskParameter(final AxTaskParameter copyConcept) { diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTasks.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTasks.java index 75fe632a6..b73b6d32b 100644 --- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTasks.java +++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxTasks.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -48,14 +49,14 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxKey; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * This class is a task container and holds a map of the tasks for an entire Apex model. All Apex * models that use tasks must have an {@link AxTasks} field. The {@link AxTasks} class implements * the helper methods of the {@link AxConceptGetter} interface to allow {@link AxTask} instances to * be retrieved by calling methods directly on this class without referencing the contained map. - * + * *

          Validation checks that the container key is not null. An error is issued if no tasks are defined * in the container. Each task entry is checked to ensure that its key and value are not null and * that the key matches the key in the map value. Each task entry is then validated individually. @@ -93,7 +94,7 @@ public class AxTasks extends AxConcept implements AxConceptGetter { /** * Copy constructor. - * + * * @param copyConcept the concept to copy from */ public AxTasks(final AxTasks copyConcept) { diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyser.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyser.java index 244346c99..d40e66ead 100644 --- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyser.java +++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyser.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -35,7 +36,7 @@ import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; import org.onap.policy.apex.model.policymodel.concepts.AxState; import org.onap.policy.apex.model.policymodel.concepts.AxStateOutput; import org.onap.policy.apex.model.policymodel.concepts.AxTask; -import org.onap.policy.apex.model.utilities.Assertions; +import org.onap.policy.common.utils.validation.Assertions; /** * This class analyses a policy model and shows what the usage of each context album, context item, data type, and event diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/Assertions.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/Assertions.java deleted file mode 100644 index 02a91a72c..000000000 --- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/Assertions.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.model.utilities; - -import org.slf4j.ext.XLogger; -import org.slf4j.ext.XLoggerFactory; - -/** - * The Class Assertions is a template class that is used as a shorthand for assertions in the source code. - * - * @author Sajeevan Achuthan (sajeevan.achuthan@ericsson.com) - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public final class Assertions { - // Logger for this class - private static final XLogger LOGGER = XLoggerFactory.getXLogger(Assertions.class); - - /** - * Private constructor used to prevent sub class instantiation. - */ - private Assertions() { - } - - /** - * Gets the validation message for a string parameter. - * - * @param parameterName the string parameter name - * @param parameterValue the string parameter value - * @param pattern The regular expression - * @return null if the parameter is valid, the validation message otherwise - */ - public static String getStringParameterValidationMessage(final String parameterName, final String parameterValue, - final String pattern) { - try { - validateStringParameter(parameterName, parameterValue, pattern); - } catch (IllegalArgumentException e) { - String message = "parameter " + parameterName + " with value " + parameterValue - + " does not match regular expression " + pattern; - if (LOGGER.isTraceEnabled()) { - LOGGER.trace(message, e); - } - - return message; - } - - return null; - } - - /** - * Checks if a string parameter matches a regular expression. - * - * @param parameterName the string parameter name - * @param parameterValue the string parameter value - * @param pattern The regular expression - * @return the trimmed string - */ - public static String validateStringParameter(final String parameterName, final String parameterValue, - final String pattern) { - argumentNotNull(parameterName, "parameter name is null"); - argumentNotNull(parameterValue, "parameter \"" + parameterName + "\" is null"); - argumentNotNull(pattern, "parameter pattern is null"); - - final String trimmedValue = parameterValue.trim(); - if (trimmedValue.matches(pattern)) { - return trimmedValue; - } else { - throw new IllegalArgumentException("parameter \"" + parameterName + "\": value \"" + parameterValue - + "\", does not match regular expression \"" + pattern + "\""); - } - } - - /** - * Used as a shorthand to check that method arguments are not null, throws IllegalArgumentException on error. - * - * @param the generic type of the argument to check - * @param value the value of the type - * @param message the error message to issue - */ - public static void argumentNotNull(final T value, final String message) { - if (value == null) { - throw new IllegalArgumentException(message); - } - } - - /** - * Used as a shorthand to check that method arguments are not false, throws IllegalArgumentException on error. - * - * @param value the value to check if false - * @param message the error message to issue - */ - public static void argumentNotFalse(final boolean value, final String message) { - if (!value) { - throw new IllegalArgumentException(message); - } - } - - /** - * Used as a shorthand to check that method arguments are not null, throws an exception of the specified type on - * error. - * - * @param the generic type of the argument to check - * @param the exception to throw if incoming value is null - * @param value the value of the type - * @param exceptionClass the class of exception to return an instance of - * @param message the error message to issue - * @throws E an instance of the passed Exception Class - */ - public static void argumentOfClassNotNull(final T value, final Class exceptionClass, - final String message) throws E { - if (value == null) { - // Instantiate the exception and throw it - try { - throw exceptionClass.getConstructor(String.class).newInstance(message); - } catch (final Exception errorException) { - throw new IllegalArgumentException(message, errorException); - } - } - } - - /** - * Used as a shorthand to check that method argument is not false, throws an exception of the specified type on - * error. - * - * @param the exception to throw if incoming value is false - * @param value the value to check if false - * @param exceptionClass the class of exception to return an instance of - * @param message the error message to issue - * @throws E an instance of the passed Exception Class - */ - public static void argumentOfClassNotFalse(final boolean value, final Class exceptionClass, - final String message) throws E { - if (!value) { - // Instantiate the exception and throw it - try { - throw exceptionClass.getConstructor(String.class).newInstance(message); - } catch (final Exception errorException) { - throw new IllegalArgumentException(message, errorException); - } - } - } - - /** - * Used as a shorthand to check that an object is an instance of a given class, throws IllegalArgumentException on - * error. - * - * @param the generic type of the argument to check - * @param objectInstance the object instance for which to check the class - * @param requiredClass the class that the object should be an instance of - * @throws IllegalArgumentException if the incoming object is not an instance of requiredClass - */ - public static void instanceOf(final Object objectInstance, final Class requiredClass) { - if (!requiredClass.isAssignableFrom(objectInstance.getClass())) { - throw new IllegalArgumentException(objectInstance.getClass().getCanonicalName() + " is not an instance of " - + requiredClass.getCanonicalName()); - } - } - - /** - * Used as a shorthand to check that an instance of a class can be an instance of a given class, throws - * IllegalArgumentException on error. - * - * @param the generic type of the argument to check - * @param checkClass the class to check - * @param requiredClass the class that the object should be an instance of - * @throws IllegalArgumentException if the incoming object is not an instance of requiredClass - */ - public static void assignableFrom(final Class checkClass, final Class requiredClass) { - if (!requiredClass.isAssignableFrom(checkClass)) { - throw new IllegalArgumentException(checkClass.getCanonicalName() + " is not an instance of " - + requiredClass.getCanonicalName()); - } - } -} diff --git a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/AssertionsTest.java b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/AssertionsTest.java deleted file mode 100644 index d1040b64b..000000000 --- a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/AssertionsTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.model.utilities; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; -import org.onap.policy.apex.model.utilities.Assertions; - -/** - * The Class ResourceUtilsTest. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ -public class AssertionsTest { - @Test - public void testAssertions() { - Assertions.argumentNotFalse(true, "it is true"); - - try { - Assertions.argumentNotFalse(false, "it is false"); - } catch (IllegalArgumentException e) { - assertEquals("it is false", e.getMessage()); - } - - Assertions.argumentOfClassNotFalse(true, ArithmeticException.class, "it is true"); - - try { - Assertions.argumentOfClassNotFalse(false, ArithmeticException.class, "it is false"); - } catch (Exception e) { - assertEquals("it is false", e.getMessage()); - } - - Assertions.argumentNotNull("Hello", "it is OK"); - - try { - Assertions.argumentNotNull(null, "it is null"); - } catch (IllegalArgumentException e) { - assertEquals("it is null", e.getMessage()); - } - - Assertions.argumentOfClassNotNull(true, ArithmeticException.class, "it is OK"); - - try { - Assertions.argumentOfClassNotNull(null, ArithmeticException.class, "it is null"); - } catch (Exception e) { - assertEquals("it is null", e.getMessage()); - } - - Assertions.assignableFrom(java.util.TreeMap.class, java.util.Map.class); - - try { - Assertions.assignableFrom(java.util.Map.class, java.util.TreeMap.class); - } catch (IllegalArgumentException e) { - assertEquals("java.util.Map is not an instance of java.util.TreeMap", e.getMessage()); - } - - Assertions.instanceOf("Hello", String.class); - - try { - Assertions.instanceOf(100, String.class); - } catch (IllegalArgumentException e) { - assertEquals("java.lang.Integer is not an instance of java.lang.String", e.getMessage()); - } - - Assertions.validateStringParameter("name", "MyName", "^M.*e$"); - - try { - Assertions.validateStringParameter("name", "MyName", "^M.*f$"); - } catch (IllegalArgumentException e) { - assertEquals("parameter \"name\": value \"MyName\", does not match regular expression \"^M.*f$\"", - e.getMessage()); - } - } -} -- cgit 1.2.3-korg