summaryrefslogtreecommitdiffstats
path: root/appc-dg-util/appc-dg-util-bundle
diff options
context:
space:
mode:
Diffstat (limited to 'appc-dg-util/appc-dg-util-bundle')
-rw-r--r--appc-dg-util/appc-dg-util-bundle/pom.xml10
-rw-r--r--appc-dg-util/appc-dg-util-bundle/src/test/java/org/onap/appc/dg/util/AppcDgUtilActivatorTest.java27
-rw-r--r--appc-dg-util/appc-dg-util-bundle/src/test/java/org/onap/appc/dg/util/impl/UpgradeStubNodeImplTest.java47
3 files changed, 50 insertions, 34 deletions
diff --git a/appc-dg-util/appc-dg-util-bundle/pom.xml b/appc-dg-util/appc-dg-util-bundle/pom.xml
index faf77e4f0..bc032ecb2 100644
--- a/appc-dg-util/appc-dg-util-bundle/pom.xml
+++ b/appc-dg-util/appc-dg-util-bundle/pom.xml
@@ -96,11 +96,6 @@
<version>4.5.3</version>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.onap.ccsdk.sli.core</groupId>
<artifactId>sli-common</artifactId>
<scope>compile</scope>
@@ -190,6 +185,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<scope>test</scope>
diff --git a/appc-dg-util/appc-dg-util-bundle/src/test/java/org/onap/appc/dg/util/AppcDgUtilActivatorTest.java b/appc-dg-util/appc-dg-util-bundle/src/test/java/org/onap/appc/dg/util/AppcDgUtilActivatorTest.java
index 447013733..910987cf9 100644
--- a/appc-dg-util/appc-dg-util-bundle/src/test/java/org/onap/appc/dg/util/AppcDgUtilActivatorTest.java
+++ b/appc-dg-util/appc-dg-util-bundle/src/test/java/org/onap/appc/dg/util/AppcDgUtilActivatorTest.java
@@ -5,7 +5,9 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
- * =============================================================================
+ * ================================================================================
+ * Copyright (C) 2018 Nokia
+ * ================================================================================
* 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
@@ -23,36 +25,29 @@
package org.onap.appc.dg.util;
-import org.junit.Before;
+import static org.mockito.Mockito.verifyZeroInteractions;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
import org.osgi.framework.BundleContext;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.modules.junit4.PowerMockRunner;
-@RunWith(PowerMockRunner.class)
+@RunWith(MockitoJUnitRunner.class)
public class AppcDgUtilActivatorTest {
@Mock
private BundleContext bundleContext;
- private AppcDgUtilActivator appcDgUtilActivator;
-
- @Before
- public void setUp() throws Exception {
- appcDgUtilActivator = new AppcDgUtilActivator();
- }
-
@Test
public void start() {
- appcDgUtilActivator.start(bundleContext);
- PowerMockito.verifyStatic();
+ new AppcDgUtilActivator().start(bundleContext);
+ verifyZeroInteractions(bundleContext);
}
@Test
public void stop() {
- appcDgUtilActivator.stop(bundleContext);
- PowerMockito.verifyStatic();
+ new AppcDgUtilActivator().stop(bundleContext);
+ verifyZeroInteractions(bundleContext);
}
} \ No newline at end of file
diff --git a/appc-dg-util/appc-dg-util-bundle/src/test/java/org/onap/appc/dg/util/impl/UpgradeStubNodeImplTest.java b/appc-dg-util/appc-dg-util-bundle/src/test/java/org/onap/appc/dg/util/impl/UpgradeStubNodeImplTest.java
index 8bb1451dd..c59d5d488 100644
--- a/appc-dg-util/appc-dg-util-bundle/src/test/java/org/onap/appc/dg/util/impl/UpgradeStubNodeImplTest.java
+++ b/appc-dg-util/appc-dg-util-bundle/src/test/java/org/onap/appc/dg/util/impl/UpgradeStubNodeImplTest.java
@@ -6,6 +6,8 @@
* ================================================================================
* Copyright (C) 2017 Amdocs
* =============================================================================
+ * Copyright (C) 2018 Nokia
+ * =============================================================================
* 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
@@ -23,40 +25,59 @@
package org.onap.appc.dg.util.impl;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.mockito.Mockito.verifyZeroInteractions;
+
+import java.util.HashMap;
+import java.util.Map;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.appc.dg.util.UpgradeStubNode;
import org.onap.appc.exceptions.APPCException;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
-import org.onap.ccsdk.sli.adaptors.aai.AAIClient;
-import org.onap.ccsdk.sli.adaptors.aai.AAIService;
-
-import java.util.HashMap;
-import java.util.Map;
+@RunWith(MockitoJUnitRunner.class)
public class UpgradeStubNodeImplTest {
+
@Mock
private SvcLogicContext svcLogicContext;
- private UpgradeStubNodeImpl upgradeStubNode;
+ private UpgradeStubNode upgradeStubNode;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
upgradeStubNode = new UpgradeStubNodeImpl();
}
@Test
- public void testHandleUpgradeStubSuccess() throws APPCException {
+ public void handleUpgradeStub_shouldCompleteSuccessfully_whenFailureIndicatorIsNull() throws APPCException {
Map<String, String> params = new HashMap<>();
upgradeStubNode.handleUpgradeStub(params, svcLogicContext);
+ verifyZeroInteractions(svcLogicContext);
}
- @Test(expected = APPCException.class)
- public void testHandleUpgradeStubException() throws APPCException {
+ @Test
+ public void handleUpgradeStub_shouldCompleteSuccessfully_whenFailureIndicatorIsFalse() throws APPCException {
+ // GIVEN
Map<String, String> params = new HashMap<>();
- params.put("failureIndicator", "true");
+ params.put("failureIndicator", "false");
+ // WHEN
upgradeStubNode.handleUpgradeStub(params, svcLogicContext);
+ // THEN
+ verifyZeroInteractions(svcLogicContext);
+ }
+
+ @Test
+ public void handleUpgradeStub_shouldThrowAPPCException_whenFailureIndicatorIsTrue() throws APPCException {
+ // GIVEN
+ Map<String, String> params = new HashMap<>();
+ params.put("failureIndicator", "true");
+ // WHEN // THEN
+ assertThatExceptionOfType(APPCException.class)
+ .isThrownBy(() -> upgradeStubNode.handleUpgradeStub(params, svcLogicContext));
+ verifyZeroInteractions(svcLogicContext);
}
} \ No newline at end of file