aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core')
-rw-r--r--openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/pom.xml6
-rw-r--r--openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/ActionVersioningManagerImpl.java10
-rw-r--r--openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/impl/ActionVersioningManagerImplTest.java176
3 files changed, 97 insertions, 95 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/pom.xml b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/pom.xml
index e956093a54..de50e6f094 100644
--- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/pom.xml
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/pom.xml
@@ -31,12 +31,6 @@
<scope>runtime</scope>
</dependency>
<dependency>
- <groupId>org.jmockit</groupId>
- <artifactId>jmockit</artifactId>
- <version>${jmockit.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.openecomp.sdc</groupId>
<artifactId>openecomp-sdc-logging-core</artifactId>
<version>${project.version}</version>
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/ActionVersioningManagerImpl.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/ActionVersioningManagerImpl.java
index a69e862582..cbff10cd7b 100644
--- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/ActionVersioningManagerImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/main/java/org/openecomp/sdc/versioning/impl/ActionVersioningManagerImpl.java
@@ -15,6 +15,7 @@
*/
package org.openecomp.sdc.versioning.impl;
+import com.google.common.annotations.VisibleForTesting;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -62,7 +63,7 @@ public class ActionVersioningManagerImpl implements ActionVersioningManager {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionVersioningManagerImpl.class);
private static final Version INITIAL_ACTIVE_VERSION = new Version(0, 0);
- private static final Map<String, Set<VersionableEntityMetadata>> VERSIONABLE_ENTITIES = new HashMap<>();
+ private static Map<String, Set<VersionableEntityMetadata>> VERSIONABLE_ENTITIES = new HashMap<>();
private final VersionInfoDao versionInfoDao;
private final VersionInfoDeletedDao versionInfoDeletedDao;
private VersionDao versionDao;
@@ -78,6 +79,13 @@ public class ActionVersioningManagerImpl implements ActionVersioningManager {
this.asdcItemManager = asdcItemManager;
}
+ @VisibleForTesting
+ ActionVersioningManagerImpl(Map<String, Set<VersionableEntityMetadata>> map) {
+ this.versionInfoDao = null;
+ this.versionInfoDeletedDao = null;
+ VERSIONABLE_ENTITIES = map;
+ }
+
private static VersionInfo getVersionInfo(VersionInfoEntity versionInfoEntity, String user, VersionableEntityAction action) {
return getVersionInfo(versionInfoEntity.getEntityId(), versionInfoEntity.getEntityType(), versionInfoEntity.getActiveVersion(),
versionInfoEntity.getCandidate(), versionInfoEntity.getStatus(), versionInfoEntity.getLatestFinalVersion(),
diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/impl/ActionVersioningManagerImplTest.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/impl/ActionVersioningManagerImplTest.java
index 18a6081b6c..64c1e38069 100644
--- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/impl/ActionVersioningManagerImplTest.java
+++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/impl/ActionVersioningManagerImplTest.java
@@ -32,11 +32,11 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
-import mockit.Deencapsulation;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -61,6 +61,7 @@ import org.openecomp.sdc.versioning.types.VersionableEntityMetadata;
@RunWith(MockitoJUnitRunner.class)
public class ActionVersioningManagerImplTest {
+
@Mock
private VersionInfoDao versionInfoDao;
@Mock
@@ -76,7 +77,7 @@ public class ActionVersioningManagerImplTest {
private VersionInfoEntity versionInfoEntity;
@Before
- public void setUp(){
+ public void setUp() {
actionVersioningManager = createSUT();
versionInfoEntity = new VersionInfoEntity();
@@ -87,11 +88,11 @@ public class ActionVersioningManagerImplTest {
private ActionVersioningManager createSUT() {
return new ActionVersioningManagerImpl(
- versionInfoDao,
- versionInfoDeletedDao,
- versionDao,
- versionCalculator,
- asdcItemManager
+ versionInfoDao,
+ versionInfoDeletedDao,
+ versionDao,
+ versionCalculator,
+ asdcItemManager
);
}
@@ -105,9 +106,9 @@ public class ActionVersioningManagerImplTest {
when(versionInfoDeletedDao.list(any(VersionInfoDeletedEntity.class))).thenReturn(new ArrayList<>());
Map<String, VersionInfo> result = actionVersioningManager.listDeletedEntitiesVersionInfo(
- "mock-type",
- "mock-user",
- VersionableEntityAction.Read
+ "mock-type",
+ "mock-user",
+ VersionableEntityAction.Read
);
assertThat(result, notNullValue());
@@ -136,9 +137,9 @@ public class ActionVersioningManagerImplTest {
when(versionInfoDao.list(any(VersionInfoEntity.class))).thenReturn(new ArrayList<>());
Map<String, VersionInfo> result = actionVersioningManager.listEntitiesVersionInfo(
- "mock-type",
- "mock-user",
- VersionableEntityAction.Read
+ "mock-type",
+ "mock-user",
+ VersionableEntityAction.Read
);
assertThat(result, notNullValue());
@@ -149,10 +150,10 @@ public class ActionVersioningManagerImplTest {
when(versionInfoDao.get(any(VersionInfoEntity.class))).thenReturn(versionInfoEntity);
VersionInfo result = actionVersioningManager.getEntityVersionInfo(
- "mock-type",
- "mock-id",
- "mock-user",
- VersionableEntityAction.Read
+ "mock-type",
+ "mock-id",
+ "mock-user",
+ VersionableEntityAction.Read
);
assertThat(result, notNullValue());
@@ -163,9 +164,9 @@ public class ActionVersioningManagerImplTest {
when(versionInfoDao.get(any(VersionInfoEntity.class))).thenReturn(null);
Version result = actionVersioningManager.create(
- "mock-type",
- "mock-id",
- "mock-user"
+ "mock-type",
+ "mock-id",
+ "mock-user"
);
assertThat(result, notNullValue());
@@ -176,9 +177,9 @@ public class ActionVersioningManagerImplTest {
when(versionInfoDao.get(any(VersionInfoEntity.class))).thenReturn(new VersionInfoEntity());
actionVersioningManager.create(
- "mock-type",
- "mock-id",
- "mock-user"
+ "mock-type",
+ "mock-id",
+ "mock-user"
);
fail("Should throw CoreException");
@@ -187,9 +188,9 @@ public class ActionVersioningManagerImplTest {
@Test
public void testCreateAlt() {
Version result = actionVersioningManager.create(
- "mock-type",
- new Version(),
- VersionCreationMethod.minor
+ "mock-type",
+ new Version(),
+ VersionCreationMethod.minor
);
assertThat(result, notNullValue());
@@ -197,17 +198,16 @@ public class ActionVersioningManagerImplTest {
@Test
public void testRegister() {
- actionVersioningManager.register(
- "mock-type",
- new VersionableEntityMetadata(
- "mock-name",
- "mock-id-name",
- "mock-ver-id-name"
- )
+ final VersionableEntityMetadata entityMetadata = new VersionableEntityMetadata(
+ "mock-name",
+ "mock-id-name",
+ "mock-ver-id-name"
);
- Map<String, Set<VersionableEntityMetadata>> entities = Deencapsulation.getField(actionVersioningManager, "VERSIONABLE_ENTITIES");
- assertThat(entities, notNullValue());
- assertThat(entities.size(), is(1));
+ Map<String, Set<VersionableEntityMetadata>> map = new HashMap<>();
+ var action = new ActionVersioningManagerImpl(map);
+ action.register("mock-type", entityMetadata);
+ assertThat(map, notNullValue());
+ assertThat(map.size(), is(1));
}
@Test
@@ -217,9 +217,9 @@ public class ActionVersioningManagerImplTest {
when(versionInfoDao.get(any(VersionInfoEntity.class))).thenReturn(versionInfoEntity);
actionVersioningManager.delete(
- "moct-type",
- "mock-id",
- "mock-user"
+ "moct-type",
+ "mock-id",
+ "mock-user"
);
verify(versionInfoDeletedDao).create(any(VersionInfoDeletedEntity.class));
@@ -235,9 +235,9 @@ public class ActionVersioningManagerImplTest {
when(versionInfoDao.get(any(VersionInfoEntity.class))).thenReturn(versionInfoEntity);
actionVersioningManager.delete(
- "moct-type",
- "mock-id",
- "mock-user"
+ "moct-type",
+ "mock-id",
+ "mock-user"
);
fail("Should throw CoreException");
}
@@ -247,9 +247,9 @@ public class ActionVersioningManagerImplTest {
when(versionInfoDeletedDao.get(any(VersionInfoDeletedEntity.class))).thenReturn(new VersionInfoDeletedEntity());
actionVersioningManager.undoDelete(
- "mock-type",
- "mock-id",
- "mock-user"
+ "mock-type",
+ "mock-id",
+ "mock-user"
);
verify(versionInfoDao).create(any(VersionInfoEntity.class));
@@ -261,9 +261,9 @@ public class ActionVersioningManagerImplTest {
when(versionInfoDeletedDao.get(any(VersionInfoDeletedEntity.class))).thenReturn(null);
actionVersioningManager.undoDelete(
- "mock-type",
- "mock-id",
- "mock-user"
+ "mock-type",
+ "mock-id",
+ "mock-user"
);
fail("Should throw CoreException");
@@ -276,9 +276,9 @@ public class ActionVersioningManagerImplTest {
when(versionInfoDao.get(any(VersionInfoEntity.class))).thenReturn(versionInfoEntity);
Version result = actionVersioningManager.checkout(
- "moct-type",
- "mock-id",
- "mock-user"
+ "moct-type",
+ "mock-id",
+ "mock-user"
);
assertThat(result, notNullValue());
@@ -290,9 +290,9 @@ public class ActionVersioningManagerImplTest {
when(versionInfoDao.get(any(VersionInfoEntity.class))).thenReturn(null);
actionVersioningManager.checkout(
- "moct-type",
- "mock-id",
- "mock-user"
+ "moct-type",
+ "mock-id",
+ "mock-user"
);
fail("Should throw CoreException");
@@ -305,9 +305,9 @@ public class ActionVersioningManagerImplTest {
when(versionInfoDao.get(any(VersionInfoEntity.class))).thenReturn(versionInfoEntity);
actionVersioningManager.checkout(
- "mock-type",
- "mock-id",
- "mock-user"
+ "mock-type",
+ "mock-id",
+ "mock-user"
);
fail("Should throw CoreException");
@@ -320,9 +320,9 @@ public class ActionVersioningManagerImplTest {
when(versionInfoDao.get(any(VersionInfoEntity.class))).thenReturn(versionInfoEntity);
Version result = actionVersioningManager.undoCheckout(
- "mock-type",
- "mock-id",
- "mock-user"
+ "mock-type",
+ "mock-id",
+ "mock-user"
);
assertThat(result, notNullValue(Version.class));
}
@@ -334,10 +334,10 @@ public class ActionVersioningManagerImplTest {
when(versionInfoDao.get(any(VersionInfoEntity.class))).thenReturn(versionInfoEntity);
Version result = actionVersioningManager.checkin(
- "mock-type",
- "mock-id",
- "mock-user",
- "mock-desc"
+ "mock-type",
+ "mock-id",
+ "mock-user",
+ "mock-desc"
);
assertThat(result, notNullValue(Version.class));
}
@@ -349,10 +349,10 @@ public class ActionVersioningManagerImplTest {
when(versionInfoDao.get(any(VersionInfoEntity.class))).thenReturn(versionInfoEntity);
Version result = actionVersioningManager.checkin(
- "mock-type",
- "mock-id",
- "mock-user",
- "mock-desc"
+ "mock-type",
+ "mock-id",
+ "mock-user",
+ "mock-desc"
);
assertThat(result, notNullValue(Version.class));
}
@@ -367,9 +367,9 @@ public class ActionVersioningManagerImplTest {
when(versionDao.get(anyString(), any(Version.class))).thenReturn(Optional.of(new Version()));
actionVersioningManager.submit(
- "mock-type",
- new Version(),
- "mock-desc"
+ "mock-type",
+ new Version(),
+ "mock-desc"
);
verify(versionDao).update(anyString(), any(Version.class));
verify(asdcItemManager).updateVersionStatus(anyString(), any(VersionStatus.class), any(VersionStatus.class));
@@ -381,10 +381,10 @@ public class ActionVersioningManagerImplTest {
when(versionInfoDao.get(any(VersionInfoEntity.class))).thenReturn(versionInfoEntity);
Version result = actionVersioningManager.submit(
- "mock-type",
- "mock-id",
- "mock-user",
- "mock-desc"
+ "mock-type",
+ "mock-id",
+ "mock-user",
+ "mock-desc"
);
assertThat(result, notNullValue(Version.class));
}
@@ -394,10 +394,10 @@ public class ActionVersioningManagerImplTest {
when(versionInfoDao.get(any(VersionInfoEntity.class))).thenReturn(null);
actionVersioningManager.submit(
- "mock-type",
- "mock-id",
- "mock-user",
- "mock-desc"
+ "mock-type",
+ "mock-id",
+ "mock-user",
+ "mock-desc"
);
fail("Should throw CoreException");
@@ -409,10 +409,10 @@ public class ActionVersioningManagerImplTest {
when(versionInfoDao.get(any(VersionInfoEntity.class))).thenReturn(versionInfoEntity);
actionVersioningManager.submit(
- "mock-type",
- "mock-id",
- "mock-user",
- "mock-desc"
+ "mock-type",
+ "mock-id",
+ "mock-user",
+ "mock-desc"
);
fail("Should throw CoreException");
@@ -424,10 +424,10 @@ public class ActionVersioningManagerImplTest {
when(versionInfoDao.get(any(VersionInfoEntity.class))).thenReturn(versionInfoEntity);
actionVersioningManager.submit(
- "mock-type",
- "mock-id",
- "mock-user",
- "mock-desc"
+ "mock-type",
+ "mock-id",
+ "mock-user",
+ "mock-desc"
);
fail("Should throw CoreException");
@@ -450,4 +450,4 @@ public class ActionVersioningManagerImplTest {
actionVersioningManager.listRevisions("mock-id", new Version());
verify(versionDao).listRevisions(anyString(), any(Version.class));
}
-} \ No newline at end of file
+}