72cbae22ce9f016873cf0a4ac23748eff6b80564
[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.client.editor.rest.handling.bean;
22
23 import static org.junit.Assert.assertNotNull;
24 import static org.junit.Assert.assertNull;
25 import static org.junit.Assert.fail;
26
27 import org.junit.Test;
28
29 /**
30  * Test the beans.
31  * @author Liam Fallon (liam.fallon@ericsson.com)
32  */
33 public class TestBeans {
34
35     @Test
36     public void testBeans() {
37         assertNotNull(new BeanEvent().toString());
38         assertNotNull(new BeanState().toString());
39         assertNotNull(new BeanContextAlbum().toString());
40         assertNotNull(new BeanPolicy().toString());
41         assertNotNull(new BeanContextSchema().toString());
42         assertNotNull(new BeanField().toString());
43         assertNotNull(new BeanModel().toString());
44         assertNotNull(new BeanLogic().toString());
45         assertNotNull(new BeanStateOutput().toString());
46         assertNotNull(new BeanTaskParameter().toString());
47         assertNotNull(new BeanKeyRef().toString());
48         assertNotNull(new BeanStateTaskRef().toString());
49         assertNotNull(new BeanTask().toString());
50
51         final BeanState beanState = new BeanState();
52         assertNull(beanState.getName());
53         beanState.setDefaultTask(new BeanKeyRef());
54         assertNotNull(beanState.getDefaultTask());
55
56         final BeanEvent beanEvent = new BeanEvent();
57         assertNull(beanEvent.get("name"));
58
59         final BeanFake beanFake = new BeanFake();
60         assertNull(beanFake.get("name"));
61         assertNull(beanFake.get("field1"));
62
63         try {
64             beanFake.get("iDontExist");
65             fail("test should throw an exception here");
66         } catch (final IllegalArgumentException e) {
67             assertNotNull(e);
68         }
69         try {
70             beanFake.get("nome");
71             fail("test should throw an exception here");
72         } catch (final IllegalArgumentException e) {
73             assertNotNull(e);
74         }
75         try {
76             beanFake.get("field2");
77             fail("test should throw an exception here");
78         } catch (final IllegalArgumentException e) {
79             assertNotNull(e);
80         }
81         try {
82             beanFake.get("field3");
83             fail("test should throw an exception here");
84         } catch (final IllegalArgumentException e) {
85             assertNotNull(e);
86         }
87     }
88 }