Enforcing HEAT validation after HEAT upload

Refactored method name , removed unused variable, Moved variable to near its usage.

Change-Id: Ief21e88bd6a4ec1b1683b89089cfdb1a948a5402
Issue-ID: SDC-1027
Signed-off-by: shrikantawachar <shrikant.awachar@amdocs.com>
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
index bf5f19f..8961df7 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
@@ -214,8 +214,6 @@
       }
       validationResponse.setUploadDataErrors(validateOrchestrationTemplate(orchestrationTemplate));
     }
-    Collection<ComponentDependencyModelEntity> componentDependencies =
-        componentDependencyModelDao.list(new ComponentDependencyModelEntity(vspId, version, null));
 
     QuestionnaireValidationResult questionnaireValidationResult = validateQuestionnaire
         (vspDetails.getId(), vspDetails.getVersion(), vspDetails.getOnboardingMethod());
@@ -230,6 +228,9 @@
       }
     }
 
+    Collection<ComponentDependencyModelEntity> componentDependencies =
+        componentDependencyModelDao.list(new ComponentDependencyModelEntity(vspId, version, null));
+
     if (validateComponentDependencies(componentDependencies)) {
       vspErrors
           .add(ComponentDependencyModelErrorBuilder.getcyclicDependencyComponentErrorBuilder());
@@ -251,11 +252,10 @@
       if (validationData.isEmpty()) {
         vspErrors.add(VendorSoftwareProductInvalidErrorBuilder
             .candidateDataNotProcessedOrAbortedErrorBuilder(fileName));
-        validationResponse.setVspErrors(vspErrors);
       } else {
         vspErrors.add(VendorSoftwareProductInvalidErrorBuilder.invalidProcessedCandidate(fileName));
-        validationResponse.setVspErrors(vspErrors);
       }
+      validationResponse.setVspErrors(vspErrors);
     }
   }
 
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImplTest.java
index e1d58c6..a86b1ef 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImplTest.java
@@ -77,8 +77,6 @@
   private static final String COMPONENT_NAME_3 = "oam_server";
   private static final String COMPONENT_NAME_4 = "ps_server";
 
-  private static final String USER1 = "vspTestUser1";
-
   @Mock
   private VendorSoftwareProductInfoDao vspInfoDaoMock;
   @Mock
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java
index 2e10f13..a9223db 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java
@@ -586,7 +586,7 @@
   }
 */
   @Test
-  public void testSubmitWithCandidateDataNotProcessed() throws IOException {
+  public void testValidateWithCandidateDataNotProcessed() throws IOException {
     VspDetails vsp =
         createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon",
             "category", "subCategory", "licenseAgreementId",
@@ -608,13 +608,10 @@
     Assert.assertNotNull(validationResponse.getVspErrors());
     Assert.assertEquals(validationResponse.getVspErrors().size(), 1);
 
-    verify(versioningManagerMock, never())
-        .submit(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
-            USER1, null);
   }
 
   @Test
-  public void testSubmitWithCandidateProcessedIsInvalid() throws IOException {
+  public void testValidateWithCandidateProcessedIsInvalid() throws IOException {
     VspDetails vsp = createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-VSP", "vendorName",
         "vl1Id", "icond", "category", "subcategory", "licenseAgreementId", Collections
             .singletonList("featureGroupId"));
@@ -633,10 +630,6 @@
     Assert.assertFalse(validationResponse.isValid());
     Assert.assertNotNull(validationResponse.getVspErrors());
     Assert.assertEquals(validationResponse.getVspErrors().size(), 1);
-
-    verify(versioningManagerMock, never())
-        .submit(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
-            USER1, null);
   }
 
   private void testLegalUpload(String vspId, Version version, InputStream upload, String user) {