From ed73921b083bddae1692e22cfd8fac5fdc2fd57b Mon Sep 17 00:00:00 2001 From: Rodrigo Lima Date: Tue, 19 May 2020 12:10:17 -0400 Subject: remove powermock dependency from pom xmls - Remove powermock from pom xml files - Remove powermock from ActivityLogManagerFactoryImplTest Issue-ID: SDC-3071 Signed-off-by: Rodrigo Lima Change-Id: I4c4b8b0751f4ce8895617a951429111fc08d8e2e --- .../externaltesting-rest-services/pom.xml | 18 ------- .../vendor-software-products-rest-services/pom.xml | 18 ------- .../openecomp-sdc-activity-log-manager/pom.xml | 18 ------- .../impl/ActivityLogManagerFactoryImpl.java | 12 ++++- .../sdc/activitylog/impl/ActivityLogDaoStub.java | 57 -------------------- .../impl/ActivityLogManagerFactoryImplTest.java | 61 --------------------- .../impl/ActivityLogManagerImplTest.java | 63 ---------------------- .../sdc/activitylog/impl/ActivityLogDaoStub.java | 57 ++++++++++++++++++++ .../impl/ActivityLogManagerFactoryImplTest.java | 37 +++++++++++++ .../impl/ActivityLogManagerImplTest.java | 55 +++++++++++++++++++ .../backend/openecomp-sdc-security-util/pom.xml | 19 ------- .../pom.xml | 18 ------- .../openecomp-sdc-logging-api/pom.xml | 13 ----- .../openecomp-sdc-logging-core/pom.xml | 18 ------- .../openecomp-sdc-notification-core/pom.xml | 6 --- 15 files changed, 159 insertions(+), 311 deletions(-) delete mode 100644 openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogDaoStub.java delete mode 100644 openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImplTest.java delete mode 100644 openecomp-be/backend/openecomp-sdc-activity-log-manager/src/main/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerImplTest.java create mode 100644 openecomp-be/backend/openecomp-sdc-activity-log-manager/src/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogDaoStub.java create mode 100644 openecomp-be/backend/openecomp-sdc-activity-log-manager/src/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImplTest.java create mode 100644 openecomp-be/backend/openecomp-sdc-activity-log-manager/src/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerImplTest.java (limited to 'openecomp-be') diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services/pom.xml index 036a072659..184ed4cd76 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services/pom.xml @@ -128,24 +128,6 @@ mockito-core test - - org.powermock - powermock-module-junit4-common - ${powermock.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.version} - test - - - org.powermock - powermock-module-junit4 - ${powermock.version} - test - org.openecomp.sdc openecomp-sdc-externaltesting-impl diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml index 1c4e61d406..6cd5727baa 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml @@ -136,24 +136,6 @@ unique-type-rest-types ${project.version} - - org.powermock - powermock-module-junit4-common - ${powermock.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.version} - test - - - org.powermock - powermock-module-junit4 - ${powermock.version} - test - 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 5dd93c33f4..ca548b44e5 100644 --- a/openecomp-be/backend/openecomp-sdc-activity-log-manager/pom.xml +++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/pom.xml @@ -46,24 +46,6 @@ ${project.version} runtime - - org.powermock - powermock-module-junit4-common - ${powermock.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.version} - test - - - org.powermock - powermock-module-junit4 - ${powermock.version} - test - 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 list(ActivityLogEntity entity) { - List 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 collection = activityLogManager.listLoggedActivities("1", new Version()); - assertEquals(collection.size(), 1); - } -} diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/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 new file mode 100644 index 0000000000..4f311775bc --- /dev/null +++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogDaoStub.java @@ -0,0 +1,57 @@ +/*- + * ============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 list(ActivityLogEntity entity) { + List 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/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 new file mode 100644 index 0000000000..4784d54862 --- /dev/null +++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerFactoryImplTest.java @@ -0,0 +1,37 @@ +/*- + * ============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.jupiter.api.Test; +import static org.mockito.Mockito.mock; +import org.openecomp.sdc.activitylog.ActivityLogManager; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +public class ActivityLogManagerFactoryImplTest { + + @Test + public void createInterfaceTest(){ + ActivityLogManager activityLogManager = + new ActivityLogManagerFactoryImpl(mock(ActivityLogManager.class)).createInterface(); + assertNotNull(activityLogManager); + } +} diff --git a/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/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 new file mode 100644 index 0000000000..44a4b20cc9 --- /dev/null +++ b/openecomp-be/backend/openecomp-sdc-activity-log-manager/src/test/java/org/openecomp/sdc/activitylog/impl/ActivityLogManagerImplTest.java @@ -0,0 +1,55 @@ +/*- + * ============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.jupiter.api.Test; +import org.mockito.Mockito; +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; + +public class ActivityLogManagerImplTest { + private ActivityLogManagerImpl activityLogManager; + + private ActivityLogDaoStub activityLogDao = Mockito.mock(ActivityLogDaoStub.class); + + @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 collection = activityLogManager.listLoggedActivities("1", new Version()); + assertEquals(collection.size(), 1); + } +} diff --git a/openecomp-be/backend/openecomp-sdc-security-util/pom.xml b/openecomp-be/backend/openecomp-sdc-security-util/pom.xml index dc114db09f..d9370ac6af 100644 --- a/openecomp-be/backend/openecomp-sdc-security-util/pom.xml +++ b/openecomp-be/backend/openecomp-sdc-security-util/pom.xml @@ -62,25 +62,6 @@ test - - org.powermock - powermock-module-junit4 - ${powermock.version} - test - - - junit - junit - - - - - - org.powermock - powermock-api-mockito2 - ${powermock.version} - test - diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/pom.xml b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/pom.xml index 26030edc44..7b23506bac 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/pom.xml +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/pom.xml @@ -160,24 +160,6 @@ openecomp-sdc-activity-log-manager ${project.version} - - org.powermock - powermock-module-junit4-common - ${powermock.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.version} - test - - - org.powermock - powermock-module-junit4 - ${powermock.version} - test - org.openecomp.sdc openecomp-sdc-activity-log-api diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/pom.xml b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/pom.xml index c87b3e5c56..8daff53abe 100644 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/pom.xml @@ -26,19 +26,6 @@ ${servlet-api.version} provided - - - org.powermock - powermock-module-junit4 - ${powermock.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.version} - test - org.projectlombok lombok diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/pom.xml b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/pom.xml index 4a324b1dd2..938787c202 100644 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/pom.xml @@ -34,24 +34,6 @@ ${easymock.version} test - - org.powermock - powermock-api-easymock - ${powermock.version} - test - - - org.powermock - powermock-core - ${powermock.version} - test - - - org.powermock - powermock-module-junit4 - ${powermock.version} - test - diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/pom.xml b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/pom.xml index 3a8413a219..15b3a6a21c 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-core/pom.xml @@ -40,12 +40,6 @@ mockito-core test - - org.powermock - powermock-module-junit4 - ${powermock.version} - test - -- cgit 1.2.3-korg