diff options
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/UploadFileTest.java')
-rw-r--r-- | openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/UploadFileTest.java | 122 |
1 files changed, 80 insertions, 42 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/UploadFileTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/UploadFileTest.java index ee31ba4d70..236b7e7594 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/UploadFileTest.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/UploadFileTest.java @@ -1,72 +1,110 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.openecomp.sdc.vendorsoftwareproduct.tree; -import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade; -import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory; -import org.openecomp.sdc.vendorsoftwareproduct.VSPCommon; -import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; + +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.mockito.Spy; +import org.openecomp.core.model.dao.ServiceModelDao; +import org.openecomp.core.model.types.ServiceElement; +import org.openecomp.sdc.healing.api.HealingManager; +import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; +import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; -import org.openecomp.sdc.vendorsoftwareproduct.impl.VendorSoftwareProductManagerImpl; +import org.openecomp.sdc.vendorsoftwareproduct.impl.OrchestrationTemplateCandidateManagerImpl; +import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionDataExtractor; +import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager; +import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService; +import org.openecomp.sdc.vendorsoftwareproduct.services.impl.filedatastructuremodule.CandidateServiceImpl; +import org.openecomp.sdc.vendorsoftwareproduct.utils.VSPCommon; import org.openecomp.sdc.versioning.dao.types.Version; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.*; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.net.URL; import java.util.zip.ZipOutputStream; -public class UploadFileTest { +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doReturn; +public class UploadFileTest { + private static final String USER1 = "vspTestUser1"; public static final Version VERSION01 = new Version(0, 1); - private static final String USER1 = "vspTestUser1"; + @Mock + private VendorSoftwareProductDao vendorSoftwareProductDaoMock; + @Mock + private OrchestrationTemplateDao orchestrationTemplateDataDaoMock; + @Spy + private CandidateServiceImpl candidateService; + @Mock + private HealingManager healingManagerMock; + @Mock + private CompositionDataExtractor compositionDataExtractorMock; + @Mock + private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDaoMock; + @Mock + private CompositionEntityDataManager compositionEntityDataManagerMock; + @Mock + private VendorSoftwareProductInfoDao vspInfoDaoMock; + + @InjectMocks + private OrchestrationTemplateCandidateManagerImpl candidateManager; + + private static String vlm1Id; public static String id001 = null; public static String id002 = null; - public static Version activeVersion002 = null; - private static VendorSoftwareProductManager vendorSoftwareProductManager = - new VendorSoftwareProductManagerImpl(); - private static VendorSoftwareProductDao vendorSoftwareProductDao = - VendorSoftwareProductDaoFactory.getInstance().createInterface(); - private static VendorLicenseFacade vendorLicenseFacade = - VendorLicenseFacadeFactory.getInstance().createInterface(); - private static String vlm1Id; - - @BeforeClass - static public void init() { - //testCreateVSP - vlm1Id = vendorLicenseFacade.createVendorLicenseModel( - VSPCommon.createVendorLicenseModel("vlmName", "vlm1Id desc", "icon1"), USER1).getId(); - VspDetails expectedVsp = VSPCommon - .createVspDetails(null, null, "VSP1", "Test-vsp", "vendorName", vlm1Id, "icon", "category", - "subCategory", "123", null); - - VspDetails createdVsp = vendorSoftwareProductManager.createNewVsp(expectedVsp, USER1); - id001 = createdVsp.getId(); - - VspDetails actualVsp = - vendorSoftwareProductDao.getVendorSoftwareProductInfo(new VspDetails(id001, VERSION01)); - expectedVsp.setId(id001); - expectedVsp.setVersion(VERSION01); + public static Version activeVersion002 = null; + @BeforeMethod + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); } @Test public void testUploadFile() { - //vspActiveVersion = vendorSoftwareProductManager.checkout(id001, USER1); - vendorSoftwareProductManager.uploadFile(id001, getZipInputStream("/legalUpload"), USER1); - //testLegalUpload(id001, vspActiveVersion, getZipInputStream("/legalUpload"), USER1); + VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0)); + doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class)); + candidateManager.upload(id001, activeVersion002, getZipInputStream("/legalUpload"), USER1); } private void testLegalUpload(String vspId, Version version, InputStream upload, String user) { - vendorSoftwareProductManager.uploadFile(vspId, upload, user); + candidateManager.upload(vspId, activeVersion002, upload, user); UploadDataEntity uploadData = - vendorSoftwareProductDao.getUploadData(new UploadDataEntity(vspId, version)); + orchestrationTemplateDataDaoMock.getOrchestrationTemplate(vspId, version); } |