aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/LimitTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/LimitTest.java')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/LimitTest.java117
1 files changed, 56 insertions, 61 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/LimitTest.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/LimitTest.java
index 07fdeeeee8..0197dd9d28 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/LimitTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/LimitTest.java
@@ -20,17 +20,11 @@
package org.openecomp.sdc.vendorlicense;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.verify;
-
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorlicense.dao.LimitDao;
import org.openecomp.sdc.vendorlicense.dao.types.AggregationFunction;
import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity;
@@ -45,19 +39,19 @@ import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
-public class LimitTest {
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
+public class LimitTest {
- private final String USER1 = "limitTestUser1";
- private final String LT1_NAME = "LT1 name";
+ private final String USER1 = "limitTestUser1";
+ private final String LT1_NAME = "LT1 name";
private static final String VLM_ID = "VLM_ID";
private static final Version VERSION = new Version(0, 1);
@@ -76,8 +70,8 @@ public class LimitTest {
private VendorLicenseManagerImpl vendorLicenseManagerImpl;
public static LimitEntity createLimitEntity(String name, LimitType type, String description,
- Version version, String metric,
- AggregationFunction aggregationFunction, int unit,
+ Version version, String metric,
+ AggregationFunction aggregationFunction, int unit,
String time) {
LimitEntity limitEntity = new LimitEntity();
limitEntity.setName(name);
@@ -92,22 +86,22 @@ public class LimitTest {
}
@BeforeMethod
- public void setUp() {
+ public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
}
@Test
public void testUpdateLimit() {
Version version = new Version();
- LimitEntity limitEntity1 = createLimitEntity(LT1_NAME,LimitType.Vendor,"string",version,
- "Core",AggregationFunction.Average,10,"Hour");
- LimitEntity limitEntity2 = createLimitEntity(LT1_NAME,LimitType.Vendor,"string",version,
- "Tokens",AggregationFunction.Peak,12,"Month");
+ LimitEntity limitEntity1 = createLimitEntity(LT1_NAME, LimitType.Vendor, "string", version,
+ "Core", AggregationFunction.Average, 10, "Hour");
+ LimitEntity limitEntity2 = createLimitEntity(LT1_NAME, LimitType.Vendor, "string", version,
+ "Tokens", AggregationFunction.Peak, 12, "Month");
VersionInfo info = new VersionInfo();
info.getViewableVersions().add(version);
info.setActiveVersion(version);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+ /*doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(), anyObject(), anyObject());*/
doReturn(true).when(limitDao).isLimitPresent(anyObject());
doReturn(limitEntity1).when(limitDao).get(anyObject());
@@ -116,27 +110,28 @@ public class LimitTest {
limitEntityList.add(limitEntity2);
limitEntity1.setId("1234");
limitEntity2.setId("1234");
- doReturn(limitEntityList).when(vendorLicenseFacade).listLimits(anyObject(),anyObject(),
- anyObject(),anyObject());
+ doReturn(limitEntityList).when(vendorLicenseFacade)
+ .listLimits(anyObject(), anyObject(), anyObject());
- vendorLicenseManagerImpl.updateLimit(limitEntity2,USER1);
+ vendorLicenseManagerImpl.updateLimit(limitEntity2);
- verify(vendorLicenseFacade).updateLimit(anyObject(), anyObject());
+ verify(vendorLicenseFacade).updateLimit(anyObject());
}
@Test
public void testUpdateLimitErrorWithSameNameType() {
try {
Version version = new Version();
- LimitEntity limitEntity1 = createLimitEntity(LT1_NAME,LimitType.Vendor,"string",version,
- "Core",AggregationFunction.Average,10,"Hour");
- LimitEntity limitEntity2 = createLimitEntity(LT1_NAME,LimitType.Vendor,"string",version,
- "Tokens",AggregationFunction.Peak,12,"Month");
+ LimitEntity limitEntity1 = createLimitEntity(LT1_NAME, LimitType.Vendor, "string", version,
+ "Core", AggregationFunction.Average, 10, "Hour");
+ LimitEntity limitEntity2 = createLimitEntity(LT1_NAME, LimitType.Vendor, "string", version,
+ "Tokens", AggregationFunction.Peak, 12, "Month");
VersionInfo info = new VersionInfo();
info.getViewableVersions().add(version);
info.setActiveVersion(version);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+/* doReturn(info).when(vendorLicenseFacade)
+ .getVersionInfo(anyObject(), anyObject(), anyObject());*/
doReturn(limitEntity1).when(limitDao).get(anyObject());
List<LimitEntity> limitEntityList = new ArrayList<>();
@@ -144,13 +139,12 @@ public class LimitTest {
limitEntityList.add(limitEntity2);
limitEntity1.setId("1234");
limitEntity2.setId("9632");
- doReturn(limitEntityList).when(vendorLicenseFacade).listLimits(anyObject(),anyObject(),
- anyObject(),anyObject());
+ doReturn(limitEntityList).when(vendorLicenseFacade)
+ .listLimits(anyObject(), anyObject(), anyObject());
- vendorLicenseManagerImpl.updateLimit(limitEntity2,USER1);
+ vendorLicenseManagerImpl.updateLimit(limitEntity2);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(),
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@@ -159,13 +153,13 @@ public class LimitTest {
@Test
public void testDeleteLimit() {
Version version = new Version();
- LimitEntity limitEntity = createLimitEntity(LT1_NAME,LimitType.Vendor,"string",version,
- "Core",AggregationFunction.Average,10,"Hour");
+ LimitEntity limitEntity = createLimitEntity(LT1_NAME, LimitType.Vendor, "string", version,
+ "Core", AggregationFunction.Average, 10, "Hour");
VersionInfo info = new VersionInfo();
info.getViewableVersions().add(version);
info.setActiveVersion(version);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+ /*doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(), anyObject(), anyObject());*/
doReturn(true).when(limitDao).isLimitPresent(anyObject());
doReturn(limitEntity).when(limitDao).get(anyObject());
@@ -173,27 +167,28 @@ public class LimitTest {
limitEntityList.add(limitEntity);
limitEntity.setId("1234");
- vendorLicenseManagerImpl.deleteLimit(limitEntity,LT1_NAME);
+ vendorLicenseManagerImpl.deleteLimit(limitEntity);
- verify(vendorLicenseManagerImpl).deleteLimit(anyObject(), anyObject());
+ verify(vendorLicenseManagerImpl).deleteLimit(anyObject());
}
@Test
public void testUpdateLimitErrorWithInvalidId() {
try {
Version version = new Version();
- LimitEntity limitEntity1 = createLimitEntity(LT1_NAME,LimitType.Vendor,"string",version,
- "Core",AggregationFunction.Average,10,"Hour");
- LimitEntity limitEntity2 = createLimitEntity(LT1_NAME,LimitType.Vendor,"string",version,
- "Tokens",AggregationFunction.Peak,12,"Month");
+ LimitEntity limitEntity1 = createLimitEntity(LT1_NAME, LimitType.Vendor, "string", version,
+ "Core", AggregationFunction.Average, 10, "Hour");
+ LimitEntity limitEntity2 = createLimitEntity(LT1_NAME, LimitType.Vendor, "string", version,
+ "Tokens", AggregationFunction.Peak, 12, "Month");
VersionInfo info = new VersionInfo();
info.getViewableVersions().add(version);
info.setActiveVersion(version);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+/* doReturn(info).when(vendorLicenseFacade)
+ .getVersionInfo(anyObject(), anyObject(), anyObject());*/
doReturn(null).when(limitDao).get(anyObject());
- vendorLicenseManagerImpl.updateLimit(limitEntity2,USER1);
+ vendorLicenseManagerImpl.updateLimit(limitEntity2);
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(),
@@ -206,14 +201,14 @@ public class LimitTest {
doReturn(Arrays.asList(
createLimit(VLM_ID, VERSION, EPLKG_ID, LIMIT1_ID),
createLimit(VLM_ID, VERSION, EPLKG_ID, LIMIT2_ID)))
- .when(vendorLicenseFacade).listLimits(VLM_ID, VERSION, EPLKG_ID, USER1);
+ .when(vendorLicenseFacade).listLimits(VLM_ID, VERSION, EPLKG_ID);
final Collection<LimitEntity> limits =
- vendorLicenseManagerImpl.listLimits(VLM_ID, VERSION, EPLKG_ID, USER1);
+ vendorLicenseManagerImpl.listLimits(VLM_ID, VERSION, EPLKG_ID);
Assert.assertEquals(limits.size(), 2);
for (LimitEntity limit : limits) {
Assert.assertEquals(limit.getName(),
- LIMIT1_ID.equals(limit.getId()) ? LIMIT1_ID+" name" : LIMIT2_ID+" name" );
+ LIMIT1_ID.equals(limit.getId()) ? LIMIT1_ID + " name" : LIMIT2_ID + " name");
}
}
@@ -224,10 +219,10 @@ public class LimitTest {
info.getViewableVersions().add(VERSION);
info.setActiveVersion(VERSION);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+ /*doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(), anyObject(), anyObject());*/
- vendorLicenseManagerImpl.createLimit(expected, USER1);
- verify(vendorLicenseFacade).createLimit(expected,USER1);
+ vendorLicenseManagerImpl.createLimit(expected);
+ verify(vendorLicenseFacade).createLimit(expected);
}
@Test
@@ -241,20 +236,19 @@ public class LimitTest {
List<LimitEntity> vfcImageList = new ArrayList<LimitEntity>();
vfcImageList.add(expectedDiffName);
- doReturn(vfcImageList).when(vendorLicenseFacade).listLimits(anyObject(), anyObject(), anyObject(),
- anyObject());
+ doReturn(vfcImageList).when(vendorLicenseFacade)
+ .listLimits(anyObject(), anyObject(), anyObject());
VersionInfo info = new VersionInfo();
info.getViewableVersions().add(VERSION);
info.setActiveVersion(VERSION);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+/* doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(), anyObject(), anyObject());*/
try {
- vendorLicenseManagerImpl.createLimit(expected, USER1);
+ vendorLicenseManagerImpl.createLimit(expected);
Assert.fail();
- }
- catch (CoreException ex) {
+ } catch (CoreException ex) {
Assert.assertEquals(ex.code().id(),
VendorLicenseErrorCodes.DUPLICATE_LIMIT_NAME_NOT_ALLOWED);
}
@@ -267,13 +261,14 @@ public class LimitTest {
info.getViewableVersions().add(VERSION);
info.setActiveVersion(VERSION);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+ /*doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(), anyObject(), anyObject());*/
try {
- vendorLicenseManagerImpl.getLimit(limit , USER1);
+ vendorLicenseManagerImpl.getLimit(limit);
Assert.fail();
} catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ Assert.assertEquals(exception.code().id(),
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
}
@@ -293,10 +288,10 @@ public class LimitTest {
info.getViewableVersions().add(VERSION);
info.setActiveVersion(VERSION);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+ /*doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(), anyObject(), anyObject());*/
LimitEntity actual = createLimit(VLM_ID, VERSION, EPLKG_ID, LIMIT1_ID);
- vendorLicenseManagerImpl.getLimit(actual, USER1);
+ vendorLicenseManagerImpl.getLimit(actual);
Assert.assertEquals(actual.getId(), expected.getId());
Assert.assertEquals(actual.getName(), expected.getName());
Assert.assertEquals(actual.getUnit(), expected.getUnit());