68c5c918ba49dcaadda09d8d76fecad87ee12499
[so.git] / mso-api-handlers / mso-api-handler-infra / src / test / java / org / onap / so / apihandlerinfra / BeanMultiTest.java
1 package org.onap.so.apihandlerinfra;
2 /*-
3  * ============LICENSE_START=======================================================
4  * ONAP - SO
5  * ================================================================================
6  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21 import org.junit.Before;
22 import org.junit.Test;
23
24 import com.openpojo.reflection.PojoClass;
25 import com.openpojo.reflection.PojoClassFilter;
26 import com.openpojo.reflection.filters.FilterEnum;
27 import com.openpojo.validation.Validator;
28 import com.openpojo.validation.ValidatorBuilder;
29 import com.openpojo.validation.rule.impl.GetterMustExistRule;
30 import com.openpojo.validation.rule.impl.SetterMustExistRule;
31 import com.openpojo.validation.test.impl.GetterTester;
32 import com.openpojo.validation.test.impl.SetterTester;
33
34 public class BeanMultiTest {
35
36         Validator validator;
37         PojoClassFilter enumFilter;
38         private PojoClassFilter filterTestClasses = new FilterTestClasses();
39
40         @Before
41         public void setup(){
42                 enumFilter = new FilterEnum();
43                 validator = ValidatorBuilder.create()
44                                 .with(new SetterMustExistRule(),
45                                                 new GetterMustExistRule())
46                                 .with(new SetterTester(),
47                                                 new GetterTester())
48                                 .build();
49         }
50         @Test
51         public void validateBeansMsoApihandlerBeans() {
52                 test("org.onap.so.apihandlerinfra.e2eserviceinstancebeans");            
53                 test("org.onap.so.apihandlerinfra.tasksbeans");
54                 test("org.onap.so.apihandlerinfra.vnfbeans");
55                 test("org.onap.so.apihandlerinfra.tenantisolationbeans");
56         }
57
58         private void test(String packageName) {
59                 validator.validate(packageName, enumFilter, filterTestClasses);
60
61         }
62         private static class FilterTestClasses implements PojoClassFilter {
63                 public boolean include(PojoClass pojoClass) {
64                         return !pojoClass.getSourcePath().contains("/test-classes/");
65                 }
66         }
67 }