summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlapentafd <francesco.lapenta@est.tech>2021-06-02 12:02:46 +0100
committerlapentafd <francesco.lapenta@est.tech>2021-06-08 10:07:11 +0100
commit1418e7fcc3bba8980e1877c6576983583877ec1e (patch)
tree8537c66c29beea9c6f7a28b256ba846d880760d4
parent328fa34f8ac18d30fec00c7c5f59a05850f631a5 (diff)
Fix Sonar Issues in apex-pdp-model
Changes made into model/basic-model Renamed test classes to match the others Issue-ID: POLICY-3093 Change-Id: I7a0d6046ead42a9165aaf96b89511dd8d064d109 Signed-off-by: lapentafd <francesco.lapenta@est.tech>
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexException.java5
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxArtifactKey.java14
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImpl.java6
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java12
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInformation.java10
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriter.java13
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReader.java15
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaver.java6
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriter.java16
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriter.java16
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexSchemaGenerator.java12
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java53
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java17
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelConceptsTest.java (renamed from model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelConceptsTester.java)19
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java (renamed from model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTester.java)4
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTest.java (renamed from model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTester.java)4
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportConceptGetterTest.java (renamed from model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportConceptGetterTester.java)241
17 files changed, 249 insertions, 214 deletions
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexException.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexException.java
index 97920c3b5..2eca2f783 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexException.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/ApexException.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -88,10 +89,10 @@ public class ApexException extends Exception {
* @return cascaded message string
*/
public static String buildCascadedMessage(Throwable throwable) {
- final StringBuilder builder = new StringBuilder();
+ final var builder = new StringBuilder();
builder.append(throwable.getMessage());
- for (Throwable t = throwable; t != null; t = t.getCause()) {
+ for (var t = throwable; t != null; t = t.getCause()) {
builder.append("\ncaused by: ");
builder.append(t.getMessage());
}
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 86c89c35e..6e0a3cf4d 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,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -235,7 +235,7 @@ public class AxArtifactKey extends AxKey {
}
final AxArtifactKey otherArtifactKey = (AxArtifactKey) otherKey;
- final Compatibility compatibility = this.getCompatibility(otherArtifactKey);
+ final var compatibility = this.getCompatibility(otherArtifactKey);
return !(compatibility == Compatibility.DIFFERENT || compatibility == Compatibility.MAJOR);
}
@@ -245,14 +245,14 @@ public class AxArtifactKey extends AxKey {
*/
@Override
public AxValidationResult validate(final AxValidationResult result) {
- final String nameValidationErrorMessage = Assertions.getStringParameterValidationMessage(NAME_TOKEN, name,
+ final var nameValidationErrorMessage = Assertions.getStringParameterValidationMessage(NAME_TOKEN, name,
NAME_REGEXP);
if (nameValidationErrorMessage != null) {
result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
"name invalid-" + nameValidationErrorMessage));
}
- final String versionValidationErrorMessage = Assertions.getStringParameterValidationMessage(VERSION_TOKEN,
+ final var versionValidationErrorMessage = Assertions.getStringParameterValidationMessage(VERSION_TOKEN,
version, VERSION_REGEXP);
if (versionValidationErrorMessage != null) {
result.addValidationMessage(new AxValidationMessage(this, this.getClass(), ValidationResult.INVALID,
@@ -276,7 +276,7 @@ public class AxArtifactKey extends AxKey {
*/
@Override
public String toString() {
- final StringBuilder builder = new StringBuilder();
+ final var builder = new StringBuilder();
builder.append(this.getClass().getSimpleName());
builder.append(":(");
builder.append("name=");
@@ -309,8 +309,8 @@ public class AxArtifactKey extends AxKey {
*/
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + name.hashCode();
result = prime * result + version.hashCode();
return result;
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 175cded08..9c907da9c 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,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -62,7 +62,7 @@ public class AxConceptGetterImpl<C> implements AxConceptGetter<C> {
Assertions.argumentNotNull(conceptKeyName, "conceptKeyName may not be null");
// The very fist key that could have this name
- final AxArtifactKey lowestArtifactKey = new AxArtifactKey(conceptKeyName, "0.0.1");
+ final var lowestArtifactKey = new AxArtifactKey(conceptKeyName, "0.0.1");
// Check if we found a key for our name
AxArtifactKey foundKey = conceptMap.ceilingKey(lowestArtifactKey);
@@ -117,7 +117,7 @@ public class AxConceptGetterImpl<C> implements AxConceptGetter<C> {
}
// The very fist key that could have this name
- final AxArtifactKey lowestArtifactKey = new AxArtifactKey(conceptKeyName, "0.0.1");
+ final var lowestArtifactKey = new AxArtifactKey(conceptKeyName, "0.0.1");
if (conceptKeyVersion != null) {
lowestArtifactKey.setVersion(conceptKeyVersion);
}
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 4b84a403a..7e92faddf 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,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -233,7 +233,7 @@ public class AxKeyInfo extends AxConcept {
*/
@Override
public String toString() {
- final StringBuilder builder = new StringBuilder();
+ final var builder = new StringBuilder();
builder.append(this.getClass().getSimpleName());
builder.append(":(");
builder.append("artifactId=");
@@ -269,8 +269,8 @@ public class AxKeyInfo extends AxConcept {
*/
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + key.hashCode();
result = prime * result + uuid.hashCode();
result = prime * result + description.hashCode();
@@ -336,14 +336,14 @@ public class AxKeyInfo extends AxConcept {
* @return the uuid
*/
public static UUID generateReproducibleUuid(final String seed) {
- Random random = sharedRandom;
+ var random = sharedRandom;
if (!StringUtils.isEmpty(seed)) {
/*
* This is not used for encryption/security, thus disabling sonar.
*/
random = new Random(seed.hashCode()); // NOSONAR
}
- final byte[] array = new byte[UUID_BYTE_LENGTH_16];
+ final var array = new byte[UUID_BYTE_LENGTH_16];
random.nextBytes(array);
return UUID.nameUUIDFromBytes(array);
}
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 2619d2eea..fe597bb08 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,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -151,7 +151,7 @@ public class AxKeyInformation extends AxConcept implements AxConceptGetter<AxKey
final AxArtifactKey artifactKey = (AxArtifactKey) axKey;
keyInfoMap.computeIfAbsent(artifactKey, unusedKey -> {
- final AxKeyInfo keyInfo = new AxKeyInfo(artifactKey);
+ final var keyInfo = new AxKeyInfo(artifactKey);
// generate a reproducible UUID
keyInfo.setUuid(AxKeyInfo.generateReproducibleUuid(keyInfo.getId() + keyInfo.getDescription()));
return keyInfo;
@@ -290,7 +290,7 @@ public class AxKeyInformation extends AxConcept implements AxConceptGetter<AxKey
*/
@Override
public String toString() {
- final StringBuilder builder = new StringBuilder();
+ final var builder = new StringBuilder();
builder.append(this.getClass().getSimpleName());
builder.append(":(");
builder.append("key=");
@@ -327,8 +327,8 @@ public class AxKeyInformation extends AxConcept implements AxConceptGetter<AxKey
*/
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + key.hashCode();
result = prime * result + keyInfoMap.hashCode();
return result;
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriter.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriter.java
index 04dd2a3f4..908ad31aa 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriter.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriter.java
@@ -1,19 +1,20 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 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=========================================================
*/
@@ -120,16 +121,14 @@ public class ApexModelFileWriter<M extends AxModel> {
*/
private void writeModelFile(final M model, final ApexModelWriter<M> modelWriter, final String modelFileName)
throws ApexException {
- final File modelFile = new File(modelFileName);
+ final var modelFile = new File(modelFileName);
if (!modelFile.getParentFile().exists() && !modelFile.getParentFile().mkdirs()) {
LOGGER.warn("could not create directory " + modelFile.getParentFile());
throw new ApexException("could not create directory " + modelFile.getParentFile());
}
- try {
- final FileOutputStream fileOutputStream = new FileOutputStream(modelFile);
+ try (final var fileOutputStream = new FileOutputStream(modelFile)) {
modelWriter.write(model, fileOutputStream);
- fileOutputStream.close();
} catch (final Exception e) {
LOGGER.warn("error processing file " + modelFile.getAbsolutePath(), e);
throw new ApexException("error processing file " + modelFile.getAbsolutePath(), e);
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 db7360e75..7e136f6b3 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,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -27,15 +27,12 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringReader;
-import java.net.URL;
import java.util.regex.Pattern;
import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.transform.stream.StreamSource;
-import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import org.eclipse.persistence.jaxb.JAXBContextFactory;
import org.eclipse.persistence.jaxb.MarshallerProperties;
@@ -86,7 +83,7 @@ public class ApexModelReader<C extends AxConcept> {
this.rootConceptClass = rootConceptClass;
try {
- final JAXBContext jaxbContext = JAXBContextFactory.createContext(new Class[] {rootConceptClass}, null);
+ final var jaxbContext = JAXBContextFactory.createContext(new Class[] {rootConceptClass}, null);
// Set up the unmarshaller to carry out validation
unmarshaller = jaxbContext.createUnmarshaller();
@@ -120,8 +117,8 @@ public class ApexModelReader<C extends AxConcept> {
if (schemaFileName != null) {
try {
// Set the concept schema
- final URL schemaUrl = ResourceUtils.getUrlResource(schemaFileName);
- final Schema apexConceptSchema =
+ final var schemaUrl = ResourceUtils.getUrlResource(schemaFileName);
+ final var apexConceptSchema =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(schemaUrl);
unmarshaller.setSchema(apexConceptSchema);
} catch (final Exception e) {
@@ -182,7 +179,7 @@ public class ApexModelReader<C extends AxConcept> {
LOGGER.entry("reading Apex concept from string . . .");
- final String apexString = apexConceptString.trim();
+ final var apexString = apexConceptString.trim();
// Set the type of input for this stream
setInputType(apexString);
@@ -193,7 +190,7 @@ public class ApexModelReader<C extends AxConcept> {
// Use JAXB to read and verify the Apex concept XML file
try {
// Load the configuration file
- final StreamSource source = new StreamSource(new StringReader(apexString));
+ final var source = new StreamSource(new StringReader(apexString));
final JAXBElement<C> rootElement = unmarshaller.unmarshal(source, rootConceptClass);
apexConcept = rootElement.getValue();
} catch (final JAXBException e) {
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 8217badbc..dea32df49 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,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -72,7 +72,7 @@ public class ApexModelSaver<M extends AxModel> {
LOGGER.debug("running apexModelWriteXML . . .");
// Write the file to disk
- final File xmlFile = new File(writePath + File.separatorChar + model.getKey().getName() + ".xml");
+ final var xmlFile = new File(writePath + File.separatorChar + model.getKey().getName() + ".xml");
new ApexModelFileWriter<M>(true).apexModelWriteXmlFile(model, rootModelClass, xmlFile.getPath());
LOGGER.debug("ran apexModelWriteXML");
@@ -87,7 +87,7 @@ public class ApexModelSaver<M extends AxModel> {
LOGGER.debug("running apexModelWriteJSON . . .");
// Write the file to disk
- final File jsonFile = new File(writePath + File.separatorChar + model.getKey().getName() + ".json");
+ final var jsonFile = new File(writePath + File.separatorChar + model.getKey().getName() + ".json");
new ApexModelFileWriter<M>(true).apexModelWriteJsonFile(model, rootModelClass, jsonFile.getPath());
LOGGER.debug("ran apexModelWriteJSON");
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 f1725d8e3..de6a72ffd 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,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -86,17 +86,14 @@ public class ApexModelStringWriter<C extends AxConcept> {
conceptWriter.getCDataFieldSet().add("logic");
conceptWriter.getCDataFieldSet().add("uiLogic");
- final ByteArrayOutputStream baOutputStream = new ByteArrayOutputStream();
- try {
+ try (var baOutputStream = new ByteArrayOutputStream()) {
conceptWriter.write(concept, baOutputStream);
- baOutputStream.close();
+ return baOutputStream.toString();
} catch (final Exception e) {
LOGGER.warn("error writing XML string", e);
throw new ApexException("error writing XML string", e);
}
- LOGGER.debug("ran writeXMLString");
- return baOutputStream.toString();
}
/**
@@ -114,17 +111,14 @@ public class ApexModelStringWriter<C extends AxConcept> {
conceptWriter.setJsonOutput(true);
conceptWriter.setValidateFlag(validateFlag);
- final ByteArrayOutputStream baOutputStream = new ByteArrayOutputStream();
- try {
+ try (var baOutputStream = new ByteArrayOutputStream()) {
conceptWriter.write(concept, baOutputStream);
- baOutputStream.close();
+ return baOutputStream.toString();
} catch (final Exception e) {
LOGGER.warn("error writing JSON string", e);
throw new ApexException("error writing JSON string", e);
}
- LOGGER.debug("ran writeJSONString");
- return baOutputStream.toString();
}
/**
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 0763492fc..9e43f76bd 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,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,6 @@ import java.io.Writer;
import java.util.Set;
import java.util.TreeSet;
import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -47,7 +46,6 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.common.utils.validation.Assertions;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
-import org.w3c.dom.Document;
/**
* This class writes an Apex concept to an XML file or JSON file from a Java Apex Concept.
@@ -87,7 +85,7 @@ public class ApexModelWriter<C extends AxConcept> {
System.setProperty("javax.xml.bind.context.factory", "org.eclipse.persistence.jaxb.JAXBContextFactory");
try {
- final JAXBContext jaxbContext = JAXBContextFactory.createContext(new Class[]{rootConceptClass}, null);
+ final var jaxbContext = JAXBContextFactory.createContext(new Class[]{rootConceptClass}, null);
// Set up the unmarshaller to carry out validation
marshaller = jaxbContext.createMarshaller();
@@ -201,17 +199,17 @@ public class ApexModelWriter<C extends AxConcept> {
try {
// Write the concept into a DOM document, then transform to add CDATA fields and pretty
// print, then write out the result
- final DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+ final var docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
docBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
docBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
- final Document document = docBuilderFactory.newDocumentBuilder().newDocument();
+ final var document = docBuilderFactory.newDocumentBuilder().newDocument();
// Marshal the concept into the empty document.
marshaller.marshal(concept, document);
- final Transformer domTransformer = getTransformer();
+ final var domTransformer = getTransformer();
// Convert the cDataFieldSet into a space delimited string
domTransformer.setOutputProperty(OutputKeys.CDATA_SECTION_ELEMENTS,
@@ -225,11 +223,11 @@ public class ApexModelWriter<C extends AxConcept> {
private Transformer getTransformer() throws TransformerConfigurationException {
// Transform the DOM to the output stream
- final TransformerFactory transformerFactory = TransformerFactory.newInstance();
+ final var transformerFactory = TransformerFactory.newInstance();
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
- final Transformer domTransformer = transformerFactory.newTransformer();
+ final var domTransformer = transformerFactory.newTransformer();
// Pretty print
try {
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexSchemaGenerator.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexSchemaGenerator.java
index 8617f2c81..d5f34785b 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexSchemaGenerator.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexSchemaGenerator.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,7 +53,7 @@ public class ApexSchemaGenerator {
if (args.length == 1) {
printStream = System.out;
} else if (args.length == 2) {
- final File schemaFile = new File(args[1]);
+ final var schemaFile = new File(args[1]);
try {
schemaFile.getParentFile().mkdirs();
@@ -94,7 +94,7 @@ public class ApexSchemaGenerator {
return null;
}
- final ApexSchemaOutputResolver sor = new ApexSchemaOutputResolver();
+ final var sor = new ApexSchemaOutputResolver();
try {
jaxbContext.generateSchema(sor);
} catch (final IOException e) {
@@ -102,7 +102,7 @@ public class ApexSchemaGenerator {
return null;
}
- String schemaString = sor.getSchema();
+ var schemaString = sor.getSchema();
schemaString = fixForUnqualifiedBug(schemaString);
return schemaString;
@@ -118,7 +118,7 @@ public class ApexSchemaGenerator {
*/
private String fixForUnqualifiedBug(final String schemaString) {
// Fix the "entry" element
- String newSchemaString = schemaString.replace(
+ var newSchemaString = schemaString.replace(
"<xs:element name=\"entry\" minOccurs=\"0\" maxOccurs=\"unbounded\">",
"<xs:element name=\"entry\" minOccurs=\"0\" maxOccurs=\"unbounded\" form=\"unqualified\">");
@@ -144,7 +144,7 @@ public class ApexSchemaGenerator {
*/
@Override
public Result createOutput(final String namespaceUri, final String suggestedFileName) throws IOException {
- final StreamResult result = new StreamResult(stringWriter);
+ final var result = new StreamResult(stringWriter);
result.setSystemId(suggestedFileName);
return result;
}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java
index bf63e6db7..36ce4e438 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java
@@ -1,19 +1,20 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 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=========================================================
*/
@@ -23,11 +24,9 @@ package org.onap.policy.apex.model.basicmodel.test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.net.URL;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
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.dao.ApexDao;
import org.onap.policy.apex.model.basicmodel.dao.ApexDaoFactory;
import org.onap.policy.apex.model.basicmodel.dao.DaoParameters;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelFileWriter;
@@ -87,7 +86,7 @@ public class TestApexModel<M extends AxModel> {
public final void testApexModelWriteReadXml() throws ApexException {
LOGGER.debug("running testApexModelWriteReadXML . . .");
- final M model = modelCreator.getModel();
+ final var model = modelCreator.getModel();
// Write the file to disk
File xmlFile;
@@ -105,8 +104,8 @@ public class TestApexModel<M extends AxModel> {
final ApexModelReader<M> modelReader = new ApexModelReader<>(rootModelClass);
try {
- final URL apexModelUrl = ResourceUtils.getLocalFile(xmlFile.getAbsolutePath());
- final M fileModel = modelReader.read(apexModelUrl.openStream());
+ final var apexModelUrl = ResourceUtils.getLocalFile(xmlFile.getAbsolutePath());
+ final var fileModel = modelReader.read(apexModelUrl.openStream());
checkModelEquality(model, fileModel, TEST_MODEL_UNEQUAL_STR + xmlFile.getAbsolutePath());
} catch (final Exception e) {
LOGGER.warn(ERROR_PROCESSING_FILE + xmlFile.getAbsolutePath(), e);
@@ -118,10 +117,10 @@ public class TestApexModel<M extends AxModel> {
modelWriter.getCDataFieldSet().add("logic");
modelWriter.getCDataFieldSet().add("uiLogic");
- final ByteArrayOutputStream baOutputStream = new ByteArrayOutputStream();
+ final var baOutputStream = new ByteArrayOutputStream();
modelWriter.write(model, baOutputStream);
- final ByteArrayInputStream baInputStream = new ByteArrayInputStream(baOutputStream.toByteArray());
- final M byteArrayModel = modelReader.read(baInputStream);
+ final var baInputStream = new ByteArrayInputStream(baOutputStream.toByteArray());
+ final var byteArrayModel = modelReader.read(baInputStream);
checkModelEquality(model, byteArrayModel, "test model does not equal XML marshalled and unmarshalled model");
@@ -136,7 +135,7 @@ public class TestApexModel<M extends AxModel> {
public final void testApexModelWriteReadJson() throws ApexException {
LOGGER.debug("running testApexModelWriteReadJSON . . .");
- final M model = modelCreator.getModel();
+ final var model = modelCreator.getModel();
// Write the file to disk
File jsonFile;
@@ -153,8 +152,8 @@ public class TestApexModel<M extends AxModel> {
final ApexModelReader<M> modelReader = new ApexModelReader<>(rootModelClass);
try {
- final URL apexModelUrl = ResourceUtils.getLocalFile(jsonFile.getAbsolutePath());
- final M fileModel = modelReader.read(apexModelUrl.openStream());
+ final var apexModelUrl = ResourceUtils.getLocalFile(jsonFile.getAbsolutePath());
+ final var fileModel = modelReader.read(apexModelUrl.openStream());
checkModelEquality(model, fileModel, TEST_MODEL_UNEQUAL_STR + jsonFile.getAbsolutePath());
} catch (final Exception e) {
LOGGER.warn(ERROR_PROCESSING_FILE + jsonFile.getAbsolutePath(), e);
@@ -164,11 +163,11 @@ public class TestApexModel<M extends AxModel> {
final ApexModelWriter<M> modelWriter = new ApexModelWriter<>(rootModelClass);
modelWriter.setJsonOutput(true);
- final ByteArrayOutputStream baOutputStream = new ByteArrayOutputStream();
+ final var baOutputStream = new ByteArrayOutputStream();
modelWriter.write(model, baOutputStream);
- final ByteArrayInputStream baInputStream = new ByteArrayInputStream(baOutputStream.toByteArray());
- final M byteArrayModel = modelReader.read(baInputStream);
-
+ final var baInputStream = new ByteArrayInputStream(baOutputStream.toByteArray());
+ final var byteArrayModel = modelReader.read(baInputStream);
+
checkModelEquality(model, byteArrayModel, "test model does not equal JSON marshalled and unmarshalled model");
LOGGER.debug("ran testApexModelWriteReadJSON");
@@ -183,13 +182,13 @@ public class TestApexModel<M extends AxModel> {
public final void testApexModelWriteReadJpa(final DaoParameters daoParameters) throws ApexException {
LOGGER.debug("running testApexModelWriteReadJPA . . .");
- final M model = modelCreator.getModel();
+ final var model = modelCreator.getModel();
- final ApexDao apexDao = new ApexDaoFactory().createApexDao(daoParameters);
+ final var apexDao = new ApexDaoFactory().createApexDao(daoParameters);
apexDao.init(daoParameters);
apexDao.create(model);
- final M dbJpaModel = apexDao.get(rootModelClass, model.getKey());
+ final var dbJpaModel = apexDao.get(rootModelClass, model.getKey());
apexDao.close();
checkModelEquality(model, dbJpaModel, "test model does not equal model written and read using generic JPA");
@@ -206,7 +205,7 @@ public class TestApexModel<M extends AxModel> {
public final AxValidationResult testApexModelValid() throws ApexException {
LOGGER.debug("running testApexModelVaid . . .");
- final M model = modelCreator.getModel();
+ final var model = modelCreator.getModel();
final AxValidationResult result = model.validate(new AxValidationResult());
if (!result.isValid()) {
@@ -228,7 +227,7 @@ public class TestApexModel<M extends AxModel> {
public final AxValidationResult testApexModelVaidateMalstructured() throws ApexException {
LOGGER.debug("running testApexModelVaidateMalstructured . . .");
- final M model = modelCreator.getMalstructuredModel();
+ final var model = modelCreator.getMalstructuredModel();
final AxValidationResult result = model.validate(new AxValidationResult());
if (result.isValid()) {
@@ -250,7 +249,7 @@ public class TestApexModel<M extends AxModel> {
public final AxValidationResult testApexModelVaidateObservation() throws ApexException {
LOGGER.debug("running testApexModelVaidateObservation . . .");
- final M model = modelCreator.getObservationModel();
+ final var model = modelCreator.getObservationModel();
final AxValidationResult result = model.validate(new AxValidationResult());
if (!result.isValid()) {
@@ -277,7 +276,7 @@ public class TestApexModel<M extends AxModel> {
public final AxValidationResult testApexModelVaidateWarning() throws ApexException {
LOGGER.debug("running testApexModelVaidateWarning . . .");
- final M model = modelCreator.getWarningModel();
+ final var model = modelCreator.getWarningModel();
final AxValidationResult result = model.validate(new AxValidationResult());
if (!result.isValid()) {
@@ -304,7 +303,7 @@ public class TestApexModel<M extends AxModel> {
public final AxValidationResult testApexModelVaidateInvalidModel() throws ApexException {
LOGGER.debug("running testApexModelVaidateInvalidModel . . .");
- final M model = modelCreator.getInvalidModel();
+ final var model = modelCreator.getInvalidModel();
final AxValidationResult result = model.validate(new AxValidationResult());
if (result.isValid()) {
@@ -319,7 +318,7 @@ public class TestApexModel<M extends AxModel> {
/**
* Check if two models are equal.
- *
+ *
* @param leftModel the left model
* @param rightModel the right model
* @param errorMessage the error message to output on inequality
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java
index 5a57ba3a6..ff7adcd26 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix-2020 Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -70,6 +70,21 @@ public class AxKeyInfoTest {
assertEquals(0, testKeyInfo.compareTo(testKeyInfo));
assertEquals(0, testKeyInfo.compareTo(clonedReferenceKey));
+
+
+ }
+
+ @Test
+ public void testAxKeyValidation() {
+ AxKeyInfo testKeyInfo = new AxKeyInfo();
+
+ AxArtifactKey key = new AxArtifactKey("key", "0.0.1");
+ testKeyInfo.setKey(key);
+
+ UUID uuid = UUID.randomUUID();
+ testKeyInfo.setUuid(uuid);
+ testKeyInfo.setDescription("Key Description");
+
assertNotEquals(0, testKeyInfo.compareTo(null));
assertNotEquals(0, testKeyInfo.compareTo(new AxArtifactKey()));
assertNotEquals(0, testKeyInfo.compareTo(new AxKeyInfo(new AxArtifactKey())));
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelConceptsTester.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelConceptsTest.java
index 8ce072c68..905a27f38 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelConceptsTester.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelConceptsTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 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,7 +42,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat
import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
-public class SupportApexBasicModelConceptsTester {
+public class SupportApexBasicModelConceptsTest {
TestApexModel<AxModel> testApexModel;
@Before
@@ -91,6 +91,12 @@ public class SupportApexBasicModelConceptsTester {
model.getKeyInformation().generateKeyInfo(model);
assertNotNull(model.getKeyInformation());
+ }
+
+ @Test
+ public void testKeyInformation() {
+
+ final AxModel model = testApexModel.getModel();
final AxKeyInformation keyI = model.getKeyInformation();
final AxKeyInformation clonedKeyI = new AxKeyInformation(keyI);
@@ -138,6 +144,14 @@ public class SupportApexBasicModelConceptsTester {
model.getKeyInformation().getKeyInfoMap().clear();
model.getKeyInformation().generateKeyInfo(model);
assertNotNull(model.getKeyInformation());
+ }
+
+ @Test
+ public void testClonedKey() {
+ final AxModel model = testApexModel.getModel();
+ final AxKeyInformation keyI = model.getKeyInformation();
+ final AxKeyInformation clonedKeyI = new AxKeyInformation(keyI);
+ AxValidationResult result = new AxValidationResult();
clonedKeyI.setKey(AxArtifactKey.getNullKey());
result = new AxValidationResult();
@@ -190,6 +204,7 @@ public class SupportApexBasicModelConceptsTester {
result = clonedKeyI.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
+ final AxModel clonedModel = new AxModel(model);
clonedModel.setKey(AxArtifactKey.getNullKey());
result = new AxValidationResult();
result = clonedModel.validate(result);
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTester.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java
index 064a107e7..1c21b6c33 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTester.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.dao.DaoParameters;
import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
-public class SupportApexBasicModelTester {
+public class SupportApexBasicModelTest {
TestApexModel<AxModel> testApexModel;
/**
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTester.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTest.java
index 2761d86da..5fc678ac0 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTester.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020-2021 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
-public class SupportBasicModelTester {
+public class SupportBasicModelTest {
@Test
public void testNormalModelCreator() throws ApexException {
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportConceptGetterTester.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportConceptGetterTest.java
index 786df5258..006c583ec 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportConceptGetterTester.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportConceptGetterTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,119 +35,82 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo;
import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
-public class SupportConceptGetterTester {
+public class SupportConceptGetterTest {
- @Test
- public void testConceptGetter() throws IOException, ApexException {
- AxModel basicModel = new DummyApexBasicModelCreator().getModel();
- assertNotNull(basicModel);
-
- AxKeyInfo intKI01 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey01", "0.0.1"), UUID.randomUUID(),
- "IntegerKIKey01 description");
- AxKeyInfo intKI11 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey11", "0.0.1"), UUID.randomUUID(),
- "IntegerKIKey11 description");
- AxKeyInfo intKI21 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey21", "0.0.1"), UUID.randomUUID(),
- "IntegerKIKey21 description");
- AxKeyInfo intKI22 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey22", "0.0.2"), UUID.randomUUID(),
- "IntegerKIKey22 description");
- AxKeyInfo intKI23 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey23", "0.0.3"), UUID.randomUUID(),
- "IntegerKIKey23 description");
- AxKeyInfo intKI24 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey24", "0.0.4"), UUID.randomUUID(),
- "IntegerKIKey24 description");
- AxKeyInfo intKI25 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey25", "0.0.5"), UUID.randomUUID(),
- "IntegerKIKey25 description");
- AxKeyInfo intKI26 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey26", "0.0.6"), UUID.randomUUID(),
- "IntegerKIKey26 description");
- AxKeyInfo intKI31 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey31", "0.0.1"), UUID.randomUUID(),
- "IntegerKIKey31 description");
- AxKeyInfo intKI41 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey41", "0.0.1"), UUID.randomUUID(),
- "IntegerKIKey41 description");
- AxKeyInfo intKI51 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey51", "0.0.1"), UUID.randomUUID(),
- "IntegerKIKey51 description");
- AxKeyInfo intKI52 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey52", "0.0.2"), UUID.randomUUID(),
- "IntegerKIKey52 description");
- AxKeyInfo intKI53 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey53", "0.0.3"), UUID.randomUUID(),
- "IntegerKIKey53 description");
- AxKeyInfo intKI54 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey54", "0.0.4"), UUID.randomUUID(),
- "IntegerKIKey54 description");
- AxKeyInfo intKI61 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey61", "0.0.1"), UUID.randomUUID(),
- "IntegerKIKey61 description");
- AxKeyInfo intKI62 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey62", "0.0.2"), UUID.randomUUID(),
- "IntegerKIKey62 description");
- AxKeyInfo intKI63 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey63", "0.0.3"), UUID.randomUUID(),
- "IntegerKIKey63 description");
- AxKeyInfo intKI64 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey64", "0.0.4"), UUID.randomUUID(),
- "IntegerKIKey64 description");
- AxKeyInfo intKI71 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey71", "0.0.1"), UUID.randomUUID(),
- "IntegerKIKey71 description");
- AxKeyInfo intKI81 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey81", "0.0.1"), UUID.randomUUID(),
- "IntegerKIKey81 description");
- AxKeyInfo intKI91 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey91", "0.0.1"), UUID.randomUUID(),
- "IntegerKIKey91 description");
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI31.getKey(), intKI31);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI24.getKey(), intKI24);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI11.getKey(), intKI11);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI64.getKey(), intKI64);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI41.getKey(), intKI41);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI51.getKey(), intKI51);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI23.getKey(), intKI23);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI81.getKey(), intKI81);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI71.getKey(), intKI71);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI01.getKey(), intKI01);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI91.getKey(), intKI91);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI52.getKey(), intKI52);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI53.getKey(), intKI53);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI62.getKey(), intKI62);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI54.getKey(), intKI54);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI26.getKey(), intKI26);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI22.getKey(), intKI22);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI25.getKey(), intKI25);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI21.getKey(), intKI21);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI61.getKey(), intKI61);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI63.getKey(), intKI63);
+ private static final AxKeyInfo intKI01 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey01", "0.0.1"),
+ UUID.randomUUID(), "IntegerKIKey01 description");
+ private static final AxKeyInfo intKI11 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey11", "0.0.1"),
+ UUID.randomUUID(), "IntegerKIKey11 description");
+ private static final AxKeyInfo intKI21 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey21", "0.0.1"),
+ UUID.randomUUID(), "IntegerKIKey21 description");
+ private static final AxKeyInfo intKI22 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey22", "0.0.2"),
+ UUID.randomUUID(), "IntegerKIKey22 description");
+ private static final AxKeyInfo intKI23 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey23", "0.0.3"),
+ UUID.randomUUID(), "IntegerKIKey23 description");
+ private static final AxKeyInfo intKI24 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey24", "0.0.4"),
+ UUID.randomUUID(), "IntegerKIKey24 description");
+ private static final AxKeyInfo intKI25 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey25", "0.0.5"),
+ UUID.randomUUID(), "IntegerKIKey25 description");
+ private static final AxKeyInfo intKI26 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey26", "0.0.6"),
+ UUID.randomUUID(), "IntegerKIKey26 description");
+ private static final AxKeyInfo intKI31 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey31", "0.0.1"),
+ UUID.randomUUID(), "IntegerKIKey31 description");
+ private static final AxKeyInfo intKI41 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey41", "0.0.1"),
+ UUID.randomUUID(), "IntegerKIKey41 description");
+ private static final AxKeyInfo intKI51 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey51", "0.0.1"),
+ UUID.randomUUID(), "IntegerKIKey51 description");
+ private static final AxKeyInfo intKI52 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey52", "0.0.2"),
+ UUID.randomUUID(), "IntegerKIKey52 description");
+ private static final AxKeyInfo intKI53 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey53", "0.0.3"),
+ UUID.randomUUID(), "IntegerKIKey53 description");
+ private static final AxKeyInfo intKI54 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey54", "0.0.4"),
+ UUID.randomUUID(), "IntegerKIKey54 description");
+ private static final AxKeyInfo intKI61 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey61", "0.0.1"),
+ UUID.randomUUID(), "IntegerKIKey61 description");
+ private static final AxKeyInfo intKI62 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey62", "0.0.2"),
+ UUID.randomUUID(), "IntegerKIKey62 description");
+ private static final AxKeyInfo intKI63 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey63", "0.0.3"),
+ UUID.randomUUID(), "IntegerKIKey63 description");
+ private static final AxKeyInfo intKI64 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey64", "0.0.4"),
+ UUID.randomUUID(), "IntegerKIKey64 description");
+ private static final AxKeyInfo intKI71 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey71", "0.0.1"),
+ UUID.randomUUID(), "IntegerKIKey71 description");
+ private static final AxKeyInfo intKI81 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey81", "0.0.1"),
+ UUID.randomUUID(), "IntegerKIKey81 description");
+ private static final AxKeyInfo intKI91 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey91", "0.0.1"),
+ UUID.randomUUID(), "IntegerKIKey91 description");
+ private static final AxKeyInfo floatKI01 = new AxKeyInfo(new AxArtifactKey("FloatKIKey01", "0.0.1"),
+ UUID.randomUUID(), "IntegerKIKey01 description");
+ private static final AxKeyInfo floatKI11 = new AxKeyInfo(new AxArtifactKey("FloatKIKey11", "0.0.1"),
+ UUID.randomUUID(), "IntegerKIKey11 description");
+ private static final AxKeyInfo floatKI21 = new AxKeyInfo(new AxArtifactKey("FloatKIKey21", "0.0.1"),
+ UUID.randomUUID(), "IntegerKIKey21 description");
+ private static final AxKeyInfo floatKI31 = new AxKeyInfo(new AxArtifactKey("FloatKIKey31", "0.0.1"),
+ UUID.randomUUID(), "IntegerKIKey31 description");
+ private static final AxKeyInfo floatKI41 = new AxKeyInfo(new AxArtifactKey("FloatKIKey41", "0.0.1"),
+ UUID.randomUUID(), "IntegerKIKey41 description");
+ private static final AxKeyInfo floatKI51 = new AxKeyInfo(new AxArtifactKey("FloatKIKey51", "0.0.1"),
+ UUID.randomUUID(), "IntegerKIKey51 description");
+ private static final AxKeyInfo floatKI61 = new AxKeyInfo(new AxArtifactKey("FloatKIKey61", "0.0.1"),
+ UUID.randomUUID(), "IntegerKIKey61 description");
+ private static final AxKeyInfo floatKI71 = new AxKeyInfo(new AxArtifactKey("FloatKIKey71", "0.0.1"),
+ UUID.randomUUID(), "IntegerKIKey71 description");
+ private static final AxKeyInfo floatKI81 = new AxKeyInfo(new AxArtifactKey("FloatKIKey81", "0.0.1"),
+ UUID.randomUUID(), "IntegerKIKey81 description");
+ private static final AxKeyInfo floatKI82 = new AxKeyInfo(new AxArtifactKey("FloatKIKey82", "0.0.2"),
+ UUID.randomUUID(), "IntegerKIKey82 description");
+ private static final AxKeyInfo floatKI83 = new AxKeyInfo(new AxArtifactKey("FloatKIKey83", "0.0.3"),
+ UUID.randomUUID(), "IntegerKIKey83 description");
+ private static final AxKeyInfo floatKI91 = new AxKeyInfo(new AxArtifactKey("FloatKIKey91", "0.0.1"),
+ UUID.randomUUID(), "IntegerKIKey91 description");
+ private static final AxKeyInfo floatKI92 = new AxKeyInfo(new AxArtifactKey("FloatKIKey92", "0.0.2"),
+ UUID.randomUUID(), "IntegerKIKey92 description");
+ private static final AxKeyInfo floatKI93 = new AxKeyInfo(new AxArtifactKey("FloatKIKey93", "0.0.3"),
+ UUID.randomUUID(), "IntegerKIKey93 description");
- AxKeyInfo floatKI01 = new AxKeyInfo(new AxArtifactKey("FloatKIKey01", "0.0.1"), UUID.randomUUID(),
- "IntegerKIKey01 description");
- AxKeyInfo floatKI11 = new AxKeyInfo(new AxArtifactKey("FloatKIKey11", "0.0.1"), UUID.randomUUID(),
- "IntegerKIKey11 description");
- AxKeyInfo floatKI21 = new AxKeyInfo(new AxArtifactKey("FloatKIKey21", "0.0.1"), UUID.randomUUID(),
- "IntegerKIKey21 description");
- AxKeyInfo floatKI31 = new AxKeyInfo(new AxArtifactKey("FloatKIKey31", "0.0.1"), UUID.randomUUID(),
- "IntegerKIKey31 description");
- AxKeyInfo floatKI41 = new AxKeyInfo(new AxArtifactKey("FloatKIKey41", "0.0.1"), UUID.randomUUID(),
- "IntegerKIKey41 description");
- AxKeyInfo floatKI51 = new AxKeyInfo(new AxArtifactKey("FloatKIKey51", "0.0.1"), UUID.randomUUID(),
- "IntegerKIKey51 description");
- AxKeyInfo floatKI61 = new AxKeyInfo(new AxArtifactKey("FloatKIKey61", "0.0.1"), UUID.randomUUID(),
- "IntegerKIKey61 description");
- AxKeyInfo floatKI71 = new AxKeyInfo(new AxArtifactKey("FloatKIKey71", "0.0.1"), UUID.randomUUID(),
- "IntegerKIKey71 description");
- AxKeyInfo floatKI81 = new AxKeyInfo(new AxArtifactKey("FloatKIKey81", "0.0.1"), UUID.randomUUID(),
- "IntegerKIKey81 description");
- AxKeyInfo floatKI82 = new AxKeyInfo(new AxArtifactKey("FloatKIKey82", "0.0.2"), UUID.randomUUID(),
- "IntegerKIKey82 description");
- AxKeyInfo floatKI83 = new AxKeyInfo(new AxArtifactKey("FloatKIKey83", "0.0.3"), UUID.randomUUID(),
- "IntegerKIKey83 description");
- AxKeyInfo floatKI91 = new AxKeyInfo(new AxArtifactKey("FloatKIKey91", "0.0.1"), UUID.randomUUID(),
- "IntegerKIKey91 description");
- AxKeyInfo floatKI92 = new AxKeyInfo(new AxArtifactKey("FloatKIKey92", "0.0.2"), UUID.randomUUID(),
- "IntegerKIKey92 description");
- AxKeyInfo floatKI93 = new AxKeyInfo(new AxArtifactKey("FloatKIKey93", "0.0.3"), UUID.randomUUID(),
- "IntegerKIKey93 description");
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI11.getKey(), floatKI11);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI83.getKey(), floatKI83);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI51.getKey(), floatKI51);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI71.getKey(), floatKI71);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI21.getKey(), floatKI21);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI81.getKey(), floatKI81);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI92.getKey(), floatKI92);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI91.getKey(), floatKI91);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI01.getKey(), floatKI01);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI82.getKey(), floatKI82);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI61.getKey(), floatKI61);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI41.getKey(), floatKI41);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI31.getKey(), floatKI31);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI93.getKey(), floatKI93);
+ @Test
+ public void testConceptGetterInteger() {
+ AxModel basicModel = setTestBasicModel();
assertNull(basicModel.getKeyInformation().get("NonExistantKey", "0.0.6"));
assertEquals(intKI26, basicModel.getKeyInformation().get("IntegerKIKey26", "0.0.6"));
@@ -167,6 +130,11 @@ public class SupportConceptGetterTester {
assertEquals(intKI71, basicModel.getKeyInformation().get("IntegerKIKey71"));
assertEquals(intKI81, basicModel.getKeyInformation().get("IntegerKIKey81"));
assertEquals(intKI91, basicModel.getKeyInformation().get("IntegerKIKey91"));
+ }
+
+ @Test
+ public void testConceptGetterFloat() {
+ AxModel basicModel = setTestBasicModel();
assertEquals(floatKI01, basicModel.getKeyInformation().get("FloatKIKey01"));
assertEquals(floatKI11, basicModel.getKeyInformation().get("FloatKIKey11"));
@@ -178,6 +146,11 @@ public class SupportConceptGetterTester {
assertEquals(floatKI71, basicModel.getKeyInformation().get("FloatKIKey71"));
assertEquals(floatKI83, basicModel.getKeyInformation().get("FloatKIKey83"));
assertEquals(floatKI93, basicModel.getKeyInformation().get("FloatKIKey93"));
+ }
+
+ @Test
+ public void testMarshalling() throws IOException, ApexException {
+ AxModel basicModel = setTestBasicModel();
// Ensure marshalling and unmarshalling is OK
ApexModelReader<AxModel> modelReader = new ApexModelReader<AxModel>(AxModel.class);
@@ -197,4 +170,48 @@ public class SupportConceptGetterTester {
assertNotNull(readXmlModel.getKeyInformation().get("FloatKIKey"));
tempXmlFile.delete();
}
+
+ private AxModel setTestBasicModel() {
+ AxModel basicModel = new DummyApexBasicModelCreator().getModel();
+ assertNotNull(basicModel);
+
+ basicModel.getKeyInformation().getKeyInfoMap().put(intKI31.getKey(), intKI31);
+ basicModel.getKeyInformation().getKeyInfoMap().put(intKI24.getKey(), intKI24);
+ basicModel.getKeyInformation().getKeyInfoMap().put(intKI11.getKey(), intKI11);
+ basicModel.getKeyInformation().getKeyInfoMap().put(intKI64.getKey(), intKI64);
+ basicModel.getKeyInformation().getKeyInfoMap().put(intKI41.getKey(), intKI41);
+ basicModel.getKeyInformation().getKeyInfoMap().put(intKI51.getKey(), intKI51);
+ basicModel.getKeyInformation().getKeyInfoMap().put(intKI23.getKey(), intKI23);
+ basicModel.getKeyInformation().getKeyInfoMap().put(intKI81.getKey(), intKI81);
+ basicModel.getKeyInformation().getKeyInfoMap().put(intKI71.getKey(), intKI71);
+ basicModel.getKeyInformation().getKeyInfoMap().put(intKI01.getKey(), intKI01);
+ basicModel.getKeyInformation().getKeyInfoMap().put(intKI91.getKey(), intKI91);
+ basicModel.getKeyInformation().getKeyInfoMap().put(intKI52.getKey(), intKI52);
+ basicModel.getKeyInformation().getKeyInfoMap().put(intKI53.getKey(), intKI53);
+ basicModel.getKeyInformation().getKeyInfoMap().put(intKI62.getKey(), intKI62);
+ basicModel.getKeyInformation().getKeyInfoMap().put(intKI54.getKey(), intKI54);
+ basicModel.getKeyInformation().getKeyInfoMap().put(intKI26.getKey(), intKI26);
+ basicModel.getKeyInformation().getKeyInfoMap().put(intKI22.getKey(), intKI22);
+ basicModel.getKeyInformation().getKeyInfoMap().put(intKI25.getKey(), intKI25);
+ basicModel.getKeyInformation().getKeyInfoMap().put(intKI21.getKey(), intKI21);
+ basicModel.getKeyInformation().getKeyInfoMap().put(intKI61.getKey(), intKI61);
+ basicModel.getKeyInformation().getKeyInfoMap().put(intKI63.getKey(), intKI63);
+
+ basicModel.getKeyInformation().getKeyInfoMap().put(floatKI11.getKey(), floatKI11);
+ basicModel.getKeyInformation().getKeyInfoMap().put(floatKI83.getKey(), floatKI83);
+ basicModel.getKeyInformation().getKeyInfoMap().put(floatKI51.getKey(), floatKI51);
+ basicModel.getKeyInformation().getKeyInfoMap().put(floatKI71.getKey(), floatKI71);
+ basicModel.getKeyInformation().getKeyInfoMap().put(floatKI21.getKey(), floatKI21);
+ basicModel.getKeyInformation().getKeyInfoMap().put(floatKI81.getKey(), floatKI81);
+ basicModel.getKeyInformation().getKeyInfoMap().put(floatKI92.getKey(), floatKI92);
+ basicModel.getKeyInformation().getKeyInfoMap().put(floatKI91.getKey(), floatKI91);
+ basicModel.getKeyInformation().getKeyInfoMap().put(floatKI01.getKey(), floatKI01);
+ basicModel.getKeyInformation().getKeyInfoMap().put(floatKI82.getKey(), floatKI82);
+ basicModel.getKeyInformation().getKeyInfoMap().put(floatKI61.getKey(), floatKI61);
+ basicModel.getKeyInformation().getKeyInfoMap().put(floatKI41.getKey(), floatKI41);
+ basicModel.getKeyInformation().getKeyInfoMap().put(floatKI31.getKey(), floatKI31);
+ basicModel.getKeyInformation().getKeyInfoMap().put(floatKI93.getKey(), floatKI93);
+
+ return basicModel;
+ }
}