2 * ============LICENSE_START=======================================================
3 * Copyright (c) 2021 Bell Canada.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 * ============LICENSE_END=========================================================
19 package org.onap.cps.temporal.controller.event.listener.exception;
21 import java.io.Serializable;
22 import java.util.ArrayList;
23 import java.util.List;
24 import lombok.AllArgsConstructor;
25 import lombok.EqualsAndHashCode;
27 import lombok.ToString;
30 * Class representing an invalid event envelop exception.
33 public class InvalidEventEnvelopException extends EventListenerException {
35 private final List<InvalidField> invalidFields = new ArrayList<>();
37 public InvalidEventEnvelopException(final String message) {
41 public void addInvalidField(final InvalidField invalidField) {
42 this.invalidFields.add(invalidField);
45 public boolean hasInvalidFields() {
46 return ! this.invalidFields.isEmpty();
50 public String getMessage() {
51 return String.format("%s. invalidFields: %s", super.getMessage(), this.invalidFields.toString());
58 public static class InvalidField implements Serializable {
60 private static final long serialVersionUID = -7118283787669377391L;
62 private final ErrorType errorType;
63 private final String fieldName;
64 private final String actualValue;
65 private final String expectedValue;
67 public enum ErrorType {