aboutsummaryrefslogtreecommitdiffstats
path: root/appc-provider
diff options
context:
space:
mode:
authorJoss Armstrong <joss.armstrong@ericsson.com>2019-01-09 19:17:28 +0000
committerPatrick Brady <patrick.brady@att.com>2019-01-09 23:19:24 +0000
commit670feaeaa8695d139e326b635c1f6bd1aa5e0dcf (patch)
treecb2e16829d5c2511283f6d250bc087fcdf5322a0 /appc-provider
parent2c496bab6f10006b28ec1aefae7b88ebd96ae437 (diff)
Test coverage for appc-provider-topology
Increased line coverage from 0% to 86% Issue-ID: APPC-1317 Change-Id: I2297634d50a389c8c250981656e00a9bb2741ea3 Signed-off-by: Joss Armstrong <joss.armstrong@ericsson.com>
Diffstat (limited to 'appc-provider')
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/topology/TopologyService.java7
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/topology/TopologyServiceTest.java27
2 files changed, 14 insertions, 20 deletions
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/topology/TopologyService.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/topology/TopologyService.java
index 74f3296d7..441aab624 100644
--- a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/topology/TopologyService.java
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/topology/TopologyService.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications (C) 2019 Ericsson
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,13 +38,10 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.att.eelf.i18n.EELFResourceManager;
import java.net.InetAddress;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import java.util.Properties;
-import java.util.TimeZone;
import org.onap.appc.Constants;
import org.onap.appc.configuration.Configuration;
import org.onap.appc.configuration.ConfigurationFactory;
@@ -601,7 +600,7 @@ public class TopologyService {
/*************************************************/
- private boolean callGraph(Properties props) {
+ protected boolean callGraph(Properties props) {
String moduleName = configuration.getProperty(Constants.PROPERTY_MODULE_NAME);
String methodName = configuration.getProperty(Constants.PROPERTY_TOPOLOGY_METHOD);
String version = configuration.getProperty(Constants.PROPERTY_TOPOLOGY_VERSION);
diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/topology/TopologyServiceTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/topology/TopologyServiceTest.java
index f3014e264..a4aed5048 100644
--- a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/topology/TopologyServiceTest.java
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/topology/TopologyServiceTest.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications (C) 2019 Ericsson
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +29,7 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.UUID;
import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.common.request.header.CommonRequestHeader;
import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.config.payload.ConfigPayload;
@@ -34,21 +37,19 @@ import org.opendaylight.yang.gen.v1.org.onap.appc.provider.rev160104.vnf.resourc
import org.onap.appc.configuration.Configuration;
import org.onap.appc.configuration.ConfigurationFactory;
import org.onap.appc.provider.AppcProvider;
-import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
-import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.internal.verification.VerificationModeFactory.times;
import static org.powermock.api.mockito.PowerMockito.mockStatic;
import static org.powermock.api.mockito.PowerMockito.spy;
-import static org.powermock.api.mockito.PowerMockito.verifyPrivate;
import static org.powermock.api.mockito.PowerMockito.when;
+import java.util.Properties;
@RunWith(PowerMockRunner.class)
-@PrepareForTest({TopologyService.class, ConfigurationFactory.class})
+@PrepareForTest(ConfigurationFactory.class)
public class TopologyServiceTest {
@Mock
private AppcProvider appcProvider;
@@ -71,11 +72,10 @@ public class TopologyServiceTest {
ConfigPayload configPayload = mock(ConfigPayload.class);
doReturn("url").when(configPayload).getConfigUrl();
doReturn("configJson").when(configPayload).getConfigJson();
- PowerMockito.doReturn(true).when(topologyService, "callGraph", any());
topologyService.modifyConfig(commonRequestHeader, configPayload);
- verifyPrivate(topologyService, times(1)).invoke("callGraph", any());
+ Mockito.verify(topologyService, times(1)).callGraph(Mockito.any(Properties.class));
}
@Test
@@ -86,11 +86,10 @@ public class TopologyServiceTest {
UUID uuid = mock(UUID.class);
doReturn("uuid-value").when(uuid).getValue();
doReturn(uuid).when(vnfResource).getVmId();
- PowerMockito.doReturn(true).when(topologyService, "callGraph", any());
topologyService.migrate(commonRequestHeader, vnfResource);
- verifyPrivate(topologyService, times(1)).invoke("callGraph", any());
+ Mockito.verify(topologyService, times(1)).callGraph(Mockito.any(Properties.class));
}
@Test
@@ -101,11 +100,10 @@ public class TopologyServiceTest {
UUID uuid = mock(UUID.class);
doReturn("uuid-value").when(uuid).getValue();
doReturn(uuid).when(vnfResource).getVmId();
- PowerMockito.doReturn(true).when(topologyService, "callGraph", any());
topologyService.restart(commonRequestHeader, vnfResource);
- verifyPrivate(topologyService, times(1)).invoke("callGraph", any());
+ Mockito.verify(topologyService, times(1)).callGraph(Mockito.any(Properties.class));
}
@Test
@@ -116,11 +114,10 @@ public class TopologyServiceTest {
UUID uuid = mock(UUID.class);
doReturn("uuid-value").when(uuid).getValue();
doReturn(uuid).when(vnfResource).getVmId();
- PowerMockito.doReturn(true).when(topologyService, "callGraph", any());
topologyService.rebuild(commonRequestHeader, vnfResource);
- verifyPrivate(topologyService, times(1)).invoke("callGraph", any());
+ Mockito.verify(topologyService, times(1)).callGraph(Mockito.any(Properties.class));
}
@Test
@@ -131,11 +128,10 @@ public class TopologyServiceTest {
UUID uuid = mock(UUID.class);
doReturn("uuid-value").when(uuid).getValue();
doReturn(uuid).when(vnfResource).getVmId();
- PowerMockito.doReturn(true).when(topologyService, "callGraph", any());
topologyService.snapshot(commonRequestHeader, vnfResource);
- verifyPrivate(topologyService, times(1)).invoke("callGraph", any());
+ Mockito.verify(topologyService, times(1)).callGraph(Mockito.any(Properties.class));
}
@Test
@@ -146,11 +142,10 @@ public class TopologyServiceTest {
UUID uuid = mock(UUID.class);
doReturn("uuid-value").when(uuid).getValue();
doReturn(uuid).when(vnfResource).getVmId();
- PowerMockito.doReturn(true).when(topologyService, "callGraph", any());
topologyService.vmstatuscheck(commonRequestHeader, vnfResource);
- verifyPrivate(topologyService, times(1)).invoke("callGraph", any());
+ Mockito.verify(topologyService, times(1)).callGraph(Mockito.any(Properties.class));
}
} \ No newline at end of file