add tosca parser verification step
[sdc.git] / test-apis-ci / src / main / java / org / openecomp / sdc / ci / tests / sanity / Onboard.java
index 44e386a..4db35a2 100644 (file)
@@ -24,8 +24,10 @@ package org.openecomp.sdc.ci.tests.sanity;
 
 
 
+import org.apache.http.HttpResponse;
 import org.junit.Rule;
 import org.junit.rules.TestName;
+import org.openecomp.sdc.be.datatypes.enums.AssetTypeEnum;
 import org.openecomp.sdc.be.model.ComponentInstance;
 import org.openecomp.sdc.be.model.Resource;
 import org.openecomp.sdc.be.model.Service;
@@ -39,9 +41,14 @@ import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject;
 import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
+import org.openecomp.sdc.ci.tests.utils.CsarToscaTester;
 import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
 import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtillViaApis;
+import org.openecomp.sdc.ci.tests.utils.rest.AssetRestUtils;
+import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
+import org.openecomp.sdc.tosca.parser.impl.SdcToscaParserFactory;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Optional;
 import org.testng.annotations.Parameters;
@@ -52,9 +59,10 @@ import com.clearspring.analytics.util.Pair;
 
 import fj.data.Either;
 
-
-
-
+import java.io.File;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
 
 
 public class Onboard extends ComponentBaseTest {
@@ -68,6 +76,8 @@ public class Onboard extends ComponentBaseTest {
        }
 
        protected String makeDistributionValue;
+       protected ISdcCsarHelper fdntCsarHelper;
+       protected SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();
 
 
 
@@ -115,12 +125,30 @@ public class Onboard extends ComponentBaseTest {
                ExtentTestActions.log(Status.INFO, String.format("Certify Service"));
                service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
 
+
 //             ExtentTestActions.log(Status.INFO, String.format("Distribute Service"));
 //             AtomicOperationUtils.distributeService(service, true);
-               
-               ExtentTestActions.log(Status.INFO, String.format("The onboarding %s test is passed ! ", vnfFile));
-       }
+               try{
+//                     HttpResponse assetResponse = AssetRestUtils.getComponentToscaModel(AssetTypeEnum.SERVICES, service.getUUID());
+//                     InputStream inputStream = assetResponse.getEntity().getContent();
+                       File csarFile = AssetRestUtils.getToscaModelCsarFile(AssetTypeEnum.SERVICES, service.getUUID());
+
+                       ExtentTestActions.log(Status.INFO, "Tosca parser is going to convert service csar file to ISdcCsarHelper object...");
+                       fdntCsarHelper = factory.getSdcCsarHelper(csarFile.getAbsolutePath());
+            CsarToscaTester.processCsar(fdntCsarHelper);
 
+                       ExtentTestActions.log(Status.INFO, String.format("Tosca parser successfully parsed service CSAR"));
 
+                       ExtentTestActions.log(Status.INFO, String.format("The onboarding %s test is passed ! ", vnfFile));
+
+               }catch(Exception e){
+                       ExtentTestActions.log(Status.ERROR, "Tosca parser FAILED to convert service csar file to ISdcCsarHelper object...");
+                       ExtentTestActions.log(Status.FAIL, e);
+
+               }
+
+
+
+       }
 
 }