aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java')
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java55
1 files changed, 13 insertions, 42 deletions
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java
index f51b6da0..58933c1f 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Intel. All rights reserved.
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2020 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,9 +22,9 @@
package org.onap.policy.distribution.reception.handling.sdc;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import com.google.gson.Gson;
@@ -60,8 +61,6 @@ import org.onap.sdc.api.notification.INotificationData;
import org.onap.sdc.api.results.IDistributionClientDownloadResult;
import org.onap.sdc.api.results.IDistributionClientResult;
import org.onap.sdc.utils.DistributionActionResultEnum;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Class to perform unit test of {@link SdcReceptionHandler}.
@@ -71,7 +70,6 @@ import org.slf4j.LoggerFactory;
@RunWith(MockitoJUnitRunner.class)
public class TestSdcReceptionHandler {
- private static final Logger LOGGER = LoggerFactory.getLogger(TestSdcReceptionHandler.class);
private static final String DUMMY_SERVICE_CSAR = "dummyService.csar";
@Mock
@@ -141,12 +139,8 @@ public class TestSdcReceptionHandler {
@Test
public final void testInitializeSdcClient() {
- try {
- sypHandler.initializeReception(pssdConfigParameters.getName());
- } catch (final Exception exp) {
- LOGGER.error("testInitializeSdcClient failed", exp);
- fail("Test should not throw any exception");
- }
+ assertThatCode(() -> sypHandler.initializeReception(pssdConfigParameters.getName()))
+ .doesNotThrowAnyException();
}
@Test
@@ -154,61 +148,38 @@ public class TestSdcReceptionHandler {
Mockito.when(successfulClientInitResult.getDistributionActionResult())
.thenReturn(DistributionActionResultEnum.FAIL).thenReturn(DistributionActionResultEnum.SUCCESS);
- try {
- sypHandler.initializeReception(pssdConfigParameters.getName());
- } catch (final Exception exp) {
- LOGGER.error("testInitializeSdcClient_Failure failed", exp);
- fail("Test should not throw any exception");
- }
+ assertThatCode(() -> sypHandler.initializeReception(pssdConfigParameters.getName()))
+ .doesNotThrowAnyException();
}
@Test
public final void testStartSdcClient_Failure() {
- try {
+ assertThatCode(() -> {
Mockito.when(distributionClient.start()).thenReturn(failureClientInitResult)
- .thenReturn(successfulClientInitResult);
+ .thenReturn(successfulClientInitResult);
sypHandler.initializeReception(pssdConfigParameters.getName());
- } catch (final Exception exp) {
- LOGGER.error("testStartSdcClient_Failure failed", exp);
- fail("Test should not throw any exception");
- }
+ }).doesNotThrowAnyException();
}
@Test
public final void testStopSdcClient() {
- try {
+ assertThatCode(() -> {
sypHandler.initializeReception(pssdConfigParameters.getName());
sypHandler.destroy();
- } catch (final Exception exp) {
- LOGGER.error("testStopSdcClient failed", exp);
- fail("Test should not throw any exception");
- }
-
+ }).doesNotThrowAnyException();
}
@Test
public final void testStopSdcClient_Failure() throws PluginInitializationException {
-
sypHandler.initializeReception(pssdConfigParameters.getName());
Mockito.when(distributionClient.stop()).thenReturn(failureClientInitResult)
.thenReturn(successfulClientInitResult);
- try {
- sypHandler.destroy();
- } catch (final Exception exp) {
- LOGGER.error("testStopSdcClient_Failure failed", exp);
- fail("Test should not throw any exception");
- }
+ assertThatCode(() -> sypHandler.destroy()).doesNotThrowAnyException();
}
@Test
public final void testStopSdcClientWithoutStart() {
- try {
- sypHandler.destroy();
- } catch (final Exception exp) {
- LOGGER.error("testStopSdcClientWithoutStart", exp);
- fail("Test should not throw any exception");
- }
-
+ assertThatCode(() -> sypHandler.destroy()).doesNotThrowAnyException();
}
@Test