c8c097175730a0a14eecf5fbb2659d1cef9b9e0c
[policy/gui.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
4  *  Modifications Copyright (C) 2020 Nordix Foundation
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.gui.editors.apex.rest.handling.bean;
23
24 import static org.assertj.core.api.Assertions.assertThatThrownBy;
25 import static org.junit.Assert.assertNotNull;
26 import static org.junit.Assert.assertNull;
27
28 import org.junit.Test;
29
30 /**
31  * Test the beans.
32  * 
33  * @author Liam Fallon (liam.fallon@ericsson.com)
34  */
35 public class BeansTest {
36
37     @Test
38     public void testBeans() {
39         assertNotNull(new BeanEvent().toString());
40         assertNotNull(new BeanState().toString());
41         assertNotNull(new BeanContextAlbum().toString());
42         assertNotNull(new BeanPolicy().toString());
43         assertNotNull(new BeanContextSchema().toString());
44         assertNotNull(new BeanField().toString());
45         assertNotNull(new BeanModel().toString());
46         assertNotNull(new BeanLogic().toString());
47         assertNotNull(new BeanStateOutput().toString());
48         assertNotNull(new BeanTaskParameter().toString());
49         assertNotNull(new BeanKeyRef().toString());
50         assertNotNull(new BeanStateTaskRef().toString());
51         assertNotNull(new BeanTask().toString());
52
53         final BeanState beanState = new BeanState();
54         assertNull(beanState.getName());
55         beanState.setDefaultTask(new BeanKeyRef());
56         assertNotNull(beanState.getDefaultTask());
57
58         final BeanEvent beanEvent = new BeanEvent();
59         assertNull(beanEvent.get("name"));
60
61         final DummyBeanBase beanFake = new DummyBeanBase();
62         assertNull(beanFake.get("name"));
63         assertNull(beanFake.get("field1"));
64
65         assertThatThrownBy(() -> beanFake.get("iDontExist")).isInstanceOf(IllegalArgumentException.class);
66         assertThatThrownBy(() -> beanFake.get("nome")).isInstanceOf(IllegalArgumentException.class);
67         assertThatThrownBy(() -> beanFake.get("field2")).isInstanceOf(IllegalArgumentException.class);
68         assertThatThrownBy(() -> beanFake.get("field3")).isInstanceOf(IllegalArgumentException.class);
69     }
70 }