e84b3e2529bc0cd94baea71fc6fd016bc8a07abf
[policy/apex-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
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
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
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  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.apex.model.basicmodel.service;
22
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertFalse;
25 import static org.junit.Assert.assertNotNull;
26 import static org.junit.Assert.assertTrue;
27
28 import org.junit.Test;
29
30 /**
31  * @author Liam Fallon (liam.fallon@ericsson.com)
32  */
33 public class TestParameterService {
34
35     @Test
36     public void testParameterService() {
37         ParameterService.clear();
38
39         assertFalse(ParameterService.existsParameters(LegalParameters.class));
40         try {
41             ParameterService.getParameters(LegalParameters.class);
42         } catch (final Exception e) {
43             assertEquals(
44                     "Parameters for org.onap.policy.apex.model.basicmodel.service.LegalParameters not found in parameter service",
45                     e.getMessage());
46         }
47
48         ParameterService.registerParameters(LegalParameters.class, new LegalParameters());
49         assertTrue(ParameterService.existsParameters(LegalParameters.class));
50         assertNotNull(ParameterService.getParameters(LegalParameters.class));
51
52         ParameterService.deregisterParameters(LegalParameters.class);
53
54         assertFalse(ParameterService.existsParameters(LegalParameters.class));
55         try {
56             ParameterService.getParameters(LegalParameters.class);
57         } catch (final Exception e) {
58             assertEquals(
59                     "Parameters for org.onap.policy.apex.model.basicmodel.service.LegalParameters not found in parameter service",
60                     e.getMessage());
61         }
62
63         ParameterService.registerParameters(LegalParameters.class, new LegalParameters());
64         assertTrue(ParameterService.existsParameters(LegalParameters.class));
65         assertNotNull(ParameterService.getParameters(LegalParameters.class));
66
67         assertNotNull(ParameterService.getAll());
68         ParameterService.clear();
69         assertFalse(ParameterService.existsParameters(LegalParameters.class));
70         try {
71             ParameterService.getParameters(LegalParameters.class);
72         } catch (final Exception e) {
73             assertEquals(
74                     "Parameters for org.onap.policy.apex.model.basicmodel.service.LegalParameters not found in parameter service",
75                     e.getMessage());
76         }
77
78     }
79 }