bdf47fedc5371cfd5c38a387f6f5f42f53ed0f21
[policy/apex-pdp.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.apex.client.editor.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  * @author Liam Fallon (liam.fallon@ericsson.com)
33  */
34 public class BeansTest {
35
36     @Test
37     public void testBeans() {
38         assertNotNull(new BeanEvent().toString());
39         assertNotNull(new BeanState().toString());
40         assertNotNull(new BeanContextAlbum().toString());
41         assertNotNull(new BeanPolicy().toString());
42         assertNotNull(new BeanContextSchema().toString());
43         assertNotNull(new BeanField().toString());
44         assertNotNull(new BeanModel().toString());
45         assertNotNull(new BeanLogic().toString());
46         assertNotNull(new BeanStateOutput().toString());
47         assertNotNull(new BeanTaskParameter().toString());
48         assertNotNull(new BeanKeyRef().toString());
49         assertNotNull(new BeanStateTaskRef().toString());
50         assertNotNull(new BeanTask().toString());
51
52         final BeanState beanState = new BeanState();
53         assertNull(beanState.getName());
54         beanState.setDefaultTask(new BeanKeyRef());
55         assertNotNull(beanState.getDefaultTask());
56
57         final BeanEvent beanEvent = new BeanEvent();
58         assertNull(beanEvent.get("name"));
59
60         final DummyBeanBase beanFake = new DummyBeanBase();
61         assertNull(beanFake.get("name"));
62         assertNull(beanFake.get("field1"));
63
64         assertThatThrownBy(() -> beanFake.get("iDontExist")).isInstanceOf(IllegalArgumentException.class);
65         assertThatThrownBy(() -> beanFake.get("nome")).isInstanceOf(IllegalArgumentException.class);
66         assertThatThrownBy(() -> beanFake.get("field2")).isInstanceOf(IllegalArgumentException.class);
67         assertThatThrownBy(() -> beanFake.get("field3")).isInstanceOf(IllegalArgumentException.class);
68     }
69 }