diff options
Diffstat (limited to 'models-interactions/model-impl')
30 files changed, 514 insertions, 2158 deletions
diff --git a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/AppcLcmBody.java b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/AppcLcmBody.java new file mode 100644 index 000000000..590690be9 --- /dev/null +++ b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/AppcLcmBody.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * appclcm + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.appclcm; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import lombok.Data; + +@Data +public class AppcLcmBody implements Serializable { + + private static final long serialVersionUID = -466220696716397231L; + + @SerializedName("input") + private AppcLcmInput input; + + @SerializedName("output") + private AppcLcmOutput output; + +} 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 new file mode 100644 index 000000000..33a3c1f23 --- /dev/null +++ b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/AppcLcmCommonHeader.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * appclcm + * ================================================================================ + * 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.appclcm; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; +import java.time.Instant; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + +@NoArgsConstructor +@RequiredArgsConstructor +@Data +public class AppcLcmCommonHeader implements Serializable { + + private static final long serialVersionUID = 6581963539127062114L; + + @SerializedName(value = "timestamp") + private Instant timeStamp = Instant.now(); + + @SerializedName(value = "api-ver") + private String apiVer = "2.00"; + + @NonNull + @SerializedName(value = "originator-id") + private String originatorId; + + @NonNull + @SerializedName(value = "request-id") + private UUID requestId; + + @NonNull + @SerializedName(value = "sub-request-id") + private String subRequestId; + + @SerializedName(value = "flags") + private Map<String, String> flags = new HashMap<>(); + + /** + * Used to copy a common header. + * + * @param commonHeader a header that is defined by the lcm api guide that contains information + * about the request (requestId, flags, etc.) + */ + public AppcLcmCommonHeader(AppcLcmCommonHeader commonHeader) { + this.originatorId = commonHeader.originatorId; + this.requestId = commonHeader.requestId; + this.subRequestId = commonHeader.subRequestId; + if (commonHeader.flags != null) { + this.flags.putAll(commonHeader.flags); + } + } + +} diff --git a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/AppcLcmDmaapWrapper.java b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/AppcLcmDmaapWrapper.java new file mode 100644 index 000000000..893678306 --- /dev/null +++ b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/AppcLcmDmaapWrapper.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * appclcm + * ================================================================================ + * 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.appclcm; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; +import lombok.Data; + +@Data +public class AppcLcmDmaapWrapper implements Serializable { + + private static final long serialVersionUID = 753005805432396532L; + + @SerializedName(value = "version") + private String version; + + @SerializedName(value = "cambria-partition") + private String cambriaPartition; + + @SerializedName(value = "rpc-name") + private String rpcName; + + @SerializedName(value = "correlation-id") + private String correlationId; + + @SerializedName(value = "type") + private String type; + + @SerializedName("body") + private AppcLcmBody body; + +} diff --git a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/AppcLcmInput.java b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/AppcLcmInput.java new file mode 100644 index 000000000..879aea6c2 --- /dev/null +++ b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/AppcLcmInput.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * appclcm + * ================================================================================ + * 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.appclcm; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; +import java.util.Map; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Data +public class AppcLcmInput implements Serializable { + + private static final long serialVersionUID = 219375564922846624L; + + @SerializedName(value = "common-header") + private AppcLcmCommonHeader commonHeader; + + @SerializedName(value = "action") + private String action; + + @SerializedName(value = "action-identifiers") + private Map<String, String> actionIdentifiers; + + @SerializedName(value = "payload") + private String payload; + +} diff --git a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/AppcLcmOutput.java b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/AppcLcmOutput.java new file mode 100644 index 000000000..93e5a008c --- /dev/null +++ b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/AppcLcmOutput.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * appclcm + * ================================================================================ + * 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.appclcm; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@Data +public class AppcLcmOutput implements Serializable { + + private static final long serialVersionUID = 6332508597287669750L; + + @SerializedName(value = "common-header") + private AppcLcmCommonHeader commonHeader; + + @SerializedName(value = "status") + private AppcLcmResponseStatus status = new AppcLcmResponseStatus(); + + @SerializedName(value = "payload") + private String payload; + + /** + * Constructs a response using the common header of the request since they will be the same. + * + * @param request an appc lcm request object specified by the lcm api guide + */ + public AppcLcmOutput(AppcLcmInput request) { + this.commonHeader = new AppcLcmCommonHeader(request.getCommonHeader()); + String requestPayload = request.getPayload(); + if (requestPayload != null) { + this.payload = requestPayload; + } + } + +} diff --git a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseCode.java b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/AppcLcmResponseCode.java index 5fe0440e5..9d36ff809 100644 --- a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseCode.java +++ b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/AppcLcmResponseCode.java @@ -25,7 +25,7 @@ package org.onap.policy.appclcm; import java.io.Serializable; import org.onap.policy.appclcm.util.StatusCodeEnum; -public class LcmResponseCode implements Serializable { +public class AppcLcmResponseCode implements Serializable { /* These fields define the key to the response code value. */ public static final String ACCEPTED = "ACCEPTED"; @@ -39,7 +39,7 @@ public class LcmResponseCode implements Serializable { private final Integer code; - protected LcmResponseCode(final int code) { + protected AppcLcmResponseCode(final int code) { this.code = code; } diff --git a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/AppcLcmResponseStatus.java b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/AppcLcmResponseStatus.java new file mode 100644 index 000000000..3d02e8236 --- /dev/null +++ b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/AppcLcmResponseStatus.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * appclcm + * ================================================================================ + * 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.appclcm; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; +import lombok.Data; + +@Data +public class AppcLcmResponseStatus implements Serializable { + + private static final long serialVersionUID = 974891505135467199L; + + @SerializedName(value = "code") + private int code; + + @SerializedName(value = "message") + private String message; + +} diff --git a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmCommonHeader.java b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmCommonHeader.java deleted file mode 100644 index a2717f49c..000000000 --- a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmCommonHeader.java +++ /dev/null @@ -1,257 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appclcm - * ================================================================================ - * 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.appclcm; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.time.Instant; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -public class LcmCommonHeader implements Serializable { - - private static final long serialVersionUID = 6581963539127062114L; - - @SerializedName(value = "timestamp") - private Instant timeStamp = Instant.now(); - - @SerializedName(value = "api-ver") - private String apiVer = "2.00"; - - @SerializedName(value = "originator-id") - private String originatorId; - - @SerializedName(value = "request-id") - private UUID requestId; - - @SerializedName(value = "sub-request-id") - private String subRequestId; - - @SerializedName(value = "flags") - private Map<String, String> flags = new HashMap<>(); - - public LcmCommonHeader() { - - } - - /** - * Used to copy a common header. - * - * @param commonHeader a header that is defined by the lcm api guide that contains information - * about the request (requestId, flags, etc.) - */ - public LcmCommonHeader(LcmCommonHeader commonHeader) { - this.originatorId = commonHeader.originatorId; - this.requestId = commonHeader.requestId; - this.subRequestId = commonHeader.subRequestId; - if (commonHeader.flags != null) { - this.flags.putAll(commonHeader.flags); - } - } - - /** - * Get the timestamp. - * - * @return the timeStamp - */ - public Instant getTimeStamp() { - return timeStamp; - } - - /** - * Set the timestamp. - * - * @param timeStamp the timeStamp to set - */ - public void setTimeStamp(Instant timeStamp) { - this.timeStamp = timeStamp; - } - - /** - * Get the API version. - * - * @return the apiVer - */ - public String getApiVer() { - return apiVer; - } - - /** - * Set the API version. - * - * @param apiVer the apiVer to set - */ - public void setApiVer(String apiVer) { - this.apiVer = apiVer; - } - - /** - * Get the originator Id. - * - * @return the originatorId - */ - public String getOriginatorId() { - return originatorId; - } - - /** - * Set the originator Id. - * - * @param originatorId the originatorId to set - */ - public void setOriginatorId(String originatorId) { - this.originatorId = originatorId; - } - - /** - * Get the request Id. - * - * @return the requestId - */ - public UUID getRequestId() { - return requestId; - } - - /** - * Set the request Id. - * - * @param requestId the requestId to set - */ - public void setRequestId(UUID requestId) { - this.requestId = requestId; - } - - /** - * Get the sub request Id. - * - * @return the subRequestId - */ - public String getSubRequestId() { - return subRequestId; - } - - /** - * Set the sub request Id. - * - * @param subRequestId the subRequestId to set - */ - public void setSubRequestId(String subRequestId) { - this.subRequestId = subRequestId; - } - - /** - * Get the flags. - * - * @return the flags - */ - public Map<String, String> getFlags() { - return flags; - } - - /** - * Set the flags. - * - * @param flags the flags to set - */ - public void setFlags(Map<String, String> flags) { - this.flags = flags; - } - - @Override - public String toString() { - return "CommonHeader [timeStamp=" + timeStamp + ", apiVer=" + apiVer + ", originatorId=" + originatorId - + ", requestId=" + requestId + ", subRequestId=" + subRequestId + ", flags=" + flags + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((apiVer == null) ? 0 : apiVer.hashCode()); - result = prime * result + ((flags == null) ? 0 : flags.hashCode()); - result = prime * result + ((originatorId == null) ? 0 : originatorId.hashCode()); - result = prime * result + ((requestId == null) ? 0 : requestId.hashCode()); - result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode()); - result = prime * result + ((timeStamp == null) ? 0 : timeStamp.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - LcmCommonHeader other = (LcmCommonHeader) obj; - if (apiVer == null) { - if (other.apiVer != null) { - return false; - } - } else if (!apiVer.equals(other.apiVer)) { - return false; - } - if (flags == null) { - if (other.flags != null) { - return false; - } - } else if (!flags.equals(other.flags)) { - return false; - } - if (originatorId == null) { - if (other.originatorId != null) { - return false; - } - } else if (!originatorId.equals(other.originatorId)) { - return false; - } - if (requestId == null) { - if (other.requestId != null) { - return false; - } - } else if (!requestId.equals(other.requestId)) { - return false; - } - if (subRequestId == null) { - if (other.subRequestId != null) { - return false; - } - } else if (!subRequestId.equals(other.subRequestId)) { - return false; - } - if (timeStamp == null) { - if (other.timeStamp != null) { - return false; - } - } else if (!timeStamp.equals(other.timeStamp)) { - return false; - } - return true; - } - -} diff --git a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmRequest.java b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmRequest.java deleted file mode 100644 index 0ea6e9c7f..000000000 --- a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmRequest.java +++ /dev/null @@ -1,176 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appclcm - * ================================================================================ - * 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.appclcm; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.Map; - -public class LcmRequest implements Serializable { - - private static final long serialVersionUID = 219375564922846624L; - - @SerializedName(value = "common-header") - private LcmCommonHeader commonHeader; - - @SerializedName(value = "action") - private String action; - - @SerializedName(value = "action-identifiers") - private Map<String, String> actionIdentifiers; - - @SerializedName(value = "payload") - private String payload; - - public LcmRequest() { - // Create a default LCM request - } - - public LcmCommonHeader getCommonHeader() { - return commonHeader; - } - - /** - * Get the action. - * - * @return the action - */ - public String getAction() { - return action; - } - - /** - * Set the action. - * - * @param action the action to set - */ - public void setAction(String action) { - this.action = action; - } - - /** - * Get the action identifiers. - * - * @return the actionIdentifiers - */ - public Map<String, String> getActionIdentifiers() { - return actionIdentifiers; - } - - /** - * Set the action identifiers. - * - * @param actionIdentifiers the actionIdentifiers to set - */ - public void setActionIdentifiers(Map<String, String> actionIdentifiers) { - this.actionIdentifiers = actionIdentifiers; - } - - /** - * Get the payload. - * - * @return the payload - */ - public String getPayload() { - return payload; - } - - /** - * Set the payload. - * - * @param payload the payload to set - */ - public void setPayload(String payload) { - this.payload = payload; - } - - /** - * Get the common header. - * - * @param commonHeader the commonHeader to set - */ - public void setCommonHeader(LcmCommonHeader commonHeader) { - this.commonHeader = commonHeader; - } - - @Override - public String toString() { - return "Request [commonHeader=" + commonHeader + ", action=" + action + ", actionIdentifiers=" - + actionIdentifiers + ", payload=" + payload + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode()); - result = prime * result + ((action == null) ? 0 : action.hashCode()); - result = prime * result + ((actionIdentifiers == null) ? 0 : actionIdentifiers.hashCode()); - result = prime * result + ((payload == null) ? 0 : payload.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - LcmRequest other = (LcmRequest) obj; - if (commonHeader == null) { - if (other.commonHeader != null) { - return false; - } - } else if (!commonHeader.equals(other.commonHeader)) { - return false; - } - if (action == null) { - if (other.action != null) { - return false; - } - } else if (!action.equals(other.action)) { - return false; - } - if (actionIdentifiers == null) { - if (other.actionIdentifiers != null) { - return false; - } - } else if (!actionIdentifiers.equals(other.actionIdentifiers)) { - return false; - } - if (payload == null) { - if (other.payload != null) { - return false; - } - } else if (!payload.equals(other.payload)) { - return false; - } - return true; - } - -} diff --git a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmRequestWrapper.java b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmRequestWrapper.java deleted file mode 100644 index 4e23bfe2c..000000000 --- a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmRequestWrapper.java +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appclcm - * ================================================================================ - * 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.appclcm; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class LcmRequestWrapper extends LcmWrapper implements Serializable { - - private static final long serialVersionUID = 424866914715980798L; - - @SerializedName(value = "body") - private LcmRequest body; - - public LcmRequestWrapper() { - super(); - } - - public LcmRequestWrapper(LcmRequest request) { - body = request; - } - - /** - * Get the body. - * - * @return the body - */ - public LcmRequest getBody() { - return body; - } - - /** - * Set the body. - * - * @param body the body to set - */ - public void setBody(LcmRequest body) { - this.body = body; - } - - @Override - public String toString() { - return "RequestWrapper [body=" + body + ", toString()=" + super.toString() + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((body == null) ? 0 : body.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - LcmRequestWrapper other = (LcmRequestWrapper) obj; - if (body == null) { - if (other.body != null) { - return false; - } - } else if (!body.equals(other.body)) { - return false; - } - return true; - } - -} diff --git a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponse.java b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponse.java deleted file mode 100644 index ac214aa75..000000000 --- a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponse.java +++ /dev/null @@ -1,162 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appclcm - * ================================================================================ - * 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.appclcm; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class LcmResponse implements Serializable { - - private static final long serialVersionUID = 6332508597287669750L; - - @SerializedName(value = "common-header") - private LcmCommonHeader commonHeader; - - @SerializedName(value = "status") - private LcmResponseStatus status = new LcmResponseStatus(); - - @SerializedName(value = "payload") - private String payload; - - public LcmResponse() { - // EMPTY - } - - /** - * Constructs a response using the common header of the request since they will be the same. - * - * @param request an appc lcm request object specified by the lcm api guide - */ - public LcmResponse(LcmRequest request) { - this.commonHeader = new LcmCommonHeader(request.getCommonHeader()); - String requestPayload = request.getPayload(); - if (requestPayload != null) { - this.payload = requestPayload; - } - } - - /** - * Get the common header. - * - * @return the commonHeader - */ - public LcmCommonHeader getCommonHeader() { - return commonHeader; - } - - /** - * Set the common header. - * - * @param commonHeader the commonHeader to set - */ - public void setCommonHeader(LcmCommonHeader commonHeader) { - this.commonHeader = commonHeader; - } - - /** - * Get the status. - * - * @return the status - */ - public LcmResponseStatus getStatus() { - return status; - } - - /** - * Set the status. - * - * @param status the status to set - */ - public void setStatus(LcmResponseStatus status) { - this.status = status; - } - - /** - * Get the payload. - * - * @return the payload - */ - public String getPayload() { - return payload; - } - - /** - * Set the payload. - * - * @param payload the payload to set - */ - public void setPayload(String payload) { - this.payload = payload; - } - - @Override - public String toString() { - return "Response [commonHeader=" + commonHeader + ", status=" + status + ", payload=" + payload + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode()); - result = prime * result + ((payload == null) ? 0 : payload.hashCode()); - result = prime * result + ((status == null) ? 0 : status.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - LcmResponse other = (LcmResponse) obj; - if (commonHeader == null) { - if (other.commonHeader != null) { - return false; - } - } else if (!commonHeader.equals(other.commonHeader)) { - return false; - } - if (payload == null) { - if (other.payload != null) { - return false; - } - } else if (!payload.equals(other.payload)) { - return false; - } - if (status == null) { - if (other.status != null) { - return false; - } - } else if (!status.equals(other.status)) { - return false; - } - return true; - } -} diff --git a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseStatus.java b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseStatus.java deleted file mode 100644 index 86ec68aa4..000000000 --- a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseStatus.java +++ /dev/null @@ -1,117 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appclcm - * ================================================================================ - * 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.appclcm; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class LcmResponseStatus implements Serializable { - - private static final long serialVersionUID = 974891505135467199L; - - @SerializedName(value = "code") - private int code; - - @SerializedName(value = "message") - private String message; - - public LcmResponseStatus() { - // Create a default LCMResponseStatus instance - } - - /** - * Get the code. - * - * @return the code - */ - public int getCode() { - return code; - } - - /** - * Set the code. - * - * @param code the code to set - */ - public void setCode(int code) { - this.code = code; - } - - /** - * Get the message. - * - * @return the message - */ - public String getMessage() { - return message; - } - - /** - * Set the message. - * - * @param message the message to set - */ - public void setMessage(String message) { - this.message = message; - } - - @Override - public String toString() { - return "ResponseStatus [code=" + code + ", message=" + message + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + code; - result = prime * result + ((message == null) ? 0 : message.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - LcmResponseStatus other = (LcmResponseStatus) obj; - if (code != other.code) { - return false; - } - if (message == null) { - if (other.message != null) { - return false; - } - } else if (!message.equals(other.message)) { - return false; - } - return true; - } - -} diff --git a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseWrapper.java b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseWrapper.java deleted file mode 100644 index 1273017b4..000000000 --- a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseWrapper.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appclcm - * ================================================================================ - * 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.appclcm; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class LcmResponseWrapper extends LcmWrapper implements Serializable { - - private static final long serialVersionUID = 463937813781086802L; - - @SerializedName(value = "body") - private LcmResponse body; - - public LcmResponseWrapper() { - super(); - } - - /** - * Get the body. - * - * @return the body - */ - public LcmResponse getBody() { - return body; - } - - /** - * Set the body. - * - * @param body the body to set - */ - public void setBody(LcmResponse body) { - this.body = body; - } - - @Override - public String toString() { - return "ResponseWrapper [body=" + body + ", toString()=" + super.toString() + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((body == null) ? 0 : body.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - LcmResponseWrapper other = (LcmResponseWrapper) obj; - if (body == null) { - if (other.body != null) { - return false; - } - } else if (!body.equals(other.body)) { - return false; - } - return true; - } -} diff --git a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmWrapper.java b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmWrapper.java deleted file mode 100644 index f9a8d5589..000000000 --- a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmWrapper.java +++ /dev/null @@ -1,209 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appclcm - * ================================================================================ - * 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.appclcm; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class LcmWrapper implements Serializable { - - private static final long serialVersionUID = 753005805432396532L; - - @SerializedName(value = "version") - private String version; - - @SerializedName(value = "cambria-partition") - private String cambriaPartition; - - @SerializedName(value = "rpc-name") - private String rpcName; - - @SerializedName(value = "correlation-id") - private String correlationId; - - @SerializedName(value = "type") - private String type; - - public LcmWrapper() { - // Create a default LCMWrapper instance - } - - /** - * Get the version. - * - * @return the version - */ - public String getVersion() { - return version; - } - - /** - * Set the version. - * - * @param version the version to set - */ - public void setVersion(String version) { - this.version = version; - } - - /** - * Get the cambria partition. - * - * @return the cambriaPartition - */ - public String getCambriaPartition() { - return cambriaPartition; - } - - /** - * Set the cambria partition. - * - * @param cambriaPartition the cambriaPartition to set - */ - public void setCambriaPartition(String cambriaPartition) { - this.cambriaPartition = cambriaPartition; - } - - /** - * Get the RPN name. - * - * @return the rpcName - */ - public String getRpcName() { - return rpcName; - } - - /** - * Set the RPC name. - * - * @param rpcName the rpcName to set - */ - public void setRpcName(String rpcName) { - this.rpcName = rpcName; - } - - /** - * Get the correlation Id. - * - * @return the correlationId - */ - public String getCorrelationId() { - return correlationId; - } - - /** - * Set the correclation Id. - * - * @param correlationId the correlationId to set - */ - public void setCorrelationId(String correlationId) { - this.correlationId = correlationId; - } - - /** - * Get the type. - * - * @return the type - */ - public String getType() { - return type; - } - - /** - * Set the type. - * - * @param type the type to set - */ - public void setType(String type) { - this.type = type; - } - - @Override - public String toString() { - return "Wrapper [version=" + version + ", cambriaPartition=" + cambriaPartition + ", rpcName=" + rpcName - + ", correlationId=" + correlationId + ", type=" + type + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((cambriaPartition == null) ? 0 : cambriaPartition.hashCode()); - result = prime * result + ((correlationId == null) ? 0 : correlationId.hashCode()); - result = prime * result + ((rpcName == null) ? 0 : rpcName.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - result = prime * result + ((version == null) ? 0 : version.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - LcmWrapper other = (LcmWrapper) obj; - if (cambriaPartition == null) { - if (other.cambriaPartition != null) { - return false; - } - } else if (!cambriaPartition.equals(other.cambriaPartition)) { - return false; - } - if (correlationId == null) { - if (other.correlationId != null) { - return false; - } - } else if (!correlationId.equals(other.correlationId)) { - return false; - } - if (rpcName == null) { - if (other.rpcName != null) { - return false; - } - } else if (!rpcName.equals(other.rpcName)) { - return false; - } - if (type == null) { - if (other.type != null) { - return false; - } - } else if (!type.equals(other.type)) { - return false; - } - if (version == null) { - if (other.version != null) { - return false; - } - } else if (!version.equals(other.version)) { - return false; - } - return true; - } - -} diff --git a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/Serialization.java b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/Serialization.java index 5274db43d..9b522f323 100644 --- a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/Serialization.java +++ b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/Serialization.java @@ -1,6 +1,6 @@ -/*- +/* * ============LICENSE_START======================================================= - * appc + * appclcm * ================================================================================ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. @@ -26,7 +26,6 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; -import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; @@ -34,55 +33,18 @@ import com.google.gson.JsonSerializer; import java.lang.reflect.Type; import java.time.Instant; -import org.onap.policy.appclcm.LcmRequest; -import org.onap.policy.appclcm.LcmResponse; - public final class Serialization { public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() .registerTypeAdapter(Instant.class, new InstantAdapter()).create(); - public static final Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() - .registerTypeAdapter(LcmRequest.class, new RequestAdapter()) - .registerTypeAdapter(LcmResponse.class, new ResponseAdapter()).create(); + public static final Gson gson = new GsonBuilder().disableHtmlEscaping() + .registerTypeAdapter(Instant.class, new InstantAdapter()).create(); public static final Gson gsonJunit = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() .registerTypeAdapter(Instant.class, new InstantJunitAdapter()).create(); private Serialization() {} - public static class RequestAdapter implements JsonSerializer<LcmRequest>, JsonDeserializer<LcmRequest> { - - @Override - public JsonElement serialize(LcmRequest src, Type typeOfSrc, JsonSerializationContext context) { - JsonElement requestJson = gsonPretty.toJsonTree(src, LcmRequest.class); - JsonObject input = new JsonObject(); - input.add("input", requestJson); - - return input; - } - - @Override - public LcmRequest deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { - return gsonPretty.fromJson(json.getAsJsonObject().get("input"), LcmRequest.class); - } - } - - public static class ResponseAdapter implements JsonSerializer<LcmResponse>, JsonDeserializer<LcmResponse> { - - @Override - public JsonElement serialize(LcmResponse src, Type typeOfSrc, JsonSerializationContext context) { - JsonElement responseJson = gsonPretty.toJsonTree(src, LcmResponse.class); - JsonObject output = new JsonObject(); - output.add("output", responseJson); - return output; - } - - @Override - public LcmResponse deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { - return gsonPretty.fromJson(json.getAsJsonObject().get("output"), LcmResponse.class); - } - } - public static class InstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> { @Override diff --git a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/StatusCodeEnum.java b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/StatusCodeEnum.java index 8e3beb3c7..ed1498958 100644 --- a/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/StatusCodeEnum.java +++ b/models-interactions/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/StatusCodeEnum.java @@ -75,7 +75,7 @@ public enum StatusCodeEnum { } private static boolean isRejectStatusCode(final int statusCode) { - return statusCode >= 300 && statusCode <= 313; + return statusCode >= 300 && statusCode <= 316; } private static boolean isFailureStatusCode(final int statusCode) { diff --git a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmCommonHeaderTest.java b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmCommonHeaderTest.java new file mode 100644 index 000000000..1c71c85b8 --- /dev/null +++ b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmCommonHeaderTest.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * appclcm + * ================================================================================ + * 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.appclcm; + +import static org.junit.Assert.assertEquals; + +import java.util.UUID; +import org.junit.Test; + +public class AppcLcmCommonHeaderTest { + + @Test + public void testAppcLcmCommonHeaderConstructor() { + AppcLcmCommonHeader commonHeader = new AppcLcmCommonHeader("Policy", UUID.randomUUID(), "1"); + AppcLcmCommonHeader commonHeaderCopy = new AppcLcmCommonHeader(commonHeader); + assertEquals(commonHeader, commonHeaderCopy); + } + +} diff --git a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmModelsTest.java b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmModelsTest.java new file mode 100644 index 000000000..d1a02ea9e --- /dev/null +++ b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmModelsTest.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * appclcm + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.appclcm; + +import com.openpojo.reflection.filters.FilterClassName; +import com.openpojo.reflection.filters.FilterPackageInfo; +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; +import org.junit.Test; +import org.onap.policy.common.utils.test.ToStringTester; + +public class AppcLcmModelsTest { + private static final String POJO_PACKAGE = "org.onap.policy.appclcm"; + + @Test + public void testAppcLcmModels() { + final Validator validator = ValidatorBuilder.create().with(new ToStringTester()).with(new SetterTester()) + .with(new GetterTester()).build(); + + // exclude Test classes + validator.validate(POJO_PACKAGE, new FilterPackageInfo(), new FilterClassName("^((?!Test$).)*$")); + } + +} diff --git a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmOutputTest.java b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmOutputTest.java new file mode 100644 index 000000000..1490416cd --- /dev/null +++ b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmOutputTest.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * appclcm + * ================================================================================ + * 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.appclcm; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import org.junit.Test; + +public class AppcLcmOutputTest { + + @Test + public void testAppcLcmOutput() { + AppcLcmCommonHeader commonHeader = new AppcLcmCommonHeader("Policy", UUID.randomUUID(), "1"); + Map<String, String> actionIdentifiers = new HashMap<>(); + AppcLcmInput input = new AppcLcmInput(commonHeader, "testAction", actionIdentifiers, "testPayload"); + + AppcLcmOutput output = new AppcLcmOutput(input); + assertEquals(input.getPayload(), output.getPayload()); + + AppcLcmCommonHeader commonHeaderCopy = output.getCommonHeader(); + assertNotNull(commonHeaderCopy); + assertEquals(commonHeader.getOriginatorId(), commonHeaderCopy.getOriginatorId()); + assertEquals(commonHeader.getRequestId(), commonHeaderCopy.getRequestId()); + assertEquals(commonHeader.getSubRequestId(), commonHeaderCopy.getSubRequestId()); + assertEquals(commonHeader.getFlags(), commonHeaderCopy.getFlags()); + } + +} diff --git a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmResponseCodeTest.java b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmResponseCodeTest.java new file mode 100644 index 000000000..4cadd1e63 --- /dev/null +++ b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmResponseCodeTest.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * appclcm + * ================================================================================ + * Copyright (C) 2017-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. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.appclcm; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import org.junit.Test; + +public class AppcLcmResponseCodeTest { + + @Test + public void testAppcLcmResponseCode() { + assertNull(AppcLcmResponseCode.toResponseValue(0)); + + assertEquals(AppcLcmResponseCode.ACCEPTED, AppcLcmResponseCode.toResponseValue(100)); + assertEquals(AppcLcmResponseCode.ERROR, AppcLcmResponseCode.toResponseValue(200)); + assertEquals(AppcLcmResponseCode.REJECT, AppcLcmResponseCode.toResponseValue(300)); + assertEquals(AppcLcmResponseCode.SUCCESS, AppcLcmResponseCode.toResponseValue(400)); + assertEquals(AppcLcmResponseCode.FAILURE, AppcLcmResponseCode.toResponseValue(450)); + assertEquals(AppcLcmResponseCode.FAILURE, AppcLcmResponseCode.toResponseValue(401)); + assertEquals(AppcLcmResponseCode.FAILURE, AppcLcmResponseCode.toResponseValue(406)); + assertEquals(AppcLcmResponseCode.PARTIAL_SUCCESS, AppcLcmResponseCode.toResponseValue(500)); + assertEquals(AppcLcmResponseCode.PARTIAL_FAILURE, AppcLcmResponseCode.toResponseValue(501)); + assertEquals(AppcLcmResponseCode.PARTIAL_FAILURE, AppcLcmResponseCode.toResponseValue(599)); + + assertEquals("100", new AppcLcmResponseCode(100).toString()); + assertEquals("200", new AppcLcmResponseCode(200).toString()); + assertEquals("300", new AppcLcmResponseCode(300).toString()); + assertEquals("400", new AppcLcmResponseCode(400).toString()); + assertEquals("450", new AppcLcmResponseCode(450).toString()); + assertEquals("500", new AppcLcmResponseCode(500).toString()); + assertEquals("510", new AppcLcmResponseCode(510).toString()); + + assertEquals(300, new AppcLcmResponseCode(300).getCode()); + } +} diff --git a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java deleted file mode 100644 index 0ee79cf17..000000000 --- a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java +++ /dev/null @@ -1,239 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appclcm - * ================================================================================ - * 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.appclcm; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.HashMap; -import java.util.UUID; - -import org.junit.Test; -import org.onap.policy.appclcm.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AppcLcmTest { - - private static final String VNF_ID_KEY = "vnf-id"; - - private static final String RESTART = "restart"; - - private static final String CORRELATION_ID = "664be3d2-6c12-4f4b-a3e7-c349acced200"; - - private static final Logger logger = LoggerFactory.getLogger(AppcLcmTest.class); - - private static LcmRequestWrapper dmaapRequest; - private static LcmResponseWrapper dmaapResponse; - - static { - /* - * Construct an APPCLCM Request to be Serialized - */ - dmaapRequest = new LcmRequestWrapper(); - dmaapRequest.setCorrelationId(CORRELATION_ID + "-" + "1"); - dmaapRequest.setRpcName(RESTART); - dmaapRequest.setType("request"); - - dmaapResponse = new LcmResponseWrapper(); - dmaapResponse.setCorrelationId(CORRELATION_ID + "-" + "1"); - dmaapResponse.setRpcName(RESTART); - dmaapResponse.setType("response"); - - LcmRequest appcRequest = new LcmRequest(); - - appcRequest.setAction(RESTART); - - HashMap<String, String> actionIdentifiers = new HashMap<>(); - actionIdentifiers.put(VNF_ID_KEY, "trial-vnf-003"); - actionIdentifiers.put("vserver-id", "08f6c1f9-99e7-49f3-a662-c62b9f200d79"); - - appcRequest.setActionIdentifiers(actionIdentifiers); - - LcmCommonHeader commonHeader = new LcmCommonHeader(); - commonHeader.setRequestId(UUID.fromString(CORRELATION_ID)); - commonHeader.setSubRequestId("1"); - commonHeader.setOriginatorId(CORRELATION_ID); - - appcRequest.setCommonHeader(commonHeader); - - appcRequest.setPayload(null); - - dmaapRequest.setBody(appcRequest); - - /* - * Construct an APPCLCM Response to be Serialized - */ - LcmResponse appcResponse = new LcmResponse(appcRequest); - appcResponse.getStatus().setCode(400); - appcResponse.getStatus().setMessage("Restart Successful"); - appcResponse.setPayload(null); - - dmaapResponse.setBody(appcResponse); - } - - @Test - public void testRequestSerialization() { - - /* - * Use the gson serializer to obtain json - */ - String jsonRequest = Serialization.gson.toJson(dmaapRequest, LcmRequestWrapper.class); - assertNotNull(jsonRequest); - - /* - * The serializer should have added an extra sub-tag called "input" that wraps the request - */ - assertTrue(jsonRequest.contains("input")); - - /* - * The common-header, request-id, and sub-request-id should exist - */ - assertTrue(jsonRequest.contains("common-header")); - assertTrue(jsonRequest.contains("request-id")); - assertTrue(jsonRequest.contains("sub-request-id")); - - /* - * action-identifiers should exist and contain a vnf-id - */ - assertTrue(jsonRequest.contains("action-identifiers")); - assertTrue(jsonRequest.contains(VNF_ID_KEY)); - - /* - * The action sub-tag should exist - */ - assertTrue(jsonRequest.contains("action")); - - logger.debug("Request as JSON: " + jsonRequest + "\n\n"); - } - - @Test - public void testRequestDeserialization() { - - /* - * Convert the LCM request object into json so we have a string of json to use for testing - */ - String jsonRequest = Serialization.gson.toJson(dmaapRequest, LcmRequestWrapper.class); - - /* - * Use the serializer to convert the json string into a java object - */ - LcmRequestWrapper req = Serialization.gson.fromJson(jsonRequest, LcmRequestWrapper.class); - assertNotNull(req); - - /* - * The type of the DMAAP wrapper should be request - */ - assertEquals("request", req.getType()); - - /* - * The DMAAP wrapper must have a body as that is the true APPC request - */ - assertNotNull(req.getBody()); - LcmRequest appcRequest = req.getBody(); - assertNotNull(appcRequest); - - /* - * The common header should not be null - */ - assertNotNull(appcRequest.getCommonHeader()); - - /* - * The action should not be null and should be set to restart - */ - assertNotNull(appcRequest.getAction()); - assertEquals(RESTART, appcRequest.getAction()); - - /* - * The action-identifiers should not be null and should contain a vnf-id - */ - assertNotNull(appcRequest.getActionIdentifiers()); - assertNotNull(appcRequest.getActionIdentifiers().get(VNF_ID_KEY)); - - logger.debug("Request as a Java Object: \n" + appcRequest.toString() + "\n\n"); - } - - @Test - public void testResponseSerialization() { - - /* - * Use the serializer to convert the object into json - */ - String jsonResponse = Serialization.gson.toJson(dmaapResponse, LcmResponseWrapper.class); - assertNotNull(jsonResponse); - - /* - * The serializer should have added an extra sub-tag called "input" that wraps the request - */ - assertTrue(jsonResponse.contains("output")); - - /* - * The response should contain a common-header, request-id, sub-request-id, and status - */ - assertTrue(jsonResponse.contains("common-header")); - assertTrue(jsonResponse.contains("request-id")); - assertTrue(jsonResponse.contains("sub-request-id")); - assertTrue(jsonResponse.contains("status")); - - logger.debug("Response as JSON: " + jsonResponse + "\n\n"); - } - - @Test - public void testResponseDeserialization() { - /* - * Convert the LCM response object into json so we have a string of json to use for testing - */ - String jsonResponse = Serialization.gson.toJson(dmaapResponse, LcmResponseWrapper.class); - - /* - * Use the serializer to convert the json string into a java object - */ - LcmResponseWrapper resp = Serialization.gson.fromJson(jsonResponse, LcmResponseWrapper.class); - assertNotNull(resp); - - /* - * The type of the DMAAP wrapper should be response - */ - assertEquals("response", resp.getType()); - - /* - * The DMAAP wrapper must have a body as that is the true APPC response - */ - assertNotNull(resp.getBody()); - LcmResponse appcResponse = resp.getBody(); - assertNotNull(appcResponse); - - /* - * The common header should not be null - */ - assertNotNull(appcResponse.getCommonHeader()); - - /* - * The status should not be null and the status code should be 400 - */ - assertNotNull(appcResponse.getStatus()); - assertEquals(400, appcResponse.getStatus().getCode()); - - logger.debug("Response as a Java Object: \n" + appcResponse.toString() + "\n\n"); - } -} diff --git a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmCommonHeaderTest.java b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmCommonHeaderTest.java deleted file mode 100644 index 32a4954c1..000000000 --- a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmCommonHeaderTest.java +++ /dev/null @@ -1,148 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * 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.appclcm; - -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 java.time.Instant; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.junit.Test; - -public class LcmCommonHeaderTest { - - private static final String KANSAS = "Kansas"; - private static final String DOROTHY = "Dorothy"; - private static final String CAN_I_GO_HOME = "Can I go home?"; - - @Test - public void testLcmCommonHeader() { - LcmCommonHeader commonHeader = new LcmCommonHeader(); - assertNotNull(commonHeader); - assertNotNull(new LcmCommonHeader(commonHeader)); - assertNotEquals(0, commonHeader.hashCode()); - - commonHeader.setApiVer(KANSAS); - assertEquals(KANSAS, commonHeader.getApiVer()); - - Map<String, String> flagMap = new HashMap<>(); - commonHeader.setFlags(flagMap); - assertEquals(flagMap, commonHeader.getFlags()); - - commonHeader.setOriginatorId(DOROTHY); - assertEquals(DOROTHY, commonHeader.getOriginatorId()); - - UUID requestId = UUID.randomUUID(); - commonHeader.setRequestId(requestId); - assertEquals(requestId, commonHeader.getRequestId()); - - commonHeader.setSubRequestId(CAN_I_GO_HOME); - assertEquals(CAN_I_GO_HOME, commonHeader.getSubRequestId()); - - Instant timestamp = Instant.now(); - commonHeader.setTimeStamp(timestamp); - assertEquals(timestamp, commonHeader.getTimeStamp()); - - assertNotEquals(0, commonHeader.hashCode()); - - assertEquals("CommonHeader [timeStamp=", commonHeader.toString().substring(0, 24)); - - LcmCommonHeader copiedLcmCommonHeader = new LcmCommonHeader(); - copiedLcmCommonHeader.setApiVer(commonHeader.getApiVer()); - copiedLcmCommonHeader.setFlags(commonHeader.getFlags()); - copiedLcmCommonHeader.setOriginatorId(commonHeader.getOriginatorId()); - copiedLcmCommonHeader.setRequestId(commonHeader.getRequestId()); - copiedLcmCommonHeader.setSubRequestId(commonHeader.getSubRequestId()); - copiedLcmCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); - - assertTrue(commonHeader.equals(commonHeader)); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - assertFalse(commonHeader.equals(null)); - assertFalse(commonHeader.equals("Hello")); - - LcmCommonHeader clonedLcmCommonHeader = new LcmCommonHeader(commonHeader); - clonedLcmCommonHeader.setApiVer(commonHeader.getApiVer()); - clonedLcmCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); - - assertTrue(commonHeader.equals(clonedLcmCommonHeader)); - - commonHeader.setApiVer(null); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setApiVer(null); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - commonHeader.setApiVer(KANSAS); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setApiVer(KANSAS); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - - commonHeader.setFlags(null); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setFlags(null); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - commonHeader.setFlags(flagMap); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setFlags(flagMap); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - - commonHeader.setOriginatorId(null); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setOriginatorId(null); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - commonHeader.setOriginatorId(DOROTHY); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setOriginatorId(DOROTHY); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - - commonHeader.setRequestId(null); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setRequestId(null); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - commonHeader.setRequestId(requestId); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setRequestId(requestId); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - - commonHeader.setSubRequestId(null); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setSubRequestId(null); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - commonHeader.setSubRequestId(CAN_I_GO_HOME); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setSubRequestId(CAN_I_GO_HOME); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - - commonHeader.setTimeStamp(null); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setTimeStamp(null); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - commonHeader.setTimeStamp(timestamp); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setTimeStamp(timestamp); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - } -} diff --git a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestTest.java b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestTest.java deleted file mode 100644 index 40662935d..000000000 --- a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * 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.appclcm; - -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 java.util.HashMap; -import java.util.Map; - -import org.junit.Test; - -public class LcmRequestTest { - - private static final String THE_EMERALD_CITY = "The Emerald City"; - private static final String GO_TO_OZ = "Go to Oz"; - - @Test - public void testLcmRequest() { - LcmRequest request = new LcmRequest(); - assertNotNull(request); - assertNotEquals(0, request.hashCode()); - - LcmCommonHeader commonHeader = new LcmCommonHeader(); - - request.setCommonHeader(commonHeader); - assertEquals(commonHeader, request.getCommonHeader()); - - request.setAction(GO_TO_OZ); - assertEquals(GO_TO_OZ, request.getAction()); - - Map<String, String> actionIdentifiers = new HashMap<>(); - actionIdentifiers.put("North", "Good Witch"); - actionIdentifiers.put("West", "Bad Witch"); - - request.setActionIdentifiers(actionIdentifiers); - assertEquals(actionIdentifiers, request.getActionIdentifiers()); - - request.setPayload(THE_EMERALD_CITY); - assertEquals(THE_EMERALD_CITY, request.getPayload()); - - assertNotEquals(0, request.hashCode()); - - assertEquals("Request [commonHeader=CommonHeader [timeStamp=", request.toString().substring(0, 46)); - - LcmRequest copiedLcmRequest = new LcmRequest(); - copiedLcmRequest.setCommonHeader(request.getCommonHeader()); - copiedLcmRequest.setAction(request.getAction()); - copiedLcmRequest.setActionIdentifiers(request.getActionIdentifiers()); - copiedLcmRequest.setPayload(request.getPayload()); - - assertTrue(request.equals(request)); - assertTrue(request.equals(copiedLcmRequest)); - assertFalse(request.equals(null)); - assertFalse(request.equals("Hello")); - - request.setCommonHeader(null); - assertFalse(request.equals(copiedLcmRequest)); - copiedLcmRequest.setCommonHeader(null); - assertTrue(request.equals(copiedLcmRequest)); - request.setCommonHeader(commonHeader); - assertFalse(request.equals(copiedLcmRequest)); - copiedLcmRequest.setCommonHeader(commonHeader); - assertTrue(request.equals(copiedLcmRequest)); - - request.setAction(null); - assertFalse(request.equals(copiedLcmRequest)); - copiedLcmRequest.setAction(null); - assertTrue(request.equals(copiedLcmRequest)); - request.setAction(GO_TO_OZ); - assertFalse(request.equals(copiedLcmRequest)); - copiedLcmRequest.setAction(GO_TO_OZ); - assertTrue(request.equals(copiedLcmRequest)); - - request.setActionIdentifiers(null); - assertFalse(request.equals(copiedLcmRequest)); - copiedLcmRequest.setActionIdentifiers(null); - assertTrue(request.equals(copiedLcmRequest)); - request.setActionIdentifiers(actionIdentifiers); - assertFalse(request.equals(copiedLcmRequest)); - copiedLcmRequest.setActionIdentifiers(actionIdentifiers); - assertTrue(request.equals(copiedLcmRequest)); - - request.setPayload(null); - assertFalse(request.equals(copiedLcmRequest)); - copiedLcmRequest.setPayload(null); - assertTrue(request.equals(copiedLcmRequest)); - request.setPayload(THE_EMERALD_CITY); - assertFalse(request.equals(copiedLcmRequest)); - copiedLcmRequest.setPayload(THE_EMERALD_CITY); - assertTrue(request.equals(copiedLcmRequest)); - } -} diff --git a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestWrapperTest.java b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestWrapperTest.java deleted file mode 100644 index cd457935e..000000000 --- a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestWrapperTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * 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.appclcm; - -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; - -public class LcmRequestWrapperTest { - - @Test - public void testLcmRequestWrapperWrapper() { - assertNotNull(new LcmRequestWrapper(new LcmRequest())); - LcmRequestWrapper requestWrapper = new LcmRequestWrapper(); - assertNotNull(requestWrapper); - assertNotEquals(0, requestWrapper.hashCode()); - - LcmRequest request = new LcmRequest(); - - requestWrapper.setBody(request); - assertEquals(request, requestWrapper.getBody()); - - assertNotEquals(0, requestWrapper.hashCode()); - - assertEquals("RequestWrapper [body=Request [commonHeader=nul", requestWrapper.toString().substring(0, 46)); - - LcmRequestWrapper copiedLcmRequestWrapper = new LcmRequestWrapper(); - copiedLcmRequestWrapper.setBody(requestWrapper.getBody()); - - assertTrue(requestWrapper.equals(requestWrapper)); - assertTrue(requestWrapper.equals(copiedLcmRequestWrapper)); - assertFalse(requestWrapper.equals(null)); - assertFalse(requestWrapper.equals("Hello")); - - requestWrapper.setBody(null); - assertFalse(requestWrapper.equals(copiedLcmRequestWrapper)); - copiedLcmRequestWrapper.setBody(null); - assertTrue(requestWrapper.equals(copiedLcmRequestWrapper)); - requestWrapper.setBody(request); - assertFalse(requestWrapper.equals(copiedLcmRequestWrapper)); - copiedLcmRequestWrapper.setBody(request); - assertTrue(requestWrapper.equals(copiedLcmRequestWrapper)); - } -} diff --git a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResonseCodeTest.java b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResonseCodeTest.java deleted file mode 100644 index c22aa6597..000000000 --- a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResonseCodeTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * 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.appclcm; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import org.junit.Test; - -public class LcmResonseCodeTest { - - @Test - public void testLcmResponseCode() { - assertNull(LcmResponseCode.toResponseValue(0)); - - assertEquals(LcmResponseCode.ACCEPTED, LcmResponseCode.toResponseValue(100)); - assertEquals(LcmResponseCode.ERROR, LcmResponseCode.toResponseValue(200)); - assertEquals(LcmResponseCode.REJECT, LcmResponseCode.toResponseValue(300)); - assertEquals(LcmResponseCode.SUCCESS, LcmResponseCode.toResponseValue(400)); - assertEquals(LcmResponseCode.FAILURE, LcmResponseCode.toResponseValue(450)); - assertEquals(LcmResponseCode.FAILURE, LcmResponseCode.toResponseValue(401)); - assertEquals(LcmResponseCode.FAILURE, LcmResponseCode.toResponseValue(406)); - assertEquals(LcmResponseCode.PARTIAL_SUCCESS, LcmResponseCode.toResponseValue(500)); - assertEquals(LcmResponseCode.PARTIAL_FAILURE, LcmResponseCode.toResponseValue(501)); - assertEquals(LcmResponseCode.PARTIAL_FAILURE, LcmResponseCode.toResponseValue(599)); - - assertEquals("100", new LcmResponseCode(100).toString()); - assertEquals("200", new LcmResponseCode(200).toString()); - assertEquals("300", new LcmResponseCode(300).toString()); - assertEquals("400", new LcmResponseCode(400).toString()); - assertEquals("450", new LcmResponseCode(450).toString()); - assertEquals("500", new LcmResponseCode(500).toString()); - assertEquals("510", new LcmResponseCode(510).toString()); - - assertEquals(300, new LcmResponseCode(300).getCode()); - } -} diff --git a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseStatusTest.java b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseStatusTest.java deleted file mode 100644 index a4d1bc6d1..000000000 --- a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseStatusTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * 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.appclcm; - -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; - -public class LcmResponseStatusTest { - - private static final String THE_WONDERFUL_LAND_OF_OZ = "The wonderful land of Oz"; - - @Test - public void testResonseStatus() { - LcmResponseStatus status = new LcmResponseStatus(); - assertNotNull(status); - assertNotEquals(0, status.hashCode()); - - status.setCode(1234); - assertEquals(1234, status.getCode()); - - status.setMessage(THE_WONDERFUL_LAND_OF_OZ); - assertEquals(THE_WONDERFUL_LAND_OF_OZ, status.getMessage()); - - assertEquals("ResponseStatus [code=1234, message=The wonderfu", status.toString().substring(0, 47)); - - LcmResponseStatus copiedStatus = new LcmResponseStatus(); - copiedStatus.setCode(status.getCode()); - copiedStatus.setMessage(status.getMessage()); - - assertTrue(status.equals(status)); - assertTrue(status.equals(copiedStatus)); - assertFalse(status.equals(null)); - assertFalse(status.equals("Hello")); - - status.setCode(-1); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setCode(-1); - assertTrue(status.equals(copiedStatus)); - status.setCode(1234); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setCode(1234); - assertTrue(status.equals(copiedStatus)); - - status.setMessage(null); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setMessage(null); - assertTrue(status.equals(copiedStatus)); - status.setMessage(THE_WONDERFUL_LAND_OF_OZ); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setMessage(THE_WONDERFUL_LAND_OF_OZ); - assertTrue(status.equals(copiedStatus)); - } -} diff --git a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseTest.java b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseTest.java deleted file mode 100644 index 9388d2d2a..000000000 --- a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseTest.java +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appclcm - * ================================================================================ - * 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.appclcm; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class LcmResponseTest { - - private static final String PAYLOAD = "payload"; - - @Test - public void testHashCode() { - LcmResponse response = new LcmResponse(); - assertTrue(response.hashCode() != 0); - response.setCommonHeader(new LcmCommonHeader()); - assertTrue(response.hashCode() != 0); - response.setPayload(PAYLOAD); - assertTrue(response.hashCode() != 0); - response.setStatus(null); - assertTrue(response.hashCode() != 0); - } - - @Test - public void testLcmResponse() { - LcmResponse response = new LcmResponse(); - assertNull(response.getCommonHeader()); - assertNull(response.getPayload()); - assertNotNull(response.getStatus()); - } - - @Test - public void testToString() { - LcmResponse response = new LcmResponse(); - assertFalse(response.toString().isEmpty()); - } - - @Test - public void testEqualsObject() { - LcmResponse response = new LcmResponse(); - assertTrue(response.equals(response)); - assertFalse(response.equals(null)); - assertFalse(response.equals(new Object())); - - LcmResponse response2 = new LcmResponse(); - assertTrue(response.equals(response2)); - - response.setCommonHeader(new LcmCommonHeader()); - assertFalse(response.equals(response2)); - response2.setCommonHeader(response.getCommonHeader()); - assertTrue(response.equals(response2)); - - response.setPayload(PAYLOAD); - assertFalse(response.equals(response2)); - response2.setPayload(response.getPayload()); - assertTrue(response.equals(response2)); - - response.setCommonHeader(null); - assertFalse(response.equals(response2)); - response2.setCommonHeader(null); - assertTrue(response.equals(response2)); - - response.setPayload(null); - assertFalse(response.equals(response2)); - response2.setPayload(response.getPayload()); - assertTrue(response.equals(response2)); - - response.setStatus(null); - assertFalse(response.equals(response2)); - response2.setStatus(response.getStatus()); - assertTrue(response.equals(response2)); - - LcmResponseStatus status = new LcmResponseStatus(); - status.setCode(5); - response.setStatus(status); - response2.setStatus(new LcmResponseStatus()); - assertFalse(response.equals(response2)); - } - - @Test - public void testResponseRequest() { - LcmRequest request = new LcmRequest(); - request.setCommonHeader(new LcmCommonHeader()); - request.setPayload(PAYLOAD); - - LcmResponse response = new LcmResponse(request); - - assertTrue(response.getPayload().equals(PAYLOAD)); - } - -} diff --git a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseWrapperTest.java b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseWrapperTest.java deleted file mode 100644 index 09755144b..000000000 --- a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseWrapperTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * 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.appclcm; - -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; - -public class LcmResponseWrapperTest { - - @Test - public void testLcmResponseWrapperWrapper() { - LcmResponseWrapper responseWrapper = new LcmResponseWrapper(); - assertNotNull(responseWrapper); - assertNotEquals(0, responseWrapper.hashCode()); - - LcmResponse response = new LcmResponse(); - - responseWrapper.setBody(response); - assertEquals(response, responseWrapper.getBody()); - - assertNotEquals(0, responseWrapper.hashCode()); - - assertEquals("ResponseWrapper [body=Response [commonHeader=n", responseWrapper.toString().substring(0, 46)); - - LcmResponseWrapper copiedLcmResponseWrapper = new LcmResponseWrapper(); - copiedLcmResponseWrapper.setBody(responseWrapper.getBody()); - - assertTrue(responseWrapper.equals(responseWrapper)); - assertTrue(responseWrapper.equals(copiedLcmResponseWrapper)); - assertFalse(responseWrapper.equals(null)); - assertFalse(responseWrapper.equals("Hello")); - - responseWrapper.setBody(null); - assertFalse(responseWrapper.equals(copiedLcmResponseWrapper)); - copiedLcmResponseWrapper.setBody(null); - assertTrue(responseWrapper.equals(copiedLcmResponseWrapper)); - responseWrapper.setBody(response); - assertFalse(responseWrapper.equals(copiedLcmResponseWrapper)); - copiedLcmResponseWrapper.setBody(response); - assertTrue(responseWrapper.equals(copiedLcmResponseWrapper)); - } -} diff --git a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmWrapperTest.java b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmWrapperTest.java deleted file mode 100644 index 7d005cdd4..000000000 --- a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmWrapperTest.java +++ /dev/null @@ -1,122 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * 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.appclcm; - -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; - -public class LcmWrapperTest { - - private static final String YELLOW_BRICK_ROAD = "YellowBrickRoad"; - private static final String TORNADO = "Tornado"; - private static final String THE_EMERALD_CITY = "The Emerald City"; - private static final String MUNCHKIN = "Munchkin"; - private static final String VERSION19 = "19.3.9"; - - @Test - public void testLcmWrapper() { - LcmWrapper wrapper = new LcmWrapper(); - assertNotNull(wrapper); - assertNotEquals(0, wrapper.hashCode()); - - wrapper.setVersion(VERSION19); - assertEquals(VERSION19, wrapper.getVersion()); - - wrapper.setCambriaPartition(THE_EMERALD_CITY); - assertEquals(THE_EMERALD_CITY, wrapper.getCambriaPartition()); - - wrapper.setRpcName(TORNADO); - assertEquals(TORNADO, wrapper.getRpcName()); - - wrapper.setCorrelationId(YELLOW_BRICK_ROAD); - assertEquals(YELLOW_BRICK_ROAD, wrapper.getCorrelationId()); - - wrapper.setType(MUNCHKIN); - assertEquals(MUNCHKIN, wrapper.getType()); - - assertNotEquals(0, wrapper.hashCode()); - - assertEquals("Wrapper [version=19.3.9, cambriaPartition=The ", wrapper.toString().substring(0, 46)); - - LcmWrapper copiedLcmWrapper = new LcmWrapper(); - copiedLcmWrapper.setVersion(wrapper.getVersion()); - copiedLcmWrapper.setCambriaPartition(wrapper.getCambriaPartition()); - copiedLcmWrapper.setRpcName(wrapper.getRpcName()); - copiedLcmWrapper.setCorrelationId(wrapper.getCorrelationId()); - copiedLcmWrapper.setType(wrapper.getType()); - - assertTrue(wrapper.equals(wrapper)); - assertTrue(wrapper.equals(copiedLcmWrapper)); - assertFalse(wrapper.equals(null)); - assertFalse(wrapper.equals("Hello")); - - wrapper.setVersion(null); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setVersion(null); - assertTrue(wrapper.equals(copiedLcmWrapper)); - wrapper.setVersion(VERSION19); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setVersion(VERSION19); - assertTrue(wrapper.equals(copiedLcmWrapper)); - - wrapper.setCambriaPartition(null); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setCambriaPartition(null); - assertTrue(wrapper.equals(copiedLcmWrapper)); - wrapper.setCambriaPartition(THE_EMERALD_CITY); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setCambriaPartition(THE_EMERALD_CITY); - assertTrue(wrapper.equals(copiedLcmWrapper)); - - wrapper.setRpcName(null); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setRpcName(null); - assertTrue(wrapper.equals(copiedLcmWrapper)); - wrapper.setRpcName(TORNADO); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setRpcName(TORNADO); - assertTrue(wrapper.equals(copiedLcmWrapper)); - - wrapper.setCorrelationId(null); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setCorrelationId(null); - assertTrue(wrapper.equals(copiedLcmWrapper)); - wrapper.setCorrelationId(YELLOW_BRICK_ROAD); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setCorrelationId(YELLOW_BRICK_ROAD); - assertTrue(wrapper.equals(copiedLcmWrapper)); - - wrapper.setType(null); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setType(null); - assertTrue(wrapper.equals(copiedLcmWrapper)); - wrapper.setType(MUNCHKIN); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setType(MUNCHKIN); - assertTrue(wrapper.equals(copiedLcmWrapper)); - } -} diff --git a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/SerializationTest.java b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/SerializationTest.java index 7c0ca0aaf..c5f7d3086 100644 --- a/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/SerializationTest.java +++ b/models-interactions/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/SerializationTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * appc + * appclcm * ================================================================================ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. |