<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
</dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
- <version>${powermock.version}</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
- <exclusion>
- <artifactId>powermock-api-mockito</artifactId>
- <groupId>org.powermock</groupId>
- </exclusion>
<exclusion>
<groupId>org.onap.aaf.authz</groupId>
<artifactId>aaf-cadi-aaf</artifactId>
<version>${commons-jci-core.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
- <version>${powermock.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito-common</artifactId>
- <version>1.7.4</version>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>mockito-core</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>
<dependency>
<groupId>org.openecomp.sdc</groupId>
<artifactId>openecomp-sdc-externaltesting-impl</artifactId>
<artifactId>unique-type-rest-types</artifactId>
<version>${project.version}</version>
</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>
<version>${project.version}</version>
<scope>runtime</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>
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() {
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);
}
}
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;
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(){
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
- <version>${powermock.version}</version>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito2</artifactId>
- <version>${powermock.version}</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<artifactId>openecomp-sdc-activity-log-manager</artifactId>
<version>${project.version}</version>
</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>
<dependency>
<groupId>org.openecomp.sdc</groupId>
<artifactId>openecomp-sdc-activity-log-api</artifactId>
<version>${servlet-api.version}</version>
<scope>provided</scope>
</dependency>
- <!-- testing -->
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</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.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${easymock.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-easymock</artifactId>
- <version>${powermock.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-core</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>
</project>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
- <version>${powermock.version}</version>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
<commons-jci-core.version>1.1</commons-jci-core.version>
<!--TESTING-->
- <powermock.version>2.0.7</powermock.version>
<mockito.version>3.3.3</mockito.version>
<mockitoJupiter.version>3.3.3</mockitoJupiter.version>
<jmockit.version>1.35</jmockit.version>