Replaced all tabs with spaces in java and pom.xml
[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 /*-
4  * ============LICENSE_START=======================================================
5  * ONAP - SO
6  * ================================================================================
7  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22 import org.junit.Before;
23 import org.junit.Test;
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().with(new SetterMustExistRule(), new GetterMustExistRule())
44                 .with(new SetterTester(), new GetterTester()).build();
45     }
46
47     @Test
48     public void validateBeansMsoApihandlerBeans() {
49         test("org.onap.so.apihandlerinfra.e2eserviceinstancebeans");
50         test("org.onap.so.apihandlerinfra.tasksbeans");
51         test("org.onap.so.apihandlerinfra.vnfbeans");
52         test("org.onap.so.apihandlerinfra.tenantisolationbeans");
53         test("org.onap.so.apihandlerinfra.workflowspecificationbeans");
54     }
55
56     private void test(String packageName) {
57         validator.validate(packageName, enumFilter, filterTestClasses);
58
59     }
60
61     private static class FilterTestClasses implements PojoClassFilter {
62         public boolean include(PojoClass pojoClass) {
63             return !pojoClass.getSourcePath().contains("/test-classes/");
64         }
65     }
66 }