summaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/backend')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/pom.xml4
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java96
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/LimitTest.java13
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/EntitlementPoolTest.java33
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/FeatureGroupTest.java13
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseAgreementTest.java19
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseKeyGroupTest.java13
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseModelTest.java12
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java9
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java6
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java10
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java35
12 files changed, 129 insertions, 134 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/pom.xml b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/pom.xml
index 4c8faf8b11..ebe100ef2b 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/pom.xml
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/pom.xml
@@ -39,8 +39,8 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java
index 4183f7950c..f27e6c05c4 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java
@@ -248,101 +248,73 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager {
@Override
public EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool) {
- entitlementPool.setStartDate(entitlementPool.getStartDate() != null ? (entitlementPool
- .getStartDate().trim().length() != 0 ? entitlementPool.getStartDate() + EP_POOL_START_TIME
- : null) : null);
- entitlementPool.setExpiryDate(entitlementPool.getExpiryDate() != null ? (entitlementPool
- .getExpiryDate().trim().length() != 0 ? entitlementPool.getExpiryDate() + EP_POOL_EXPIRY_TIME
- : null) : null);
-
+ entitlementPool.setStartDate(getDate(entitlementPool.getStartDate(), EP_POOL_START_TIME));
+ entitlementPool.setExpiryDate(getDate(entitlementPool.getExpiryDate(), EP_POOL_EXPIRY_TIME));
validateCreateDate(entitlementPool.getStartDate(), entitlementPool.getExpiryDate(),
entitlementPool.getVendorLicenseModelId());
return vendorLicenseFacade.createEntitlementPool(entitlementPool);
}
- private void validateCreateDate(String startDate, String expiryDate,
- String vendorLicenseModelId) {
- LocalDate parsedStartDate = parseLocalDate(startDate);
- LocalDate parsedExpiryDate = parseLocalDate(expiryDate);
-
-
- validateIfStartAndExpiryDateIsNotNull(startDate, expiryDate,
- vendorLicenseModelId, parsedStartDate, parsedExpiryDate);
-
- if (startDate != null && expiryDate == null
- && parsedStartDate.atStartOfDay().isBefore
- (LocalDate.now().atStartOfDay())) {
- throw new CoreException(
- new InvalidDateErrorBuilder(vendorLicenseModelId)
- .build());
- }
-
- if (startDate == null && expiryDate != null) {
- throw new CoreException(
- new InvalidDateErrorBuilder(vendorLicenseModelId)
- .build());
-
- }
+ private String getDate(String date, String poolTime){
+ return date != null ? (!date.trim().isEmpty() ? date + poolTime: null) : null;
}
- private void validateIfStartAndExpiryDateIsNotNull(String startDate, String expiryDate,
- String vendorLicenseModelId,
- LocalDate parsedStartDate,
- LocalDate parsedExpiryDate) {
- if (startDate != null && expiryDate != null
- && isValidatStartAndExpiryDate(parsedStartDate, parsedExpiryDate)) {
+ private void validateCreateDate(String startDate, String expiryDate,
+ String vendorLicenseModelId) {
+ if(isNull(startDate, expiryDate) || isEmpty(startDate, expiryDate) ||
+ isInvalidStartEndDate(startDate, expiryDate)){
throw new CoreException(
new InvalidDateErrorBuilder(vendorLicenseModelId)
.build());
}
}
- private boolean isValidatStartAndExpiryDate(LocalDate parsedStartDate,
- LocalDate parsedExpiryDate) {
+ private boolean isInvalidStartEndDate(String startDate, String expiryDate) {
+ LocalDate parsedStartDate = parseLocalDate(startDate);
+ LocalDate parsedExpiryDate = parseLocalDate(expiryDate);
+
return parsedStartDate.atStartOfDay().isBefore(LocalDate.now().atStartOfDay())
- || parsedExpiryDate.atStartOfDay().isEqual(parsedStartDate.atStartOfDay())
- || parsedExpiryDate.isBefore(parsedStartDate);
+ || parsedExpiryDate.atStartOfDay().isEqual(parsedStartDate.atStartOfDay())
+ || parsedExpiryDate.isBefore(parsedStartDate);
}
- private static LocalDate parseLocalDate(String date) {
- if (date == null || date.isEmpty()) {
- return null;
- }
+ private boolean isEmpty(String startDate, String expiryDate) {
+ return startDate.isEmpty() || expiryDate.isEmpty();
+ }
+ private boolean isNull(String startDate, String expiryDate) {
+ return startDate == null || expiryDate == null;
+ }
+
+ private static LocalDate parseLocalDate(String date) {
return LocalDate.parse(date, FORMATTER );
}
private void validateUpdateDate(String startDate, String expiryDate,
String vendorLicenseModelId) {
- LocalDate parsedStartDate = parseLocalDate(startDate);
- LocalDate parsedExpiryDate = parseLocalDate(expiryDate);
- if (startDate != null && expiryDate != null
- && (parsedExpiryDate.atStartOfDay()
- .isEqual(parsedStartDate.atStartOfDay())
- || parsedExpiryDate.isBefore(parsedStartDate ))) {
+ if(isNull(startDate, expiryDate) || isEmpty(startDate, expiryDate)
+ || isInvalidUpdateDate(startDate, expiryDate)){
throw new CoreException(
new InvalidDateErrorBuilder(vendorLicenseModelId)
.build());
}
+ }
- if (startDate == null && expiryDate != null) {
- throw new CoreException(
- new InvalidDateErrorBuilder(vendorLicenseModelId)
- .build());
+ private boolean isInvalidUpdateDate(String startDate, String expiryDate) {
- }
+ LocalDate parsedStartDate = parseLocalDate(startDate);
+ LocalDate parsedExpiryDate = parseLocalDate(expiryDate);
+
+ return parsedExpiryDate.atStartOfDay()
+ .isEqual(parsedStartDate.atStartOfDay())
+ || parsedExpiryDate.isBefore(parsedStartDate);
}
@Override
public void updateEntitlementPool(EntitlementPoolEntity entitlementPool) {
- entitlementPool.setStartDate(entitlementPool.getStartDate() != null ? (entitlementPool
- .getStartDate().trim().length() != 0 ? entitlementPool.getStartDate() + EP_POOL_START_TIME
- : null) : null);
- entitlementPool.setExpiryDate(entitlementPool.getExpiryDate() != null ? (entitlementPool
- .getExpiryDate().trim().length() != 0 ? entitlementPool.getExpiryDate() + EP_POOL_EXPIRY_TIME
- : null) : null);
-
+ entitlementPool.setStartDate(getDate(entitlementPool.getStartDate(), EP_POOL_START_TIME));
+ entitlementPool.setExpiryDate(getDate(entitlementPool.getExpiryDate(), EP_POOL_EXPIRY_TIME));
validateUpdateDate(entitlementPool.getStartDate(), entitlementPool.getExpiryDate(),
entitlementPool.getVendorLicenseModelId());
vendorLicenseFacade.updateEntitlementPool(entitlementPool);
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 986e732410..101ecde4c8 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
@@ -16,6 +16,10 @@
package org.openecomp.sdc.vendorlicense;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -31,11 +35,6 @@ import org.openecomp.sdc.vendorlicense.impl.VendorLicenseManagerImpl;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.errors.VersioningErrorCodes;
import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -82,12 +81,12 @@ public class LimitTest {
return limitEntity;
}
- @BeforeMethod
+ @Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
}
- @AfterMethod
+ @After
public void tearDown(){
vendorLicenseManagerImpl = null;
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/EntitlementPoolTest.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/EntitlementPoolTest.java
index ca242f5810..03be183ab7 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/EntitlementPoolTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/EntitlementPoolTest.java
@@ -17,6 +17,10 @@
package org.openecomp.sdc.vendorlicense.impl;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -28,11 +32,6 @@ import org.openecomp.sdc.vendorlicense.dao.types.*;
import org.openecomp.sdc.vendorlicense.errors.VendorLicenseErrorCodes;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@@ -94,13 +93,13 @@ public class EntitlementPoolTest {
return entitlementPool;
}
- @BeforeMethod
+ @Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
}
- @AfterMethod
+ @After
public void tearDown(){
vendorLicenseManagerImpl = null;
}
@@ -127,8 +126,7 @@ public class EntitlementPoolTest {
}
- @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp = "Vendor " +
- "license model with id vlm1_id has invalid date range.")
+ @Test(expected = CoreException.class)
public void createWithInvalidStartExpiryDateTest() {
Set<OperationalScope> opScopeChoices;
@@ -146,12 +144,11 @@ public class EntitlementPoolTest {
ep2.setExpiryDate(LocalDate.now().minusDays(2L).format(formatter));
ep2.setVendorLicenseModelId(vlm1_id);
vendorLicenseManagerImpl.createEntitlementPool(ep2).getId();
- Assert.fail();
+ Assert.fail("Vendor license model with id vlm1_id has invalid date range.");
}
- @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp = "Vendor " +
- "license model with id vlm1_id has invalid date range.")
+ @Test(expected = CoreException.class)
public void createWithoutStartDateTest() {
Set<OperationalScope> opScopeChoices;
@@ -168,12 +165,11 @@ public class EntitlementPoolTest {
ep2.setExpiryDate(LocalDate.now().plusDays(2L).format(formatter));
ep2.setVendorLicenseModelId(vlm1_id);
vendorLicenseManagerImpl.createEntitlementPool(ep2).getId();
- Assert.fail();
+ Assert.fail("Vendor license model with id vlm1_id has invalid date range.");
}
- @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp = "Vendor " +
- "license model with id vlm1_id has invalid date range.")
+ @Test(expected = CoreException.class)
public void createWithSameStartExpiryDateTest() {
Set<OperationalScope> opScopeChoices;
@@ -191,7 +187,7 @@ public class EntitlementPoolTest {
ep2.setExpiryDate(LocalDate.now().format(formatter));
ep2.setVendorLicenseModelId(vlm1_id);
vendorLicenseManagerImpl.createEntitlementPool(ep2).getId();
- Assert.fail();
+ Assert.fail("Vendor license model with id vlm1_id has invalid date range.");
}
@Test
@@ -214,8 +210,7 @@ public class EntitlementPoolTest {
vendorLicenseManagerImpl.updateEntitlementPool(ep2);
}
- @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp = "Vendor " +
- "license model with id vlm1_id has invalid date range.")
+ @Test(expected = CoreException.class)
public void updateWithInvalidStartExpiryDateTest() {
Set<OperationalScope> opScopeChoices;
@@ -233,7 +228,7 @@ public class EntitlementPoolTest {
ep2.setExpiryDate(LocalDate.now().minusDays(2L).format(formatter));
ep2.setVendorLicenseModelId(vlm1_id);
vendorLicenseManagerImpl.updateEntitlementPool(ep2);
- Assert.fail();
+ Assert.fail("Vendor license model with id vlm1_id has invalid date range.");
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/FeatureGroupTest.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/FeatureGroupTest.java
index b7636bb514..ca37dcd801 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/FeatureGroupTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/FeatureGroupTest.java
@@ -16,6 +16,10 @@
package org.openecomp.sdc.vendorlicense.impl;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -28,11 +32,6 @@ import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
import org.openecomp.sdc.versioning.VersioningManager;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
@@ -87,7 +86,7 @@ public class FeatureGroupTest {
private VendorLicenseManagerImpl vendorLicenseManagerImpl;
- @AfterMethod
+ @After
public void tearDown(){
vendorLicenseManagerImpl = null;
}
@@ -114,7 +113,7 @@ public class FeatureGroupTest {
return featureGroup;
}
- @BeforeMethod
+ @Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseAgreementTest.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseAgreementTest.java
index 511ebb87d0..722343a4a3 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseAgreementTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseAgreementTest.java
@@ -16,6 +16,10 @@
package org.openecomp.sdc.vendorlicense.impl;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
import org.mockito.*;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
@@ -27,12 +31,11 @@ import org.openecomp.sdc.vendorlicense.dao.types.LicenseTerm;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
import org.openecomp.sdc.versioning.VersioningManager;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.*;
@@ -78,12 +81,12 @@ public class LicenseAgreementTest {
private ArgumentCaptor<ActivityLogEntity> activityLogEntityArg;
- @BeforeMethod
+ @Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
}
- @AfterMethod
+ @After
public void tearDown(){
vendorLicenseManager = null;
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseKeyGroupTest.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseKeyGroupTest.java
index c5076fdf2c..d8e2959464 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseKeyGroupTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseKeyGroupTest.java
@@ -17,6 +17,10 @@
package org.openecomp.sdc.vendorlicense.impl;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -31,11 +35,6 @@ import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope;
import org.openecomp.sdc.vendorlicense.errors.VendorLicenseErrorCodes;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
@@ -73,12 +72,12 @@ public class LicenseKeyGroupTest {
@Spy
private VendorLicenseManagerImpl vendorLicenseManagerImpl;
- @BeforeMethod
+ @Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
}
- @AfterMethod
+ @After
public void tearDown(){
vendorLicenseManagerImpl = null;
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseModelTest.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseModelTest.java
index b81c2e805f..e072453421 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseModelTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseModelTest.java
@@ -1,5 +1,8 @@
package org.openecomp.sdc.vendorlicense.impl;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.mockito.*;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
@@ -8,9 +11,6 @@ import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
import org.openecomp.sdc.versioning.VersioningManager;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.*;
@@ -59,12 +59,12 @@ public class VendorLicenseModelTest {
private ArgumentCaptor<ActivityLogEntity> activityLogEntityArg;
- @BeforeMethod
+ @Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
}
- @AfterMethod
+ @After
public void tearDown(){
vendorLicenseManager = null;
}
@@ -121,7 +121,7 @@ public class VendorLicenseModelTest {
verify(vendorLicenseFacadeMcok).getVendorLicenseModel(vlm1_id, VERSION01);
}
- @Test(expectedExceptions = UnsupportedOperationException.class)
+ @Test(expected = UnsupportedOperationException.class)
public void testDeleteVLMUnsupportedOperation() {
vendorLicenseManager.deleteVendorLicenseModel(vlm1_id, null); // TODO: 8/13/2017
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java
index 1d8c0b430d..58cb2cf2d6 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java
@@ -21,6 +21,8 @@ import org.openecomp.sdc.generator.core.services.ManualVspToscaGenerationService
import org.openecomp.sdc.generator.datatypes.tosca.DeploymentFlavorModel;
import org.openecomp.sdc.generator.datatypes.tosca.MultiFlavorVfcImage;
import org.openecomp.sdc.generator.datatypes.tosca.VspModelInfo;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.vendorsoftwareproduct.ManualVspToscaManager;
import org.openecomp.sdc.vendorsoftwareproduct.services.ManualVspDataCollectionService;
@@ -33,6 +35,8 @@ import java.util.Optional;
public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ManualVspToscaManagerImpl.class);
+
private final ManualVspDataCollectionService
manualVspDataCollectionService = new ManualVspDataCollectionService();
@@ -45,6 +49,7 @@ public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
releaseVendor = manualVspDataCollectionService.getReleaseVendor(vspId, version);
} catch (Exception ex) {
releaseVendor = Optional.empty();
+ LOGGER.error("Failed to get release vendor: {}", ex.getMessage(), ex);
}
releaseVendor.ifPresent(vspModelInfo::setReleaseVendor);
@@ -54,6 +59,7 @@ public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
allowedFlavors = manualVspDataCollectionService.getAllowedFlavors(vspId, version);
} catch (Exception ex) {
allowedFlavors = null;
+ LOGGER.error("Failed to get allowed flavours: {}", ex.getMessage(), ex);
}
if (MapUtils.isNotEmpty(allowedFlavors)) {
vspModelInfo.setAllowedFlavors(allowedFlavors);
@@ -66,6 +72,7 @@ public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
manualVspDataCollectionService.getVspComponentImages(vspId, version);
} catch (Exception ex) {
vspComponentImages = null;
+ LOGGER.error("Failed to get VSP components Images: {}", ex.getMessage(), ex);
}
if (MapUtils.isNotEmpty(vspComponentImages)) {
vspModelInfo.setMultiFlavorVfcImages(vspComponentImages);
@@ -77,6 +84,7 @@ public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
vspComponents = manualVspDataCollectionService.getVspComponents(vspId, version);
} catch (Exception ex) {
vspComponents = null;
+ LOGGER.error("Failed to get VSP components: {}", ex.getMessage(), ex);
}
if (MapUtils.isNotEmpty(vspComponents)) {
vspModelInfo.setComponents(vspComponents);
@@ -88,6 +96,7 @@ public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
vspComponentNics = manualVspDataCollectionService.getVspComponentNics(vspId, version);
} catch (Exception ex) {
vspComponentNics = null;
+ LOGGER.error("Failed to get VSP component NIC data: {}", ex.getMessage(), ex);
}
if (MapUtils.isNotEmpty(vspComponentNics)) {
vspModelInfo.setNics(vspComponentNics);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java
index c78e0001bf..3dfe3a25c2 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java
@@ -36,6 +36,8 @@ import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree;
import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
import org.openecomp.sdc.heat.services.tree.HeatTreeManager;
import org.openecomp.sdc.heat.services.tree.HeatTreeManagerUtil;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManagerFactory;
@@ -56,6 +58,7 @@ import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConst
public class OrchestrationUtil {
+ private static final Logger LOGGER = LoggerFactory.getLogger(OrchestrationUtil.class);
public static final String ORCHESTRATION_CONFIG_NAMESPACE = "orchestration";
public static final String ORCHESTRATION_IMPL_KEY = "orchestration_impl";
@@ -112,9 +115,12 @@ public class OrchestrationUtil {
uploadFileResponse.addStructureError(
SdcCommon.UPLOAD_FILE,
new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_ZIP_FILE.getErrorMessage()));
+ LOGGER.error("{}\n{}", Messages.INVALID_ZIP_FILE.getErrorMessage(),
+ exception.getMessage(), exception);
} catch (CoreException coreException) {
uploadFileResponse.addStructureError(
SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR, coreException.getMessage()));
+ LOGGER.error(coreException.getMessage(), coreException);
}
return Optional.ofNullable(contentMap);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java
index 49233c4ff9..a76acf5177 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java
@@ -288,9 +288,9 @@ class SOL004MetaDirectoryValidator implements Validator{
}
private boolean isPnfMetadata(Map<String, String> metadata) {
- String metadataType = null;
+ String metadataType = "";
for(String key: metadata.keySet()) {
- if(metadataType == null){
+ if(metadataType.isEmpty()){
metadataType = key.contains(TOSCA_TYPE_PNF) ? TOSCA_TYPE_PNF : TOSCA_TYPE_VNF;
}else if(!key.contains(metadataType)){
throw new InvalidManifestMetadataException(Messages.MANIFEST_METADATA_INVALID_ENTRY.getErrorMessage());
@@ -300,9 +300,9 @@ class SOL004MetaDirectoryValidator implements Validator{
}
private void handleVnfMetadataEntries(Map<String, String> metadata) {
- for (String requiredPnfEntry : MANIFEST_VNF_METADATA) {
- if (!metadata.containsKey(requiredPnfEntry)) {
- reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_METADATA_MISSING_ENTRY.getErrorMessage(), requiredPnfEntry));
+ for (String requiredVnfEntry : MANIFEST_VNF_METADATA) {
+ if (!metadata.containsKey(requiredVnfEntry)) {
+ reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_METADATA_MISSING_ENTRY.getErrorMessage(), requiredVnfEntry));
}
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
index 28eb7f143d..7be3eb9fdb 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
@@ -18,12 +18,12 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.process;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.core.impl.ToscaConverterImpl;
+import org.openecomp.core.impl.ToscaSolConverterImpl;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.core.validation.util.MessageContainerUtil;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.common.errors.ErrorCode;
-import org.openecomp.sdc.common.errors.GeneralErrorBuilder;
+import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree;
@@ -39,6 +39,8 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CandidateServiceFactory;
import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil;
import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
+import org.openecomp.sdc.vendorsoftwareproduct.services.impl.etsi.ETSIService;
+import org.openecomp.sdc.vendorsoftwareproduct.services.impl.etsi.ETSIServiceImpl;
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
@@ -46,12 +48,12 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.*;
-public class OrchestrationTemplateProcessCsarHandler
- implements OrchestrationTemplateProcessHandler {
- private static final Logger LOGGER = LoggerFactory
- .getLogger(OrchestrationTemplateProcessCsarHandler.class);
- private final CandidateService candidateService = CandidateServiceFactory
- .getInstance().createInterface();
+public class OrchestrationTemplateProcessCsarHandler implements OrchestrationTemplateProcessHandler {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(OrchestrationTemplateProcessCsarHandler.class);
+ private static final String SDC_ONBOARDED_PACKAGE_DIR = "ONBOARDED_PACKAGE/";
+ private static final String EXT_SEPARATOR = ".";
+ private final CandidateService candidateService = CandidateServiceFactory.getInstance().createInterface();
private final ToscaTreeManager toscaTreeManager = new ToscaTreeManager();
@Override
@@ -69,8 +71,11 @@ public class OrchestrationTemplateProcessCsarHandler
FileContentHandler fileContentHandler = fileContent.get();
processCsar(vspDetails, fileContentHandler, candidateData, response);
} catch (CoreException e) {
- LOGGER.error(e.getMessage());
+ LOGGER.error(e.getMessage(), e);
response.addErrorMessageToMap(e.code().id(), e.code().message(),ErrorLevel.ERROR);
+ }catch (IOException e){
+ LOGGER.error(e.getMessage(), e);
+ response.addErrorMessageToMap(SdcCommon.PROCESS_FILE, e.getMessage(), ErrorLevel.ERROR);
}
} else {
if (!uploadFileResponse.getErrors().isEmpty()) {
@@ -83,7 +88,7 @@ public class OrchestrationTemplateProcessCsarHandler
private void processCsar(VspDetails vspDetails,
FileContentHandler fileContentHandler,
OrchestrationTemplateCandidateData candidateData,
- OrchestrationTemplateActionResponse response) {
+ OrchestrationTemplateActionResponse response) throws IOException{
response.setFileNames(new ArrayList<>(fileContentHandler.getFileList()));
Map<String, List<ErrorMessage>> errors = validateCsar(fileContentHandler);
toscaTreeManager.createTree();
@@ -117,7 +122,15 @@ public class OrchestrationTemplateProcessCsarHandler
.saveUploadData(vspDetails, candidateData, byteArrayInputStream,
fileContentHandler, tree));
- ToscaServiceModel toscaServiceModel = new ToscaConverterImpl().convert(fileContentHandler);
+ ETSIService etsiService = new ETSIServiceImpl();
+ ToscaServiceModel toscaServiceModel;
+ if(etsiService.isSol004WithToscaMetaDirectory(fileContentHandler)){
+ fileContentHandler.addFile(SDC_ONBOARDED_PACKAGE_DIR + candidateData.getFileName() +
+ EXT_SEPARATOR + candidateData.getFileSuffix(), candidateData.getContentData().array());
+ toscaServiceModel = new ToscaSolConverterImpl().convert(fileContentHandler);
+ }else{
+ toscaServiceModel = new ToscaConverterImpl().convert(fileContentHandler);
+ }
orchestrationUtil.saveServiceModel(vspDetails.getId(),
vspDetails.getVersion(), toscaServiceModel,
toscaServiceModel);