diff options
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main')
4 files changed, 10 insertions, 183 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/main/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogDaoStub.java deleted file mode 100644 index 4f311775bc..0000000000 --- a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogDaoStub.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -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 deleted file mode 100644 index c00bcc3b54..0000000000 --- a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImplTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -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 deleted file mode 100644 index 0ce6098c61..0000000000 --- a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerImplTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -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); - } -} |