2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.controlloop.actorserviceprovider.parameters;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNull;
25 import static org.junit.Assert.assertSame;
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.onap.policy.common.parameters.ObjectValidationResult;
30 import org.onap.policy.common.parameters.ValidationResult;
31 import org.onap.policy.common.parameters.ValidationStatus;
32 import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
34 public class ParameterValidationRuntimeExceptionTest {
36 private static final String THE_MESSAGE = "the message";
37 private static final IllegalStateException EXPECTED_EXCEPTION = new IllegalStateException("expected exception");
39 private ValidationResult result;
43 result = new ObjectValidationResult("param", null, ValidationStatus.INVALID, "null");
47 public void testParameterValidationExceptionValidationResult() {
48 ParameterValidationRuntimeException ex = new ParameterValidationRuntimeException(result);
49 assertSame(result, ex.getResult());
50 assertNull(ex.getMessage());
54 public void testParameterValidationExceptionValidationResultString() {
55 ParameterValidationRuntimeException ex = new ParameterValidationRuntimeException(THE_MESSAGE, result);
56 assertSame(result, ex.getResult());
57 assertEquals(THE_MESSAGE, ex.getMessage());
61 public void testParameterValidationExceptionValidationResultThrowable() {
62 ParameterValidationRuntimeException ex = new ParameterValidationRuntimeException(EXPECTED_EXCEPTION, result);
63 assertSame(result, ex.getResult());
64 assertEquals(EXPECTED_EXCEPTION.toString(), ex.getMessage());
65 assertEquals(EXPECTED_EXCEPTION, ex.getCause());
69 public void testParameterValidationExceptionValidationResultStringThrowable() {
70 ParameterValidationRuntimeException ex =
71 new ParameterValidationRuntimeException(THE_MESSAGE, EXPECTED_EXCEPTION, result);
72 assertSame(result, ex.getResult());
73 assertEquals(THE_MESSAGE, ex.getMessage());
74 assertEquals(EXPECTED_EXCEPTION, ex.getCause());
78 public void testGetResult() {
79 ParameterValidationRuntimeException ex = new ParameterValidationRuntimeException(result);
80 assertSame(result, ex.getResult());