aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-activity-log-manager
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-activity-log-manager')
-rw-r--r--openecomp-be/backend/openecomp-sdc-activity-log-manager/pom.xml23
-rw-r--r--openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogDaoStub.java37
-rw-r--r--openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImplTest.java41
-rw-r--r--openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerImplTest.java43
4 files changed, 144 insertions, 0 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/pom.xml b/openecomp-be/backend/openecomp-sdc-activity-log-manager/pom.xml
index deb8ac5c34..f96282e013 100644
--- a/openecomp-be/backend/openecomp-sdc-activity-log-manager/pom.xml
+++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/pom.xml
@@ -46,6 +46,29 @@
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4-common</artifactId>
+ <version>${powermock.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito2</artifactId>
+ <version>${powermock.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>${powermock.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
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/main/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogDaoStub.java
new file mode 100644
index 0000000000..438c8cb986
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogDaoStub.java
@@ -0,0 +1,37 @@
+package org.openecomp.sdc.activitylog.impl;
+
+import org.openecomp.sdc.activitylog.dao.ActivityLogDao;
+import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+public class ActivityLogDaoStub implements ActivityLogDao {
+ @Override
+ public Collection<ActivityLogEntity> list(ActivityLogEntity entity) {
+ List<ActivityLogEntity> list = new ArrayList<>();
+ list.add(entity);
+ return list;
+ }
+
+ @Override
+ public void create(ActivityLogEntity entity) {
+ //stub method
+ }
+
+ @Override
+ public void update(ActivityLogEntity entity) {
+ //stub method
+ }
+
+ @Override
+ public ActivityLogEntity get(ActivityLogEntity entity) {
+ return null;
+ }
+
+ @Override
+ public void delete(ActivityLogEntity entity) {
+ //stub method
+ }
+}
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/main/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImplTest.java
new file mode 100644
index 0000000000..7bf8028352
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImplTest.java
@@ -0,0 +1,41 @@
+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.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;
+
+@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();
+ 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/main/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerImplTest.java
new file mode 100644
index 0000000000..44efcc75fa
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerImplTest.java
@@ -0,0 +1,43 @@
+package org.openecomp.sdc.activitylog.impl;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.Collection;
+
+import static org.junit.Assert.assertEquals;
+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);
+ }
+
+ @Test
+ public void logActivityTest(){
+ activityLogManager = new ActivityLogManagerImpl(activityLogDao);
+ activityLogManager.logActivity(new ActivityLogEntity());
+ verify(activityLogDao, times(1)).create(any());
+ }
+
+ @Test
+ public void listLoggedActivitiesTest(){
+ activityLogManager = new ActivityLogManagerImpl(activityLogDao);
+ when(activityLogDao.list(any())).thenCallRealMethod();
+ Collection<ActivityLogEntity> collection = activityLogManager.listLoggedActivities("1", new Version());
+ assertEquals(collection.size(), 1);
+ }
+}