diff options
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-activity-log-manager/src')
4 files changed, 18 insertions, 42 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImpl.java index 82d5ae10d7..c1dd5d0a75 100644 --- a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImpl.java +++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImpl.java @@ -20,8 +20,16 @@ import org.openecomp.sdc.activitylog.ActivityLogManagerFactory; import org.openecomp.sdc.activitylog.dao.ActivityLogDaoFactory; public class ActivityLogManagerFactoryImpl extends ActivityLogManagerFactory { - private static final ActivityLogManager INSTANCE = - new ActivityLogManagerImpl(ActivityLogDaoFactory.getInstance().createInterface()); + private final ActivityLogManager INSTANCE; + + + public ActivityLogManagerFactoryImpl() { + this.INSTANCE = new ActivityLogManagerImpl(ActivityLogDaoFactory.getInstance().createInterface()); + } + + ActivityLogManagerFactoryImpl(ActivityLogManager activityLogManager) { + this.INSTANCE = activityLogManager; + } @Override public ActivityLogManager createInterface() { diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogDaoStub.java b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogDaoStub.java index 4f311775bc..4f311775bc 100644 --- a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogDaoStub.java +++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogDaoStub.java diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImplTest.java b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImplTest.java index c00bcc3b54..4784d54862 100644 --- a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImplTest.java +++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImplTest.java @@ -20,42 +20,18 @@ package org.openecomp.sdc.activitylog.impl; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; +import org.junit.jupiter.api.Test; +import static org.mockito.Mockito.mock; import org.openecomp.sdc.activitylog.ActivityLogManager; -import org.openecomp.sdc.activitylog.dao.ActivityLogDao; -import org.openecomp.sdc.activitylog.dao.ActivityLogDaoFactory; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import static org.junit.Assert.assertNotNull; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.powermock.api.mockito.PowerMockito.when; +import static org.junit.jupiter.api.Assertions.assertNotNull; -@RunWith(PowerMockRunner.class) -@PrepareForTest(ActivityLogDaoFactory.class) public class ActivityLogManagerFactoryImplTest { - @Mock - ActivityLogDaoFactory activityLogDaoFactory; - @Mock - ActivityLogDao activityLogDao; - - @Before - public void setUp(){ - initMocks(this); - PowerMockito.mockStatic(ActivityLogDaoFactory.class); - when(ActivityLogDaoFactory.getInstance()).thenReturn(activityLogDaoFactory); - when(activityLogDaoFactory.createInterface()).thenReturn(activityLogDao); - - } - @Test public void createInterfaceTest(){ - ActivityLogManager activityLogManager = new ActivityLogManagerFactoryImpl().createInterface(); + ActivityLogManager activityLogManager = + new ActivityLogManagerFactoryImpl(mock(ActivityLogManager.class)).createInterface(); assertNotNull(activityLogManager); } } diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerImplTest.java index 0ce6098c61..44a4b20cc9 100644 --- a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerImplTest.java +++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerImplTest.java @@ -20,9 +20,8 @@ package org.openecomp.sdc.activitylog.impl; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity; import org.openecomp.sdc.versioning.dao.types.Version; @@ -33,18 +32,11 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; public class ActivityLogManagerImplTest { private ActivityLogManagerImpl activityLogManager; - @Mock - private ActivityLogDaoStub activityLogDao; - - @Before - public void setUp(){ - initMocks(this); - } + private ActivityLogDaoStub activityLogDao = Mockito.mock(ActivityLogDaoStub.class); @Test public void logActivityTest(){ |