2 * ============LICENSE_START=======================================================
3 * PNF-REGISTRATION-HANDLER
4 * ================================================================================
5 * Copyright (C) 2023 Deutsche Telekom 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=========================================================
20 package org.onap.dcaegen2.services.prh.configuration;
22 import static com.github.stefanbirkner.systemlambda.SystemLambda.withEnvironmentVariable;
23 import static java.lang.ClassLoader.getSystemResource;
24 import static org.assertj.core.api.Assertions.assertThat;
25 import static org.junit.jupiter.api.Assertions.assertEquals;
26 import java.nio.file.Files;
27 import java.nio.file.Paths;
28 import org.junit.jupiter.api.Test;
29 import com.google.gson.Gson;
30 import com.google.gson.JsonObject;
33 * * @author <a href="mailto:PRANIT.KAPDULE@t-systems.com">Pranit Kapdule</a> on
37 public class CbsConfigurationForAutoCommitDisabledModeTest {
40 * Testcase is used to check correctness of values provided by
41 * autoCommitDisabledConfigurationFromCbs2.json
45 void beforecbsConfigurationForAutoCommitDisabledMode() throws Exception {
46 withEnvironmentVariable("JAAS_CONFIG", "jaas_config").execute(() -> {
47 this.cbsConfigurationForAutoCommitDisabledMode();
51 void cbsConfigurationForAutoCommitDisabledMode() throws Exception {
53 JsonObject cbsConfigJsonForAutoCommitDisabled = new Gson().fromJson(
54 new String(Files.readAllBytes(
55 Paths.get(getSystemResource("autoCommitDisabledConfigurationFromCbs2.json").toURI()))),
57 CbsConfigurationForAutoCommitDisabledMode cbsConfigurationForAutoCommitDisabled = new CbsConfigurationForAutoCommitDisabledMode();
59 cbsConfigurationForAutoCommitDisabled.parseCBSConfig(cbsConfigJsonForAutoCommitDisabled);
61 String expectedKafKaBoostrapServerConfig = "onap-strimzi-kafka-bootstrap:9092";
62 String actualKafkaBoostrapServerConfig = (cbsConfigurationForAutoCommitDisabled.getKafkaConfig()
63 .kafkaBoostrapServerConfig());
65 String expectedGroupIdConfig = "OpenDCAE-c12";
66 String actualGroupIdConfig = (cbsConfigurationForAutoCommitDisabled.getKafkaConfig().groupIdConfig());
68 String expectedKafkaSecurityProtocol = "SASL_PLAINTEXT";
69 String actualKafkaSecurityProtocol = (cbsConfigurationForAutoCommitDisabled.getKafkaConfig()
70 .kafkaSecurityProtocol());
72 String expectedKafkaSaslMechanism = "SCRAM-SHA-512";
73 String actualKafkaSaslMechanism = (cbsConfigurationForAutoCommitDisabled.getKafkaConfig().kafkaSaslMechanism());
75 String expectedKafkaJaasConfig = "jaas_config";
76 String actualKafkaJaasConfig = (cbsConfigurationForAutoCommitDisabled.getKafkaConfig().kafkaJaasConfig());
78 String expectedAaiUserName = "AAI";
79 String actualAaiUserName = (cbsConfigurationForAutoCommitDisabled.getAaiClientConfiguration().aaiUserName());
81 String expectedConsumerGroup = "OpenDCAE-c12";
82 String actualConsumerGroup = (cbsConfigurationForAutoCommitDisabled.getMessageRouterSubscribeRequest()
85 assertEquals(expectedKafKaBoostrapServerConfig, actualKafkaBoostrapServerConfig,
86 "Expected value of KafKaBoostrapServerConfig is not matching with actual value");
87 assertEquals(expectedGroupIdConfig, actualGroupIdConfig,
88 "Expected value of GroupIdConfig is not matching with actual value");
89 assertEquals(expectedKafkaSecurityProtocol, actualKafkaSecurityProtocol,
90 "Expected value of KafkaSecurityProtocol is not matching with actual value");
91 assertEquals(expectedKafkaSaslMechanism, actualKafkaSaslMechanism,
92 "Expected value of KafkaSaslMechanism is not matching with actual value");
93 assertEquals(expectedKafkaJaasConfig, actualKafkaJaasConfig,
94 "Expected value of KafkaJaasConfig is not matching with actual value");
95 assertEquals(expectedAaiUserName, actualAaiUserName,
96 "Expected value of AaiUserName is not matching with actual value");
97 assertEquals(expectedConsumerGroup, actualConsumerGroup,
98 "Expected value of ConsumerGroup is not matching with actual value");
100 assertThat((cbsConfigurationForAutoCommitDisabled).getAaiClientConfiguration()).isNotNull();
101 assertThat((cbsConfigurationForAutoCommitDisabled).getMessageRouterPublisher()).isNotNull();
102 assertThat((cbsConfigurationForAutoCommitDisabled).getMessageRouterSubscriber()).isNotNull();
103 assertThat((cbsConfigurationForAutoCommitDisabled).getMessageRouterPublishRequest()).isNotNull();
104 assertThat((cbsConfigurationForAutoCommitDisabled).getMessageRouterSubscribeRequest()).isNotNull();
105 assertThat((cbsConfigurationForAutoCommitDisabled).getMessageRouterUpdatePublishRequest()).isNotNull();