2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.mso.db.catalog.beans;
23 import static org.hamcrest.CoreMatchers.isA;
24 import static org.mockito.Matchers.eq;
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;
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;
46 public class BeansTest {
48 private PojoClassFilter filterTestClasses = new FilterTestClasses();
50 private PojoClassFilter enumFilter = new FilterEnum();
55 public void pojoStructure() {
56 test("org.openecomp.mso.db.catalog.beans");
59 private void test(String pojoPackage) {
60 Validator validator = ValidatorBuilder.create()
61 .with(new GetterMustExistRule())
62 .with(new SetterMustExistRule())
63 .with(new HasToStringRule())
66 .with(new SetterTester())
67 .with(new GetterTester())
68 .with(new ToStringTester())
69 .with(new EqualsAndHashCodeTester().onlyDeclaredMethods())
73 validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses,enumFilter,new FilterNonConcrete());
75 private static class FilterTestClasses implements PojoClassFilter {
76 public boolean include(PojoClass pojoClass) {
77 return !pojoClass.getSourcePath().contains("/test-classes/");