summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-05-16 08:54:54 +0200
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-05-16 08:59:11 +0200
commitc4208db72297836601e1e4a579b60f96960bbdf3 (patch)
treeade19694865508d2089e3d0bdee85ae9953867a4 /src/test
parenta61b2948f9cbe25d0ec6cd957671d51d83c62a1a (diff)
Stop sdc-distribution-client upon service shutdown
- restore old behaviour by calling distributionClient.stop() - downgrade sdc-distribution-client version to 2.0.0 Issue-ID: AAI-3848 Change-Id: Id252f4d8e387a916dcbdebd5110b46432858ee6b Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/aai/modelloader/config/DistributionClientStartupConfigTest.java62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/test/java/org/onap/aai/modelloader/config/DistributionClientStartupConfigTest.java b/src/test/java/org/onap/aai/modelloader/config/DistributionClientStartupConfigTest.java
new file mode 100644
index 0000000..4dbdddb
--- /dev/null
+++ b/src/test/java/org/onap/aai/modelloader/config/DistributionClientStartupConfigTest.java
@@ -0,0 +1,62 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom AG Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.modelloader.config;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import org.junit.jupiter.api.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.onap.aai.modelloader.notification.EventCallback;
+import org.onap.sdc.api.IDistributionClient;
+import org.onap.sdc.api.results.IDistributionClientResult;
+import org.onap.sdc.utils.DistributionActionResultEnum;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+public class DistributionClientStartupConfigTest {
+
+ @Mock IDistributionClient distributionClient;
+ @Mock ModelLoaderConfig config;
+ @Mock EventCallback eventCallback;
+ @InjectMocks DistributionClientStartupConfig startupConfig;
+
+ @Test
+ public void thatClientIsInitialized() {
+ IDistributionClientResult initResult = mock(IDistributionClientResult.class);
+ when(distributionClient.init(any(), any())).thenReturn(initResult);
+ when(distributionClient.start()).thenReturn(initResult);
+ when(initResult.getDistributionActionResult()).thenReturn(DistributionActionResultEnum.SUCCESS);
+ startupConfig.initSdcClient();
+ verify(distributionClient, times(1)).init(any(), any());
+ verify(distributionClient, times(1)).start();
+ }
+
+ @Test
+ public void thatClientIsStoppedOnPreDestroy() {
+ startupConfig.destroy();
+ verify(distributionClient, times(1)).stop();
+ }
+
+}