Merge "Reorder modifiers"
[so.git] / mso-catalog-db / src / test / java / org / openecomp / mso / db / catalog / beans / BeansTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.mso.db.catalog.beans;
22
23 import static org.hamcrest.CoreMatchers.isA;
24 import static org.mockito.Matchers.eq;
25
26 import org.hamcrest.CoreMatchers;
27 import org.hamcrest.Matcher;
28 import org.junit.Test;
29 import org.openecomp.mso.openpojo.rules.EqualsAndHashCodeTester;
30 import org.openecomp.mso.openpojo.rules.HasToStringRule;
31 import org.openecomp.mso.openpojo.rules.ToStringTester;
32
33 import com.openpojo.reflection.PojoClass;
34 import com.openpojo.reflection.PojoClassFilter;
35 import com.openpojo.reflection.filters.FilterEnum;
36 import com.openpojo.reflection.filters.FilterNonConcrete;
37 import com.openpojo.reflection.filters.FilterPackageInfo;
38 import com.openpojo.validation.Validator;
39 import com.openpojo.validation.ValidatorBuilder;
40 import com.openpojo.validation.rule.impl.GetterMustExistRule;
41 import com.openpojo.validation.rule.impl.SetterMustExistRule;
42 import com.openpojo.validation.test.impl.GetterTester;
43 import com.openpojo.validation.test.impl.SetterTester;
44
45
46 public class BeansTest {
47
48         private PojoClassFilter filterTestClasses = new FilterTestClasses();
49         
50         private PojoClassFilter  enumFilter = new FilterEnum();
51         
52         
53
54         @Test
55         public void pojoStructure() {   
56                 test("org.openecomp.mso.db.catalog.beans");             
57         }
58
59         private void test(String pojoPackage) {
60                 Validator validator = ValidatorBuilder.create()
61                                 .with(new GetterMustExistRule())
62                                 .with(new SetterMustExistRule())
63                                 .with(new HasToStringRule())
64                                 
65                                 
66                                 .with(new SetterTester())
67                                 .with(new GetterTester())
68                                 .with(new ToStringTester())
69                                 .with(new EqualsAndHashCodeTester().onlyDeclaredMethods())
70                                 .build();
71                 
72         
73                 validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses,enumFilter,new FilterNonConcrete());
74         }
75         private static class FilterTestClasses implements PojoClassFilter {
76                 public boolean include(PojoClass pojoClass) {
77                         return !pojoClass.getSourcePath().contains("/test-classes/");
78                 }
79         }
80 }