diff options
82 files changed, 852 insertions, 5021 deletions
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java b/models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java index f5baae7fe..5e3295ec7 100644 --- a/models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java +++ b/models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java @@ -21,19 +21,12 @@ package org.onap.policy.models.base; -import java.util.ArrayList; -import java.util.List; - import javax.persistence.Column; import javax.persistence.Embeddable; - import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; -import lombok.ToString; - import org.onap.policy.common.utils.validation.Assertions; -import org.onap.policy.models.base.PfValidationResult.ValidationResult; /** * An concept key uniquely identifies every first order entity in the system. Every first order concept in the system @@ -45,14 +38,10 @@ import org.onap.policy.models.base.PfValidationResult.ValidationResult; */ @Embeddable @Getter -@ToString @EqualsAndHashCode(callSuper = false) -public class PfConceptKey extends PfKey { +public class PfConceptKey extends PfKeyImpl { private static final long serialVersionUID = 8932717618579392561L; - private static final String NAME_TOKEN = "name"; - private static final String VERSION_TOKEN = "version"; - @Column(name = NAME_TOKEN, length = 120) private String name; @@ -71,10 +60,8 @@ public class PfConceptKey extends PfKey { * * @param copyConcept the concept to copy from */ - public PfConceptKey(@NonNull final PfConceptKey copyConcept) { + public PfConceptKey(final PfConceptKey copyConcept) { super(copyConcept); - this.name = copyConcept.name; - this.version = copyConcept.version; } /** @@ -83,10 +70,8 @@ public class PfConceptKey extends PfKey { * @param name the key name * @param version the key version */ - public PfConceptKey(@NonNull final String name, @NonNull final String version) { - super(); - this.name = Assertions.validateStringParameter(NAME_TOKEN, name, NAME_REGEXP); - this.version = Assertions.validateStringParameter(VERSION_TOKEN, version, VERSION_REGEXP); + public PfConceptKey(final String name, final String version) { + super(name, version); } /** @@ -94,218 +79,29 @@ public class PfConceptKey extends PfKey { * * @param id the key ID in a format that respects the KEY_ID_REGEXP */ - public PfConceptKey(@NonNull final String id) { - // Check the incoming ID is valid - Assertions.validateStringParameter("id", id, KEY_ID_REGEXP); - - // Split on colon, if the id passes the regular expression test above - // it'll have just one colon separating the name and version - // No need for range checks or size checks on the array - final String[] nameVersionArray = id.split(":"); - - // Return the new key - name = Assertions.validateStringParameter(NAME_TOKEN, nameVersionArray[0], NAME_REGEXP); - version = Assertions.validateStringParameter(VERSION_TOKEN, nameVersionArray[1], VERSION_REGEXP); - } - - /** - * Get a null concept key. - * - * @return a null concept key - */ - public static final PfConceptKey getNullKey() { - return new PfConceptKey(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_VERSION); - } - - @Override - public PfConceptKey getKey() { - return this; + public PfConceptKey(final String id) { + super(id); } public void setName(@NonNull final String name) { - this.name = Assertions.validateStringParameter(NAME_TOKEN, name, NAME_REGEXP); + this.name = Assertions.validateStringParameter(NAME_TOKEN, name, getNameRegEx()); } public void setVersion(@NonNull final String version) { - this.version = Assertions.validateStringParameter(VERSION_TOKEN, version, VERSION_REGEXP); - } - - @Override - public List<PfKey> getKeys() { - final List<PfKey> keyList = new ArrayList<>(); - keyList.add(getKey()); - return keyList; - } - - @Override - public String getId() { - return name + ':' + version; - } - - @Override - public boolean isNullKey() { - return this.equals(PfConceptKey.getNullKey()); + this.version = Assertions.validateStringParameter(VERSION_TOKEN, version, getVersionRegEx()); } /** - * Determines if the version is "null". + * Get a null concept key. * - * @return {@code true} if the version is null, {@code false} otherwise + * @return a null concept key */ - public boolean isNullVersion() { - return PfKey.NULL_KEY_VERSION.equals(getVersion()); - } - - @Override - public PfKey.Compatibility getCompatibility(@NonNull final PfKey otherKey) { - if (!(otherKey instanceof PfConceptKey)) { - return Compatibility.DIFFERENT; - } - final PfConceptKey otherConceptKey = (PfConceptKey) otherKey; - - if (this.equals(otherConceptKey)) { - return Compatibility.IDENTICAL; - } - if (!this.getName().equals(otherConceptKey.getName())) { - return Compatibility.DIFFERENT; - } - - final String[] thisVersionArray = getVersion().split("\\."); - final String[] otherVersionArray = otherConceptKey.getVersion().split("\\."); - - // There must always be at least one element in each version - if (!thisVersionArray[0].equals(otherVersionArray[0])) { - return Compatibility.MAJOR; - } - - if (thisVersionArray.length >= 2 && otherVersionArray.length >= 2 - && !thisVersionArray[1].equals(otherVersionArray[1])) { - return Compatibility.MINOR; - } - - return Compatibility.PATCH; - } - - @Override - public boolean isCompatible(@NonNull final PfKey otherKey) { - if (!(otherKey instanceof PfConceptKey)) { - return false; - } - final PfConceptKey otherConceptKey = (PfConceptKey) otherKey; - - final Compatibility compatibility = this.getCompatibility(otherConceptKey); - - return !(compatibility == Compatibility.DIFFERENT || compatibility == Compatibility.MAJOR); - } - - @Override - public boolean isNewerThan(@NonNull final PfKey otherKey) { - Assertions.instanceOf(otherKey, PfConceptKey.class); - - final PfConceptKey otherConceptKey = (PfConceptKey) otherKey; - - if (this.equals(otherConceptKey)) { - return false; - } - - if (!this.getName().equals(otherConceptKey.getName())) { - return this.getName().compareTo(otherConceptKey.getName()) > 0; - } - - final String[] thisVersionArray = getVersion().split("\\."); - final String[] otherVersionArray = otherConceptKey.getVersion().split("\\."); - - // There must always be at least one element in each version - if (!thisVersionArray[0].equals(otherVersionArray[0])) { - return Integer.valueOf(thisVersionArray[0]) > Integer.valueOf(otherVersionArray[0]); - } - - if (thisVersionArray.length >= 2 && otherVersionArray.length >= 2 - && !thisVersionArray[1].equals(otherVersionArray[1])) { - return Integer.valueOf(thisVersionArray[1]) > Integer.valueOf(otherVersionArray[1]); - } - - if (thisVersionArray.length >= 3 && otherVersionArray.length >= 3 - && !thisVersionArray[2].equals(otherVersionArray[2])) { - return Integer.valueOf(thisVersionArray[2]) > Integer.valueOf(otherVersionArray[2]); - } - - return false; - } - - @Override - public int getMajorVersion() { - final String[] versionArray = getVersion().split("\\."); - - // There must always be at least one element in each version - return Integer.parseInt(versionArray[0]); - } - - @Override - public int getMinorVersion() { - final String[] versionArray = getVersion().split("\\."); - - if (versionArray.length >= 2) { - return Integer.parseInt(versionArray[1]); - } - else { - return 0; - } - } - - @Override - public int getPatchVersion() { - final String[] versionArray = getVersion().split("\\."); - - if (versionArray.length >= 3) { - return Integer.parseInt(versionArray[2]); - } - else { - return 0; - } - } - - @Override - public PfValidationResult validate(final PfValidationResult result) { - final String nameValidationErrorMessage = Assertions.getStringParameterValidationMessage(NAME_TOKEN, name, - NAME_REGEXP); - if (nameValidationErrorMessage != null) { - result.addValidationMessage(new PfValidationMessage(this, this.getClass(), ValidationResult.INVALID, - "name invalid-" + nameValidationErrorMessage)); - } - - final String versionValidationErrorMessage = Assertions.getStringParameterValidationMessage(VERSION_TOKEN, - version, VERSION_REGEXP); - if (versionValidationErrorMessage != null) { - result.addValidationMessage(new PfValidationMessage(this, this.getClass(), ValidationResult.INVALID, - "version invalid-" + versionValidationErrorMessage)); - } - - return result; - } - - @Override - public void clean() { - name = Assertions.validateStringParameter(NAME_TOKEN, name, NAME_REGEXP); - version = Assertions.validateStringParameter(VERSION_TOKEN, version, VERSION_REGEXP); + public static final PfConceptKey getNullKey() { + return new PfConceptKey(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_VERSION); } @Override - public int compareTo(@NonNull final PfConcept otherObj) { - Assertions.argumentNotNull(otherObj, "comparison object may not be null"); - - if (this == otherObj) { - return 0; - } - if (getClass() != otherObj.getClass()) { - return getClass().getName().compareTo(otherObj.getClass().getName()); - } - - final PfConceptKey other = (PfConceptKey) otherObj; - - if (!name.equals(other.name)) { - return name.compareTo(other.name); - } - return version.compareTo(other.version); + public String toString() { + return "PfConceptKey(name=" + getName() + ", version=" + getVersion() + ")"; } } diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfKeyImpl.java b/models-base/src/main/java/org/onap/policy/models/base/PfKeyImpl.java new file mode 100644 index 000000000..461fd2495 --- /dev/null +++ b/models-base/src/main/java/org/onap/policy/models/base/PfKeyImpl.java @@ -0,0 +1,306 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. 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.models.base; + +import java.util.ArrayList; +import java.util.List; +import lombok.Getter; +import lombok.NonNull; +import lombok.ToString; +import org.onap.policy.common.utils.validation.Assertions; +import org.onap.policy.models.base.PfValidationResult.ValidationResult; + +/** + * A key, upon which other key subclasses can be built, providing implementations of the methods. + */ +@Getter +@ToString +public abstract class PfKeyImpl extends PfKey { + private static final long serialVersionUID = 8932717618579392561L; + + public static final String NAME_TOKEN = "name"; + public static final String VERSION_TOKEN = "version"; + + /** + * The default constructor creates a null concept key. + */ + public PfKeyImpl() { + this(NULL_KEY_NAME, NULL_KEY_VERSION); + } + + /** + * Copy constructor. + * + * @param copyConcept the concept to copy from + */ + public PfKeyImpl(final PfKeyImpl copyConcept) { + super(copyConcept); + setName(copyConcept.getName()); + setVersion(copyConcept.getVersion()); + } + + /** + * Constructor to create a key with the specified name and version. + * + * @param name the key name + * @param version the key version + */ + public PfKeyImpl(@NonNull final String name, @NonNull final String version) { + super(); + setName(name); + setVersion(version); + } + + /** + * Constructor to create a key using the key and version from the specified key ID. + * + * @param id the key ID in a format that respects the KEY_ID_REGEXP + */ + public PfKeyImpl(@NonNull final String id) { + // Check the incoming ID is valid + Assertions.validateStringParameter("id", id, getKeyIdRegEx()); + + // Split on colon, if the id passes the regular expression test above + // it'll have just one colon separating the name and version + // No need for range checks or size checks on the array + final String[] nameVersionArray = id.split(":"); + + // Return the new key + setName(nameVersionArray[0]); + setVersion(nameVersionArray[1]); + } + + public abstract void setName(@NonNull final String name); + + public abstract void setVersion(@NonNull final String version); + + @Override + public PfKeyImpl getKey() { + return this; + } + + @Override + public List<PfKey> getKeys() { + final List<PfKey> keyList = new ArrayList<>(); + keyList.add(getKey()); + return keyList; + } + + @Override + public String getId() { + return getName() + ':' + getVersion(); + } + + @Override + public boolean isNullKey() { + return (PfKey.NULL_KEY_NAME.equals(getName()) && PfKey.NULL_KEY_VERSION.equals(getVersion())); + } + + /** + * Determines if the version is "null". + * + * @return {@code true} if the version is null, {@code false} otherwise + */ + public boolean isNullVersion() { + return PfKey.NULL_KEY_VERSION.equals(getVersion()); + } + + @Override + public PfKey.Compatibility getCompatibility(@NonNull final PfKey otherKey) { + if (!(otherKey instanceof PfKeyImpl)) { + return Compatibility.DIFFERENT; + } + final PfKeyImpl otherConceptKey = (PfKeyImpl) otherKey; + + if (this.equals(otherConceptKey)) { + return Compatibility.IDENTICAL; + } + if (!this.getName().equals(otherConceptKey.getName())) { + return Compatibility.DIFFERENT; + } + + final String[] thisVersionArray = getVersion().split("\\."); + final String[] otherVersionArray = otherConceptKey.getVersion().split("\\."); + + // There must always be at least one element in each version + if (!thisVersionArray[0].equals(otherVersionArray[0])) { + return Compatibility.MAJOR; + } + + if (thisVersionArray.length >= 2 && otherVersionArray.length >= 2 + && !thisVersionArray[1].equals(otherVersionArray[1])) { + return Compatibility.MINOR; + } + + return Compatibility.PATCH; + } + + @Override + public boolean isCompatible(@NonNull final PfKey otherKey) { + if (!(otherKey instanceof PfKeyImpl)) { + return false; + } + final PfKeyImpl otherConceptKey = (PfKeyImpl) otherKey; + + final Compatibility compatibility = this.getCompatibility(otherConceptKey); + + return !(compatibility == Compatibility.DIFFERENT || compatibility == Compatibility.MAJOR); + } + + @Override + public boolean isNewerThan(@NonNull final PfKey otherKey) { + Assertions.instanceOf(otherKey, PfKeyImpl.class); + + final PfKeyImpl otherConceptKey = (PfKeyImpl) otherKey; + + if (this.equals(otherConceptKey)) { + return false; + } + + if (!this.getName().equals(otherConceptKey.getName())) { + return this.getName().compareTo(otherConceptKey.getName()) > 0; + } + + final String[] thisVersionArray = getVersion().split("\\."); + final String[] otherVersionArray = otherConceptKey.getVersion().split("\\."); + + // There must always be at least one element in each version + if (!thisVersionArray[0].equals(otherVersionArray[0])) { + return Integer.valueOf(thisVersionArray[0]) > Integer.valueOf(otherVersionArray[0]); + } + + if (thisVersionArray.length >= 2 && otherVersionArray.length >= 2 + && !thisVersionArray[1].equals(otherVersionArray[1])) { + return Integer.valueOf(thisVersionArray[1]) > Integer.valueOf(otherVersionArray[1]); + } + + if (thisVersionArray.length >= 3 && otherVersionArray.length >= 3 + && !thisVersionArray[2].equals(otherVersionArray[2])) { + return Integer.valueOf(thisVersionArray[2]) > Integer.valueOf(otherVersionArray[2]); + } + + return false; + } + + @Override + public int getMajorVersion() { + final String[] versionArray = getVersion().split("\\."); + + // There must always be at least one element in each version + return Integer.parseInt(versionArray[0]); + } + + @Override + public int getMinorVersion() { + final String[] versionArray = getVersion().split("\\."); + + if (versionArray.length >= 2) { + return Integer.parseInt(versionArray[1]); + } + else { + return 0; + } + } + + @Override + public int getPatchVersion() { + final String[] versionArray = getVersion().split("\\."); + + if (versionArray.length >= 3) { + return Integer.parseInt(versionArray[2]); + } + else { + return 0; + } + } + + @Override + public PfValidationResult validate(final PfValidationResult result) { + final String nameValidationErrorMessage = Assertions.getStringParameterValidationMessage(NAME_TOKEN, getName(), + getNameRegEx()); + if (nameValidationErrorMessage != null) { + result.addValidationMessage(new PfValidationMessage(this, this.getClass(), ValidationResult.INVALID, + "name invalid-" + nameValidationErrorMessage)); + } + + final String versionValidationErrorMessage = Assertions.getStringParameterValidationMessage(VERSION_TOKEN, + getVersion(), getVersionRegEx()); + if (versionValidationErrorMessage != null) { + result.addValidationMessage(new PfValidationMessage(this, this.getClass(), ValidationResult.INVALID, + "version invalid-" + versionValidationErrorMessage)); + } + + return result; + } + + @Override + public void clean() { + setName(getName()); + setVersion(getVersion()); + } + + @Override + public int compareTo(@NonNull final PfConcept otherObj) { + Assertions.argumentNotNull(otherObj, "comparison object may not be null"); + + if (this == otherObj) { + return 0; + } + if (getClass() != otherObj.getClass()) { + return getClass().getName().compareTo(otherObj.getClass().getName()); + } + + final PfKeyImpl other = (PfKeyImpl) otherObj; + + if (!getName().equals(other.getName())) { + return getName().compareTo(other.getName()); + } + return getVersion().compareTo(other.getVersion()); + } + + /** + * Gets the regular expression used to validate a name. + * + * @return the regular expression used to validate a name + */ + protected String getNameRegEx() { + return NAME_REGEXP; + } + + /** + * Gets the regular expression used to validate a version. + * + * @return the regular expression used to validate a version + */ + protected String getVersionRegEx() { + return VERSION_REGEXP; + } + + /** + * Gets the regular expression used to validate a key id. + * + * @return the regular expression used to validate a key id + */ + protected String getKeyIdRegEx() { + return KEY_ID_REGEXP; + } +} diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfSearchableKey.java b/models-base/src/main/java/org/onap/policy/models/base/PfSearchableKey.java new file mode 100644 index 000000000..bed1a3598 --- /dev/null +++ b/models-base/src/main/java/org/onap/policy/models/base/PfSearchableKey.java @@ -0,0 +1,111 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. 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.models.base; + +import javax.persistence.Column; +import javax.persistence.Embeddable; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NonNull; +import org.onap.policy.common.utils.validation.Assertions; + +/** + * A key that is used to search for other concept keys. The name field may contain a + * trailing ".*", to indicate wild-card matching. + */ +@Embeddable +@Getter +@EqualsAndHashCode(callSuper = false) +public class PfSearchableKey extends PfKeyImpl { + private static final long serialVersionUID = 8932717618579392561L; + + /** Regular expression to specify the structure of key names. */ + public static final String WILDCARD_NAME_REGEXP = "^[A-Za-z0-9\\-_\\.]+(?:\\.\\*)?$"; + + @Column(name = NAME_TOKEN, length = 120) + private String name; + + @Column(name = VERSION_TOKEN, length = 20) + private String version; + + /** + * The default constructor creates a null key. + */ + public PfSearchableKey() { + this(NULL_KEY_NAME, NULL_KEY_VERSION); + } + + /** + * Copy constructor. + * + * @param copyKey the key to copy from + */ + public PfSearchableKey(final PfSearchableKey copyKey) { + super(copyKey); + } + + /** + * Constructor to create a key with the specified name and version. + * + * @param name the key name + * @param version the key version + */ + public PfSearchableKey(final String name, final String version) { + super(name, version); + } + + /** + * Constructor to create a key using the key and version from the specified key ID. + * + * @param id the key ID in a format that respects the KEY_ID_REGEXP + */ + public PfSearchableKey(final String id) { + super(id); + } + + public void setName(@NonNull final String name) { + this.name = Assertions.validateStringParameter(NAME_TOKEN, name, getNameRegEx()); + } + + public void setVersion(@NonNull final String version) { + this.version = Assertions.validateStringParameter(VERSION_TOKEN, version, getVersionRegEx()); + } + + /** + * Get a null key. + * + * @return a null key + */ + public static final PfSearchableKey getNullKey() { + return new PfSearchableKey(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_VERSION); + } + + @Override + protected String getNameRegEx() { + return WILDCARD_NAME_REGEXP; + } + + @Override + public String toString() { + return "PfSearchableKey(name=" + getName() + ", version=" + getVersion() + ")"; + } +} diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfConceptKeyTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfConceptKeyTest.java new file mode 100644 index 000000000..a29858393 --- /dev/null +++ b/models-base/src/test/java/org/onap/policy/models/base/PfConceptKeyTest.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * Modifications Copyright (C) 2019 AT&T Intellectual Property. 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.models.base; + +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.policy.models.base.testconcepts.DummyPfConcept; + +public class PfConceptKeyTest { + + private static final String VERSION001 = "0.0.1"; + private static final String ID_IS_NULL = "id is marked @NonNull but is null"; + + @Test + public void testConceptKey() { + PfConceptKey someKey0 = new PfConceptKey(); + assertEquals(PfConceptKey.getNullKey(), someKey0); + assertTrue(someKey0.isNullKey()); + assertEquals("PfConceptKey(name=NULL, version=0.0.0)", someKey0.toString()); + + PfConceptKey someKey1 = new PfConceptKey("my-name", VERSION001); + PfConceptKey someKey2 = new PfConceptKey(someKey1); + PfConceptKey someKey3 = new PfConceptKey(someKey1.getId()); + assertEquals(someKey1, someKey2); + assertEquals(someKey1, someKey3); + assertFalse(someKey1.isNullVersion()); + assertEquals("PfConceptKey(name=my-name, version=0.0.1)", someKey1.toString()); + + assertEquals("my-name", someKey1.getName()); + assertEquals(VERSION001, someKey1.getVersion()); + + assertEquals(someKey2, someKey1.getKey()); + assertEquals(1, someKey1.getKeys().size()); + + + PfConcept pfc = new DummyPfConcept(); + assertEquals(PfConceptKey.getNullKey().getId(), pfc.getId()); + + assertTrue(PfConceptKey.getNullKey().matchesId(pfc.getId())); + + assertTrue(PfConceptKey.getNullKey().isNullKey()); + + assertThatThrownBy(() -> PfConceptKey.getNullKey().matchesId(null)).hasMessage(ID_IS_NULL); + + assertThatThrownBy(() -> someKey0.setName(null)).isInstanceOf(NullPointerException.class) + .hasMessage("name is marked @NonNull but is null"); + + assertThatThrownBy(() -> someKey0.setVersion(null)).isInstanceOf(NullPointerException.class) + .hasMessage("version is marked @NonNull but is null"); + + assertThatIllegalArgumentException().isThrownBy(() -> new PfConceptKey("my-name.*", VERSION001)).withMessage( + "parameter 'name': value 'my-name.*', does not match regular expression '^[A-Za-z0-9\\-_\\.]+$'" + .replace('\'', '"')); + } +} diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfKeyTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfKeyImplTest.java index fca73b0d6..f467ec35a 100644 --- a/models-base/src/test/java/org/onap/policy/models/base/PfKeyTest.java +++ b/models-base/src/test/java/org/onap/policy/models/base/PfKeyImplTest.java @@ -29,12 +29,15 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.lang.reflect.Field; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; import org.junit.Test; import org.onap.policy.models.base.PfKey.Compatibility; -import org.onap.policy.models.base.testconcepts.DummyPfConcept; import org.onap.policy.models.base.testconcepts.DummyPfKey; -public class PfKeyTest { +public class PfKeyImplTest { private static final String OTHER_IS_NULL = "otherKey is marked @NonNull but is null"; private static final String ID_IS_NULL = "id is marked @NonNull but is null"; @@ -44,21 +47,23 @@ public class PfKeyTest { @Test public void testConceptKey() { - assertThatIllegalArgumentException().isThrownBy(() -> new PfConceptKey("some bad key id")) + assertThatIllegalArgumentException().isThrownBy(() -> new MyKey("some bad key id")) .withMessage("parameter \"id\": value \"some bad key id\", " + "does not match regular expression \"" + PfKey.KEY_ID_REGEXP + "\""); - assertThatThrownBy(() -> new PfConceptKey((PfConceptKey) null)) + assertThatThrownBy(() -> new MyKey((MyKey) null)) .hasMessage("copyConcept is marked @NonNull but is null"); - PfConceptKey someKey0 = new PfConceptKey(); - assertEquals(PfConceptKey.getNullKey(), someKey0); + MyKey someKey0 = new MyKey(); + assertTrue(someKey0.isNullKey()); + assertEquals(new MyKey(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_VERSION), someKey0); - PfConceptKey someKey1 = new PfConceptKey("name", VERSION001); - PfConceptKey someKey2 = new PfConceptKey(someKey1); - PfConceptKey someKey3 = new PfConceptKey(someKey1.getId()); + MyKey someKey1 = new MyKey("name", VERSION001); + MyKey someKey2 = new MyKey(someKey1); + MyKey someKey3 = new MyKey(someKey1.getId()); assertEquals(someKey1, someKey2); assertEquals(someKey1, someKey3); + assertFalse(someKey1.isNullKey()); assertFalse(someKey1.isNullVersion()); assertEquals(someKey2, someKey1.getKey()); @@ -69,28 +74,22 @@ public class PfKeyTest { someKey3.setVersion("0.0.2"); - PfConceptKey someKey4 = new PfConceptKey(someKey1); + MyKey someKey4 = new MyKey(someKey1); someKey4.setVersion("0.1.2"); - PfConceptKey someKey4a = new PfConceptKey(someKey1); + MyKey someKey4a = new MyKey(someKey1); someKey4a.setVersion("0.0.0"); - PfConceptKey someKey5 = new PfConceptKey(someKey1); + MyKey someKey5 = new MyKey(someKey1); someKey5.setVersion("1.2.2"); - PfConceptKey someKey6 = new PfConceptKey(someKey1); + MyKey someKey6 = new MyKey(someKey1); someKey6.setVersion("3.0.0"); assertEquals("name:0.1.2", someKey4.getId()); - PfConcept pfc = new DummyPfConcept(); - assertEquals(PfConceptKey.getNullKey().getId(), pfc.getId()); - - assertTrue(PfConceptKey.getNullKey().matchesId(pfc.getId())); - - assertTrue(PfConceptKey.getNullKey().isNullKey()); - - assertThatThrownBy(() -> PfConceptKey.getNullKey().matchesId(null)).hasMessage(ID_IS_NULL); + assertThatThrownBy(() -> someKey0.getCompatibility(null)).isInstanceOf(NullPointerException.class) + .hasMessage("otherKey is marked @NonNull but is null"); assertEquals(Compatibility.DIFFERENT, someKey0.getCompatibility(new DummyPfKey())); assertEquals(Compatibility.DIFFERENT, someKey0.getCompatibility(someKey1)); @@ -127,7 +126,7 @@ public class PfKeyTest { someKey0.clean(); assertNotNull(someKey0.toString()); - PfConceptKey someKey7 = new PfConceptKey(someKey1); + MyKey someKey7 = new MyKey(someKey1); assertEquals(244799191, someKey7.hashCode()); assertEquals(0, someKey7.compareTo(someKey1)); assertEquals(-12, someKey7.compareTo(someKey0)); @@ -141,27 +140,31 @@ public class PfKeyTest { assertFalse(someKey0.equals(null)); assertTrue(someKey0.equals(someKey0)); assertFalse(someKey0.equals(new DummyPfKey())); + + MyKey someKey8 = new MyKey(); + someKey8.setVersion(VERSION001); + assertFalse(someKey8.isNullKey()); } @Test public void testNullArguments() { - assertThatThrownBy(() -> new PfConceptKey((String) null)).hasMessage(ID_IS_NULL); + assertThatThrownBy(() -> new MyKey((String) null)).hasMessage(ID_IS_NULL); - assertThatThrownBy(() -> new PfConceptKey((PfConceptKey) null)) + assertThatThrownBy(() -> new MyKey((MyKey) null)) .hasMessage("copyConcept is marked @NonNull but is null"); - assertThatThrownBy(() -> new PfConceptKey(null, null)).hasMessage("name is marked @NonNull but is null"); + assertThatThrownBy(() -> new MyKey(null, null)).hasMessage("name is marked @NonNull but is null"); - assertThatThrownBy(() -> new PfConceptKey("name", null)).hasMessage("version is marked @NonNull but is null"); + assertThatThrownBy(() -> new MyKey("name", null)).hasMessage("version is marked @NonNull but is null"); - assertThatThrownBy(() -> new PfConceptKey(null, VERSION001)).hasMessage("name is marked @NonNull but is null"); + assertThatThrownBy(() -> new MyKey(null, VERSION001)).hasMessage("name is marked @NonNull but is null"); - assertThatThrownBy(() -> new PfConceptKey("AKey", VERSION001).isCompatible(null)).hasMessage(OTHER_IS_NULL); + assertThatThrownBy(() -> new MyKey("AKey", VERSION001).isCompatible(null)).hasMessage(OTHER_IS_NULL); } @Test public void testValidation() throws Exception { - PfConceptKey testKey = new PfConceptKey("TheKey", VERSION001); + MyKey testKey = new MyKey("TheKey", VERSION001); assertEquals("TheKey:0.0.1", testKey.getId()); Field nameField = testKey.getClass().getDeclaredField("name"); @@ -191,20 +194,20 @@ public class PfKeyTest { @Test public void testkeynewerThan() { - PfConceptKey key1 = new PfConceptKey("Key1", VERSION123); + MyKey key1 = new MyKey("Key1", VERSION123); assertThatThrownBy(() -> key1.isNewerThan(null)).hasMessage(OTHER_IS_NULL); assertThatThrownBy(() -> key1.isNewerThan(new PfReferenceKey())) .hasMessage("org.onap.policy.models.base.PfReferenceKey is not " - + "an instance of org.onap.policy.models.base.PfConceptKey"); + + "an instance of " + PfKeyImpl.class.getName()); assertFalse(key1.isNewerThan(key1)); - PfConceptKey key1a = new PfConceptKey("Key1a", VERSION123); + MyKey key1a = new MyKey("Key1a", VERSION123); assertFalse(key1.isNewerThan(key1a)); - PfConceptKey key1b = new PfConceptKey("Key0", VERSION123); + MyKey key1b = new MyKey("Key0", VERSION123); assertTrue(key1.isNewerThan(key1b)); key1a.setName("Key1"); @@ -240,28 +243,50 @@ public class PfKeyTest { assertThatThrownBy(() -> refKey.isNewerThan(null)).hasMessage(OTHER_IS_NULL); - assertThatThrownBy(() -> refKey.isNewerThan(new PfConceptKey())) - .hasMessage("org.onap.policy.models.base.PfConceptKey is not " - + "an instance of org.onap.policy.models.base.PfReferenceKey"); + assertThatThrownBy(() -> refKey.isNewerThan(new MyKey())) + .hasMessage(MyKey.class.getName() + " is not an instance of " + PfReferenceKey.class.getName()); assertFalse(refKey.isNewerThan(refKey)); } @Test public void testmajorMinorPatch() { - PfConceptKey key = new PfConceptKey("Key", VERSION100); + MyKey key = new MyKey("Key", VERSION100); assertEquals(1, key.getMajorVersion()); assertEquals(0, key.getMinorVersion()); assertEquals(0, key.getPatchVersion()); - key = new PfConceptKey("Key", "1.2.0"); + key = new MyKey("Key", "1.2.0"); assertEquals(1, key.getMajorVersion()); assertEquals(2, key.getMinorVersion()); assertEquals(0, key.getPatchVersion()); - key = new PfConceptKey("Key", VERSION123); + key = new MyKey("Key", VERSION123); assertEquals(1, key.getMajorVersion()); assertEquals(2, key.getMinorVersion()); assertEquals(3, key.getPatchVersion()); } + + @Getter + @Setter + @EqualsAndHashCode(callSuper = false) + @NoArgsConstructor + private static class MyKey extends PfKeyImpl { + private static final long serialVersionUID = 1L; + + private String name; + private String version; + + public MyKey(String name, String version) { + super(name, version); + } + + public MyKey(String id) { + super(id); + } + + public MyKey(MyKey myKey) { + super(myKey); + } + } } diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfSearchableKeyTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfSearchableKeyTest.java new file mode 100644 index 000000000..942f47c1d --- /dev/null +++ b/models-base/src/test/java/org/onap/policy/models/base/PfSearchableKeyTest.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * Modifications Copyright (C) 2019 AT&T Intellectual Property. 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.models.base; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.policy.models.base.testconcepts.DummyPfConcept; + +public class PfSearchableKeyTest { + + private static final String VERSION001 = "0.0.1"; + private static final String ID_IS_NULL = "id is marked @NonNull but is null"; + + @Test + public void testSearchableKey() { + PfSearchableKey someKey0 = new PfSearchableKey(); + assertEquals(PfSearchableKey.getNullKey(), someKey0); + assertTrue(someKey0.isNullKey()); + assertEquals("PfSearchableKey(name=NULL, version=0.0.0)", someKey0.toString()); + + PfSearchableKey someKey1 = new PfSearchableKey("my-name", VERSION001); + PfSearchableKey someKey2 = new PfSearchableKey(someKey1); + PfSearchableKey someKey3 = new PfSearchableKey(someKey1.getId()); + assertEquals(someKey1, someKey2); + assertEquals(someKey1, someKey3); + assertFalse(someKey1.isNullVersion()); + assertEquals("PfSearchableKey(name=my-name, version=0.0.1)", someKey1.toString()); + + assertEquals("my-name", someKey1.getName()); + assertEquals(VERSION001, someKey1.getVersion()); + + assertEquals(someKey2, someKey1.getKey()); + assertEquals(1, someKey1.getKeys().size()); + + + PfConcept pfc = new DummyPfConcept(); + assertEquals(PfSearchableKey.getNullKey().getId(), pfc.getId()); + + assertTrue(PfSearchableKey.getNullKey().matchesId(pfc.getId())); + + assertTrue(PfSearchableKey.getNullKey().isNullKey()); + + assertThatThrownBy(() -> PfSearchableKey.getNullKey().matchesId(null)).hasMessage(ID_IS_NULL); + + assertThatThrownBy(() -> someKey0.setName(null)).isInstanceOf(NullPointerException.class) + .hasMessage("name is marked @NonNull but is null"); + + assertThatThrownBy(() -> someKey0.setVersion(null)).isInstanceOf(NullPointerException.class) + .hasMessage("version is marked @NonNull but is null"); + + PfSearchableKey someKey4 = new PfSearchableKey("my-name.*", VERSION001); + assertEquals("my-name.*", someKey4.getName()); + assertEquals(VERSION001, someKey4.getVersion()); + } +} diff --git a/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java b/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java index 447a2720d..fb307587d 100644 --- a/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java +++ b/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java @@ -30,15 +30,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.UUID; -import org.onap.policy.aai.AaiManager; -import org.onap.policy.aai.AaiNqInstanceFilters; -import org.onap.policy.aai.AaiNqInventoryResponseItem; -import org.onap.policy.aai.AaiNqNamedQuery; -import org.onap.policy.aai.AaiNqQueryParameters; -import org.onap.policy.aai.AaiNqRequest; -import org.onap.policy.aai.AaiNqResponse; -import org.onap.policy.aai.util.AaiException; import org.onap.policy.appclcm.AppcLcmBody; import org.onap.policy.appclcm.AppcLcmCommonHeader; import org.onap.policy.appclcm.AppcLcmDmaapWrapper; @@ -50,7 +41,6 @@ import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; import org.onap.policy.controlloop.policy.Policy; import org.onap.policy.controlloop.policy.PolicyResult; -import org.onap.policy.rest.RestManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -104,77 +94,6 @@ public class AppcLcmActorServiceProvider implements Actor { return ImmutableList.copyOf(payloads.getOrDefault(recipe, Collections.emptyList())); } - /** - * This method recursively traverses the A&AI named query response to find the generic-vnf - * object that contains a model-invariant-id that matches the resourceId of the policy. Once - * this match is found the generic-vnf object's vnf-id is returned. - * - * @param items the list of items related to the vnf returned by A&AI - * @param resourceId the id of the target from the sdc catalog - * - * @return the vnf-id of the target vnf to act upon or null if not found - */ - private static String parseAaiResponse(List<AaiNqInventoryResponseItem> items, String resourceId) { - String vnfId = null; - for (AaiNqInventoryResponseItem item : items) { - if ((item.getGenericVnf() != null) && (item.getGenericVnf().getModelInvariantId() != null) - && (resourceId.equals(item.getGenericVnf().getModelInvariantId()))) { - vnfId = item.getGenericVnf().getVnfId(); - break; - } else { - if ((item.getItems() != null) && (item.getItems().getInventoryResponseItems() != null)) { - vnfId = parseAaiResponse(item.getItems().getInventoryResponseItems(), resourceId); - } - } - } - return vnfId; - } - - /** - * Constructs an A&AI Named Query using a source vnf-id to determine the vnf-id of the target - * entity specified in the policy to act upon. - * - * @param resourceId the id of the target from the sdc catalog - * - * @param sourceVnfId the vnf id of the source entity reporting the alert - * - * @return the target entities vnf id to act upon - * @throws AaiException it an error occurs - */ - public static String vnfNamedQuery(String resourceId, String sourceVnfId, String aaiUrl, - String aaiUser, String aaiPassword) throws AaiException { - - // TODO: This request id should not be hard coded in future releases - UUID requestId = UUID.fromString("a93ac487-409c-4e8c-9e5f-334ae8f99087"); - - AaiNqRequest aaiRequest = new AaiNqRequest(); - aaiRequest.setQueryParameters(new AaiNqQueryParameters()); - aaiRequest.getQueryParameters().setNamedQuery(new AaiNqNamedQuery()); - aaiRequest.getQueryParameters().getNamedQuery().setNamedQueryUuid(requestId); - - Map<String, Map<String, String>> filter = new HashMap<>(); - Map<String, String> filterItem = new HashMap<>(); - - filterItem.put("vnf-id", sourceVnfId); - filter.put("generic-vnf", filterItem); - - aaiRequest.setInstanceFilters(new AaiNqInstanceFilters()); - aaiRequest.getInstanceFilters().getInstanceFilter().add(filter); - - AaiNqResponse aaiResponse = new AaiManager(new RestManager()).postQuery(aaiUrl, - aaiUser, aaiPassword, aaiRequest, requestId); - - if (aaiResponse == null) { - throw new AaiException("The named query response was null"); - } - - String targetVnfId = parseAaiResponse(aaiResponse.getInventoryResponseItems(), resourceId); - if (targetVnfId == null) { - throw new AaiException("Target vnf-id could not be found"); - } - - return targetVnfId; - } /** * Constructs an APPC request conforming to the lcm API. The actual request is constructed and diff --git a/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProviderTest.java b/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProviderTest.java index 45057f008..88fb6e97f 100644 --- a/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProviderTest.java +++ b/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProviderTest.java @@ -332,19 +332,6 @@ public class AppcLcmActorServiceProviderTest { } /* - * This test ensures that that if the the source entity is also the target entity, the source - * will be used for the APPC request. - */ - @Test - public void sourceIsTargetTest() throws Exception { - String resourceId = "82194af1-3c2c-485a-8f44-420e22a9eaa4"; - String targetVnfId = AppcLcmActorServiceProvider.vnfNamedQuery(resourceId, VNF01, "http://localhost:6666", - "AAI", "AAI"); - assertNotNull(targetVnfId); - assertEquals(VNF01, targetVnfId); - } - - /* * This test exercises getters not exercised in other tests. */ @Test diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java index 842d0f6a5..b85307547 100644 --- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java +++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java @@ -33,9 +33,6 @@ import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.ServiceInstance; import org.onap.aai.domain.yang.Tenant; import org.onap.policy.aai.AaiCqResponse; -import org.onap.policy.aai.AaiNqExtraProperty; -import org.onap.policy.aai.AaiNqInventoryResponseItem; -import org.onap.policy.aai.AaiNqResponseWrapper; import org.onap.policy.controlloop.ControlLoopOperation; import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; @@ -82,10 +79,6 @@ public class SoActorServiceProvider implements Actor { // name of configuration parameters within policy payload public static final String CONFIG_PARAM_NM = "configurationParameters"; - private static final String MODEL_NAME_PROPERTY_KEY = "model-ver.model-name"; - private static final String MODEL_VERSION_PROPERTY_KEY = "model-ver.model-version"; - private static final String MODEL_VERSION_ID_PROPERTY_KEY = "model-ver.model-version-id"; - // used to decode configuration parameters via gson private static final Type CONFIG_TYPE = new TypeToken<List<Map<String, String>>>() {}.getType(); @@ -116,79 +109,6 @@ public class SoActorServiceProvider implements Actor { return Collections.emptyList(); } - /** - * Constructs a SO request conforming to the lcm API. The actual request is constructed and then placed in a wrapper - * object used to send through DMAAP. - * - * @param onset the event that is reporting the alert for policy to perform an action - * @param operation the control loop operation specifying the actor, operation, target, etc. - * @param policy the policy the was specified from the yaml generated by CLAMP or through the Policy GUI/API - * @param aaiResponseWrapper wrapper for AAI vserver named-query response - * @return a SO request conforming to the lcm API using the DMAAP wrapper - */ - public SoRequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, Policy policy, - AaiNqResponseWrapper aaiResponseWrapper) { - if (!SO_ACTOR.equals(policy.getActor()) || !recipes().contains(policy.getRecipe())) { - return null; - } - - // A&AI named query should have been performed by now. If not, return null - if (aaiResponseWrapper == null) { - return null; - } - - AaiNqInventoryResponseItem vnfItem; - AaiNqInventoryResponseItem vnfServiceItem; - AaiNqInventoryResponseItem tenantItem; - - // Extract the items we're interested in from the response - try { - vnfItem = aaiResponseWrapper.getAaiNqResponse().getInventoryResponseItems().get(0).getItems() - .getInventoryResponseItems().get(0); - } catch (Exception e) { - logger.error("VNF Item not found in AAI response {}", Serialization.gsonPretty.toJson(aaiResponseWrapper), - e); - return null; - } - - try { - vnfServiceItem = vnfItem.getItems().getInventoryResponseItems().get(0); - } catch (Exception e) { - logger.error("VNF Service Item not found in AAI response {}", - Serialization.gsonPretty.toJson(aaiResponseWrapper), e); - return null; - } - - try { - tenantItem = aaiResponseWrapper.getAaiNqResponse().getInventoryResponseItems().get(0).getItems() - .getInventoryResponseItems().get(1); - } catch (Exception e) { - logger.error(TENANT_NOT_FOUND, - Serialization.gsonPretty.toJson(aaiResponseWrapper), e); - return null; - } - - // Find the index for base vf module and non-base vf module - AaiNqInventoryResponseItem baseItem = findVfModule(aaiResponseWrapper, true); - - SoModelInfo soModelInfo = prepareSoModelInfo(policy); - - // Report the error if either base vf module or non-base vf module is not found - if (baseItem == null || soModelInfo == null) { - logger.error("Either base or non-base vf module is not found from AAI response."); - return null; - } - - // Construct SO Request for a policy's recipe - if (RECIPE_VF_MODULE_CREATE.equals(policy.getRecipe())) { - return constructCreateRequest(aaiResponseWrapper, policy, tenantItem, vnfItem, vnfServiceItem, soModelInfo); - } else if (RECIPE_VF_MODULE_DELETE.equals(policy.getRecipe())) { - return constructDeleteRequest(tenantItem, vnfItem, vnfServiceItem, policy); - } else { - return null; - } - } - private SoModelInfo prepareSoModelInfo(Policy policy) { if (policy.getTarget() == null || policy.getTarget().getModelCustomizationId() == null @@ -212,139 +132,6 @@ public class SoActorServiceProvider implements Actor { } /** - * Construct SO request to create vf-module. - * - * @param aaiResponseWrapper the AAI response containing the VF modules - * @param policy the policy - * @param tenantItem tenant item from A&AI named-query response - * @param vnfItem vnf item from A&AI named-query response - * @param vnfServiceItem vnf service item from A&AI named-query response - * @param vfModuleItem vf module item from A&AI named-query response - * @return SO create vf-module request - */ - private SoRequest constructCreateRequest(AaiNqResponseWrapper aaiResponseWrapper, Policy policy, - AaiNqInventoryResponseItem tenantItem, AaiNqInventoryResponseItem vnfItem, - AaiNqInventoryResponseItem vnfServiceItem, SoModelInfo vfModuleItem) { - SoRequest request = new SoRequest(); - request.setOperationType(SoOperationType.SCALE_OUT); - // - // - // Do NOT send So the requestId, they do not support this field - // - request.setRequestDetails(new SoRequestDetails()); - request.getRequestDetails().setRequestParameters(new SoRequestParameters()); - request.getRequestDetails().getRequestParameters().setUserParams(null); - - // cloudConfiguration - request.getRequestDetails().setCloudConfiguration(constructCloudConfiguration(tenantItem)); - // modelInfo - request.getRequestDetails().setModelInfo(vfModuleItem); - - // requestInfo - request.getRequestDetails().setRequestInfo(constructRequestInfo()); - String vfModuleName = aaiResponseWrapper.genVfModuleName(); - request.getRequestDetails().getRequestInfo().setInstanceName(vfModuleName); - - // relatedInstanceList - SoRelatedInstanceListElement relatedInstanceListElement1 = new SoRelatedInstanceListElement(); - SoRelatedInstanceListElement relatedInstanceListElement2 = new SoRelatedInstanceListElement(); - relatedInstanceListElement1.setRelatedInstance(new SoRelatedInstance()); - relatedInstanceListElement2.setRelatedInstance(new SoRelatedInstance()); - - // Service Item - relatedInstanceListElement1.getRelatedInstance() - .setInstanceId(vnfServiceItem.getServiceInstance().getServiceInstanceId()); - relatedInstanceListElement1.getRelatedInstance().setModelInfo(new SoModelInfo()); - relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelType("service"); - relatedInstanceListElement1.getRelatedInstance().getModelInfo() - .setModelInvariantId(vnfServiceItem.getServiceInstance().getModelInvariantId()); - for (AaiNqExtraProperty prop : vnfServiceItem.getExtraProperties().getExtraProperty()) { - if (prop.getPropertyName().equals(MODEL_NAME_PROPERTY_KEY)) { - relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelName(prop.getPropertyValue()); - } else if (prop.getPropertyName().equals(MODEL_VERSION_PROPERTY_KEY)) { - relatedInstanceListElement1.getRelatedInstance().getModelInfo() - .setModelVersion(prop.getPropertyValue()); - } else if (prop.getPropertyName().equals(MODEL_VERSION_ID_PROPERTY_KEY)) { - relatedInstanceListElement1.getRelatedInstance().getModelInfo() - .setModelVersionId(prop.getPropertyValue()); - } - } - - // VNF Item - relatedInstanceListElement2.getRelatedInstance().setInstanceId(vnfItem.getGenericVnf().getVnfId()); - relatedInstanceListElement2.getRelatedInstance().setModelInfo(new SoModelInfo()); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelType("vnf"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo() - .setModelInvariantId(vnfItem.getGenericVnf().getModelInvariantId()); - for (AaiNqExtraProperty prop : vnfItem.getExtraProperties().getExtraProperty()) { - if (prop.getPropertyName().equals(MODEL_NAME_PROPERTY_KEY)) { - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelName(prop.getPropertyValue()); - } else if (prop.getPropertyName().equals(MODEL_VERSION_PROPERTY_KEY)) { - relatedInstanceListElement2.getRelatedInstance().getModelInfo() - .setModelVersion(prop.getPropertyValue()); - } else if (prop.getPropertyName().equals(MODEL_VERSION_ID_PROPERTY_KEY)) { - relatedInstanceListElement2.getRelatedInstance().getModelInfo() - .setModelVersionId(prop.getPropertyValue()); - } - } - - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelCustomizationName(vnfItem - .getGenericVnf().getVnfType().substring(vnfItem.getGenericVnf().getVnfType().lastIndexOf('/') + 1)); - relatedInstanceListElement2.getRelatedInstance().getModelInfo() - .setModelCustomizationId(vnfItem.getGenericVnf().getModelCustomizationId()); - - // Insert the Service Item and VNF Item - request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement1); - request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement2); - - // Request Parameters - buildRequestParameters(policy, request.getRequestDetails()); - - // Configuration Parameters - buildConfigurationParameters(policy, request.getRequestDetails()); - // Save the instance IDs for the VNF and service to static fields - // vfModuleId is not required for the create vf-module - preserveInstanceIds(vnfItem.getGenericVnf().getVnfId(), - vnfServiceItem.getServiceInstance().getServiceInstanceId(), null); - if (logger.isDebugEnabled()) { - logger.debug(CONSTRUCTED_SO_MSG, Serialization.gsonPretty.toJson(request)); - } - return request; - } - - /** - * Construct SO request to delete vf-module. - * - * @param tenantItem tenant item from A&AI named-query response - * @param vnfItem vnf item from A&AI named-query response - * @param vnfServiceItem vnf service item from A&AI named-query response - * @return SO delete vf-module request - */ - private SoRequest constructDeleteRequest(AaiNqInventoryResponseItem tenantItem, AaiNqInventoryResponseItem vnfItem, - AaiNqInventoryResponseItem vnfServiceItem, Policy policy) { - SoRequest request = new SoRequest(); - request.setOperationType(SoOperationType.DELETE_VF_MODULE); - request.setRequestDetails(new SoRequestDetails()); - request.getRequestDetails().setRelatedInstanceList(null); - request.getRequestDetails().setConfigurationParameters(null); - - // cloudConfiguration - request.getRequestDetails().setCloudConfiguration(constructCloudConfiguration(tenantItem)); - // modelInfo - request.getRequestDetails().setModelInfo(prepareSoModelInfo(policy)); - // requestInfo - request.getRequestDetails().setRequestInfo(constructRequestInfo()); - // Save the instance IDs for the VNF, service and vfModule to static fields - preserveInstanceIds(vnfItem.getGenericVnf().getVnfId(), - vnfServiceItem.getServiceInstance().getServiceInstanceId(), null); - - if (logger.isDebugEnabled()) { - logger.debug(CONSTRUCTED_SO_MSG, Serialization.gsonPretty.toJson(request)); - } - return request; - } - - /** * Construct requestInfo for the SO requestDetails. * * @return SO request information @@ -358,20 +145,6 @@ public class SoActorServiceProvider implements Actor { } /** - * Construct cloudConfiguration for the SO requestDetails. - * - * @param tenantItem tenant item from A&AI named-query response - * @return SO cloud configuration - */ - private SoCloudConfiguration constructCloudConfiguration(AaiNqInventoryResponseItem tenantItem) { - SoCloudConfiguration cloudConfiguration = new SoCloudConfiguration(); - cloudConfiguration.setTenantId(tenantItem.getTenant().getTenantId()); - cloudConfiguration.setLcpCloudRegionId( - tenantItem.getItems().getInventoryResponseItems().get(0).getCloudRegion().getCloudRegionId()); - return cloudConfiguration; - } - - /** * This method is needed to get the serviceInstanceId and vnfInstanceId which is used in the asyncSORestCall. * * @param requestId the request Id @@ -388,18 +161,6 @@ public class SoActorServiceProvider implements Actor { lastVfModuleItemVfModuleInstanceId, (SoRequest) request); } - /** - * Find the base or non base VF module item in an AAI response. If there is more than one item, then the <i>last</i> - * item is returned - * - * @param aaiResponseWrapper the AAI response containing the VF modules - * @param baseFlag true if we are searching for the base, false if we are searching for the non base - * @return the base or non base VF module item or null if the module was not found - */ - private AaiNqInventoryResponseItem findVfModule(AaiNqResponseWrapper aaiResponseWrapper, boolean baseFlag) { - List<AaiNqInventoryResponseItem> lst = aaiResponseWrapper.getVfModuleItems(baseFlag); - return (lst.isEmpty() ? null : lst.get(lst.size() - 1)); - } /** * Builds the request parameters from the policy payload. diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorServiceProviderTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorServiceProviderTest.java index 175d2fe0c..b46ac52fb 100644 --- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorServiceProviderTest.java +++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorServiceProviderTest.java @@ -37,8 +37,6 @@ import java.util.UUID; import org.apache.commons.io.IOUtils; import org.junit.Test; import org.onap.policy.aai.AaiCqResponse; -import org.onap.policy.aai.AaiNqResponse; -import org.onap.policy.aai.AaiNqResponseWrapper; import org.onap.policy.controlloop.ControlLoopOperation; import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.policy.Policy; @@ -55,113 +53,6 @@ public class SoActorServiceProviderTest { private static final String VF_MODULE_CREATE = "VF Module Create"; private static final String VF_MODULE_DELETE = "VF Module Delete"; - @Test - public void testConstructRequest() throws Exception { - VirtualControlLoopEvent onset = new VirtualControlLoopEvent(); - final ControlLoopOperation operation = new ControlLoopOperation(); - final AaiNqResponseWrapper aaiNqResp = loadAaiResponse(onset, "aai/AaiNqResponse-Full.json"); - - final UUID requestId = UUID.randomUUID(); - onset.setRequestId(requestId); - - Policy policy = new Policy(); - policy.setActor("Dorothy"); - policy.setRecipe("GoToOz"); - - instantiateTarget(policy); - - assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp)); - - policy.setActor("SO"); - assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp)); - - policy.setRecipe(VF_MODULE_CREATE); - - // empty policy payload - SoRequest request = new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp); - assertNotNull(request); - - assertEquals("my_module_3", request.getRequestDetails().getRequestInfo().getInstanceName()); - assertEquals("policy", request.getRequestDetails().getRequestInfo().getRequestorId()); - assertEquals("RegionOne", request.getRequestDetails().getCloudConfiguration().getLcpCloudRegionId()); - - // non-empty policy payload - policy.setPayload(makePayload()); - request = new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp); - assertNotNull(request); - assertEquals(true, request.getRequestDetails().getRequestParameters().isUsePreload()); - assertEquals(A_VALUE, request.getRequestDetails().getRequestParameters().getUserParams().get(0).get("akey")); - assertEquals(1, request.getRequestDetails().getConfigurationParameters().size()); - assertEquals(C_VALUE, request.getRequestDetails().getConfigurationParameters().get(0).get("ckey")); - - // payload with config, but no request params - policy.setPayload(makePayload()); - policy.getPayload().remove(SoActorServiceProvider.REQ_PARAM_NM); - request = new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp); - assertNotNull(request); - assertNull(request.getRequestDetails().getRequestParameters()); - assertNotNull(request.getRequestDetails().getConfigurationParameters()); - - // payload with request, but no config params - policy.setPayload(makePayload()); - policy.getPayload().remove(SoActorServiceProvider.CONFIG_PARAM_NM); - request = new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp); - assertNotNull(request); - assertNotNull(request.getRequestDetails().getRequestParameters()); - assertNull(request.getRequestDetails().getConfigurationParameters()); - - // null response - assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, null)); - - // response has no base VF module - assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, - loadAaiResponse(onset, "aai/AaiNqResponse-NoBase.json"))); - - policy.setTarget(null); - - // response has no non-base VF modules (other than the "dummy") - assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, - loadAaiResponse(onset, "aai/AaiNqResponse-NoNonBase.json"))); - - instantiateTarget(policy); - policy.setRecipe(VF_MODULE_DELETE); - SoRequest deleteRequest = new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp); - assertNotNull(deleteRequest); - assertEquals(SoOperationType.DELETE_VF_MODULE, deleteRequest.getOperationType()); - - /* - * NOTE: The remaining tests must be done in order - */ - - policy.setRecipe(VF_MODULE_CREATE); - - // null tenant - aaiNqResp.getAaiNqResponse().getInventoryResponseItems().get(0).getItems().getInventoryResponseItems() - .remove(1); - assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp)); - - // null service item - aaiNqResp.getAaiNqResponse().getInventoryResponseItems().get(0).getItems().getInventoryResponseItems().get(0) - .setItems(null); - assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp)); - - // null response - aaiNqResp.setAaiNqResponse(null); - assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp)); - } - - private void instantiateTarget(Policy policy) { - - Target target = new Target(); - target.setModelCustomizationId("3e2d67ad-3495-4732-82f6-b0b872791fff"); - target.setModelInvariantId("90b793b5-b8ae-4c36-b10b-4b6372859d3a"); - target.setModelName("SproutScalingVf..scaling_sprout..module-1"); - target.setModelVersion("1"); - target.setModelVersionId("2210154d-e61a-4d7f-8fb9-0face1aee3f8"); - - policy.setTarget(target); - } - private void instantiateTargetCq(Policy policy) { Target target = new Target(); @@ -336,18 +227,4 @@ public class SoActorServiceProviderTest { return Serialization.gsonPretty.toJson(lst); } - /** - * Reads an AAI vserver named-query response from a file. - * - * @param onset the ONSET event - * @param fileName name of the file containing the JSON response - * @return output from the AAI vserver named-query - * @throws IOException if the file cannot be read - */ - private AaiNqResponseWrapper loadAaiResponse(VirtualControlLoopEvent onset, String fileName) throws IOException { - String resp = IOUtils.toString(getClass().getResource(fileName), StandardCharsets.UTF_8); - AaiNqResponse aaiNqResponse = Serialization.gsonPretty.fromJson(resp, AaiNqResponse.class); - - return new AaiNqResponseWrapper(onset.getRequestId(), aaiNqResponse); - } } diff --git a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java index a41d9e82d..482c25730 100644 --- a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java +++ b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java @@ -24,15 +24,11 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import java.util.Collections; import java.util.List; -import java.util.UUID; import org.onap.policy.aai.AaiCqResponse; -import org.onap.policy.aai.AaiGetVnfResponse; -import org.onap.policy.aai.AaiManager; import org.onap.policy.controlloop.ControlLoopOperation; import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; import org.onap.policy.controlloop.policy.Policy; -import org.onap.policy.rest.RestManager; import org.onap.policy.vfc.VfcHealActionVmInfo; import org.onap.policy.vfc.VfcHealAdditionalParams; import org.onap.policy.vfc.VfcHealRequest; @@ -79,76 +75,6 @@ public class VfcActorServiceProvider implements Actor { } /** - * Construct a request. - * - * @param onset the onset event - * @param operation the control loop operation - * @param policy the policy - * @param vnfResponse the VNF response - * @return the constructed request - */ - public static VfcRequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, - Policy policy, AaiGetVnfResponse vnfResponse, String aaiUrl, String aaiUsername, String aaiPassword) { - - // Construct an VFC request - VfcRequest request = new VfcRequest(); - String serviceInstance = onset.getAai().get("service-instance.service-instance-id"); - if (serviceInstance == null || "".equals(serviceInstance)) { - AaiGetVnfResponse tempVnfResp = vnfResponse; - if (tempVnfResp == null) { // if the response is null, we haven't queried - // This does the AAI query since we haven't already - tempVnfResp = getAaiServiceInstance(onset, aaiUrl, aaiUsername, aaiPassword); - if (tempVnfResp == null) { - return null; - } - } - serviceInstance = tempVnfResp.getServiceId(); - } - request.setNsInstanceId(serviceInstance); - request.setRequestId(onset.getRequestId()); - request.setHealRequest(new VfcHealRequest()); - request.getHealRequest().setVnfInstanceId(onset.getAai().get(GENERIC_VNF_ID)); - request.getHealRequest().setCause(operation.getMessage()); - request.getHealRequest().setAdditionalParams(new VfcHealAdditionalParams()); - - if (policy.getRecipe().toLowerCase().equalsIgnoreCase(RECIPE_RESTART)) { - request.getHealRequest().getAdditionalParams().setAction("restartvm"); - request.getHealRequest().getAdditionalParams().setActionInfo(new VfcHealActionVmInfo()); - request.getHealRequest().getAdditionalParams().getActionInfo() - .setVmid(onset.getAai().get("vserver.vserver-id")); - request.getHealRequest().getAdditionalParams().getActionInfo() - .setVmname(onset.getAai().get("vserver.vserver-name")); - } else { - return null; - } - return request; - } - - private static AaiGetVnfResponse getAaiServiceInstance(VirtualControlLoopEvent event, String aaiUrl, - String aaiUsername, String aaiPassword) { - AaiGetVnfResponse response = null; - UUID requestId = event.getRequestId(); - String vnfName = event.getAai().get("generic-vnf.vnf-name"); - String vnfId = event.getAai().get(GENERIC_VNF_ID); - try { - if (vnfName != null) { - String url = aaiUrl + "/aai/v11/network/generic-vnfs/generic-vnf?vnf-name="; - response = new AaiManager(new RestManager()).getQueryByVnfName(url, aaiUsername, aaiPassword, requestId, - vnfName); - } else if (vnfId != null) { - String url = aaiUrl + "/aai/v11/network/generic-vnfs/generic-vnf/"; - response = new AaiManager(new RestManager()).getQueryByVnfId(url, aaiUsername, aaiPassword, requestId, - vnfId); - } else { - logger.error("getAAIServiceInstance failed"); - } - } catch (Exception e) { - logger.error("getAAIServiceInstance exception: ", e); - } - return response; - } - - /** * This method constructs the VFC request. * * @param onset onset object diff --git a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java index 300cd29f0..db224b065 100644 --- a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java +++ b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java @@ -35,7 +35,6 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.onap.policy.aai.AaiCqResponse; -import org.onap.policy.aai.AaiGetVnfResponse; import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; import org.onap.policy.controlloop.ControlLoopOperation; import org.onap.policy.controlloop.VirtualControlLoopEvent; @@ -45,7 +44,6 @@ import org.onap.policy.vfc.VfcRequest; public class VfcActorServiceProviderTest { - private static final String LOCAL_URL = "http://localhost:6666"; private static final String DOROTHY_GALE_1939 = "dorothy.gale.1939"; private static final String CQ_RESPONSE_JSON = "aai/AaiCqResponse.json"; private static final String RESTART = "Restart"; @@ -65,53 +63,6 @@ public class VfcActorServiceProviderTest { } @Test - public void testConstructRequest() { - VirtualControlLoopEvent onset = new VirtualControlLoopEvent(); - ControlLoopOperation operation = new ControlLoopOperation(); - - Policy policy = new Policy(); - policy.setRecipe("GoToOz"); - - assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, null, null, null)); - - onset.getAai().put("generic-vnf.vnf-id", DOROTHY_GALE_1939); - assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, null, null, null)); - - assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, LOCAL_URL, - "AAI", "AAI")); - - UUID requestId = UUID.randomUUID(); - onset.setRequestId(requestId); - assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, LOCAL_URL, - "AAI", "AAI")); - - onset.getAai().put("generic-vnf.vnf-name", "Dorothy"); - assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, LOCAL_URL, - "AAI", null)); - - assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, LOCAL_URL, - "AAI", "AAI")); - - onset.getAai().put("service-instance.service-instance-id", ""); - assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null, LOCAL_URL, - "AAI", "AAI")); - - assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, new AaiGetVnfResponse(), - LOCAL_URL, "AAI", "AAI")); - - policy.setRecipe(RESTART); - assertNotNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, new AaiGetVnfResponse(), - LOCAL_URL, "AAI", "AAI")); - - VfcRequest request = VfcActorServiceProvider.constructRequest(onset, operation, policy, new AaiGetVnfResponse(), - LOCAL_URL, "AAI", "AAI"); - - assertEquals(requestId, Objects.requireNonNull(request).getRequestId()); - assertEquals(DOROTHY_GALE_1939, request.getHealRequest().getVnfInstanceId()); - assertEquals("restartvm", request.getHealRequest().getAdditionalParams().getAction()); - } - - @Test public void testMethods() { VfcActorServiceProvider sp = new VfcActorServiceProvider(); diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetResponse.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetResponse.java deleted file mode 100644 index 61dde9270..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetResponse.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import java.io.Serializable; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class AaiGetResponse implements Serializable { - private static final long serialVersionUID = 7311418432051756162L; - - private AaiNqRequestError requestError; -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetVnfResponse.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetVnfResponse.java deleted file mode 100644 index dc587f2c7..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetVnfResponse.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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 excthe License at - * ept in compliance with the License. - * You may obtain a copy of - * 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import com.google.gson.annotations.SerializedName; -import java.io.Serializable; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -@Data -@EqualsAndHashCode(callSuper = true) -@NoArgsConstructor -public class AaiGetVnfResponse extends AaiGetResponse implements Serializable { - - private static final long serialVersionUID = -6247505944905898871L; - - @SerializedName("vnf-id") - private String vnfId; - - @SerializedName("vnf-name") - private String vnfName; - - @SerializedName("vnf-type") - private String vnfType; - - @SerializedName("service-id") - private String serviceId; - - @SerializedName("orchestration-status") - private String orchestrationStatus; - - @SerializedName("in-maint") - private boolean inMaint; - - @SerializedName("is-closed-loop-disabled") - private boolean isClosedLoopDisabled; - - @SerializedName("model-invariant-id") - private String modelInvariantId; - - @SerializedName("prov-status") - private String provStatus; - - @SerializedName("resource-version") - private String resourceVersion; - - @SerializedName("relationship-list") - private RelationshipList relationshipList; -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetVserverResponse.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetVserverResponse.java deleted file mode 100644 index c79f72c9f..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetVserverResponse.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import java.io.Serializable; -import java.util.LinkedList; -import java.util.List; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -@Data -@EqualsAndHashCode(callSuper = true) -@NoArgsConstructor -public class AaiGetVserverResponse extends AaiGetResponse implements Serializable { - - private static final long serialVersionUID = -6247505944905898871L; - - private List<AaiNqVServer> vserver = new LinkedList<>(); -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java index d95068b2b..eae1dca8e 100644 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java +++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java @@ -22,7 +22,6 @@ package org.onap.policy.aai; -import com.google.gson.JsonSyntaxException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; @@ -30,9 +29,9 @@ import java.util.HashMap; import java.util.Map; import java.util.UUID; import java.util.stream.Collectors; + import org.json.JSONArray; import org.json.JSONObject; -import org.onap.policy.aai.util.Serialization; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; import org.onap.policy.common.endpoints.utils.NetLoggerUtil; import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; @@ -55,14 +54,13 @@ public final class AaiManager { private static final StandardCoder CODER = new StandardCoder(); - /** The rest manager. */ // The REST manager used for processing REST calls for this AAI manager private final RestManager restManager; /** custom query and other AAI resource URLs. */ private static final String CQ_URL = "/aai/v16/query?format=resource"; - private static final String TENANT_URL = - "/aai/v16/search/nodes-query?search-node-type=vserver&filter=vserver-name:EQUALS:"; + private static final String TENANT_URL = "/aai/v16/search/nodes-query?" + + "search-node-type=vserver&filter=vserver-name:EQUALS:"; private static final String PREFIX = "/aai/v16"; private static final String PNF_URL = PREFIX + "/network/pnfs/pnf/"; private static final String AAI_DEPTH_SUFFIX = "?depth=0"; @@ -116,7 +114,7 @@ public final class AaiManager { * @return String */ private String getCustomQueryRequestPayload(String url, String username, String password, UUID requestId, - String vserver) { + String vserver) { String urlGet = url + TENANT_URL; @@ -135,7 +133,7 @@ public final class AaiManager { * @return AaiCqResponse response from Aai for custom query */ public AaiCqResponse getCustomQueryResponse(String url, String username, String password, UUID requestId, - String vserver) { + String vserver) { final Map<String, String> headers = createHeaders(requestId); @@ -145,8 +143,8 @@ public final class AaiManager { url = url + CQ_URL; - Pair<Integer, String> httpDetails = - this.restManager.put(url, username, password, headers, APPLICATION_JSON, requestJson); + Pair<Integer, String> httpDetails = this.restManager.put(url, username, password, headers, APPLICATION_JSON, + requestJson); logger.debug("RestManager.put after"); if (httpDetails == null) { @@ -178,7 +176,7 @@ public final class AaiManager { * @return String returns the string from the get query */ private String getStringQuery(final String url, final String username, final String password, final UUID requestId, - final String key) { + final String key) { Map<String, String> headers = createHeaders(requestId); @@ -218,143 +216,6 @@ public final class AaiManager { } /** - * Post a query to A&AI. - * - * @param url the A&AI URL - * @param username the user name for authentication - * @param password the password for authentication - * @param request the request to issue towards A&AI - * @param requestId the UUID of the request - * @return the response from A&AI - */ - public AaiNqResponse postQuery(String url, String username, String password, AaiNqRequest request, UUID requestId) { - - final Map<String, String> headers = createHeaders(requestId); - - url = url + "/aai/search/named-query"; - - logger.debug("RestManager.post before"); - String requestJson = Serialization.gsonPretty.toJson(request); - NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, url, requestJson); - Pair<Integer, String> httpDetails = - restManager.post(url, username, password, headers, APPLICATION_JSON, requestJson); - logger.debug("RestManager.post after"); - - if (httpDetails == null) { - logger.info("AAI POST Null Response to {}", url); - return null; - } - - int httpResponseCode = httpDetails.first; - - logger.info(url); - logger.info("{}", httpResponseCode); - logger.info(httpDetails.second); - - if (httpDetails.second != null) { - return composeResponse(httpDetails, url, AaiNqResponse.class); - } - return null; - } - - /** - * Perform a GET request for a particular virtual server towards A&AI. - * - * @param urlGet the A&AI URL - * @param username the user name for authentication - * @param password the password for authentication - * @param requestId the UUID of the request - * @param key the key of the virtual server - * @return the response for the virtual server from A&AI - */ - public AaiGetVserverResponse getQueryByVserverName(String urlGet, String username, String password, UUID requestId, - String key) { - return getQuery(urlGet, username, password, requestId, key, AaiGetVserverResponse.class); - } - - /** - * Perform a GET request for a particular VNF by VNF ID towards A&AI. - * - * @param urlGet the A&AI URL - * @param username the user name for authentication - * @param password the password for authentication - * @param requestId the UUID of the request - * @param key the ID of the VNF - * @return the response for the virtual server from A&AI - */ - public AaiGetVnfResponse getQueryByVnfId(String urlGet, String username, String password, UUID requestId, - String key) { - return getQuery(urlGet, username, password, requestId, key, AaiGetVnfResponse.class); - } - - /** - * Perform a GET request for a particular VNF by VNF name towards A&AI. - * - * @param urlGet the A&AI URL - * @param username the user name for authentication - * @param password the password for authentication - * @param requestId the UUID of the request - * @param key the name of the VNF - * @return the response for the virtual server from A&AI - */ - public AaiGetVnfResponse getQueryByVnfName(String urlGet, String username, String password, UUID requestId, - String key) { - return getQuery(urlGet, username, password, requestId, key, AaiGetVnfResponse.class); - } - - /** - * Perform a GET query for a particular entity towards A&AI. - * - * @param <T> the generic type for the response - * @param url the A&AI URL - * @param username the user name for authentication - * @param password the password for authentication - * @param requestId the UUID of the request - * @param key the name of the VNF - * @param classOfResponse the class of the response to return - * @return the response for the virtual server from A&AI - */ - private <T> T getQuery(final String url, final String username, final String password, final UUID requestId, - final String key, final Class<T> classOfResponse) { - - Map<String, String> headers = createHeaders(requestId); - - String urlGet = url + key; - - int attemptsLeft = 3; - - while (attemptsLeft-- > 0) { - NetLoggerUtil.getNetworkLogger().info("[OUT|{}|{}|]", CommInfrastructure.REST, urlGet); - Pair<Integer, String> httpDetailsGet = restManager.get(urlGet, username, password, headers); - if (httpDetailsGet == null) { - logger.info("AAI GET Null Response to {}", urlGet); - return null; - } - - int httpResponseCode = httpDetailsGet.first; - - logger.info(urlGet); - logger.info("{}", httpResponseCode); - logger.info(httpDetailsGet.second); - - if (httpResponseCode == 200) { - T responseGet = composeResponse(httpDetailsGet, urlGet, classOfResponse); - if (responseGet != null) { - return responseGet; - } - } - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - - } - - return null; - } - - /** * Create the headers for the HTTP request. * * @param requestId the request ID to insert in the headers @@ -371,28 +232,6 @@ public final class AaiManager { } /** - * This method uses Google's GSON to create a response object from a JSON string. - * - * @param <T> the generic type - * @param httpDetails the HTTP response - * @param url the URL from which the response came - * @param classOfResponse The response class - * @return an instance of the response class - * @throws JsonSyntaxException on GSON errors instantiating the response - */ - private <T> T composeResponse(final Pair<Integer, String> httpDetails, final String url, - final Class<T> classOfResponse) { - try { - T response = Serialization.gsonPretty.fromJson(httpDetails.second, classOfResponse); - NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, url, httpDetails.second); - return response; - } catch (JsonSyntaxException e) { - logger.error("postQuery threw: ", e); - return null; - } - } - - /** * Perform a GET request for a particular PNF by PNF ID towards A&AI. * * @param url the A&AI URL @@ -417,12 +256,13 @@ public final class AaiManager { return null; } try { + @SuppressWarnings("unchecked") Map<String, String> pnfParams = CODER.decode(responseGet, HashMap.class); // Map to AAI node.attribute notation return pnfParams.entrySet().stream() - .collect(Collectors.toMap(e -> "pnf." + e.getKey(), Map.Entry::getValue)); + .collect(Collectors.toMap(e -> "pnf." + e.getKey(), Map.Entry::getValue)); } catch (CoderException e) { - logger.error("Failed to fetch PNF from AAI"); + logger.error("Failed to fetch PNF from AAI", e); return null; } } diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqCloudRegion.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqCloudRegion.java deleted file mode 100644 index 851c4f6af..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqCloudRegion.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class AaiNqCloudRegion implements Serializable { - - private static final long serialVersionUID = -897231529157222683L; - - @SerializedName("cloud-owner") - private String cloudOwner; - - @SerializedName("cloud-region-id") - private String cloudRegionId; - - @SerializedName("cloud-region-version") - private String cloudRegionVersion; - - @SerializedName("complex-name") - private String complexName; - - @SerializedName("resource-version") - private String resourceVersion; -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqExtraProperties.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqExtraProperties.java deleted file mode 100644 index f33d10ca9..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqExtraProperties.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.LinkedList; -import java.util.List; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class AaiNqExtraProperties implements Serializable { - private static final long serialVersionUID = 4109625574744702319L; - - @SerializedName("extra-property") - private List<AaiNqExtraProperty> extraProperty = new LinkedList<>(); -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqExtraProperty.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqExtraProperty.java deleted file mode 100644 index acab811d0..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqExtraProperty.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@AllArgsConstructor -@NoArgsConstructor -public class AaiNqExtraProperty implements Serializable { - - private static final long serialVersionUID = -3861240617222397736L; - - @SerializedName("property-name") - private String propertyName; - - @SerializedName("property-value") - private String propertyValue; -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqGenericVnf.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqGenericVnf.java deleted file mode 100644 index 72b27779f..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqGenericVnf.java +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import com.google.gson.annotations.SerializedName; -import java.io.Serializable; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class AaiNqGenericVnf implements Serializable { - - private static final long serialVersionUID = 834322706248060560L; - - @SerializedName("vnf-id") - private String vnfId; - - @SerializedName("vnf-name") - private String vnfName; - - @SerializedName("vnf-name2") - private String vnfName2; - - @SerializedName("vnf-type") - private String vnfType; - - @SerializedName("service-id") - private String serviceId; - - @SerializedName("prov-status") - private String provStatus; - - @SerializedName("operational-state") - private String operationalState; - - @SerializedName("ipv4-oam-address") - private String ipv4OamAddress; - - @SerializedName("ipv4-loopback0-address") - private String ipv4Loopback0Address; - - @SerializedName("in-maint") - private Boolean inMaint; - - @SerializedName("is-closed-loop-disabled") - private Boolean isClosedLoopDisabled; - - @SerializedName("resource-version") - private String resourceVersion; - - @SerializedName("encrypted-access-flag") - private Boolean encrypedAccessFlag; - - @SerializedName("persona-model-id") - private String personaModelId; - - @SerializedName("persona-model-version") - private String personaModelVersion; - - @SerializedName("model-invariant-id") - private String modelInvariantId; - - @SerializedName("model-version-id") - private String modelVersionId; - - @SerializedName("model-customization-id") - private String modelCustomizationId = null; -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInstanceFilters.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInstanceFilters.java deleted file mode 100644 index 90e0668b4..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInstanceFilters.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class AaiNqInstanceFilters implements Serializable { - - private static final long serialVersionUID = 8993824591338121185L; - - @SerializedName("instance-filter") - private List<Map<String, Map<String, String>>> instanceFilter = new LinkedList<>(); -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInventoryResponseItem.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInventoryResponseItem.java deleted file mode 100644 index 50f101e27..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInventoryResponseItem.java +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class AaiNqInventoryResponseItem implements Serializable { - - private static final long serialVersionUID = 7142072567154675183L; - - @SerializedName("model-name") - private String modelName; - - @SerializedName("vf-module") - private AaiNqVfModule vfModule; - - @SerializedName("service-instance") - private AaiNqServiceInstance serviceInstance; - - @SerializedName("vserver") - private AaiNqVServer vserver; - - @SerializedName("tenant") - private AaiNqTenant tenant; - - @SerializedName("cloud-region") - private AaiNqCloudRegion cloudRegion; - - @SerializedName("generic-vnf") - private AaiNqGenericVnf genericVnf; - - @SerializedName("extra-properties") - private AaiNqExtraProperties extraProperties; - - @SerializedName("inventory-response-items") - private AaiNqInventoryResponseItems items; -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInventoryResponseItems.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInventoryResponseItems.java deleted file mode 100644 index 51b3e9067..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInventoryResponseItems.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.LinkedList; -import java.util.List; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class AaiNqInventoryResponseItems implements Serializable { - private static final long serialVersionUID = 7602807659381179004L; - - @SerializedName("inventory-response-item") - private List<AaiNqInventoryResponseItem> inventoryResponseItems = new LinkedList<>(); -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqNamedQuery.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqNamedQuery.java deleted file mode 100644 index 3847dcf6e..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqNamedQuery.java +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.UUID; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class AaiNqNamedQuery implements Serializable { - private static final long serialVersionUID = -3277980060302645333L; - - @SerializedName("named-query-uuid") - private UUID namedQueryUuid; -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqQueryParameters.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqQueryParameters.java deleted file mode 100644 index 873f836eb..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqQueryParameters.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class AaiNqQueryParameters implements Serializable { - private static final long serialVersionUID = -4291227193197126982L; - - @SerializedName("named-query") - private AaiNqNamedQuery namedQuery; -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqRequest.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqRequest.java deleted file mode 100644 index d99244782..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqRequest.java +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class AaiNqRequest implements Serializable { - private static final long serialVersionUID = -3283942659786236032L; - - @SerializedName("query-parameters") - private AaiNqQueryParameters queryParameters; - - @SerializedName("instance-filters") - private AaiNqInstanceFilters instanceFilters; -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqRequestError.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqRequestError.java deleted file mode 100644 index c4222b422..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqRequestError.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class AaiNqRequestError implements Serializable { - private static final long serialVersionUID = -7742674155387022932L; - - @SerializedName("serviceException") - private AaiNqServiceExcept serviceExcept; -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqResponse.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqResponse.java deleted file mode 100644 index 3c42a0d96..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqResponse.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.LinkedList; -import java.util.List; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class AaiNqResponse implements Serializable { - private static final long serialVersionUID = 8411407444051746101L; - - @SerializedName("inventory-response-item") - private List<AaiNqInventoryResponseItem> inventoryResponseItems = new LinkedList<>(); - - @SerializedName("requestError") - private AaiNqRequestError requestError; -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqResponseWrapper.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqResponseWrapper.java deleted file mode 100644 index 68d07270a..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqResponseWrapper.java +++ /dev/null @@ -1,153 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.UUID; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiNqResponseWrapper implements Serializable { - private static final long serialVersionUID = 8411407444051746101L; - - private static final Logger logger = LoggerFactory.getLogger(AaiNqResponseWrapper.class); - - private static final Pattern VF_MODULE_NAME_PAT = Pattern.compile("(.*_)(\\d+)"); - - private UUID requestId; - private AaiNqResponse aaiNqResponse; - - public AaiNqResponseWrapper() {} - - public AaiNqResponseWrapper(UUID requestId, AaiNqResponse aaiNqResponse) { - this.requestId = requestId; - this.aaiNqResponse = aaiNqResponse; - } - - public UUID getRequestId() { - return requestId; - } - - public void setRequestId(UUID requestId) { - this.requestId = requestId; - } - - public AaiNqResponse getAaiNqResponse() { - return aaiNqResponse; - } - - public void setAaiNqResponse(AaiNqResponse aaiNqResponse) { - this.aaiNqResponse = aaiNqResponse; - } - - /** - * Counts the number of VF modules, if any, in the response. - * - * @return the number of VF modules, or {@code 0} if there are none - */ - public int countVfModules() { - return getVfModuleItems(false).size(); - } - - /** - * Generates the name for the next VF module. - * - * @return the name of the next VF module, or {@code null} if the name could not be - * generated (i.e., because the response has no matching VF module names on - * which to model it) - */ - public String genVfModuleName() { - /* - * Loop through the VF modules, extracting the name prefix and the largest number - * suffix - */ - String prefix = null; - int maxSuffix = -1; - - for (AaiNqInventoryResponseItem item : getVfModuleItems(false)) { - String name = item.getVfModule().getVfModuleName(); - Matcher matcher = VF_MODULE_NAME_PAT.matcher(name); - if (matcher.matches()) { - int suffix = Integer.parseInt(matcher.group(2)); - if (suffix > maxSuffix) { - maxSuffix = suffix; - prefix = matcher.group(1); - } - } - } - - ++maxSuffix; - - return (prefix == null ? null : prefix + maxSuffix); - } - - /** - * Gets a list of VF modules. If the non-base VF modules are requested, then only - * those whose names match the name pattern, {@link #VF_MODULE_NAME_PAT}, are - * returned. - * - * @param wantBaseModule {@code true} if the the base VF module(s) is desired, - * {@code false} otherwise - * @return the list of VF module items - */ - public List<AaiNqInventoryResponseItem> getVfModuleItems(boolean wantBaseModule) { - // get the list of items - List<AaiNqInventoryResponseItem> itemList; - try { - itemList = aaiNqResponse.getInventoryResponseItems().get(0).getItems().getInventoryResponseItems().get(0) - .getItems().getInventoryResponseItems(); - - } catch (NullPointerException | IndexOutOfBoundsException e) { - logger.debug("no VF modules in AAI response", e); - return Collections.emptyList(); - } - - if (itemList == null) { - return Collections.emptyList(); - } - - /* - * Walk the items looking for VF modules, allocating the list only when an item is - * found. - */ - List<AaiNqInventoryResponseItem> vfModuleItems = new ArrayList<>(itemList.size()); - - for (AaiNqInventoryResponseItem inventoryResponseItem : itemList) { - AaiNqVfModule vfmod = inventoryResponseItem.getVfModule(); - if (vfmod == null) { - continue; - } - - if (vfmod.getIsBaseVfModule() == wantBaseModule - && (wantBaseModule || VF_MODULE_NAME_PAT.matcher(vfmod.getVfModuleName()).matches())) { - vfModuleItems.add(inventoryResponseItem); - } - } - - return vfModuleItems; - } -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqServiceExcept.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqServiceExcept.java deleted file mode 100644 index 27751e776..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqServiceExcept.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class AaiNqServiceExcept implements Serializable { - private static final long serialVersionUID = 2858343404484338546L; - - @SerializedName("messageId") - private String messageId; - - @SerializedName("text") - private String text; - - @SerializedName("variables") - private String[] variables; -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqServiceInstance.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqServiceInstance.java deleted file mode 100644 index 79213c354..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqServiceInstance.java +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class AaiNqServiceInstance implements Serializable { - private static final long serialVersionUID = -8000944396593889586L; - - @SerializedName("service-instance-id") - private String serviceInstanceId; - - @SerializedName("service-instance-name") - private String serviceInstanceName; - - @SerializedName("persona-model-id") - private String personaModelId; - - @SerializedName("persona-model-version") - private String personaModelVersion; - - @SerializedName("service-instance-location-id") - private String serviceInstanceLocationId; - - @SerializedName("resource-version") - private String resourceVersion; - - @SerializedName("model-invariant-id") - private String modelInvariantId; - - @SerializedName("model-version-id") - private String modelVersionId; -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqTenant.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqTenant.java deleted file mode 100644 index 5e68f4109..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqTenant.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class AaiNqTenant implements Serializable { - private static final long serialVersionUID = 4702784101671984364L; - - @SerializedName("tenant-id") - private String tenantId; - - @SerializedName("tenant-name") - private String tenantName; - - @SerializedName("resource-version") - private String resourceVersion; -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqVServer.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqVServer.java deleted file mode 100644 index 68917137c..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqVServer.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class AaiNqVServer implements Serializable { - private static final long serialVersionUID = -6718526692734215643L; - - @SerializedName("vserver-id") - private String vserverId; - - @SerializedName("vserver-name") - private String vserverName; - - @SerializedName("vserver-name2") - private String vserverName2; - - @SerializedName("prov-status") - private String provStatus; - - @SerializedName("vserver-selflink") - private String vserverSelflink; - - @SerializedName("in-maint") - private Boolean inMaint; - - @SerializedName("is-closed-loop-disabled") - private Boolean isClosedLoopDisabled; - - @SerializedName("resource-version") - private String resourceVersion; - - @SerializedName("relationship-list") - private RelationshipList relationshipList; -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqVfModule.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqVfModule.java deleted file mode 100644 index ce38a3e3b..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqVfModule.java +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import com.google.gson.annotations.SerializedName; -import java.io.Serializable; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class AaiNqVfModule implements Serializable { - private static final long serialVersionUID = 8019133081429638232L; - - @SerializedName("vf-module-id") - private String vfModuleId; - - @SerializedName("vf-module-name") - private String vfModuleName; - - @SerializedName("heat-stack-id") - private String heatStackId; - - @SerializedName("orchestration-status") - private String orchestrationStatus; - - @SerializedName("is-base-vf-module") - private Boolean isBaseVfModule; - - @SerializedName("resource-version") - private String resourceVersion; - - @SerializedName("persona-model-id") - private String personaModelId; - - @SerializedName("persona-model-version") - private String personaModelVersion; - - @SerializedName("widget-model-id") - private String widgetModelId; - - @SerializedName("widget-model-version") - private String widgetModelVersion; - - @SerializedName("contrail-service-instance-fqdn") - private String contrailServiceInstanceFqdn; - - @SerializedName("model-invariant-id") - private String modelInvariantId; - - @SerializedName("model-version-id") - private String modelVersionId; - - @SerializedName("model-customization-id") - private String modelCustomizationId = null; -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/Pnf.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/Pnf.java deleted file mode 100644 index ae6b97970..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/Pnf.java +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import java.io.Serializable; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class Pnf implements Serializable { - private static final long serialVersionUID = -3535108358668248501L; - - private String pnfName; - private PnfType pnfType; - - public Pnf(Pnf pnf) { - this.pnfName = pnf.pnfName; - this.pnfType = pnf.pnfType; - } -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/PnfInstance.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/PnfInstance.java deleted file mode 100644 index 6a7ad83c5..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/PnfInstance.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import java.io.Serializable; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class PnfInstance implements Serializable { - - private static final long serialVersionUID = -3694152433472165034L; - - private String pnfName; - private String pnfInstanceName; - private PnfType pnfType; - private String pnfSerial; - - /** - * Create an instance from a given instance. - * - * @param instance the instance - */ - public PnfInstance(PnfInstance instance) { - if (instance == null) { - return; - } - this.pnfName = instance.pnfName; - this.pnfInstanceName = instance.pnfInstanceName; - this.pnfType = instance.pnfType; - this.pnfSerial = instance.pnfSerial; - } -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/PnfType.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/PnfType.java deleted file mode 100644 index a549d7b9d..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/PnfType.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -public enum PnfType { - ENODEB("eNodeB"), PSERVER("pserver"); - - private String type; - - private PnfType(String type) { - this.type = type; - } - - @Override - public String toString() { - return this.type; - } -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToProperty.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToProperty.java deleted file mode 100644 index f65b642ed..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToProperty.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class RelatedToProperty implements Serializable { - private static final long serialVersionUID = 5644372985092588638L; - - @SerializedName("property-key") - private String propertyKey; - @SerializedName("property-value") - private String propertyValue; -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/Relationship.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/Relationship.java deleted file mode 100644 index 78421b0f2..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/Relationship.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.LinkedList; -import java.util.List; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class Relationship implements Serializable { - private static final long serialVersionUID = -68508443869003055L; - - @SerializedName("related-to") - private String relatedTo; - - @SerializedName("related-link") - private String relatedLink; - - @SerializedName("relationship-data") - private List<RelationshipData> relationshipData = new LinkedList<>(); - - @SerializedName("related-to-property") - private List<RelatedToProperty> relatedToProperty = new LinkedList<>(); -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipData.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipData.java deleted file mode 100644 index 9119bf6ac..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipData.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class RelationshipData implements Serializable { - private static final long serialVersionUID = 550450041634939768L; - - @SerializedName("relationship-key") - private String relationshipKey; - @SerializedName("relationship-value") - private String relationshipValue; -} diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipList.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipList.java deleted file mode 100644 index 91bc32844..000000000 --- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipList.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.LinkedList; -import java.util.List; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -public class RelationshipList implements Serializable { - private static final long serialVersionUID = 6115655704973981990L; - - @SerializedName("relationship") - private List<Relationship> relationships = new LinkedList<>(); -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetResponseTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetResponseTest.java deleted file mode 100644 index 8c2cd5fb6..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetResponseTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= -*/ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import java.io.File; -import java.nio.file.Files; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiGetResponseTest { - private static final Logger logger = LoggerFactory.getLogger(AaiGetResponseTest.class); - - @Test - public void test() throws Exception { - // deserialize json and verify fields are populated properly - String json = new String(Files.readAllBytes( - new File("src/test/resources/org/onap/policy/aai/AaiGetResponseError.json").toPath())); - - AaiGetResponse resp = Serialization.gsonPretty.fromJson(json, AaiGetResponse.class); - - // don't need to verify this in depth, as it has its own tests that do that - assertNotNull(resp.getRequestError()); - assertNotNull(resp.getRequestError().getServiceExcept()); - assertEquals("SVC3001", resp.getRequestError().getServiceExcept().getMessageId()); - - logger.info(Serialization.gsonPretty.toJson(resp)); - - // verify that setXxx methods work - resp.setRequestError(null); - assertNull(resp.getRequestError()); - - AaiNqRequestError err = new AaiNqRequestError(); - resp.setRequestError(err); - assertEquals(err, resp.getRequestError()); - } - -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVnfResponseTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVnfResponseTest.java deleted file mode 100644 index 47ee5ba6f..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVnfResponseTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.nio.file.Files; -import java.util.List; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiGetVnfResponseTest { - private static final Logger logger = LoggerFactory.getLogger(AaiGetVnfResponseTest.class); - - @Test - public void test() throws Exception { - // deserialize json and verify fields are populated properly - String json = new String(Files.readAllBytes( - new File("src/test/resources/org/onap/policy/aai/AaiGetVnfResponse.json").toPath())); - - AaiGetVnfResponse resp = Serialization.gsonPretty.fromJson(json, AaiGetVnfResponse.class); - - assertEquals("807a3f02-f878-436b-870c-f0e91e81570d", resp.getVnfId()); - assertEquals("vLoadBalancerMS-Vnf-0809-2", resp.getVnfName()); - assertEquals("vLoadBalancerMS/vLoadBalancerMS 0", resp.getVnfType()); - assertEquals("1533850960381", resp.getResourceVersion()); - assertFalse(resp.isInMaint()); - assertTrue(resp.isClosedLoopDisabled()); - assertEquals("53638a85-361a-437d-8830-4b0d5329225e", resp.getModelInvariantId()); - assertEquals("PROV", resp.getProvStatus()); - assertEquals("Active", resp.getOrchestrationStatus()); - assertEquals("50e1b0be-e0c9-48e2-9f42-15279a783ee8", resp.getServiceId()); - - // don't need to verify this in depth, as it has its own tests that do that - RelationshipList relationshipList = resp.getRelationshipList(); - assertNotNull(relationshipList); - - List<Relationship> lst = relationshipList.getRelationships(); - assertNotNull(lst); - - assertEquals(5, lst.size()); - assertEquals("service-instance", lst.get(0).getRelatedTo()); - assertEquals("line-of-business", lst.get(1).getRelatedTo()); - - logger.info(Serialization.gsonPretty.toJson(resp)); - - // verify that setXxx methods work - relationshipList = new RelationshipList(); - - resp.setInMaint(true); - resp.setClosedLoopDisabled(false); - resp.setModelInvariantId("modiv"); - resp.setOrchestrationStatus("orch"); - resp.setProvStatus("mystatus"); - resp.setRelationshipList(relationshipList); - resp.setResourceVersion("vers"); - resp.setServiceId("svc"); - resp.setVnfId("vnfid"); - resp.setVnfName("vnfname"); - resp.setVnfType("vnftype"); - - assertEquals("vnfid", resp.getVnfId()); - assertEquals("vnfname", resp.getVnfName()); - assertEquals("vnftype", resp.getVnfType()); - assertEquals("vers", resp.getResourceVersion()); - assertTrue(resp.isInMaint()); - assertFalse(resp.isClosedLoopDisabled()); - assertEquals("modiv", resp.getModelInvariantId()); - assertEquals("mystatus", resp.getProvStatus()); - assertEquals("orch", resp.getOrchestrationStatus()); - assertEquals("svc", resp.getServiceId()); - assertEquals(relationshipList, resp.getRelationshipList()); - - - // test error case - json = new String(Files.readAllBytes( - new File("src/test/resources/org/onap/policy/aai/AaiGetResponseError.json").toPath())); - resp = Serialization.gsonPretty.fromJson(json, AaiGetVnfResponse.class); - - // don't need to verify this in depth, as it has its own tests that do that - assertNotNull(resp.getRequestError()); - assertNotNull(resp.getRequestError().getServiceExcept()); - assertEquals("SVC3001", resp.getRequestError().getServiceExcept().getMessageId()); - } -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVserverResponseTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVserverResponseTest.java deleted file mode 100644 index 6f063ecf9..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVserverResponseTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.File; -import java.nio.file.Files; -import java.util.LinkedList; -import java.util.List; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiGetVserverResponseTest { - private static final Logger logger = LoggerFactory.getLogger(AaiGetVserverResponseTest.class); - - @Test - public void test() throws Exception { - // deserialize json and verify fields are populated properly - String json = new String(Files.readAllBytes( - new File("src/test/resources/org/onap/policy/aai/AaiGetVserverResponse.json").toPath())); - - AaiGetVserverResponse resp = Serialization.gsonPretty.fromJson(json, AaiGetVserverResponse.class); - - // don't need to verify this in depth, as it has its own tests that do that - List<AaiNqVServer> lst = resp.getVserver(); - assertEquals(1, lst.size()); - - AaiNqVServer svr = lst.get(0); - assertNotNull(svr); - assertEquals("1c94da3f-16f1-4fc7-9ed1-e018dfa62774", svr.getVserverId()); - - logger.info(Serialization.gsonPretty.toJson(resp)); - - // verify that setXxx methods work - lst = new LinkedList<>(); - lst.add(new AaiNqVServer()); - lst.add(new AaiNqVServer()); - - resp.setVserver(lst); - - assertEquals(lst, resp.getVserver()); - - - // test error case - json = new String(Files.readAllBytes( - new File("src/test/resources/org/onap/policy/aai/AaiGetResponseError.json").toPath())); - resp = Serialization.gsonPretty.fromJson(json, AaiGetVserverResponse.class); - - // don't need to verify this in depth, as it has its own tests that do that - assertNotNull(resp.getRequestError()); - assertNotNull(resp.getRequestError().getServiceExcept()); - assertEquals("SVC3001", resp.getRequestError().getServiceExcept().getMessageId()); - } - -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java index ff86577b9..8a007fb4a 100644 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java +++ b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java @@ -28,7 +28,6 @@ import static org.mockito.ArgumentMatchers.anyMap; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.contains; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.ArgumentMatchers.startsWith; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -40,26 +39,19 @@ import java.util.Map; import java.util.UUID; import org.junit.Before; import org.junit.Test; -import org.onap.policy.aai.util.Serialization; import org.onap.policy.rest.RestManager; import org.onap.policy.rest.RestManager.Pair; public class AaiManagerTest { - private static final String VSERVER_NAME = "vserverName"; private static final String CQ_QUERY_URL = "http://testing.cq.query"; - private static final String WITCH = "Witch"; private static final String DOROTHY = "Dorothy"; private static final String SOME_URL = "http://somewhere.over.the.rainbow"; - private static final String ANOTHER_URL = "http://somewhere.under.the.rainbow"; private static final String TENANT_RESPONSE_SAMPLE = "src/test/resources/org/onap/policy/aai/AaiTenantResponse.json"; private RestManager restManagerMock; - private UUID aaiNqRequestUuid = UUID.randomUUID(); - private Pair<Integer, String> httpResponseOk; private Pair<Integer, String> httpResponseErr0; private Pair<Integer, String> httpResponseErr1; - private Pair<Integer, String> httpResponseWait; private Pair<Integer, String> httpTenantResponseOk; private Pair<Integer, String> httpCqResponseOk; @@ -76,11 +68,8 @@ public class AaiManagerTest { String tenantResponse = this.getTenantQueryResponse(); httpCqResponseOk = restManagerMock.new Pair<>(200, aaiCqResponse); httpTenantResponseOk = restManagerMock.new Pair<>(200, tenantResponse); - AaiNqResponse aaiNqResponse = new AaiNqResponseTest().getAaiNqResponse(); - httpResponseOk = restManagerMock.new Pair<>(200, Serialization.gsonPretty.toJson(aaiNqResponse)); httpResponseErr0 = restManagerMock.new Pair<>(200, null); httpResponseErr1 = restManagerMock.new Pair<>(200, "{"); - httpResponseWait = restManagerMock.new Pair<>(503, null); } @@ -130,105 +119,6 @@ public class AaiManagerTest { return responseString; } - @Test - public void testAaiManagerAaiNqRequest() { - - AaiManager aaiManager = new AaiManager(restManagerMock); - assertNotNull(aaiManager); - - UUID aaiNqUuid = UUID.randomUUID(); - - AaiNqQueryParameters aaiNqQueryParameters = new AaiNqQueryParameters(); - AaiNqNamedQuery aaiNqNamedQuery = new AaiNqNamedQuery(); - aaiNqNamedQuery.setNamedQueryUuid(aaiNqUuid); - aaiNqQueryParameters.setNamedQuery(aaiNqNamedQuery); - - AaiNqRequest aaiNqRequest = new AaiNqRequest(); - aaiNqRequest.setQueryParameters(aaiNqQueryParameters); - - when(restManagerMock.post(startsWith(SOME_URL), eq(DOROTHY), eq("Gale"), anyMap(), - anyString(), anyString())).thenReturn(httpResponseOk); - - AaiNqResponse aaiNqOkResponse = aaiManager.postQuery(SOME_URL, DOROTHY, "Gale", - aaiNqRequest, aaiNqRequestUuid); - assertNotNull(aaiNqOkResponse); - - when(restManagerMock.post(isNull(), eq(DOROTHY), anyString(), anyMap(), anyString(), anyString())) - .thenReturn(null); - - AaiNqResponse aaiNqNullResponse = aaiManager.postQuery(null, DOROTHY, "Gale", null, aaiNqRequestUuid); - assertNull(aaiNqNullResponse); - - when(restManagerMock.post(startsWith(SOME_URL), eq(WITCH), eq("West"), anyMap(), - anyString(), anyString())).thenReturn(httpResponseErr0); - - AaiNqResponse aaiNqNotOkResponse0 = aaiManager.postQuery(SOME_URL, WITCH, "West", - aaiNqRequest, aaiNqRequestUuid); - assertNull(aaiNqNotOkResponse0); - - when(restManagerMock.post(startsWith(ANOTHER_URL), eq(WITCH), eq("West"), anyMap(), - anyString(), anyString())).thenReturn(httpResponseErr1); - - AaiNqResponse aaiNqNotOkResponse1 = aaiManager.postQuery(ANOTHER_URL, WITCH, "West", - aaiNqRequest, aaiNqRequestUuid); - assertNull(aaiNqNotOkResponse1); - } - - @Test - public void testAaiManagerQueryByVserverName() { - AaiManager aaiManager = new AaiManager(restManagerMock); - assertNotNull(aaiManager); - - UUID vserverNameRequestId = UUID.randomUUID(); - - when(restManagerMock.get(startsWith(SOME_URL), eq(DOROTHY), eq("Gale"), anyMap())) - .thenReturn(httpResponseOk); - - AaiGetVserverResponse vserverResponse = aaiManager.getQueryByVserverName(SOME_URL, - DOROTHY, "Gale", vserverNameRequestId, VSERVER_NAME); - assertNotNull(vserverResponse); - - AaiGetVserverResponse vserverNullResponse = - aaiManager.getQueryByVserverName(null, DOROTHY, "Gale", vserverNameRequestId, VSERVER_NAME); - assertNull(vserverNullResponse); - - when(restManagerMock.get(startsWith(ANOTHER_URL), eq(WITCH), eq("West"), anyMap())) - .thenReturn(httpResponseErr0); - - AaiGetVserverResponse vserverNotOkResponse0 = aaiManager.getQueryByVserverName( - ANOTHER_URL, WITCH, "West", vserverNameRequestId, VSERVER_NAME); - assertNull(vserverNotOkResponse0); - } - - @Test - public void testAaiManagerQueryByVnfId() { - AaiManager aaiManager = new AaiManager(restManagerMock); - assertNotNull(aaiManager); - - UUID vserverNameRequestId = UUID.randomUUID(); - - when(restManagerMock.get(startsWith(SOME_URL), eq(DOROTHY), eq("Gale"), anyMap())) - .thenReturn(httpResponseOk); - - AaiGetVnfResponse vnfResponse = aaiManager.getQueryByVnfId(SOME_URL, DOROTHY, - "Gale", vserverNameRequestId, "vnfID"); - assertNotNull(vnfResponse); - } - - @Test - public void testAaiManagerQueryByVnfName() { - AaiManager aaiManager = new AaiManager(restManagerMock); - assertNotNull(aaiManager); - - UUID vserverNameRequestId = UUID.randomUUID(); - - when(restManagerMock.get(startsWith(SOME_URL), eq(DOROTHY), eq("Gale"), anyMap())) - .thenReturn(httpResponseOk); - - AaiGetVnfResponse vnfResponse = aaiManager.getQueryByVnfId(SOME_URL, DOROTHY, - "Gale", vserverNameRequestId, "vnfName"); - assertNotNull(vnfResponse); - } @Test public void testAaiManagerGetPnf() { diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqCloudRegionTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqCloudRegionTest.java deleted file mode 100644 index 9bdc758ed..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqCloudRegionTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class AaiNqCloudRegionTest { - - @Test - public void test() { - AaiNqCloudRegion aaiNqCloudRegion = new AaiNqCloudRegion(); - aaiNqCloudRegion.setCloudOwner("Rackspace"); - aaiNqCloudRegion.setCloudRegionId("DFW"); - aaiNqCloudRegion.setCloudRegionVersion("v1"); - aaiNqCloudRegion.setComplexName("SharedNode"); - aaiNqCloudRegion.setResourceVersion("1504789196021"); - assertNotNull(aaiNqCloudRegion); - assertEquals("Rackspace", aaiNqCloudRegion.getCloudOwner()); - assertEquals("DFW", aaiNqCloudRegion.getCloudRegionId()); - assertEquals("v1", aaiNqCloudRegion.getCloudRegionVersion()); - assertEquals("SharedNode", aaiNqCloudRegion.getComplexName()); - assertEquals("1504789196021", aaiNqCloudRegion.getResourceVersion()); - } -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertiesTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertiesTest.java deleted file mode 100644 index ed76f8a12..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertiesTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class AaiNqExtraPropertiesTest { - - @Test - public void test() { - AaiNqExtraProperties aaiNqExtraProperties = new AaiNqExtraProperties(); - aaiNqExtraProperties.getExtraProperty().add(new AaiNqExtraProperty("model.model-name", "service-instance")); - aaiNqExtraProperties.getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); - aaiNqExtraProperties.getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); - aaiNqExtraProperties.getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4")); - aaiNqExtraProperties.getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9")); - assertNotNull(aaiNqExtraProperties); - } - -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertyTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertyTest.java deleted file mode 100644 index 483753679..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertyTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class AaiNqExtraPropertyTest { - - @Test - public void test() { - AaiNqExtraProperty aaiNqExtraProperty = new AaiNqExtraProperty(); - aaiNqExtraProperty.setPropertyName("model.model-name"); - aaiNqExtraProperty.setPropertyValue("service-instance"); - assertNotNull(aaiNqExtraProperty); - - assertEquals("model.model-name", aaiNqExtraProperty.getPropertyName()); - assertEquals("service-instance", aaiNqExtraProperty.getPropertyValue()); - } -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqGenericVnfTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqGenericVnfTest.java deleted file mode 100644 index 93119c73e..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqGenericVnfTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class AaiNqGenericVnfTest { - - private static final String VERSION_ID = "98f410f6-4c63-447b-97d2-42508437cec0"; - private static final String INVARIANT_ID = "653d2caa-7e47-4614-95b3-26c8d82755b8"; - - @Test - public void test() { - AaiNqGenericVnf aaiNqGenericVnf = new AaiNqGenericVnf(); - aaiNqGenericVnf.setEncrypedAccessFlag(true); - aaiNqGenericVnf.setInMaint(false); - aaiNqGenericVnf.setIpv4Loopback0Address("aa"); - aaiNqGenericVnf.setIpv4OamAddress("oamAddress"); - aaiNqGenericVnf.setIsClosedLoopDisabled(false); - aaiNqGenericVnf.setModelInvariantId(INVARIANT_ID); - aaiNqGenericVnf.setModelVersionId(VERSION_ID); - aaiNqGenericVnf.setModelCustomizationId("SomeCustomizationId"); - aaiNqGenericVnf.setOperationalState("active"); - aaiNqGenericVnf.setPersonaModelId(INVARIANT_ID); - aaiNqGenericVnf.setPersonaModelVersion(VERSION_ID); - aaiNqGenericVnf.setProvStatus("complete"); - aaiNqGenericVnf.setResourceVersion("1505056714553"); - aaiNqGenericVnf.setServiceId("e8cb8968-5411-478b-906a-f28747de72cd"); - aaiNqGenericVnf.setVnfId("ed8b2bce-6b27-4089-992c-4a2c66024bcd"); - aaiNqGenericVnf.setVnfName("vCPEInfraVNF14a"); - aaiNqGenericVnf.setVnfName2("malumabb12"); - aaiNqGenericVnf.setVnfType("vCPEInfraService10/vCPEInfraService10 0"); - assertNotNull(aaiNqGenericVnf); - - assertEquals(true, aaiNqGenericVnf.getEncrypedAccessFlag()); - assertEquals(false, aaiNqGenericVnf.getInMaint()); - assertEquals("aa", aaiNqGenericVnf.getIpv4Loopback0Address()); - assertEquals("oamAddress", aaiNqGenericVnf.getIpv4OamAddress()); - assertEquals(false, aaiNqGenericVnf.getIsClosedLoopDisabled()); - assertEquals(INVARIANT_ID, aaiNqGenericVnf.getModelInvariantId()); - assertEquals(VERSION_ID, aaiNqGenericVnf.getModelVersionId()); - assertEquals("SomeCustomizationId", aaiNqGenericVnf.getModelCustomizationId()); - assertEquals("active", aaiNqGenericVnf.getOperationalState()); - assertEquals(INVARIANT_ID, aaiNqGenericVnf.getPersonaModelId()); - assertEquals(VERSION_ID, aaiNqGenericVnf.getPersonaModelVersion()); - assertEquals("complete", aaiNqGenericVnf.getProvStatus()); - assertEquals("1505056714553", aaiNqGenericVnf.getResourceVersion()); - assertEquals("e8cb8968-5411-478b-906a-f28747de72cd", aaiNqGenericVnf.getServiceId()); - assertEquals("ed8b2bce-6b27-4089-992c-4a2c66024bcd", aaiNqGenericVnf.getVnfId()); - assertEquals("vCPEInfraVNF14a", aaiNqGenericVnf.getVnfName()); - assertEquals("malumabb12", aaiNqGenericVnf.getVnfName2()); - assertEquals("vCPEInfraService10/vCPEInfraService10 0", aaiNqGenericVnf.getVnfType()); - } - -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInstanceFiltersTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInstanceFiltersTest.java deleted file mode 100644 index 4b4cc6a6a..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInstanceFiltersTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class AaiNqInstanceFiltersTest { - - @Test - public void test() { - AaiNqInstanceFilters aaiNqInstanceFilters = new AaiNqInstanceFilters(); - assertNotNull(aaiNqInstanceFilters); - - aaiNqInstanceFilters.setInstanceFilter(aaiNqInstanceFilters.getInstanceFilter());; - assertNotNull(aaiNqInstanceFilters); - assertNotNull(aaiNqInstanceFilters.getInstanceFilter()); - } - -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemTest.java deleted file mode 100644 index 79f23b629..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemTest.java +++ /dev/null @@ -1,171 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertNotNull; - -import java.util.LinkedList; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiNqInventoryResponseItemTest { - private static final String WIDGET = "widget"; - private static final String SERVICE_INSTANCE = "service-instance"; - private static final String MODEL_VERSION_KEY = "model.model-version"; - private static final String MODEL_TYPE_KEY = "model.model-type"; - private static final String MODEL_NAME_KEY = "model.model-name"; - private static final String MODEL_ID_KEY = "model.model-id"; - private static final String PERSONA_MODEL_ID2 = "ef86f9c5-2165-44f3-8fc3-96018b609ea5"; - private static final String PERSONA_MODEL_ID = "82194af1-3c2c-485a-8f44-420e22a9eaa4"; - private static final String RESOURCE_VERSION = "1485366450"; - private static final Logger logger = LoggerFactory.getLogger(AaiNqInventoryResponseItemTest.class); - - @Test - public void test() { - AaiNqInventoryResponseItem aaiNqInventoryResponseItem = new AaiNqInventoryResponseItem(); - aaiNqInventoryResponseItem.setModelName(SERVICE_INSTANCE); - AaiNqCloudRegion aaiNqCloudRegion = new AaiNqCloudRegion(); - aaiNqCloudRegion.setCloudOwner("OWNER"); - aaiNqCloudRegion.setCloudRegionId("REGIONID"); - aaiNqCloudRegion.setCloudRegionVersion("2.5"); - aaiNqCloudRegion.setComplexName("COMPLEXNAME"); - aaiNqCloudRegion.setResourceVersion("1485365988"); - aaiNqInventoryResponseItem.setCloudRegion(aaiNqCloudRegion); - AaiNqExtraProperties aaiNqExtraProperties = new AaiNqExtraProperties(); - aaiNqExtraProperties.setExtraProperty(new LinkedList<>()); - aaiNqExtraProperties.getExtraProperty().add(new AaiNqExtraProperty(MODEL_NAME_KEY, "generic-vnf")); - aaiNqExtraProperties.getExtraProperty().add(new AaiNqExtraProperty(MODEL_TYPE_KEY, WIDGET)); - aaiNqExtraProperties.getExtraProperty().add(new AaiNqExtraProperty(MODEL_VERSION_KEY, "1.0")); - aaiNqExtraProperties.getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_ID_KEY, "acc6edd8-a8d4-4b93-afaa-0994068be14c")); - aaiNqExtraProperties.getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name-version-id", "93a6166f-b3d5-4f06-b4ba-aed48d009ad9")); - aaiNqInventoryResponseItem.setExtraProperties(aaiNqExtraProperties); - AaiNqGenericVnf aaiNqGenericVnf = new AaiNqGenericVnf(); - aaiNqGenericVnf.setVnfId("dhv-test-gvnf"); - aaiNqGenericVnf.setVnfName("dhv-test-gvnf-name"); - aaiNqGenericVnf.setVnfName2("dhv-test-gvnf-name2"); - aaiNqGenericVnf.setVnfType("SW"); - aaiNqGenericVnf.setServiceId("d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4"); - aaiNqGenericVnf.setProvStatus("PREPROV"); - aaiNqGenericVnf.setOperationalState("dhv-test-operational-state"); - aaiNqGenericVnf.setIpv4OamAddress("dhv-test-gvnf-ipv4-oam-address"); - aaiNqGenericVnf.setIpv4Loopback0Address("dhv-test-gvnfipv4-loopback0-address"); - aaiNqGenericVnf.setInMaint(false); - aaiNqGenericVnf.setIsClosedLoopDisabled(false); - aaiNqGenericVnf.setResourceVersion(RESOURCE_VERSION); - aaiNqGenericVnf.setEncrypedAccessFlag(true); - aaiNqGenericVnf.setPersonaModelId("acc6edd8-a8d4-4b93-afaa-0994068be14c"); - aaiNqGenericVnf.setPersonaModelVersion("1.0"); - aaiNqInventoryResponseItem.setGenericVnf(aaiNqGenericVnf); - AaiNqInventoryResponseItem serviceItem = new AaiNqInventoryResponseItem(); - serviceItem.setModelName(SERVICE_INSTANCE); - serviceItem.setServiceInstance(new AaiNqServiceInstance()); - serviceItem.getServiceInstance().setServiceInstanceId("dhv-test-vhnfportal-service-instance-id"); - serviceItem.getServiceInstance().setServiceInstanceName("dhv-test-service-instance-name1"); - serviceItem.getServiceInstance().setPersonaModelId(PERSONA_MODEL_ID); - serviceItem.getServiceInstance().setPersonaModelVersion("1.0"); - serviceItem.getServiceInstance().setServiceInstanceLocationId("dhv-test-service-instance-location-id1"); - serviceItem.getServiceInstance().setResourceVersion("1485366092"); - serviceItem.setExtraProperties(new AaiNqExtraProperties()); - serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_NAME_KEY, SERVICE_INSTANCE)); - serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_TYPE_KEY, WIDGET)); - serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_VERSION_KEY, "1.0")); - serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_ID_KEY, PERSONA_MODEL_ID)); - serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "46b92144-923a-4d20-b85a-3cbd847668a9")); - - AaiNqInventoryResponseItem vfModuleItem = new AaiNqInventoryResponseItem(); - vfModuleItem.setModelName("vf-module"); - vfModuleItem.setVfModule(new AaiNqVfModule()); - vfModuleItem.getVfModule().setVfModuleId("example-vf-module-id-val-49261"); - vfModuleItem.getVfModule().setVfModuleName("example-vf-module-name-val-73074"); - vfModuleItem.getVfModule().setHeatStackId("example-heat-stack-id-val-86300"); - vfModuleItem.getVfModule().setOrchestrationStatus("example-orchestration-status-val-56523"); - vfModuleItem.getVfModule().setIsBaseVfModule(true); - vfModuleItem.getVfModule().setResourceVersion(RESOURCE_VERSION); - vfModuleItem.getVfModule().setPersonaModelId(PERSONA_MODEL_ID2); - vfModuleItem.getVfModule().setPersonaModelVersion("1.0"); - vfModuleItem.getVfModule().setWidgetModelId("example-widget-model-id-val-92571"); - vfModuleItem.getVfModule().setWidgetModelVersion("example-widget-model-version-val-83317"); - vfModuleItem.getVfModule().setContrailServiceInstanceFqdn("example-contrail-service-instance-fqdn-val-86796"); - vfModuleItem.setExtraProperties(new AaiNqExtraProperties()); - vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "vf-module")); - vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_TYPE_KEY, WIDGET)); - vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_VERSION_KEY, "1.0")); - vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_ID_KEY, PERSONA_MODEL_ID2)); - vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "c00563ae-812b-4e62-8330-7c4d0f47088a")); - - AaiNqInventoryResponseItems aaiNqInventoryResponseItems = new AaiNqInventoryResponseItems(); - aaiNqInventoryResponseItems.getInventoryResponseItems().add(serviceItem); - aaiNqInventoryResponseItems.getInventoryResponseItems().add(vfModuleItem); - aaiNqInventoryResponseItem.setItems(aaiNqInventoryResponseItems); - aaiNqInventoryResponseItem.setModelName("model-name"); - AaiNqServiceInstance serviceInstance = new AaiNqServiceInstance(); - serviceInstance.setServiceInstanceId("dhv-test-vhnfportal-service-instance-id"); - serviceInstance.setServiceInstanceName("dhv-test-service-instance-name1"); - serviceInstance.setPersonaModelId(PERSONA_MODEL_ID); - serviceInstance.setPersonaModelVersion("1.0"); - serviceInstance.setServiceInstanceLocationId("dhv-test-service-instance-location-id1"); - serviceInstance.setResourceVersion("1485366092"); - aaiNqInventoryResponseItem.setServiceInstance(serviceInstance); - AaiNqTenant aaiNqTenant = new AaiNqTenant(); - aaiNqTenant.setTenantId("dhv-test-tenant"); - aaiNqTenant.setTenantName("dhv-test-tenant-name"); - aaiNqTenant.setResourceVersion("1485366334"); - aaiNqInventoryResponseItem.setTenant(aaiNqTenant); - AaiNqVfModule aaiNqVfModule = new AaiNqVfModule(); - aaiNqVfModule.setVfModuleId("example-vf-module-id-val-49261"); - aaiNqVfModule.setVfModuleName("example-vf-module-name-val-73074"); - aaiNqVfModule.setHeatStackId("example-heat-stack-id-val-86300"); - aaiNqVfModule.setOrchestrationStatus("example-orchestration-status-val-56523"); - aaiNqVfModule.setIsBaseVfModule(true); - aaiNqVfModule.setResourceVersion(RESOURCE_VERSION); - aaiNqVfModule.setPersonaModelId(PERSONA_MODEL_ID2); - aaiNqVfModule.setPersonaModelVersion("1.0"); - aaiNqVfModule.setWidgetModelId("example-widget-model-id-val-92571"); - aaiNqVfModule.setWidgetModelVersion("example-widget-model-version-val-83317"); - aaiNqVfModule.setContrailServiceInstanceFqdn("example-contrail-service-instance-fqdn-val-86796"); - aaiNqInventoryResponseItem.setVfModule(aaiNqVfModule); - AaiNqVServer aaiNqVServer = new AaiNqVServer(); - aaiNqVServer.setVserverId("dhv-test-vserver"); - aaiNqVServer.setVserverName("dhv-test-vserver-name"); - aaiNqVServer.setVserverName2("dhv-test-vserver-name2"); - aaiNqVServer.setProvStatus("PREPROV"); - aaiNqVServer.setVserverSelflink("dhv-test-vserver-selflink"); - aaiNqVServer.setInMaint(false); - aaiNqVServer.setIsClosedLoopDisabled(false); - aaiNqVServer.setResourceVersion("1485366417"); - aaiNqInventoryResponseItem.setVserver(aaiNqVServer); - assertNotNull(aaiNqInventoryResponseItem); - - logger.info(Serialization.gsonPretty.toJson(aaiNqInventoryResponseItem)); - } - -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemsTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemsTest.java deleted file mode 100644 index ef1dd4e09..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemsTest.java +++ /dev/null @@ -1,161 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.LinkedList; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiNqInventoryResponseItemsTest { - private static final String WIDGET = "widget"; - private static final String SERVICE_INSTANCE = "service-instance"; - private static final String MODEL_VERSION_KEY = "model.model-version"; - private static final String MODEL_TYPE_KEY = "model.model-type"; - private static final String MODEL_NAME_KEY = "model.model-name"; - private static final String MODEL_ID_KEY = "model.model-id"; - private static final Logger logger = LoggerFactory.getLogger(AaiNqInventoryResponseItemsTest.class); - - @Test - public void test() { - AaiNqInventoryResponseItem serviceItem = new AaiNqInventoryResponseItem(); - serviceItem.setModelName(SERVICE_INSTANCE); - assertEquals(SERVICE_INSTANCE, serviceItem.getModelName()); - - serviceItem.setServiceInstance(new AaiNqServiceInstance()); - serviceItem.getServiceInstance().setServiceInstanceId("dhv-test-vhnfportal-service-instance-id"); - serviceItem.getServiceInstance().setServiceInstanceName("dhv-test-service-instance-name1"); - serviceItem.getServiceInstance().setPersonaModelId("82194af1-3c2c-485a-8f44-420e22a9eaa4"); - serviceItem.getServiceInstance().setPersonaModelVersion("1.0"); - serviceItem.getServiceInstance().setServiceInstanceLocationId("dhv-test-service-instance-location-id1"); - serviceItem.getServiceInstance().setResourceVersion("1485366092"); - serviceItem.setExtraProperties(new AaiNqExtraProperties()); - serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_NAME_KEY, SERVICE_INSTANCE)); - serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_TYPE_KEY, WIDGET)); - serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_VERSION_KEY, "1.0")); - serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_ID_KEY, "82194af1-3c2c-485a-8f44-420e22a9eaa4")); - serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "46b92144-923a-4d20-b85a-3cbd847668a9")); - - AaiNqInventoryResponseItem vfModuleItem = new AaiNqInventoryResponseItem(); - vfModuleItem.setModelName("vf-module"); - vfModuleItem.setVfModule(new AaiNqVfModule()); - vfModuleItem.getVfModule().setVfModuleId("example-vf-module-id-val-49261"); - vfModuleItem.getVfModule().setVfModuleName("example-vf-module-name-val-73074"); - vfModuleItem.getVfModule().setHeatStackId("example-heat-stack-id-val-86300"); - vfModuleItem.getVfModule().setOrchestrationStatus("example-orchestration-status-val-56523"); - vfModuleItem.getVfModule().setIsBaseVfModule(true); - vfModuleItem.getVfModule().setResourceVersion("1485366450"); - vfModuleItem.getVfModule().setPersonaModelId("ef86f9c5-2165-44f3-8fc3-96018b609ea5"); - vfModuleItem.getVfModule().setPersonaModelVersion("1.0"); - vfModuleItem.getVfModule().setWidgetModelId("example-widget-model-id-val-92571"); - vfModuleItem.getVfModule().setWidgetModelVersion("example-widget-model-version-val-83317"); - vfModuleItem.getVfModule().setContrailServiceInstanceFqdn("example-contrail-service-instance-fqdn-val-86796"); - vfModuleItem.setExtraProperties(new AaiNqExtraProperties()); - vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "vf-module")); - vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_TYPE_KEY, WIDGET)); - vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_VERSION_KEY, "1.0")); - vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_ID_KEY, "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); - vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "c00563ae-812b-4e62-8330-7c4d0f47088a")); - - AaiNqInventoryResponseItem genericVnfItem = new AaiNqInventoryResponseItem(); - genericVnfItem.setModelName("generic-vnf"); - genericVnfItem.setGenericVnf(new AaiNqGenericVnf()); - genericVnfItem.getGenericVnf().setVnfId("dhv-test-gvnf"); - genericVnfItem.getGenericVnf().setVnfName("dhv-test-gvnf-name"); - genericVnfItem.getGenericVnf().setVnfName2("dhv-test-gvnf-name2"); - genericVnfItem.getGenericVnf().setVnfType("SW"); - genericVnfItem.getGenericVnf().setServiceId("d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4"); - genericVnfItem.getGenericVnf().setProvStatus("PREPROV"); - genericVnfItem.getGenericVnf().setOperationalState("dhv-test-operational-state"); - genericVnfItem.getGenericVnf().setIpv4OamAddress("dhv-test-gvnf-ipv4-oam-address"); - genericVnfItem.getGenericVnf().setIpv4Loopback0Address("dhv-test-gvnfipv4-loopback0-address"); - genericVnfItem.getGenericVnf().setInMaint(false); - genericVnfItem.getGenericVnf().setIsClosedLoopDisabled(false); - genericVnfItem.getGenericVnf().setResourceVersion("1485366450"); - genericVnfItem.getGenericVnf().setEncrypedAccessFlag(true); - genericVnfItem.getGenericVnf().setPersonaModelId("acc6edd8-a8d4-4b93-afaa-0994068be14c"); - genericVnfItem.getGenericVnf().setPersonaModelVersion("1.0"); - genericVnfItem.setExtraProperties(new AaiNqExtraProperties()); - genericVnfItem.getExtraProperties().setExtraProperty(new LinkedList<>()); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "generic-vnf")); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_TYPE_KEY, WIDGET)); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_VERSION_KEY, "1.0")); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_ID_KEY, "acc6edd8-a8d4-4b93-afaa-0994068be14c")); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name-version-id", "93a6166f-b3d5-4f06-b4ba-aed48d009ad9")); - genericVnfItem.setItems(new AaiNqInventoryResponseItems()); - genericVnfItem.getItems().setInventoryResponseItems(new LinkedList<>()); - genericVnfItem.getItems().getInventoryResponseItems().add(serviceItem); - genericVnfItem.getItems().getInventoryResponseItems().add(vfModuleItem); - - AaiNqInventoryResponseItem cloudItem = new AaiNqInventoryResponseItem(); - cloudItem.setCloudRegion(new AaiNqCloudRegion()); - cloudItem.getCloudRegion().setCloudOwner("OWNER"); - cloudItem.getCloudRegion().setCloudRegionId("REGIONID"); - cloudItem.getCloudRegion().setCloudRegionVersion("2.5"); - cloudItem.getCloudRegion().setComplexName("COMPLEXNAME"); - cloudItem.getCloudRegion().setResourceVersion("1485365988"); - - AaiNqInventoryResponseItem tenantItem = new AaiNqInventoryResponseItem(); - tenantItem.setTenant(new AaiNqTenant()); - tenantItem.getTenant().setTenantId("dhv-test-tenant"); - tenantItem.getTenant().setTenantName("dhv-test-tenant-name"); - tenantItem.getTenant().setResourceVersion("1485366334"); - tenantItem.setItems(new AaiNqInventoryResponseItems()); - tenantItem.getItems().setInventoryResponseItems(new LinkedList<>()); - tenantItem.getItems().getInventoryResponseItems().add(cloudItem); - AaiNqInventoryResponseItem vserverItem = new AaiNqInventoryResponseItem(); - vserverItem.setVserver(new AaiNqVServer()); - vserverItem.getVserver().setVserverId("dhv-test-vserver"); - vserverItem.getVserver().setVserverName("dhv-test-vserver-name"); - vserverItem.getVserver().setVserverName2("dhv-test-vserver-name2"); - vserverItem.getVserver().setProvStatus("PREPROV"); - vserverItem.getVserver().setVserverSelflink("dhv-test-vserver-selflink"); - vserverItem.getVserver().setInMaint(false); - vserverItem.getVserver().setIsClosedLoopDisabled(false); - vserverItem.getVserver().setResourceVersion("1485366417"); - vserverItem.setItems(new AaiNqInventoryResponseItems()); - vserverItem.getItems().setInventoryResponseItems(new LinkedList<>()); - vserverItem.getItems().getInventoryResponseItems().add(genericVnfItem); - vserverItem.getItems().getInventoryResponseItems().add(tenantItem); - - AaiNqInventoryResponseItems aaiNqInventoryResponseItems = new AaiNqInventoryResponseItems(); - aaiNqInventoryResponseItems.getInventoryResponseItems().add(vserverItem); - assertNotNull(aaiNqInventoryResponseItems); - logger.info(Serialization.gsonPretty.toJson(aaiNqInventoryResponseItems)); - } - -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqNamedQueryTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqNamedQueryTest.java deleted file mode 100644 index a4344d8e6..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqNamedQueryTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= -*/ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.UUID; -import org.junit.Test; - -public class AaiNqNamedQueryTest { - - @Test - public void test() { - AaiNqNamedQuery aaiNqNamedQuery = new AaiNqNamedQuery(); - UUID uuid = UUID.randomUUID(); - aaiNqNamedQuery.setNamedQueryUuid(uuid); - assertNotNull(aaiNqNamedQuery); - assertEquals(aaiNqNamedQuery.getNamedQueryUuid(), uuid); - } -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqQueryParametersTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqQueryParametersTest.java deleted file mode 100644 index f304713f9..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqQueryParametersTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= -*/ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.UUID; -import org.junit.Test; - -public class AaiNqQueryParametersTest { - - @Test - public void test() { - AaiNqQueryParameters aaiNqQueryParameters = new AaiNqQueryParameters(); - AaiNqNamedQuery aaiNqNamedQuery = new AaiNqNamedQuery(); - aaiNqNamedQuery.setNamedQueryUuid(UUID.randomUUID()); - aaiNqQueryParameters.setNamedQuery(aaiNqNamedQuery); - assertNotNull(aaiNqNamedQuery); - assertEquals(aaiNqQueryParameters.getNamedQuery(), aaiNqNamedQuery); - } - -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqRequestErrorTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqRequestErrorTest.java deleted file mode 100644 index 029cc59f3..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqRequestErrorTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import org.junit.Test; - -public class AaiNqRequestErrorTest { - - @Test - public void test() { - AaiNqRequestError aainqRequestError = new AaiNqRequestError(); - AaiNqServiceExcept serviceExcept = new AaiNqServiceExcept(); - aainqRequestError.setServiceExcept(serviceExcept); - assertEquals(aainqRequestError.getServiceExcept(), serviceExcept); - - assertNull(serviceExcept.getMessageId()); - assertNull(serviceExcept.getText()); - assertNull(serviceExcept.getVariables()); - } -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqRequestTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqRequestTest.java deleted file mode 100644 index 35108a03a..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqRequestTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= -*/ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.UUID; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiNqRequestTest { - private static final Logger logger = LoggerFactory.getLogger(AaiNqRequestTest.class); - - @Test - public void test() { - AaiNqRequest aaiNqRequest = new AaiNqRequest(); - AaiNqInstanceFilters aaiNqInstanceFilters = new AaiNqInstanceFilters(); - - aaiNqRequest.setInstanceFilters(aaiNqInstanceFilters); - assertNotNull(aaiNqRequest.getInstanceFilters()); - AaiNqNamedQuery aaiNqNamedQuery = new AaiNqNamedQuery(); - UUID uuid = UUID.randomUUID(); - aaiNqNamedQuery.setNamedQueryUuid(uuid); - - AaiNqQueryParameters aaiNqQueryParameters = new AaiNqQueryParameters(); - aaiNqQueryParameters.setNamedQuery(aaiNqNamedQuery); - aaiNqRequest.setQueryParameters(aaiNqQueryParameters); - - assertNotNull(aaiNqRequest); - - assertEquals(aaiNqNamedQuery.getNamedQueryUuid(), uuid); - assertEquals(aaiNqQueryParameters.getNamedQuery(), aaiNqNamedQuery); - assertEquals(aaiNqRequest.getQueryParameters(), aaiNqQueryParameters); - - logger.info(Serialization.gsonPretty.toJson(aaiNqRequest)); - } - -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseTest.java deleted file mode 100644 index ba160e2c7..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseTest.java +++ /dev/null @@ -1,166 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import java.util.LinkedList; - -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiNqResponseTest { - private static final String WIDGET = "widget"; - private static final String MODEL_VERSION_KEY = "model.model-version"; - private static final String MODEL_TYPE_KEY = "model.model-type"; - private static final String MODEL_NAME_KEY = "model.model-name"; - private static final String MODEL_ID_KEY = "model.model-id"; - private static final Logger logger = LoggerFactory.getLogger(AaiNqResponseTest.class); - - @Test - public void test() { - getAaiNqResponse(); - } - - /** - * Get A&AI NQ response. - * - * @return the A&AI NG response - */ - public AaiNqResponse getAaiNqResponse() { - AaiNqInventoryResponseItem serviceItem = new AaiNqInventoryResponseItem(); - serviceItem.setModelName("service-instance"); - serviceItem.setServiceInstance(new AaiNqServiceInstance()); - serviceItem.getServiceInstance().setServiceInstanceId("dhv-test-vhnfportal-service-instance-id"); - serviceItem.getServiceInstance().setServiceInstanceName("dhv-test-service-instance-name1"); - serviceItem.getServiceInstance().setPersonaModelId("82194af1-3c2c-485a-8f44-420e22a9eaa4"); - serviceItem.getServiceInstance().setPersonaModelVersion("1.0"); - serviceItem.getServiceInstance().setServiceInstanceLocationId("dhv-test-service-instance-location-id1"); - serviceItem.getServiceInstance().setResourceVersion("1485366092"); - serviceItem.setExtraProperties(new AaiNqExtraProperties()); - serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "service-instance")); - serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_TYPE_KEY, WIDGET)); - serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_VERSION_KEY, "1.0")); - serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_ID_KEY, "82194af1-3c2c-485a-8f44-420e22a9eaa4")); - serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "46b92144-923a-4d20-b85a-3cbd847668a9")); - - AaiNqInventoryResponseItem vfModuleItem = new AaiNqInventoryResponseItem(); - vfModuleItem.setModelName("vf-module"); - vfModuleItem.setVfModule(new AaiNqVfModule()); - vfModuleItem.getVfModule().setVfModuleId("example-vf-module-id-val-49261"); - vfModuleItem.getVfModule().setVfModuleName("example-vf-module-name-val-73074"); - vfModuleItem.getVfModule().setHeatStackId("example-heat-stack-id-val-86300"); - vfModuleItem.getVfModule().setOrchestrationStatus("example-orchestration-status-val-56523"); - vfModuleItem.getVfModule().setIsBaseVfModule(true); - vfModuleItem.getVfModule().setResourceVersion("1485366450"); - vfModuleItem.getVfModule().setPersonaModelId("ef86f9c5-2165-44f3-8fc3-96018b609ea5"); - vfModuleItem.getVfModule().setPersonaModelVersion("1.0"); - vfModuleItem.getVfModule().setWidgetModelId("example-widget-model-id-val-92571"); - vfModuleItem.getVfModule().setWidgetModelVersion("example-widget-model-version-val-83317"); - vfModuleItem.getVfModule().setContrailServiceInstanceFqdn("example-contrail-service-instance-fqdn-val-86796"); - vfModuleItem.setExtraProperties(new AaiNqExtraProperties()); - vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "vf-module")); - vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_TYPE_KEY, WIDGET)); - vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_VERSION_KEY, "1.0")); - vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_ID_KEY, "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); - vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "c00563ae-812b-4e62-8330-7c4d0f47088a")); - - AaiNqInventoryResponseItem genericVnfItem = new AaiNqInventoryResponseItem(); - genericVnfItem.setModelName("generic-vnf"); - genericVnfItem.setGenericVnf(new AaiNqGenericVnf()); - genericVnfItem.getGenericVnf().setVnfId("dhv-test-gvnf"); - genericVnfItem.getGenericVnf().setVnfName("dhv-test-gvnf-name"); - genericVnfItem.getGenericVnf().setVnfName2("dhv-test-gvnf-name2"); - genericVnfItem.getGenericVnf().setVnfType("SW"); - genericVnfItem.getGenericVnf().setServiceId("d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4"); - genericVnfItem.getGenericVnf().setProvStatus("PREPROV"); - genericVnfItem.getGenericVnf().setOperationalState("dhv-test-operational-state"); - genericVnfItem.getGenericVnf().setIpv4OamAddress("dhv-test-gvnf-ipv4-oam-address"); - genericVnfItem.getGenericVnf().setIpv4Loopback0Address("dhv-test-gvnfipv4-loopback0-address"); - genericVnfItem.getGenericVnf().setInMaint(false); - genericVnfItem.getGenericVnf().setIsClosedLoopDisabled(false); - genericVnfItem.getGenericVnf().setResourceVersion("1485366450"); - genericVnfItem.getGenericVnf().setEncrypedAccessFlag(true); - genericVnfItem.getGenericVnf().setPersonaModelId("acc6edd8-a8d4-4b93-afaa-0994068be14c"); - genericVnfItem.getGenericVnf().setPersonaModelVersion("1.0"); - genericVnfItem.setExtraProperties(new AaiNqExtraProperties()); - genericVnfItem.getExtraProperties().setExtraProperty(new LinkedList<>()); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "generic-vnf")); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_TYPE_KEY, WIDGET)); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_VERSION_KEY, "1.0")); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_ID_KEY, "acc6edd8-a8d4-4b93-afaa-0994068be14c")); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name-version-id", "93a6166f-b3d5-4f06-b4ba-aed48d009ad9")); - genericVnfItem.setItems(new AaiNqInventoryResponseItems()); - genericVnfItem.getItems().setInventoryResponseItems(new LinkedList<>()); - genericVnfItem.getItems().getInventoryResponseItems().add(serviceItem); - genericVnfItem.getItems().getInventoryResponseItems().add(vfModuleItem); - - AaiNqInventoryResponseItem cloudItem = new AaiNqInventoryResponseItem(); - cloudItem.setCloudRegion(new AaiNqCloudRegion()); - cloudItem.getCloudRegion().setCloudOwner("OWNER"); - cloudItem.getCloudRegion().setCloudRegionId("REGIONID"); - cloudItem.getCloudRegion().setCloudRegionVersion("2.5"); - cloudItem.getCloudRegion().setComplexName("COMPLEXNAME"); - cloudItem.getCloudRegion().setResourceVersion("1485365988"); - - AaiNqInventoryResponseItem tenantItem = new AaiNqInventoryResponseItem(); - tenantItem.setTenant(new AaiNqTenant()); - tenantItem.getTenant().setTenantId("dhv-test-tenant"); - tenantItem.getTenant().setTenantName("dhv-test-tenant-name"); - tenantItem.getTenant().setResourceVersion("1485366334"); - tenantItem.setItems(new AaiNqInventoryResponseItems()); - tenantItem.getItems().setInventoryResponseItems(new LinkedList<>()); - tenantItem.getItems().getInventoryResponseItems().add(cloudItem); - - AaiNqInventoryResponseItem vserverItem = new AaiNqInventoryResponseItem(); - vserverItem.setVserver(new AaiNqVServer()); - vserverItem.getVserver().setVserverId("dhv-test-vserver"); - vserverItem.getVserver().setVserverName("dhv-test-vserver-name"); - vserverItem.getVserver().setVserverName2("dhv-test-vserver-name2"); - vserverItem.getVserver().setProvStatus("PREPROV"); - vserverItem.getVserver().setVserverSelflink("dhv-test-vserver-selflink"); - vserverItem.getVserver().setInMaint(false); - vserverItem.getVserver().setIsClosedLoopDisabled(false); - vserverItem.getVserver().setResourceVersion("1485366417"); - vserverItem.setItems(new AaiNqInventoryResponseItems()); - vserverItem.getItems().setInventoryResponseItems(new LinkedList<>()); - vserverItem.getItems().getInventoryResponseItems().add(genericVnfItem); - vserverItem.getItems().getInventoryResponseItems().add(tenantItem); - - AaiNqResponse aaiResponse = new AaiNqResponse(); - aaiResponse.getInventoryResponseItems().add(vserverItem); - logger.info(Serialization.gsonPretty.toJson(aaiResponse)); - - return aaiResponse; - } -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseWrapperTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseWrapperTest.java deleted file mode 100644 index f80fd82bd..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseWrapperTest.java +++ /dev/null @@ -1,269 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= -*/ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.LinkedList; -import java.util.List; -import java.util.UUID; -import org.apache.commons.io.IOUtils; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiNqResponseWrapperTest { - private static final String WIDGET = "widget"; - private static final String MODEL_VERSION_KEY = "model.model-version"; - private static final String MODEL_TYPE_KEY = "model.model-type"; - private static final String MODEL_NAME_KEY = "model.model-name"; - private static final String MODEL_ID_KEY = "model.model-id"; - private static final String VERSION_JSON = "AaiNqResponseWrapper-Vserver.json"; - private static final String NO_NAMES_JSON = "AaiNqResponseWrapper-NoNames.json"; - private static final Logger logger = LoggerFactory.getLogger(AaiNqResponseWrapperTest.class); - - @Test - public void test() { - AaiNqInventoryResponseItem serviceItem = new AaiNqInventoryResponseItem(); - serviceItem.setModelName("service-instance"); - serviceItem.setServiceInstance(new AaiNqServiceInstance()); - serviceItem.getServiceInstance().setServiceInstanceId("dhv-test-vhnfportal-service-instance-id"); - serviceItem.getServiceInstance().setServiceInstanceName("dhv-test-service-instance-name1"); - serviceItem.getServiceInstance().setPersonaModelId("82194af1-3c2c-485a-8f44-420e22a9eaa4"); - serviceItem.getServiceInstance().setPersonaModelVersion("1.0"); - serviceItem.getServiceInstance().setServiceInstanceLocationId("dhv-test-service-instance-location-id1"); - serviceItem.getServiceInstance().setResourceVersion("1485366092"); - serviceItem.setExtraProperties(new AaiNqExtraProperties()); - serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "service-instance")); - serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_TYPE_KEY, WIDGET)); - serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_VERSION_KEY, "1.0")); - serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_ID_KEY, "82194af1-3c2c-485a-8f44-420e22a9eaa4")); - serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "46b92144-923a-4d20-b85a-3cbd847668a9")); - - AaiNqInventoryResponseItem vfModuleItem = new AaiNqInventoryResponseItem(); - vfModuleItem.setModelName("vf-module"); - vfModuleItem.setVfModule(new AaiNqVfModule()); - vfModuleItem.getVfModule().setVfModuleId("example-vf-module-id-val-49261"); - vfModuleItem.getVfModule().setVfModuleName("example-vf-module-name-val-73074"); - vfModuleItem.getVfModule().setHeatStackId("example-heat-stack-id-val-86300"); - vfModuleItem.getVfModule().setOrchestrationStatus("example-orchestration-status-val-56523"); - vfModuleItem.getVfModule().setIsBaseVfModule(true); - vfModuleItem.getVfModule().setResourceVersion("1485366450"); - vfModuleItem.getVfModule().setPersonaModelId("ef86f9c5-2165-44f3-8fc3-96018b609ea5"); - vfModuleItem.getVfModule().setPersonaModelVersion("1.0"); - vfModuleItem.getVfModule().setWidgetModelId("example-widget-model-id-val-92571"); - vfModuleItem.getVfModule().setWidgetModelVersion("example-widget-model-version-val-83317"); - vfModuleItem.getVfModule().setContrailServiceInstanceFqdn("example-contrail-service-instance-fqdn-val-86796"); - vfModuleItem.setExtraProperties(new AaiNqExtraProperties()); - vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "vf-module")); - vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_TYPE_KEY, WIDGET)); - vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty(MODEL_VERSION_KEY, "1.0")); - vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_ID_KEY, "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); - vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "c00563ae-812b-4e62-8330-7c4d0f47088a")); - - AaiNqInventoryResponseItem genericVnfItem = new AaiNqInventoryResponseItem(); - genericVnfItem.setModelName("generic-vnf"); - genericVnfItem.setGenericVnf(new AaiNqGenericVnf()); - genericVnfItem.getGenericVnf().setVnfId("dhv-test-gvnf"); - genericVnfItem.getGenericVnf().setVnfName("dhv-test-gvnf-name"); - genericVnfItem.getGenericVnf().setVnfName2("dhv-test-gvnf-name2"); - genericVnfItem.getGenericVnf().setVnfType("SW"); - genericVnfItem.getGenericVnf().setServiceId("d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4"); - genericVnfItem.getGenericVnf().setProvStatus("PREPROV"); - genericVnfItem.getGenericVnf().setOperationalState("dhv-test-operational-state"); - genericVnfItem.getGenericVnf().setIpv4OamAddress("dhv-test-gvnf-ipv4-oam-address"); - genericVnfItem.getGenericVnf().setIpv4Loopback0Address("dhv-test-gvnfipv4-loopback0-address"); - genericVnfItem.getGenericVnf().setInMaint(false); - genericVnfItem.getGenericVnf().setIsClosedLoopDisabled(false); - genericVnfItem.getGenericVnf().setResourceVersion("1485366450"); - genericVnfItem.getGenericVnf().setEncrypedAccessFlag(true); - genericVnfItem.getGenericVnf().setPersonaModelId("acc6edd8-a8d4-4b93-afaa-0994068be14c"); - genericVnfItem.getGenericVnf().setPersonaModelVersion("1.0"); - genericVnfItem.setExtraProperties(new AaiNqExtraProperties()); - genericVnfItem.getExtraProperties().setExtraProperty(new LinkedList<>()); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_NAME_KEY, "generic-vnf")); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_TYPE_KEY, WIDGET)); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_VERSION_KEY, "1.0")); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty(MODEL_ID_KEY, "acc6edd8-a8d4-4b93-afaa-0994068be14c")); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name-version-id", "93a6166f-b3d5-4f06-b4ba-aed48d009ad9")); - genericVnfItem.setItems(new AaiNqInventoryResponseItems()); - genericVnfItem.getItems().setInventoryResponseItems(new LinkedList<>()); - genericVnfItem.getItems().getInventoryResponseItems().add(serviceItem); - genericVnfItem.getItems().getInventoryResponseItems().add(vfModuleItem); - - AaiNqInventoryResponseItem cloudItem = new AaiNqInventoryResponseItem(); - cloudItem.setCloudRegion(new AaiNqCloudRegion()); - cloudItem.getCloudRegion().setCloudOwner("OWNER"); - cloudItem.getCloudRegion().setCloudRegionId("REGIONID"); - cloudItem.getCloudRegion().setCloudRegionVersion("2.5"); - cloudItem.getCloudRegion().setComplexName("COMPLEXNAME"); - cloudItem.getCloudRegion().setResourceVersion("1485365988"); - - AaiNqInventoryResponseItem tenantItem = new AaiNqInventoryResponseItem(); - tenantItem.setTenant(new AaiNqTenant()); - tenantItem.getTenant().setTenantId("dhv-test-tenant"); - tenantItem.getTenant().setTenantName("dhv-test-tenant-name"); - tenantItem.getTenant().setResourceVersion("1485366334"); - tenantItem.setItems(new AaiNqInventoryResponseItems()); - tenantItem.getItems().setInventoryResponseItems(new LinkedList<>()); - tenantItem.getItems().getInventoryResponseItems().add(cloudItem); - - AaiNqInventoryResponseItem vserverItem = new AaiNqInventoryResponseItem(); - vserverItem.setVserver(new AaiNqVServer()); - vserverItem.getVserver().setVserverId("dhv-test-vserver"); - vserverItem.getVserver().setVserverName("dhv-test-vserver-name"); - vserverItem.getVserver().setVserverName2("dhv-test-vserver-name2"); - vserverItem.getVserver().setProvStatus("PREPROV"); - vserverItem.getVserver().setVserverSelflink("dhv-test-vserver-selflink"); - vserverItem.getVserver().setInMaint(false); - vserverItem.getVserver().setIsClosedLoopDisabled(false); - vserverItem.getVserver().setResourceVersion("1485366417"); - vserverItem.setItems(new AaiNqInventoryResponseItems()); - vserverItem.getItems().setInventoryResponseItems(new LinkedList<>()); - vserverItem.getItems().getInventoryResponseItems().add(genericVnfItem); - vserverItem.getItems().getInventoryResponseItems().add(tenantItem); - - AaiNqResponse aaiResponse = new AaiNqResponse(); - aaiResponse.getInventoryResponseItems().add(vserverItem); - AaiNqResponseWrapper aaiNqResponseWarapper = new AaiNqResponseWrapper(); - aaiNqResponseWarapper.setAaiNqResponse(aaiResponse); - aaiNqResponseWarapper.setRequestId(UUID.randomUUID()); - assertNotNull(aaiNqResponseWarapper); - logger.info(Serialization.gsonPretty.toJson(aaiNqResponseWarapper)); - - AaiNqResponse aaiResponse2 = new AaiNqResponse(); - aaiResponse2.getInventoryResponseItems().add(vserverItem); - AaiNqResponseWrapper aaiNqResponseWarapper2 = new AaiNqResponseWrapper(UUID.randomUUID(), aaiResponse); - assertNotNull(aaiNqResponseWarapper2); - assertNotNull(aaiNqResponseWarapper2.getRequestId()); - assertNotNull(aaiNqResponseWarapper2.getAaiNqResponse()); - logger.info(Serialization.gsonPretty.toJson(aaiNqResponseWarapper2)); - } - - @Test - public void testCountVfModules() throws Exception { - AaiNqResponseWrapper resp; - - // null item - resp = new AaiNqResponseWrapper(); - assertEquals(0, resp.countVfModules()); - - // no names - resp.setAaiNqResponse(load(NO_NAMES_JSON)); - assertEquals(0, resp.countVfModules()); - - // has VF modules - resp.setAaiNqResponse(load(VERSION_JSON)); - assertEquals(3, resp.countVfModules()); - } - - @Test - public void testGenVfModuleName() throws Exception { - AaiNqResponseWrapper resp; - - // null item - resp = new AaiNqResponseWrapper(); - assertEquals(null, resp.genVfModuleName()); - - // no names - resp.setAaiNqResponse(load(NO_NAMES_JSON)); - assertEquals(null, resp.genVfModuleName()); - - // has VF modules - resp.setAaiNqResponse(load(VERSION_JSON)); - assertEquals("my-module-abc_124", resp.genVfModuleName()); - } - - @Test - public void testGetVfModules() throws Exception { - AaiNqResponseWrapper resp; - - // null item - resp = new AaiNqResponseWrapper(); - assertTrue(resp.getVfModuleItems(true).isEmpty()); - - // missing item - resp = new AaiNqResponseWrapper(); - resp.setAaiNqResponse(new AaiNqResponse()); - assertTrue(resp.getVfModuleItems(false).isEmpty()); - - // null item list - resp.setAaiNqResponse(load("AaiNqResponseWrapper-NoItems.json")); - resp.getAaiNqResponse().getInventoryResponseItems().get(0).getItems().getInventoryResponseItems().get(0) - .getItems().setInventoryResponseItems(null); - assertTrue(resp.getVfModuleItems(false).isEmpty()); - - // no modules - resp.setAaiNqResponse(load("AaiNqResponseWrapper-NoModules.json")); - assertTrue(resp.getVfModuleItems(false).isEmpty()); - - // no names - resp.setAaiNqResponse(load(NO_NAMES_JSON)); - List<AaiNqInventoryResponseItem> lst; - lst = resp.getVfModuleItems(false); - assertEquals(0, lst.size()); - - // base VF modules - resp.setAaiNqResponse(load(VERSION_JSON)); - lst = resp.getVfModuleItems(true); - assertEquals(1, lst.size()); - assertEquals("Vfmodule_vLBMS-0809-1", lst.get(0).getVfModule().getVfModuleName()); - - // non base VF modules - resp.setAaiNqResponse(load(VERSION_JSON)); - lst = resp.getVfModuleItems(false); - assertEquals(3, lst.size()); - int index; - index = 0; - assertEquals("my-module-abc_1", lst.get(index++).getVfModule().getVfModuleName()); - assertEquals("my-module-abc_123", lst.get(index++).getVfModule().getVfModuleName()); - assertEquals("my-module-abc_34", lst.get(index++).getVfModule().getVfModuleName()); - } - - /** - * Loads a response from a JSON file. - * - * @param fileName name of the file containing the JSON response - * @return the response - * @throws IOException if the file cannot be read - */ - private AaiNqResponse load(String fileName) throws IOException { - String json = IOUtils.toString(getClass().getResource(fileName), StandardCharsets.UTF_8); - return Serialization.gsonPretty.fromJson(json, AaiNqResponse.class); - } -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqServiceInstanceTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqServiceInstanceTest.java deleted file mode 100644 index 45a55c99b..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqServiceInstanceTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= -*/ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiNqServiceInstanceTest { - private static final Logger logger = LoggerFactory.getLogger(AaiNqServiceInstanceTest.class); - - @Test - public void test() { - AaiNqServiceInstance aaiNqServiceInstance = new AaiNqServiceInstance(); - aaiNqServiceInstance.setServiceInstanceId("dhv-test-vhnfportal-service-instance-id"); - aaiNqServiceInstance.setServiceInstanceName("dhv-test-service-instance-name1"); - aaiNqServiceInstance.setPersonaModelId("82194af1-3c2c-485a-8f44-420e22a9eaa4"); - aaiNqServiceInstance.setPersonaModelVersion("1.0"); - aaiNqServiceInstance.setServiceInstanceLocationId("dhv-test-service-instance-location-id1"); - aaiNqServiceInstance.setResourceVersion("1485366092"); - aaiNqServiceInstance.setModelInvariantId("SomeID"); - aaiNqServiceInstance.setModelVersionId("SomeVersion"); - assertNotNull(aaiNqServiceInstance); - assertEquals("dhv-test-vhnfportal-service-instance-id", aaiNqServiceInstance.getServiceInstanceId()); - assertEquals("dhv-test-service-instance-name1", aaiNqServiceInstance.getServiceInstanceName()); - assertEquals("82194af1-3c2c-485a-8f44-420e22a9eaa4", aaiNqServiceInstance.getPersonaModelId()); - assertEquals("1.0", aaiNqServiceInstance.getPersonaModelVersion()); - assertEquals("dhv-test-service-instance-location-id1", aaiNqServiceInstance.getServiceInstanceLocationId()); - assertEquals("1485366092", aaiNqServiceInstance.getResourceVersion()); - assertEquals("SomeID", aaiNqServiceInstance.getModelInvariantId()); - assertEquals("SomeVersion", aaiNqServiceInstance.getModelVersionId()); - logger.info(Serialization.gsonPretty.toJson(aaiNqServiceInstance)); - } - -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqTenantTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqTenantTest.java deleted file mode 100644 index ed4cdb705..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqTenantTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= -*/ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiNqTenantTest { - private static final Logger logger = LoggerFactory.getLogger(AaiNqTenantTest.class); - - @Test - public void test() { - AaiNqTenant aaiNqTenant = new AaiNqTenant(); - aaiNqTenant.setTenantId("dhv-test-tenant"); - aaiNqTenant.setTenantName("dhv-test-tenant-name"); - aaiNqTenant.setResourceVersion("1485366334"); - assertNotNull(aaiNqTenant); - assertEquals("dhv-test-tenant", aaiNqTenant.getTenantId()); - assertEquals("dhv-test-tenant-name", aaiNqTenant.getTenantName()); - assertEquals("1485366334", aaiNqTenant.getResourceVersion()); - - logger.info(Serialization.gsonPretty.toJson(aaiNqTenant)); - } - -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVServerTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVServerTest.java deleted file mode 100644 index c613a0223..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVServerTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= -*/ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.File; -import java.nio.file.Files; -import java.util.List; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiNqVServerTest { - private static final Logger logger = LoggerFactory.getLogger(AaiNqVServerTest.class); - - @Test - public void test() throws Exception { - // deserialize json and verify fields are populated properly - String json = new String(Files - .readAllBytes(new File("src/test/resources/org/onap/policy/aai/AaiNqVServer.json").toPath())); - - AaiNqVServer resp = Serialization.gsonPretty.fromJson(json, AaiNqVServer.class); - - assertEquals(false, resp.getInMaint()); - assertEquals(true, resp.getIsClosedLoopDisabled()); - assertEquals("ACTIVE", resp.getProvStatus()); - assertEquals("1533850964910", resp.getResourceVersion()); - assertEquals("1c94da3f-16f1-4fc7-9ed1-e018dfa62774", resp.getVserverId()); - assertEquals("vlb-ms-0809-1", resp.getVserverName()); - assertEquals("vlb-ms-0809-7", resp.getVserverName2()); - assertEquals("http://localhost:8774/v2.1/4086f396c5e04caf9502c5fdeca575c4/servers/1c94da3f-16f1-4fc7-9ed1-e018dfa62774", - resp.getVserverSelflink()); - - // don't need to verify this in depth, as it has its own tests that do that - RelationshipList relationshipList = resp.getRelationshipList(); - assertNotNull(relationshipList); - - List<Relationship> lst = relationshipList.getRelationships(); - assertNotNull(lst); - - assertEquals(3, lst.size()); - assertEquals("generic-vnf", lst.get(0).getRelatedTo()); - assertEquals("image", lst.get(1).getRelatedTo()); - - logger.info(Serialization.gsonPretty.toJson(resp)); - - // verify that setXxx methods work - relationshipList = new RelationshipList(); - - resp.setInMaint(true); - resp.setIsClosedLoopDisabled(false); - resp.setProvStatus("inactive"); - resp.setRelationshipList(relationshipList); - resp.setResourceVersion("vers"); - resp.setVserverId("vid"); - resp.setVserverName("vname"); - resp.setVserverName2("vname2"); - resp.setVserverSelflink("link"); - - assertEquals(true, resp.getInMaint()); - assertEquals(false, resp.getIsClosedLoopDisabled()); - assertEquals("inactive", resp.getProvStatus()); - assertEquals("vers", resp.getResourceVersion()); - assertEquals("vid", resp.getVserverId()); - assertEquals("vname", resp.getVserverName()); - assertEquals("vname2", resp.getVserverName2()); - assertEquals("link", resp.getVserverSelflink()); - assertEquals(relationshipList, resp.getRelationshipList()); - } - -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVfModuleTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVfModuleTest.java deleted file mode 100644 index 65bde98c2..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVfModuleTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiNqVfModuleTest { - private static final Logger logger = LoggerFactory.getLogger(AaiNqVfModuleTest.class); - - @Test - public void test() { - AaiNqVfModule aaiNqVfModule = new AaiNqVfModule(); - aaiNqVfModule.setVfModuleId("example-vf-module-id-val-49261"); - aaiNqVfModule.setVfModuleName("example-vf-module-name-val-73074"); - aaiNqVfModule.setHeatStackId("example-heat-stack-id-val-86300"); - aaiNqVfModule.setOrchestrationStatus("example-orchestration-status-val-56523"); - aaiNqVfModule.setIsBaseVfModule(true); - aaiNqVfModule.setResourceVersion("1485366450"); - aaiNqVfModule.setPersonaModelId("ef86f9c5-2165-44f3-8fc3-96018b609ea5"); - aaiNqVfModule.setPersonaModelVersion("1.0"); - aaiNqVfModule.setWidgetModelId("example-widget-model-id-val-92571"); - aaiNqVfModule.setWidgetModelVersion("example-widget-model-version-val-83317"); - aaiNqVfModule.setContrailServiceInstanceFqdn("example-contrail-service-instance-fqdn-val-86796"); - aaiNqVfModule.setModelInvariantId("SomeId"); - aaiNqVfModule.setModelVersionId("SomeVersion"); - aaiNqVfModule.setModelCustomizationId("SomeCustomizationId"); - assertNotNull(aaiNqVfModule); - assertEquals("example-vf-module-id-val-49261", aaiNqVfModule.getVfModuleId()); - assertEquals("example-vf-module-name-val-73074", aaiNqVfModule.getVfModuleName()); - assertEquals("example-heat-stack-id-val-86300", aaiNqVfModule.getHeatStackId()); - assertEquals("example-orchestration-status-val-56523", aaiNqVfModule.getOrchestrationStatus()); - assertEquals(true, aaiNqVfModule.getIsBaseVfModule()); - assertEquals("1485366450", aaiNqVfModule.getResourceVersion()); - assertEquals("ef86f9c5-2165-44f3-8fc3-96018b609ea5", aaiNqVfModule.getPersonaModelId()); - assertEquals("1.0", aaiNqVfModule.getPersonaModelVersion()); - assertEquals("example-widget-model-id-val-92571", aaiNqVfModule.getWidgetModelId()); - assertEquals("example-widget-model-version-val-83317", aaiNqVfModule.getWidgetModelVersion()); - assertEquals("example-contrail-service-instance-fqdn-val-86796", - aaiNqVfModule.getContrailServiceInstanceFqdn()); - assertEquals("SomeId", aaiNqVfModule.getModelInvariantId()); - assertEquals("SomeVersion", aaiNqVfModule.getModelVersionId()); - assertEquals("SomeCustomizationId", aaiNqVfModule.getModelCustomizationId()); - logger.info(Serialization.gsonPretty.toJson(aaiNqVfModule)); - } - -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfInstanceTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfInstanceTest.java deleted file mode 100644 index db3e90ed0..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfInstanceTest.java +++ /dev/null @@ -1,98 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= -*/ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class PnfInstanceTest { - private static final String PNF_NAME_TEST = "pnf-name-test"; - private static final Logger logger = LoggerFactory.getLogger(PnfInstanceTest.class); - - @Test - public void test() { - PnfInstance pnfInstance = new PnfInstance(); - pnfInstance.setPnfInstanceName("pnf-instance-name-test"); - pnfInstance.setPnfName(PNF_NAME_TEST); - pnfInstance.setPnfType(PnfType.ENODEB); - pnfInstance.setPnfSerial("pnf-serial-test"); - assertNotNull(pnfInstance); - assertEquals("pnf-instance-name-test", pnfInstance.getPnfInstanceName()); - - PnfInstance pnfInstanceNull = new PnfInstance(null); - assertNotNull(pnfInstanceNull); - - PnfInstance pnfInstanceClone = new PnfInstance(pnfInstance); - assertNotNull(pnfInstanceClone); - - assertEquals(PNF_NAME_TEST, pnfInstanceClone.getPnfName()); - assertEquals(PnfType.ENODEB, pnfInstanceClone.getPnfType()); - assertEquals("pnf-serial-test", pnfInstanceClone.getPnfSerial()); - - assertNotNull(pnfInstanceClone.toString()); - assertNotEquals(0, pnfInstanceClone.hashCode()); - assertNotEquals(0, new Pnf().hashCode()); - - PnfInstance pnfInstanceOther0 = new PnfInstance(); - pnfInstanceOther0.setPnfName(PNF_NAME_TEST); - - PnfInstance pnfInstanceOther1 = new PnfInstance(pnfInstance); - pnfInstanceOther1.setPnfName("pnf-name-test-diff"); - - PnfInstance pnfInstanceOther2 = new PnfInstance(pnfInstance); - pnfInstanceOther2.setPnfInstanceName("pnf-instance-name-test-diff"); - - PnfInstance pnfInstanceOther3 = new PnfInstance(pnfInstance); - pnfInstanceOther3.setPnfName(null); - - PnfInstance pnfInstanceOther4 = new PnfInstance(pnfInstance); - pnfInstanceOther4.setPnfSerial(null); - - PnfInstance pnfInstanceOther5 = new PnfInstance(pnfInstance); - pnfInstanceOther5.setPnfSerial("pnf-serial-test-diff"); - - assertEquals(pnfInstance, pnfInstance); - assertNotEquals(null, pnfInstance); - assertNotEquals("hello", pnfInstance); - assertEquals(pnfInstance, pnfInstanceClone); - assertNotEquals(pnfInstance, new Pnf()); - assertNotEquals(new Pnf(), pnfInstance); - assertNotEquals(new Pnf(), pnfInstanceOther0); - assertNotEquals(pnfInstanceOther0, pnfInstance); - assertNotEquals(pnfInstanceOther1, pnfInstance); - assertNotEquals(pnfInstanceOther2, pnfInstance); - assertNotEquals(pnfInstanceOther3, pnfInstance); - assertNotEquals(pnfInstanceOther4, pnfInstance); - assertNotEquals(pnfInstanceOther5, pnfInstance); - - logger.info(Serialization.gsonPretty.toJson(pnfInstance)); - } - -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTest.java deleted file mode 100644 index d7fc0d2b7..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= -*/ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class PnfTest { - private static final String PNF_NAME_TEST = "pnf-name-test"; - private static final Logger logger = LoggerFactory.getLogger(PnfTest.class); - - @Test - public void test() { - Pnf pnf = new Pnf(); - pnf.setPnfName(PNF_NAME_TEST); - pnf.setPnfType(PnfType.ENODEB); - assertNotNull(pnf); - - Pnf pnfClone = new Pnf(pnf); - assertNotNull(pnfClone); - - assertEquals(PNF_NAME_TEST, pnfClone.getPnfName()); - assertEquals(PnfType.ENODEB, pnfClone.getPnfType()); - - assertNotNull(pnfClone.toString()); - assertNotEquals(0, pnfClone.hashCode()); - assertNotEquals(0, new Pnf().hashCode()); - - Pnf pnfOther = new Pnf(); - pnfOther.setPnfName(PNF_NAME_TEST); - - assertEquals(pnf, pnf); - assertNotNull(pnf); - assertNotEquals("hello", pnf); - assertEquals(pnf, pnfClone); - assertNotEquals(pnf, new Pnf()); - assertNotEquals(new Pnf(), pnf); - assertNotEquals(new Pnf(), pnfOther); - assertNotEquals(pnfOther, pnf); - - logger.info(Serialization.gsonPretty.toJson(pnf)); - } -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTypeTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTypeTest.java deleted file mode 100644 index d3236904d..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTypeTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= -*/ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class PnfTypeTest { - private static final Logger logger = LoggerFactory.getLogger(PnfTypeTest.class); - - @Test - public void test() { - PnfType pnfType = PnfType.ENODEB; - assertNotNull(pnfType); - assertNotNull(pnfType.toString()); - logger.info(Serialization.gsonPretty.toJson(pnfType)); - } - -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/RelatedToPropertyTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/RelatedToPropertyTest.java deleted file mode 100644 index 4d40a1eb7..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/RelatedToPropertyTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= -*/ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertEquals; - -import java.io.File; -import java.nio.file.Files; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RelatedToPropertyTest { - private static final Logger logger = LoggerFactory.getLogger(RelatedToPropertyTest.class); - - @Test - public void test() throws Exception { - // deserialize json and verify fields are populated properly - String json = new String(Files.readAllBytes( - new File("src/test/resources/org/onap/policy/aai/RelatedToProperty.json").toPath())); - - RelatedToProperty relatedToProperty = Serialization.gsonPretty.fromJson(json, RelatedToProperty.class); - - assertEquals("generic-vnf.vnf-name", relatedToProperty.getPropertyKey()); - assertEquals("vLoadBalancerMS-Vnf-0809-1", relatedToProperty.getPropertyValue()); - - logger.info(Serialization.gsonPretty.toJson(relatedToProperty)); - - // verify that setXxx methods work - relatedToProperty.setPropertyKey("a key"); - relatedToProperty.setPropertyValue("a value"); - - assertEquals("a key", relatedToProperty.getPropertyKey()); - assertEquals("a value", relatedToProperty.getPropertyValue()); - } - -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipDataTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipDataTest.java deleted file mode 100644 index d5c11d9e4..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipDataTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= -*/ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertEquals; - -import java.io.File; -import java.nio.file.Files; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RelationshipDataTest { - private static final Logger logger = LoggerFactory.getLogger(RelationshipDataTest.class); - - @Test - public void test() throws Exception { - // deserialize json and verify fields are populated properly - String json = new String(Files.readAllBytes( - new File("src/test/resources/org/onap/policy/aai/RelationshipData.json").toPath())); - - RelationshipData relationshipData = Serialization.gsonPretty.fromJson(json, RelationshipData.class); - - assertEquals("generic-vnf.vnf-id", relationshipData.getRelationshipKey()); - assertEquals("807a3f02-f878-436b-870c-f0e91e81570d", relationshipData.getRelationshipValue()); - - logger.info(Serialization.gsonPretty.toJson(relationshipData)); - - // verify that setXxx methods work - relationshipData.setRelationshipKey("a key"); - relationshipData.setRelationshipValue("a value"); - - assertEquals("a key", relationshipData.getRelationshipKey()); - assertEquals("a value", relationshipData.getRelationshipValue()); - } - -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipListTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipListTest.java deleted file mode 100644 index 2104c1898..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipListTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= -*/ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.File; -import java.nio.file.Files; -import java.util.LinkedList; -import java.util.List; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RelationshipListTest { - private static final Logger logger = LoggerFactory.getLogger(RelationshipListTest.class); - - @Test - public void test() throws Exception { - // deserialize json and verify fields are populated properly - String json = new String(Files.readAllBytes( - new File("src/test/resources/org/onap/policy/aai/RelationshipList.json").toPath())); - - RelationshipList relationshipList = Serialization.gsonPretty.fromJson(json, RelationshipList.class); - - List<Relationship> lst = relationshipList.getRelationships(); - assertNotNull(lst); - assertEquals(3, lst.size()); - - // don't need to verify this in depth, as it has its own tests that do that - assertEquals("generic-vnf", lst.get(0).getRelatedTo()); - assertEquals("image", lst.get(1).getRelatedTo()); - assertEquals("flavor", lst.get(2).getRelatedTo()); - - logger.info(Serialization.gsonPretty.toJson(relationshipList)); - - // verify that setXxx methods work - lst = new LinkedList<>(); - lst.add(new Relationship()); - lst.add(new Relationship()); - - relationshipList.setRelationships(lst); - assertEquals(lst, relationshipList.getRelationships()); - } - -} diff --git a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipTest.java b/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipTest.java deleted file mode 100644 index acc6243d6..000000000 --- a/models-interactions/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. 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. - * ============LICENSE_END========================================================= -*/ - -package org.onap.policy.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.File; -import java.nio.file.Files; -import java.util.LinkedList; -import java.util.List; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RelationshipTest { - private static final Logger logger = LoggerFactory.getLogger(RelationshipTest.class); - - @Test - public void test() throws Exception { - // deserialize json and verify fields are populated properly - String json = new String(Files - .readAllBytes(new File("src/test/resources/org/onap/policy/aai/Relationship.json").toPath())); - - Relationship relationship = Serialization.gsonPretty.fromJson(json, Relationship.class); - - assertEquals("/aai/v11/network/generic-vnfs/generic-vnf/807a3f02-f878-436b-870c-f0e91e81570d", - relationship.getRelatedLink()); - assertEquals("generic-vnf", relationship.getRelatedTo()); - - // don't need to verify this in depth, as it has its own tests that do that - List<RelatedToProperty> relatedToProperty = relationship.getRelatedToProperty(); - assertNotNull(relatedToProperty); - assertEquals(2, relatedToProperty.size()); - assertEquals("vLoadBalancerMS-Vnf-0809-1", relatedToProperty.get(0).getPropertyValue()); - assertEquals("vLoadBalancerMS-Vnf-0809-2", relatedToProperty.get(1).getPropertyValue()); - - // don't need to verify this in depth, as it has its own tests that do that - List<RelationshipData> relationshipData = relationship.getRelationshipData(); - assertNotNull(relationshipData); - assertEquals(2, relationshipData.size()); - assertEquals("807a3f02-f878-436b-870c-f0e91e81570d", relationshipData.get(0).getRelationshipValue()); - assertEquals("907a3f02-f878-436b-870c-f0e91e81570e", relationshipData.get(1).getRelationshipValue()); - - logger.info(Serialization.gsonPretty.toJson(relationship)); - - // verify that setXxx methods work - relatedToProperty = new LinkedList<>(); - relatedToProperty.add(new RelatedToProperty()); - relatedToProperty.add(new RelatedToProperty()); - relatedToProperty.add(new RelatedToProperty()); - - relationshipData = new LinkedList<>(); - relationshipData.add(new RelationshipData()); - relationshipData.add(new RelationshipData()); - relationshipData.add(new RelationshipData()); - - relationship.setRelatedLink("related-link"); - relationship.setRelatedTo("related-to"); - relationship.setRelatedToProperty(relatedToProperty); - relationship.setRelationshipData(relationshipData); - - assertEquals("related-link", relationship.getRelatedLink()); - assertEquals("related-to", relationship.getRelatedTo()); - assertEquals(relatedToProperty, relationship.getRelatedToProperty()); - assertEquals(relationshipData, relationship.getRelationshipData()); - } - -} diff --git a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/AppcLcmCommonHeader.java b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/AppcLcmCommonHeader.java index 33a3c1f23..363ea35a5 100644 --- a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/AppcLcmCommonHeader.java +++ b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/AppcLcmCommonHeader.java @@ -71,6 +71,7 @@ public class AppcLcmCommonHeader implements Serializable { this.originatorId = commonHeader.originatorId; this.requestId = commonHeader.requestId; this.subRequestId = commonHeader.subRequestId; + this.timeStamp = commonHeader.timeStamp; if (commonHeader.flags != null) { this.flags.putAll(commonHeader.flags); } diff --git a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java index 793babf24..3b1772342 100644 --- a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java +++ b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java @@ -23,13 +23,9 @@ package org.onap.policy.simulators; import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.util.Map; -import java.util.Map.Entry; -import java.util.TreeMap; import java.util.UUID; import javax.ws.rs.Consumes; import javax.ws.rs.GET; -import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @@ -37,13 +33,10 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import org.apache.commons.io.IOUtils; -import org.onap.policy.aai.AaiNqRequest; -import org.onap.policy.aai.util.Serialization; @Path("/aai") public class AaiSimulatorJaxRs { - private static final String VSERVER = "vserver"; private static final String DISABLE_CLOSEDLOOP = "disableClosedLoop"; private static final String ERROR = "error"; private static final String GETFAIL = "getFail"; @@ -60,8 +53,8 @@ public class AaiSimulatorJaxRs { @Produces("application/json") public String aaiGetQuery(@PathParam("vnfID") final String vnfId) { return "{\"relationship-list\": {\"relationship\":[{\"related-to-property\": [{\"property-key\": " - + "\"service-instance.service-instance-name\"}]},{\"related-to-property\": [ {\"property-key\": " - + "\"vserver.vserver-name\",\"property-value\": \"USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}"; + + "\"service-instance.service-instance-name\"}]},{\"related-to-property\": [ {\"property-key\": " + + "\"vserver.vserver-name\",\"property-value\": \"USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}"; } /** @@ -73,14 +66,19 @@ public class AaiSimulatorJaxRs { @Path("/v16/search/nodes-query") @Consumes(MediaType.APPLICATION_JSON) @Produces("application/json") - public String aaiGetVserverQuery() { - return "{\"result-data\":[{\"resource-type\": \"vserver\",\"resource-link\":\"/aai/v15/" + public String aaiGetVserverQuery(@QueryParam("filter") final String filter) { + if (filter.equals("vserver-name:EQUALS:f953c499-4b1e-426b-8c6d-e9e9f1fc730f") + || filter.equals("vserver-name:EQUALS:OzVServer") + || filter.equals("vserver-name:EQUALS:testVserverName")) { + return "{\"result-data\":[{\"resource-type\": \"vserver\",\"resource-link\":\"/aai/v15/" + "cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants" + "/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/" + "6c3b3714-e36c-45af-9f16-7d3a73d99497\"}]}}"; + } else { + return null; + } } - /** * A&AI put query. * @@ -93,56 +91,8 @@ public class AaiSimulatorJaxRs { @Consumes(MediaType.APPLICATION_JSON) @Produces("application/json") public String aaiPutQuery(final String req) throws IOException { - return IOUtils.toString(getClass().getResource("aai/AaiCqResponse.json"), StandardCharsets.UTF_8); - } - - /** - * A&AI post query. - * - * @param req the request - * @return the response - * @throws IOException if a response file cannot be read - */ - @POST - @Path("/search/named-query") - @Consumes(MediaType.APPLICATION_JSON) - @Produces("application/json") - public String aaiPostQuery(final String req) throws IOException { - final AaiNqRequest request = Serialization.gsonPretty.fromJson(req, AaiNqRequest.class); - - if (request.getInstanceFilters().getInstanceFilter().get(0).containsKey(VSERVER)) { - final String vserverName = - request.getInstanceFilters().getInstanceFilter().get(0).get(VSERVER).get("vserver-name"); - if (ERROR.equals(vserverName)) { - Map<String, String> params = new TreeMap<>(); - params.put("type", VSERVER); - return load("aai/AaiNqResponse-Error.json", params); - } else { - // vll format - new - // new aai response from Brian 11/13/2017 - return load("aai/AaiNqResponse-Vserver.json", new TreeMap<>()); - } - } else { - final String vnfId = - request.getInstanceFilters().getInstanceFilter().get(0).get("generic-vnf").get("vnf-id"); - if (ERROR.equals(vnfId)) { - Map<String, String> params = new TreeMap<>(); - params.put("type", "generic-vnf"); - return load("aai/AaiNqResponse-Error.json", params); - } else { - Map<String, String> params = new TreeMap<>(); - params.put("vnfId", "" + vnfId); - params.put("vnfName", getUuidValue(vnfId, "ZRDM2MMEX39")); - params.put("pnfVndName", "pnf-test-" + vnfId); - params.put("pnfVnfId", getUuidValue(params.get("pnfVndName"), "jimmy-test")); - - params.put("serviceInstanceVnfName", "service-instance-test-" + vnfId); - params.put("serviceInstanceVnfId", - getUuidValue(params.get("serviceInstanceVnfName"), "jimmy-test-vnf2")); - - return load("aai/AaiNqResponse-GenericVnf.json", params); - } - } + return IOUtils.toString(getClass().getResource("aai/AaiCqResponse.json"), + StandardCharsets.UTF_8); } /** @@ -158,66 +108,66 @@ public class AaiSimulatorJaxRs { public String getByVnfName(@QueryParam("vnf-name") final String vnfName) { if (GETFAIL.equals(vnfName)) { return "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC3001\",\"text\":\"Resource not" - + " found for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"GET\",\"network/generic-vnfs/" - + "generic-vnf\",\"Node Not Found:No Node of type generic-vnf found at network/generic-vnfs" - + "/generic-vnf\",\"ERR.5.4.6114\"]}}}"; + + " found for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"GET\",\"network/generic-vnfs/" + + "generic-vnf\",\"Node Not Found:No Node of type generic-vnf found at network/generic-vnfs" + + "/generic-vnf\",\"ERR.5.4.6114\"]}}}"; } final boolean isDisabled = DISABLE_CLOSEDLOOP.equals(vnfName); if (ERROR.equals(vnfName)) { return "{ \"vnf-id\": \"error\", \"vnf-name\": \"" + vnfName - + "\", \"vnf-type\": \"RT\", \"service-id\": \"d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4\", \"" - + "equipment-role\": \"UCPE\", \"orchestration-status\": \"created\", \"management-option\": \"" - + "ATT\", \"ipv4-oam-address\": \"32.40.68.35\", \"ipv4-loopback0-address\": \"32.40.64.57\", \"" - + "nm-lan-v6-address\": \"2001:1890:e00e:fffe::1345\", \"management-v6-address\": \"" - + "2001:1890:e00e:fffd::36\", \"in-maint\": false, \"prov-status\":\"ACTIVE\", " - + "\"is-closed-loop-disabled\": " + isDisabled - + ", \"resource-version\": \"1493389458092\", \"relationship-list\": {\"relationship\":[{ \"" - + "related-to\": \"service-instance\", \"related-link\": \"/aai/v11/business/customers/customer/" - + "1610_Func_Global_20160817084727/service-subscriptions/service-subscription/uCPE-VMS/" - + "service-instances/service-instance/USUCP0PCOIL0110UJZZ01\", \"relationship-data\":[{ \"" - + "relationship-key\": \"customer.global-customer-id\", \"relationship-value\": \"" - + "1610_Func_Global_20160817084727\"},{ \"relationship-key\": \"service-subscription.service-type" - + "\", \"relationship-value\": \"uCPE-VMS\"},{ \"relationship-key\": \"" - + "service-instance.service-instance-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01" - + "\"} ], \"related-to-property\": [{\"property-key\": \"service-instance.service-instance-name" - + "\"}]},{ \"related-to\": \"vserver\", \"related-link\": \"/aai/v11/cloud-infrastructure/" - + "cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/" - + "USUCP0PCOIL0110UJZZ01%3A%3AuCPE-VMS/vservers/vserver/3b2558f4-39d8-40e7-bfc7-30660fb52c45" - + "\", \"relationship-data\":[{ \"relationship-key\": \"cloud-region.cloud-owner\", \"" - + "relationship-value\": \"att-aic\"},{ \"relationship-key\": \"cloud-region.cloud-region-id" - + "\", \"relationship-value\": \"AAIAIC25\"},{ \"relationship-key\": \"tenant.tenant-id" - + "\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01::uCPE-VMS\"},{ \"relationship-key\": \"" - + "vserver.vserver-id\", \"relationship-value\": \"3b2558f4-39d8-40e7-bfc7-30660fb52c45\"} ], \"" - + "related-to-property\": [ {\"property-key\": \"vserver.vserver-name\",\"property-value\": \"" - + "USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}"; - - } - final String vnfId = getUuidValue(vnfName, "5e49ca06-2972-4532-9ed4-6d071588d792"); - return "{ \"vnf-id\": \"" + vnfId + "\", \"vnf-name\": \"" + vnfName + "\", \"vnf-type\": \"RT\", \"service-id\": \"d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4\", \"" - + "equipment-role\": \"UCPE\", \"orchestration-status\": \"created\", \"management-option\": \"ATT" - + "\", \"ipv4-oam-address\": \"32.40.68.35\", \"ipv4-loopback0-address\": \"32.40.64.57\", \"" + + "equipment-role\": \"UCPE\", \"orchestration-status\": \"created\", \"management-option\": \"" + + "ATT\", \"ipv4-oam-address\": \"32.40.68.35\", \"ipv4-loopback0-address\": \"32.40.64.57\", \"" + "nm-lan-v6-address\": \"2001:1890:e00e:fffe::1345\", \"management-v6-address\": \"" + "2001:1890:e00e:fffd::36\", \"in-maint\": false, \"prov-status\":\"ACTIVE\", " + "\"is-closed-loop-disabled\": " + isDisabled + ", \"resource-version\": \"1493389458092\", \"relationship-list\": {\"relationship\":[{ \"" - + "related-to\": \"service-instance\", \"related-link\": \"/aai/v11/business/customers/customer" - + "/1610_Func_Global_20160817084727/service-subscriptions/service-subscription/uCPE-VMS/" + + "related-to\": \"service-instance\", \"related-link\": \"/aai/v11/business/customers/customer/" + + "1610_Func_Global_20160817084727/service-subscriptions/service-subscription/uCPE-VMS/" + "service-instances/service-instance/USUCP0PCOIL0110UJZZ01\", \"relationship-data\":[{ \"" + "relationship-key\": \"customer.global-customer-id\", \"relationship-value\": \"" + "1610_Func_Global_20160817084727\"},{ \"relationship-key\": \"service-subscription.service-type" + "\", \"relationship-value\": \"uCPE-VMS\"},{ \"relationship-key\": \"" - + "service-instance.service-instance-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01\"} ], \"" - + "related-to-property\": [{\"property-key\": \"service-instance.service-instance-name\"}]},{ \"" - + "related-to\": \"vserver\", \"related-link\": \"/aai/v11/cloud-infrastructure/cloud-regions/" - + "cloud-region/att-aic/AAIAIC25/tenants/tenant/USUCP0PCOIL0110UJZZ01%3A%3AuCPE-VMS/vservers/vserver" - + "/3b2558f4-39d8-40e7-bfc7-30660fb52c45\", \"relationship-data\":[{ \"relationship-key\": \"" - + "cloud-region.cloud-owner\", \"relationship-value\": \"att-aic\"},{ \"relationship-key\": \"" - + "cloud-region.cloud-region-id\", \"relationship-value\": \"AAIAIC25\"},{ \"relationship-key\": \"" - + "tenant.tenant-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01::uCPE-VMS\"},{ \"" - + "relationship-key\": \"vserver.vserver-id\", \"relationship-value\": \"" - + "3b2558f4-39d8-40e7-bfc7-30660fb52c45\"} ], \"related-to-property\": [ {\"property-key\": \"" - + "vserver.vserver-name\",\"property-value\": \"USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}"; + + "service-instance.service-instance-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01" + + "\"} ], \"related-to-property\": [{\"property-key\": \"service-instance.service-instance-name" + + "\"}]},{ \"related-to\": \"vserver\", \"related-link\": \"/aai/v11/cloud-infrastructure/" + + "cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/" + + "USUCP0PCOIL0110UJZZ01%3A%3AuCPE-VMS/vservers/vserver/3b2558f4-39d8-40e7-bfc7-30660fb52c45" + + "\", \"relationship-data\":[{ \"relationship-key\": \"cloud-region.cloud-owner\", \"" + + "relationship-value\": \"att-aic\"},{ \"relationship-key\": \"cloud-region.cloud-region-id" + + "\", \"relationship-value\": \"AAIAIC25\"},{ \"relationship-key\": \"tenant.tenant-id" + + "\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01::uCPE-VMS\"},{ \"relationship-key\": \"" + + "vserver.vserver-id\", \"relationship-value\": \"3b2558f4-39d8-40e7-bfc7-30660fb52c45\"} ], \"" + + "related-to-property\": [ {\"property-key\": \"vserver.vserver-name\",\"property-value\": \"" + + "USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}"; + + } + final String vnfId = getUuidValue(vnfName, "5e49ca06-2972-4532-9ed4-6d071588d792"); + return "{ \"vnf-id\": \"" + vnfId + "\", \"vnf-name\": \"" + vnfName + + "\", \"vnf-type\": \"RT\", \"service-id\": \"d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4\", \"" + + "equipment-role\": \"UCPE\", \"orchestration-status\": \"created\", \"management-option\": \"ATT" + + "\", \"ipv4-oam-address\": \"32.40.68.35\", \"ipv4-loopback0-address\": \"32.40.64.57\", \"" + + "nm-lan-v6-address\": \"2001:1890:e00e:fffe::1345\", \"management-v6-address\": \"" + + "2001:1890:e00e:fffd::36\", \"in-maint\": false, \"prov-status\":\"ACTIVE\", " + + "\"is-closed-loop-disabled\": " + isDisabled + + ", \"resource-version\": \"1493389458092\", \"relationship-list\": {\"relationship\":[{ \"" + + "related-to\": \"service-instance\", \"related-link\": \"/aai/v11/business/customers/customer" + + "/1610_Func_Global_20160817084727/service-subscriptions/service-subscription/uCPE-VMS/" + + "service-instances/service-instance/USUCP0PCOIL0110UJZZ01\", \"relationship-data\":[{ \"" + + "relationship-key\": \"customer.global-customer-id\", \"relationship-value\": \"" + + "1610_Func_Global_20160817084727\"},{ \"relationship-key\": \"service-subscription.service-type" + + "\", \"relationship-value\": \"uCPE-VMS\"},{ \"relationship-key\": \"" + + "service-instance.service-instance-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01\"} ], \"" + + "related-to-property\": [{\"property-key\": \"service-instance.service-instance-name\"}]},{ \"" + + "related-to\": \"vserver\", \"related-link\": \"/aai/v11/cloud-infrastructure/cloud-regions/" + + "cloud-region/att-aic/AAIAIC25/tenants/tenant/USUCP0PCOIL0110UJZZ01%3A%3AuCPE-VMS/vservers/vserver" + + "/3b2558f4-39d8-40e7-bfc7-30660fb52c45\", \"relationship-data\":[{ \"relationship-key\": \"" + + "cloud-region.cloud-owner\", \"relationship-value\": \"att-aic\"},{ \"relationship-key\": \"" + + "cloud-region.cloud-region-id\", \"relationship-value\": \"AAIAIC25\"},{ \"relationship-key\": \"" + + "tenant.tenant-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01::uCPE-VMS\"},{ \"" + + "relationship-key\": \"vserver.vserver-id\", \"relationship-value\": \"" + + "3b2558f4-39d8-40e7-bfc7-30660fb52c45\"} ], \"related-to-property\": [ {\"property-key\": \"" + + "vserver.vserver-name\",\"property-value\": \"USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}"; } /** @@ -233,37 +183,37 @@ public class AaiSimulatorJaxRs { public String getByVnfId(@PathParam("vnfId") final String vnfId) { if (GETFAIL.equals(vnfId)) { return "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC3001\",\"text\":\"Resource not found" - + " for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"GET\",\"network/generic-vnfs/" - + "generic-vnf/getFail\",\"Node Not Found:No Node of type generic-vnf found at network/" - + "generic-vnfs/generic-vnf/getFail\",\"ERR.5.4.6114\"]}}}"; + + " for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"GET\",\"network/generic-vnfs/" + + "generic-vnf/getFail\",\"Node Not Found:No Node of type generic-vnf found at network/" + + "generic-vnfs/generic-vnf/getFail\",\"ERR.5.4.6114\"]}}}"; } final boolean isDisabled = DISABLE_CLOSEDLOOP.equals(vnfId); final String vnfName = getUuidValue(vnfId, "USUCP0PCOIL0110UJRT01"); return "{ \"vnf-id\": \"" + vnfId + "\", \"vnf-name\": \"" + vnfName - + "\", \"vnf-type\": \"RT\", \"service-id\": \"" - + "d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4\", \"equipment-role\": \"UCPE\", \"orchestration-status" - + "\": \"created\", \"management-option\": \"ATT\", \"ipv4-oam-address\": \"32.40.68.35\", \"" - + "ipv4-loopback0-address\": \"32.40.64.57\", \"nm-lan-v6-address\": \"2001:1890:e00e:fffe::1345" - + "\", \"management-v6-address\": \"2001:1890:e00e:fffd::36\", \"in-maint\": false, " - + "\"prov-status\":\"ACTIVE\", \"" + "" + "is-closed-loop-disabled\": " + isDisabled - + ", \"resource-version\": \"1493389458092\", \"" - + "relationship-list\": {\"relationship\":[{ \"related-to\": \"service-instance\", \"related-link" - + "\": \"/aai/v11/business/customers/customer/1610_Func_Global_20160817084727/service-subscriptions" - + "/service-subscription/uCPE-VMS/service-instances/service-instance/USUCP0PCOIL0110UJZZ01\", \"" - + "relationship-data\":[{ \"relationship-key\": \"customer.global-customer-id\", \"" - + "relationship-value\": \"1610_Func_Global_20160817084727\"},{ \"relationship-key\": \"" - + "service-subscription.service-type\", \"relationship-value\": \"uCPE-VMS\"},{ \"relationship-key" - + "\": \"service-instance.service-instance-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01\"} " - + "], \"related-to-property\": [{\"property-key\": \"service-instance.service-instance-name\"}]}," - + "{ \"related-to\": \"vserver\", \"related-link\": \"/aai/v11/cloud-infrastructure/cloud-regions/" - + "cloud-region/att-aic/AAIAIC25/tenants/tenant/USUCP0PCOIL0110UJZZ01%3A%3AuCPE-VMS/vservers/vserver" - + "/3b2558f4-39d8-40e7-bfc7-30660fb52c45\", \"relationship-data\":[{ \"relationship-key\": \"" - + "cloud-region.cloud-owner\", \"relationship-value\": \"att-aic\"},{ \"relationship-key\": \"" - + "cloud-region.cloud-region-id\", \"relationship-value\": \"AAIAIC25\"},{ \"relationship-key\": \"" - + "tenant.tenant-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01::uCPE-VMS\"},{ \"" - + "relationship-key\": \"vserver.vserver-id\", \"relationship-value\": \"" - + "3b2558f4-39d8-40e7-bfc7-30660fb52c45\"} ], \"related-to-property\": [ {\"property-key\": \"" - + "vserver.vserver-name\",\"property-value\": \"USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}"; + + "\", \"vnf-type\": \"RT\", \"service-id\": \"" + + "d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4\", \"equipment-role\": \"UCPE\", \"orchestration-status" + + "\": \"created\", \"management-option\": \"ATT\", \"ipv4-oam-address\": \"32.40.68.35\", \"" + + "ipv4-loopback0-address\": \"32.40.64.57\", \"nm-lan-v6-address\": \"2001:1890:e00e:fffe::1345" + + "\", \"management-v6-address\": \"2001:1890:e00e:fffd::36\", \"in-maint\": false, " + + "\"prov-status\":\"ACTIVE\", \"" + "" + "is-closed-loop-disabled\": " + isDisabled + + ", \"resource-version\": \"1493389458092\", \"" + + "relationship-list\": {\"relationship\":[{ \"related-to\": \"service-instance\", \"related-link" + + "\": \"/aai/v11/business/customers/customer/1610_Func_Global_20160817084727/service-subscriptions" + + "/service-subscription/uCPE-VMS/service-instances/service-instance/USUCP0PCOIL0110UJZZ01\", \"" + + "relationship-data\":[{ \"relationship-key\": \"customer.global-customer-id\", \"" + + "relationship-value\": \"1610_Func_Global_20160817084727\"},{ \"relationship-key\": \"" + + "service-subscription.service-type\", \"relationship-value\": \"uCPE-VMS\"},{ \"relationship-key" + + "\": \"service-instance.service-instance-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01\"} " + + "], \"related-to-property\": [{\"property-key\": \"service-instance.service-instance-name\"}]}," + + "{ \"related-to\": \"vserver\", \"related-link\": \"/aai/v11/cloud-infrastructure/cloud-regions/" + + "cloud-region/att-aic/AAIAIC25/tenants/tenant/USUCP0PCOIL0110UJZZ01%3A%3AuCPE-VMS/vservers/vserver" + + "/3b2558f4-39d8-40e7-bfc7-30660fb52c45\", \"relationship-data\":[{ \"relationship-key\": \"" + + "cloud-region.cloud-owner\", \"relationship-value\": \"att-aic\"},{ \"relationship-key\": \"" + + "cloud-region.cloud-region-id\", \"relationship-value\": \"AAIAIC25\"},{ \"relationship-key\": \"" + + "tenant.tenant-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01::uCPE-VMS\"},{ \"" + + "relationship-key\": \"vserver.vserver-id\", \"relationship-value\": \"" + + "3b2558f4-39d8-40e7-bfc7-30660fb52c45\"} ], \"related-to-property\": [ {\"property-key\": \"" + + "vserver.vserver-name\",\"property-value\": \"USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}"; } /** @@ -279,47 +229,28 @@ public class AaiSimulatorJaxRs { public String getByVserverName(@QueryParam("vserver-name") final String vserverName) { if (GETFAIL.equals(vserverName)) { return "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC3001\",\"text\":\"Resource not found" - + " for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"GET\",\"nodes/vservers\",\"Node Not" - + " Found:No Node of type generic-vnf found at nodes/vservers\",\"ERR.5.4.6114\"]}}}"; + + " for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"GET\",\"nodes/vservers\",\"Node Not" + + " Found:No Node of type generic-vnf found at nodes/vservers\",\"ERR.5.4.6114\"]}}}"; } final boolean isDisabled = DISABLE_CLOSEDLOOP.equals(vserverName); final String vserverId = getUuidValue(vserverName, "d0668d4f-c25e-4a1b-87c4-83845c01efd8"); - return "{\"vserver\": [{ \"vserver-id\": \"" + vserverId + "\", \"vserver-name\": \"" + vserverName - + "\", \"vserver-name2\": \"vjunos0\", \"vserver-selflink\": \"https://aai-ext1.test.att.com:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/USMSO1SX7NJ0103UJZZ01%3A%3AuCPE-VMS/vservers/vserver/d0668d4f-c25e-4a1b-87c4-83845c01efd8\", \"in-maint\": false, \"is-closed-loop-disabled\": " - + isDisabled + ", \"prov-status\":\"ACTIVE\", \"resource-version\": \"1494001931513\", " - + "\"relationship-list\": {\"relationship\":[{ \"related-to" - + "\": \"generic-vnf\", \"related-link\": \"/aai/v11/network/generic-vnfs/generic-vnf/" - + "e1a41e99-4ede-409a-8f9d-b5e12984203a\", \"relationship-data\": [ {\"relationship-key\": \"" - + "generic-vnf.vnf-id\",\"relationship-value\": \"e1a41e99-4ede-409a-8f9d-b5e12984203a\" }], \"" - + "related-to-property\": [ {\"property-key\": \"generic-vnf.vnf-name\",\"property-value\": \"" - + "USMSO1SX7NJ0103UJSW01\" }]},{ \"related-to\": \"pserver\", \"related-link\": \"/aai/v11/" - + "cloud-infrastructure/pservers/pserver/USMSO1SX7NJ0103UJZZ01\", \"relationship-data\": [ {\"" - + "relationship-key\": \"pserver.hostname\",\"relationship-value\": \"USMSO1SX7NJ0103UJZZ01\" }], \"" - + "related-to-property\": [{\"property-key\": \"pserver.pserver-name2\"}]} ]}}]}"; + return "{\"vserver\": [{ \"vserver-id\": \"" + vserverId + "\", \"vserver-name\": \"" + + vserverName + + "\", \"vserver-name2\": \"vjunos0\", \"vserver-selflink\": \"https://aai-ext1.test.att.com:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/USMSO1SX7NJ0103UJZZ01%3A%3AuCPE-VMS/vservers/vserver/d0668d4f-c25e-4a1b-87c4-83845c01efd8\", \"in-maint\": false, \"is-closed-loop-disabled\": " + + isDisabled + ", \"prov-status\":\"ACTIVE\", \"resource-version\": \"1494001931513\", " + + "\"relationship-list\": {\"relationship\":[{ \"related-to" + + "\": \"generic-vnf\", \"related-link\": \"/aai/v11/network/generic-vnfs/generic-vnf/" + + "e1a41e99-4ede-409a-8f9d-b5e12984203a\", \"relationship-data\": [ {\"relationship-key\": \"" + + "generic-vnf.vnf-id\",\"relationship-value\": \"e1a41e99-4ede-409a-8f9d-b5e12984203a\" }], \"" + + "related-to-property\": [ {\"property-key\": \"generic-vnf.vnf-name\",\"property-value\": \"" + + "USMSO1SX7NJ0103UJSW01\" }]},{ \"related-to\": \"pserver\", \"related-link\": \"/aai/v11/" + + "cloud-infrastructure/pservers/pserver/USMSO1SX7NJ0103UJZZ01\", \"relationship-data\": [ {\"" + + "relationship-key\": \"pserver.hostname\",\"relationship-value\": \"USMSO1SX7NJ0103UJZZ01\" }], \"" + + "related-to-property\": [{\"property-key\": \"pserver.pserver-name2\"}]} ]}}]}"; } private String getUuidValue(final String value, final String defaultValue) { return value != null ? UUID.nameUUIDFromBytes(value.getBytes()).toString() : defaultValue; } - /** - * Loads a JSON response from a file and then replaces parameters of the form, ${xxx}, with values. - * - * @param fileName name of the file containing the JSON - * @param params parameters to be substituted - * @return the JSON response, after parameter substitution - * @throws IOException if the file cannot be read - */ - private String load(String fileName, Map<String, String> params) throws IOException { - String json = IOUtils.toString(getClass().getResource(fileName), StandardCharsets.UTF_8); - - // perform parameter substitution - for (Entry<String, String> ent : params.entrySet()) { - String name = "${" + ent.getKey() + "}"; - String value = ent.getValue(); - json = json.replace(name, value); - } - - return json; - } } diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java index a03010a00..1d60af0e1 100644 --- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java +++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java @@ -23,26 +23,14 @@ package org.onap.policy.simulators; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; import java.util.UUID; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.onap.policy.aai.AaiCqResponse; -import org.onap.policy.aai.AaiGetVnfResponse; import org.onap.policy.aai.AaiManager; -import org.onap.policy.aai.AaiNqInstanceFilters; -import org.onap.policy.aai.AaiNqNamedQuery; -import org.onap.policy.aai.AaiNqQueryParameters; -import org.onap.policy.aai.AaiNqRequest; -import org.onap.policy.aai.AaiNqResponse; import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; import org.onap.policy.rest.RestManager; @@ -66,82 +54,10 @@ public class AaiSimulatorTest { } @Test - public void testGet() { - final AaiGetVnfResponse response = new AaiManager(new RestManager()).getQueryByVnfId( - "http://localhost:6666/aai/v11/network/generic-vnfs/generic-vnf/", "testUser", "testPass", - UUID.randomUUID(), "5e49ca06-2972-4532-9ed4-6d071588d792"); - assertNotNull(response); - assertNotNull(response.getRelationshipList()); - } - - @Test public void testCqGet() { final AaiCqResponse response = new AaiManager(new RestManager()).getCustomQueryResponse("http://localhost:6666", - "testUser", "testPass", UUID.randomUUID(), "Ete_vFWCLvFWSNK_7ba1fbde_0"); - assertNotNull(response); - assertEquals(response.getVserver().getVserverName(), "Ete_vFWCLvFWSNK_7ba1fbde_0"); - } - - @Test - public void testPost() { - // check vserver named query - final AaiNqRequest request = new AaiNqRequest(); - final AaiNqQueryParameters tempQueryParameters = new AaiNqQueryParameters(); - final AaiNqNamedQuery tempNamedQuery = new AaiNqNamedQuery(); - tempNamedQuery.setNamedQueryUuid(UUID.fromString("4ff56a54-9e3f-46b7-a337-07a1d3c6b469")); - tempQueryParameters.setNamedQuery(tempNamedQuery); - request.setQueryParameters(tempQueryParameters); - Map<String, String> tempInnerMap = new HashMap<>(); - tempInnerMap.put("vserver-name", "vserver-name-16102016-aai3255-data-11-1"); - Map<String, Map<String, String>> tempOuterMap = new HashMap<>(); - tempOuterMap.put("vserver", tempInnerMap); - List<Map<String, Map<String, String>>> tempInstanceFilter = new LinkedList<>(); - tempInstanceFilter.add(tempOuterMap); - AaiNqInstanceFilters tempInstanceFilters = new AaiNqInstanceFilters(); - tempInstanceFilters.setInstanceFilter(tempInstanceFilter); - request.setInstanceFilters(tempInstanceFilters); - - AaiNqResponse response = new AaiManager(new RestManager()).postQuery("http://localhost:6666", "testUser", - "testPass", request, UUID.randomUUID()); - assertNotNull(response); - assertNotNull(response.getInventoryResponseItems()); - - // check error response for vserver query - tempInnerMap.put("vserver-name", "error"); - - response = new AaiManager(new RestManager()).postQuery("http://localhost:6666", "testUser", "testPass", request, - UUID.randomUUID()); - assertNotNull(response); - assertNotNull(response.getRequestError()); - assertTrue(response.getRequestError().getServiceExcept().getVariables()[2].contains("vserver")); - - // check generic-vnf named query - tempNamedQuery.setNamedQueryUuid(UUID.fromString("a93ac487-409c-4e8c-9e5f-334ae8f99087")); - tempQueryParameters.setNamedQuery(tempNamedQuery); - request.setQueryParameters(tempQueryParameters); - tempInnerMap = new HashMap<>(); - tempInnerMap.put("vnf-id", "de7cc3ab-0212-47df-9e64-da1c79234deb"); - tempOuterMap = new HashMap<>(); - tempOuterMap.put("generic-vnf", tempInnerMap); - tempInstanceFilter = new LinkedList<>(); - tempInstanceFilter.add(tempOuterMap); - tempInstanceFilters = new AaiNqInstanceFilters(); - tempInstanceFilters.setInstanceFilter(tempInstanceFilter); - request.setInstanceFilters(tempInstanceFilters); - - response = new AaiManager(new RestManager()).postQuery("http://localhost:6666", "testUser", "testPass", request, - UUID.randomUUID()); - assertNotNull(response); - assertNotNull(response.getInventoryResponseItems()); - assertNull(response.getRequestError()); - - // check error response for generic-vnf query - tempInnerMap.put("vnf-id", "error"); - - response = new AaiManager(new RestManager()).postQuery("http://localhost:6666", "testUser", "testPass", request, - UUID.randomUUID()); + "testUser", "testPass", UUID.randomUUID(), "f953c499-4b1e-426b-8c6d-e9e9f1fc730f"); assertNotNull(response); - assertNotNull(response.getRequestError()); - assertTrue(response.getRequestError().getServiceExcept().getVariables()[2].contains("generic-vnf")); + assertEquals(response.getVserver().getVserverId(), "f953c499-4b1e-426b-8c6d-e9e9f1fc730f"); } } diff --git a/models-interactions/model-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoop.java b/models-interactions/model-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoop.java index 69f62b28e..95494d8e9 100644 --- a/models-interactions/model-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoop.java +++ b/models-interactions/model-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoop.java @@ -25,7 +25,7 @@ import java.io.Serializable; import java.util.LinkedList; import java.util.List; -import org.onap.policy.aai.Pnf; +import org.onap.aai.domain.yang.Pnf; import org.onap.policy.sdc.Resource; import org.onap.policy.sdc.Service; diff --git a/models-interactions/model-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java b/models-interactions/model-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java index 280c13ec1..1c96b2b90 100644 --- a/models-interactions/model-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java +++ b/models-interactions/model-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java @@ -21,7 +21,7 @@ package org.onap.policy.controlloop.policy.builder; -import org.onap.policy.aai.Pnf; +import org.onap.aai.domain.yang.Pnf; import org.onap.policy.controlloop.policy.ControlLoop; import org.onap.policy.controlloop.policy.OperationsAccumulateParams; import org.onap.policy.controlloop.policy.Policy; diff --git a/models-interactions/model-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java b/models-interactions/model-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java index 30eaf1bf2..779e3096f 100644 --- a/models-interactions/model-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java +++ b/models-interactions/model-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java @@ -25,7 +25,7 @@ import com.google.common.base.Strings; import java.util.LinkedList; import java.util.UUID; -import org.onap.policy.aai.Pnf; +import org.onap.aai.domain.yang.Pnf; import org.onap.policy.controlloop.compiler.CompilerException; import org.onap.policy.controlloop.compiler.ControlLoopCompiler; import org.onap.policy.controlloop.compiler.ControlLoopCompilerCallback; @@ -176,7 +176,7 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder { if (pnf == null) { throw new BuilderException("PNF must not be null"); } - if (pnf.getPnfName() == null && pnf.getPnfType() == null) { + if (pnf.getPnfName() == null && pnf.getEquipType() == null) { throw new BuilderException("Invalid PNF - need either pnfName or pnfType"); } controlLoopPolicy.getControlLoop().setPnf(pnf); diff --git a/models-interactions/model-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java b/models-interactions/model-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java index 3236bca3f..b6b5c7acb 100644 --- a/models-interactions/model-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java +++ b/models-interactions/model-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java @@ -36,8 +36,7 @@ import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.onap.policy.aai.Pnf; -import org.onap.policy.aai.PnfType; +import org.onap.aai.domain.yang.Pnf; import org.onap.policy.controlloop.policy.builder.BuilderException; import org.onap.policy.controlloop.policy.builder.ControlLoopPolicyBuilder; import org.onap.policy.controlloop.policy.builder.Message; @@ -239,7 +238,7 @@ public class ControlLoopPolicyBuilderTest { // PLEASE ADVISE IF THE BEHAVIOUR IS INCORRECT OR THE TEST CASE IS INVALID public void testControlLoopForPnf() throws BuilderException { Pnf pnf = new Pnf(); - pnf.setPnfType(PnfType.ENODEB); + //pnf.setPnfType(PnfType.ENODEB); ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400, pnf); assertEquals(pnf, builder.getControlLoop().getPnf()); @@ -257,7 +256,7 @@ public class ControlLoopPolicyBuilderTest { assertNull(builder.getControlLoop().getPnf()); Pnf pnf = new Pnf(); - pnf.setPnfType(PnfType.ENODEB); + //pnf.setPnfType(PnfType.ENODEB); builder.setPnf(pnf); assertEquals(pnf, builder.getControlLoop().getPnf()); diff --git a/models-interactions/model-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopTest.java b/models-interactions/model-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopTest.java index 23287da68..c0131f506 100644 --- a/models-interactions/model-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopTest.java +++ b/models-interactions/model-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopTest.java @@ -31,7 +31,7 @@ import java.util.List; import org.junit.Ignore; import org.junit.Test; -import org.onap.policy.aai.Pnf; +import org.onap.aai.domain.yang.Pnf; import org.onap.policy.common.utils.io.Serializer; import org.onap.policy.sdc.Resource; import org.onap.policy.sdc.ResourceType; diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java index d67f2d4cb..7faf19748 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. 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. @@ -121,7 +122,7 @@ public class PdpGroupFilter implements PfObjectFilter<PdpGroup> { if (matchPolicyTypesExactly && areListsIdentical(pdpSubGroup.getSupportedPolicyTypes(), typeFilter)) { return true; } else if (!matchPolicyTypesExactly - && findSingleElement(pdpSubGroup.getSupportedPolicyTypes(), typeFilter)) { + && findSupportedPolicyType(pdpSubGroup.getSupportedPolicyTypes(), typeFilter)) { return true; } } @@ -131,6 +132,32 @@ public class PdpGroupFilter implements PfObjectFilter<PdpGroup> { } /** + * Find a single supported type. + * + * @param supportedPolicyTypes supported types + * @param typeFilter the list of types, one of which we wish to find supported by + * the list we are searching + * @return true if one element of the elements to find is supported by an element on + * the list we searched + */ + private boolean findSupportedPolicyType(List<ToscaPolicyTypeIdentifier> supportedPolicyTypes, + List<ToscaPolicyTypeIdentifier> typeFilter) { + for (ToscaPolicyTypeIdentifier supportedPolicyType : supportedPolicyTypes) { + String supName = supportedPolicyType.getName(); + if (supName.endsWith(".*")) { + String substr = supName.substring(0, supName.length() - 1); + if (typeFilter.stream().anyMatch(type -> type.getName().startsWith(substr))) { + return true; + } + } else if (typeFilter.contains(supportedPolicyType)) { + return true; + } + } + + return false; + } + + /** * Filter PDP groups on policy. * * @param pdpGroup the PDP group to check diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java index 3a81c0b30..7d018860e 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java @@ -50,6 +50,7 @@ import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfKey; import org.onap.policy.models.base.PfKeyUse; import org.onap.policy.models.base.PfReferenceKey; +import org.onap.policy.models.base.PfSearchableKey; import org.onap.policy.models.base.PfUtils; import org.onap.policy.models.base.PfValidationMessage; import org.onap.policy.models.base.PfValidationResult; @@ -76,7 +77,7 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro private PfReferenceKey key; @ElementCollection - private List<PfConceptKey> supportedPolicyTypes; + private List<PfSearchableKey> supportedPolicyTypes; @ElementCollection private List<PfConceptKey> policies; @@ -127,7 +128,7 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro * @param policies policies deployed on this PDP subgroups * @param pdpInstances the PDP instances on this PDP subgroups */ - public JpaPdpSubGroup(@NonNull final PfReferenceKey key, @NonNull final List<PfConceptKey> supportedPolicyTypes, + public JpaPdpSubGroup(@NonNull final PfReferenceKey key, @NonNull final List<PfSearchableKey> supportedPolicyTypes, @NonNull List<PfConceptKey> policies, @NonNull final List<JpaPdp> pdpInstances) { this.key = key; this.supportedPolicyTypes = supportedPolicyTypes; @@ -144,7 +145,7 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro super(copyConcept); this.key = new PfReferenceKey(copyConcept.key); this.supportedPolicyTypes = PfUtils.mapList(copyConcept.supportedPolicyTypes, - PfConceptKey::new, new ArrayList<>(0)); + PfSearchableKey::new, new ArrayList<>(0)); this.policies = PfUtils.mapList(copyConcept.policies, PfConceptKey::new, new ArrayList<>(0)); this.currentInstanceCount = copyConcept.currentInstanceCount; this.desiredInstanceCount = copyConcept.desiredInstanceCount; @@ -168,7 +169,7 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro pdpSubgroup.setPdpType(getKey().getLocalName()); pdpSubgroup.setSupportedPolicyTypes(new ArrayList<>()); - for (PfConceptKey supportedPolicyTypeKey : supportedPolicyTypes) { + for (PfSearchableKey supportedPolicyTypeKey : supportedPolicyTypes) { ToscaPolicyTypeIdentifier supportedPolicyTypeIdent = new ToscaPolicyTypeIdentifier( supportedPolicyTypeKey.getName(), supportedPolicyTypeKey.getVersion()); pdpSubgroup.getSupportedPolicyTypes().add(supportedPolicyTypeIdent); @@ -205,7 +206,7 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro if (pdpSubgroup.getSupportedPolicyTypes() != null) { for (ToscaPolicyTypeIdentifier supportedPolicyType : pdpSubgroup.getSupportedPolicyTypes()) { this.supportedPolicyTypes - .add(new PfConceptKey(supportedPolicyType.getName(), supportedPolicyType.getVersion())); + .add(new PfSearchableKey(supportedPolicyType.getName(), supportedPolicyType.getVersion())); } } @@ -236,7 +237,7 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro public List<PfKey> getKeys() { List<PfKey> keyList = getKey().getKeys(); - for (PfConceptKey ptkey : supportedPolicyTypes) { + for (PfSearchableKey ptkey : supportedPolicyTypes) { keyList.add(new PfKeyUse(ptkey)); } @@ -256,7 +257,7 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro public void clean() { key.clean(); - for (PfConceptKey ptkey : supportedPolicyTypes) { + for (PfSearchableKey ptkey : supportedPolicyTypes) { ptkey.clean(); } @@ -330,7 +331,7 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID, "a PDP subgroup must support at least one policy type")); } else { - for (PfConceptKey supportedPolicyType : supportedPolicyTypes) { + for (PfSearchableKey supportedPolicyType : supportedPolicyTypes) { result = supportedPolicyType.validate(result); } } diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupFilterTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupFilterTest.java index 808bfe7d4..9ffb0f41d 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupFilterTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/PdpGroupFilterTest.java @@ -27,7 +27,7 @@ import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.List; - +import java.util.stream.Collectors; import org.junit.Before; import org.junit.Test; import org.onap.policy.common.utils.coder.CoderException; @@ -183,6 +183,22 @@ public class PdpGroupFilterTest { assertEquals(0, filteredList.size()); identifierList.clear(); + // don't match wild cards + identifierList.add(new ToscaPolicyTypeIdentifier(NON_EXISTANT, VERSION1)); + filter = PdpGroupFilter.builder().policyTypeList(identifierList).build(); + final List<PdpGroup> wildCards = + pdpGroupList.stream().map(this::makeWildCardPolicyTypes).collect(Collectors.toList()); + filteredList = filter.filter(wildCards); + assertEquals(0, filteredList.size()); + identifierList.clear(); + + // match wild cards + identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE0, VERSION1)); + filter = PdpGroupFilter.builder().policyTypeList(identifierList).build(); + filteredList = filter.filter(wildCards); + assertEquals(4, filteredList.size()); + identifierList.clear(); + identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE0, VERSION1)); filter = PdpGroupFilter.builder().policyTypeList(identifierList).build(); filteredList = filter.filter(pdpGroupList); @@ -251,6 +267,27 @@ public class PdpGroupFilterTest { assertEquals(1, filteredList.size()); } + /** + * Makes a clone of a PdpGroup, changing all occurrences of supported policy type, + * "policy.type.0", to a wild card type, "policy.type.*". + * + * @param group group to be cloned + * @return a new PdpGroup containing wild card policy types + */ + private PdpGroup makeWildCardPolicyTypes(PdpGroup group) { + PdpGroup newGroup = new PdpGroup(group); + + for (PdpSubGroup subgroup : newGroup.getPdpSubgroups()) { + for (ToscaPolicyTypeIdentifier subType : subgroup.getSupportedPolicyTypes()) { + if (POLICY_TYPE0.equals(subType.getName())) { + subType.setName("policy.type.*"); + } + } + } + + return newGroup; + } + @Test public void testFilterPolicy() { List<ToscaPolicyIdentifier> identifierList = new ArrayList<>(); diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java index ad0164ad4..2d2306978 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroupTest.java @@ -36,6 +36,7 @@ import java.util.List; import org.junit.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfReferenceKey; +import org.onap.policy.models.base.PfSearchableKey; import org.onap.policy.models.base.PfValidationResult; import org.onap.policy.models.pdp.concepts.PdpSubGroup; import org.onap.policy.models.pdp.testconcepts.DummyJpaPdpSubgroupChild; @@ -152,7 +153,7 @@ public class JpaPdpSubGroupTest { .contains("INVALID:a PDP subgroup must support at least one policy type")); testJpaPdpSubGroup.setSupportedPolicyTypes(new ArrayList<>()); - testJpaPdpSubGroup.getSupportedPolicyTypes().add(new PfConceptKey("APolicyType:1.0.0")); + testJpaPdpSubGroup.getSupportedPolicyTypes().add(new PfSearchableKey("APolicyType:1.0.0")); assertTrue(testJpaPdpSubGroup.validate(new PfValidationResult()).isOk()); assertFalse(testJpaPdpSubGroup.validate(new PfValidationResult()).toString() .contains("INVALID:a PDP subgroup must support at least one policy type")); @@ -188,7 +189,7 @@ public class JpaPdpSubGroupTest { testJpaPdpSubGroup.setProperties(null); assertTrue(testJpaPdpSubGroup.validate(new PfValidationResult()).isOk()); - List<PfConceptKey> supportedPolicyTypes = testJpaPdpSubGroup.getSupportedPolicyTypes(); + List<PfSearchableKey> supportedPolicyTypes = testJpaPdpSubGroup.getSupportedPolicyTypes(); assertNotNull(supportedPolicyTypes); testJpaPdpSubGroup.setSupportedPolicyTypes(null); assertFalse(testJpaPdpSubGroup.validate(new PfValidationResult()).isOk()); @@ -236,7 +237,7 @@ public class JpaPdpSubGroupTest { testJpaPdpSubGroup.setDesiredInstanceCount(0); assertEquals(0, testJpaPdpSubGroup.compareTo(otherJpaPdpSubGroup)); - PfConceptKey anotherPolicyType = new PfConceptKey("AnotherPolicyType", "1.0.0"); + PfSearchableKey anotherPolicyType = new PfSearchableKey("AnotherPolicyType.*", "1.0.0"); testJpaPdpSubGroup.getSupportedPolicyTypes().add(anotherPolicyType); assertNotEquals(0, testJpaPdpSubGroup.compareTo(otherJpaPdpSubGroup)); testJpaPdpSubGroup.getSupportedPolicyTypes().remove(anotherPolicyType); diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java index 565eb9afc..9971454bd 100644 --- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java +++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java @@ -111,7 +111,6 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider { daoParameters.setJdbcProperties(jdbcProperties); - pfDao = new PfDaoFactory().createPfDao(daoParameters); try { pfDao = new PfDaoFactory().createPfDao(daoParameters); pfDao.init(daoParameters); |