Jakarta changes in slice-analysis-ms for IBN Cloud leased line update and CCVPN close...
[dcaegen2/services.git] / components / slice-analysis-ms / src / test / java / org / onap / slice / analysis / ms / dmaap / MRTopicParamsTest.java
1 /*******************************************************************************
2  *  ============LICENSE_START=======================================================
3  *  slice-analysis-ms
4  *  ================================================================================
5  *   Copyright (C) 2022 Huawei Canada Limited.
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
22 package org.onap.slice.analysis.ms.dmaap;
23
24 import com.openpojo.reflection.PojoClass;
25 import com.openpojo.reflection.impl.PojoClassFactory;
26 import com.openpojo.validation.Validator;
27 import com.openpojo.validation.ValidatorBuilder;
28 import com.openpojo.validation.rule.impl.GetterMustExistRule;
29 import com.openpojo.validation.rule.impl.SetterMustExistRule;
30 import com.openpojo.validation.test.impl.GetterTester;
31 import com.openpojo.validation.test.impl.SetterTester;
32 import org.junit.Test;
33 import static org.junit.Assert.assertEquals;
34
35 public class MRTopicParamsTest {
36     private static final String TEST_TOPIC = "test-topic";
37     private static final String TEST_HOST = "test-host";
38     private static final String MY_CLIENT = "my-client";
39     private static final String MY_CG = "my-cg";
40     private static final String MY_CI = "my-ci";
41     private static final String MY_API_SEC = "my-api-sec";
42     private static final String MY_API_KEY = "my-api-key";
43     private static final int MY_FETCH_LIMIT = 100;
44     private static final int MY_FETCH_TIMEOUT = 1000;
45     private static final String MY_PASS = "my-pass";
46     private static final String MY_USERNAME = "my-username";
47     private static final int MY_PORT = 5555;
48
49     @Test
50     public void builderTest() {
51         MRTopicParams params = MRTopicParams.builder()
52                 .topic(TEST_TOPIC)
53                 .hostname(TEST_HOST)
54                 .clientName(MY_CLIENT)
55                 .consumerGroup(MY_CG)
56                 .consumerInstance(MY_CI)
57                 .apiSecret(MY_API_SEC)
58                 .apiKey(MY_API_KEY)
59                 .fetchLimit(MY_FETCH_LIMIT)
60                 .fetchTimeout(MY_FETCH_TIMEOUT)
61                 .password(MY_PASS)
62                 .userName(MY_USERNAME)
63                 .port(MY_PORT)
64                 .build();
65
66         assertEquals(TEST_TOPIC, params.getTopic());
67         assertEquals(TEST_HOST, params.getHostname());
68         assertEquals(MY_CLIENT, params.getClientName());
69         assertEquals(MY_CG, params.getConsumerGroup());
70         assertEquals(MY_CI, params.getConsumerInstance());
71         assertEquals(MY_API_SEC, params.getApiSecret());
72         assertEquals(MY_API_KEY, params.getApiKey());
73         assertEquals(MY_FETCH_LIMIT, params.getFetchLimit());
74         assertEquals(MY_FETCH_TIMEOUT, params.getFetchTimeout());
75         assertEquals(MY_PASS, params.getPassword());
76         assertEquals(MY_USERNAME, params.getUserName());
77         assertEquals(MY_PORT, params.getPort());
78     }
79
80     @Test
81     public void testGetterSetterMRTopicParams() {
82         PojoClass pojoclass = PojoClassFactory.getPojoClass(MRTopicParams.class);
83         validateMd(pojoclass);
84     }
85
86     public void validateMd(PojoClass pojoclass) {
87         Validator validator = ValidatorBuilder
88                 .create()
89                 .with(new SetterMustExistRule())
90                 .with(new GetterMustExistRule())
91                 .with(new SetterTester())
92                 .with(new GetterTester())
93                 .build();
94         validator.validate(pojoclass);
95     }
96 }