41b6e48d73959aeb03ade21c1bfd715ecbe191d4
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 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.onap.so.apihandlerinfra.tenantisolationbeans;
22
23 import static org.junit.Assert.assertNotNull;
24 import java.util.List;
25 import org.junit.Test;
26 import org.onap.so.apihandlerinfra.BaseTest;
27 import com.openpojo.reflection.PojoClass;
28 import com.openpojo.reflection.filters.FilterPackageInfo;
29 import com.openpojo.reflection.impl.PojoClassFactory;
30 import com.openpojo.validation.Validator;
31 import com.openpojo.validation.ValidatorBuilder;
32 import com.openpojo.validation.affirm.Affirm;
33 import com.openpojo.validation.rule.impl.GetterMustExistRule;
34 import com.openpojo.validation.rule.impl.SetterMustExistRule;
35 import com.openpojo.validation.test.impl.GetterTester;
36 import com.openpojo.validation.test.impl.SetterTester;
37
38 public class TenantIsolationBeansTest extends BaseTest {
39
40     private static final int EXPECTED_CLASS_COUNT = 25;
41     private static final String POJO_PACKAGE = "org.onap.so.apihandlerinfra.tenantisolationbeans";
42
43     @Test
44     public void ensureExpectedPojoCount() {
45         List<PojoClass> pojoClasses = PojoClassFactory.getPojoClasses(POJO_PACKAGE, new FilterPackageInfo());
46         Affirm.affirmEquals("Classes added / removed?", EXPECTED_CLASS_COUNT, pojoClasses.size());
47     }
48
49     @Test
50     public void testPojoStructureAndBehavior() {
51         Validator validator = ValidatorBuilder.create().with(new GetterMustExistRule()).with(new SetterMustExistRule())
52                 .with(new SetterTester()).with(new GetterTester()).build();
53
54         validator.validate(POJO_PACKAGE, new FilterPackageInfo());
55     }
56
57     @Test
58     public void testTenantIsolationToString() {
59         TenantIsolationRequest request = new TenantIsolationRequest();
60         request.setRequestId("requestId");
61         request.setRequestScope("scope");
62         request.setRequestType("type");
63         request.setStartTime("time");
64         request.setRequestDetails(new RequestDetails());
65         request.setRequestStatus(new RequestStatus());
66
67         assertNotNull(request.toString());
68     }
69
70     @Test
71     public void testRequestListToString() {
72         RequestList list = new RequestList();
73         list.setRequest(new Request());
74         list.setRequestStatus(new RequestStatus());
75
76         assertNotNull(list.toString());
77     }
78 }