2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2019 Nordix Foundation.
5 * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * SPDX-License-Identifier: Apache-2.0
20 * ============LICENSE_END=========================================================
23 package org.onap.policy.apex.testsuites.integration.context.entities;
25 import java.util.Arrays;
26 import java.util.List;
27 import javax.persistence.EmbeddedId;
28 import javax.persistence.Entity;
29 import javax.persistence.Table;
30 import javax.xml.bind.annotation.XmlElement;
31 import lombok.AllArgsConstructor;
32 import lombok.EqualsAndHashCode;
35 import lombok.ToString;
36 import org.apache.commons.lang3.builder.CompareToBuilder;
37 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
38 import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
39 import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
40 import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
43 * The Class ArtifactKeyTestEntity is an entity for testing artifact keys.
46 @Table(name = "ArtifactKeyTestEntity")
50 @EqualsAndHashCode(callSuper = false)
52 public class ArtifactKeyTestEntity extends AxConcept {
53 private static final long serialVersionUID = -2962570563281067896L;
56 @XmlElement(name = "key", required = true)
57 protected AxArtifactKey key;
59 private double doubleValue;
62 * Instantiates a new artifact key test entity.
64 public ArtifactKeyTestEntity() {
65 this.key = new AxArtifactKey();
70 * Instantiates a new artifact key test entity.
72 * @param doubleValue the double value
74 public ArtifactKeyTestEntity(final Double doubleValue) {
75 this.key = new AxArtifactKey();
76 this.doubleValue = doubleValue;
83 public List<AxKey> getKeys() {
84 return Arrays.asList((AxKey) getKey());
90 * @return true, if successful
92 public boolean checkSetKey() {
93 return (this.key != null);
100 public AxValidationResult validate(final AxValidationResult result) {
101 return key.validate(result);
108 public void clean() {
116 public AxConcept copyTo(final AxConcept target) {
117 final Object copyObject = ((target == null) ? new ArtifactKeyTestEntity() : target);
118 if (copyObject instanceof ArtifactKeyTestEntity) {
119 final ArtifactKeyTestEntity copy = ((ArtifactKeyTestEntity) copyObject);
120 if (this.checkSetKey()) {
121 copy.setKey(new AxArtifactKey(key));
125 copy.doubleValue = doubleValue;
136 public int compareTo(final AxConcept otherObj) {
137 if (otherObj == null) {
140 if (this == otherObj) {
143 if (getClass() != otherObj.getClass()) {
146 final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) otherObj;
147 return new CompareToBuilder()
148 .append(key, other.key)
149 .append(doubleValue, other.doubleValue)