Test coverage for appc-provider-topology 83/75583/2
authorJoss Armstrong <joss.armstrong@ericsson.com>
Wed, 9 Jan 2019 19:17:28 +0000 (19:17 +0000)
committerPatrick Brady <patrick.brady@att.com>
Wed, 9 Jan 2019 23:19:24 +0000 (23:19 +0000)
Increased line coverage from 0% to 86%

Issue-ID: APPC-1317
Change-Id: I2297634d50a389c8c250981656e00a9bb2741ea3
Signed-off-by: Joss Armstrong <joss.armstrong@ericsson.com>
appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/topology/TopologyService.java
appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/topology/TopologyServiceTest.java

index 74f3296..441aab6 100644 (file)
@@ -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);
index f3014e2..a4aed50 100644 (file)
@@ -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