Actor redesign.
[policy/models.git] / models-interactions / model-actors / actorServiceProvider / src / test / java / org / onap / policy / controlloop / actorserviceprovider / parameters / ParameterValidationRuntimeExceptionTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.policy.controlloop.actorserviceprovider.parameters;
22
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNull;
25 import static org.junit.Assert.assertSame;
26
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;
33
34 public class ParameterValidationRuntimeExceptionTest {
35
36     private static final String THE_MESSAGE = "the message";
37     private static final IllegalStateException EXPECTED_EXCEPTION = new IllegalStateException("expected exception");
38
39     private ValidationResult result;
40
41     @Before
42     public void setUp() {
43         result = new ObjectValidationResult("param", null, ValidationStatus.INVALID, "null");
44     }
45
46     @Test
47     public void testParameterValidationExceptionValidationResult() {
48         ParameterValidationRuntimeException ex = new ParameterValidationRuntimeException(result);
49         assertSame(result, ex.getResult());
50         assertNull(ex.getMessage());
51     }
52
53     @Test
54     public void testParameterValidationExceptionValidationResultString() {
55         ParameterValidationRuntimeException ex = new ParameterValidationRuntimeException(THE_MESSAGE, result);
56         assertSame(result, ex.getResult());
57         assertEquals(THE_MESSAGE, ex.getMessage());
58     }
59
60     @Test
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());
66     }
67
68     @Test
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());
75     }
76
77     @Test
78     public void testGetResult() {
79         ParameterValidationRuntimeException ex = new ParameterValidationRuntimeException(result);
80         assertSame(result, ex.getResult());
81     }
82 }