diff options
Diffstat (limited to 'integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api')
8 files changed, 1971 insertions, 0 deletions
diff --git a/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api/AttSdcTest.java b/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api/AttSdcTest.java new file mode 100644 index 0000000000..b3373ee4bd --- /dev/null +++ b/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api/AttSdcTest.java @@ -0,0 +1,192 @@ +/*- + * ============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.ci.tests.api; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import org.junit.*; +import org.junit.rules.TestName; +import org.junit.rules.TestWatcher; +import org.openecomp.sdc.ci.tests.config.Config; +import org.openecomp.sdc.ci.tests.rules.MyTestWatcher; +import org.openecomp.sdc.ci.tests.utils.Utils; +import org.openecomp.sdc.ci.tests.utils.general.FileUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.List; + +import static org.junit.Assert.assertTrue; + +public abstract class AttSdcTest { + + public static StringBuilder doc = new StringBuilder(); + public static String file = null; + public static Config config = null; + // protected Gson gson = new Gson(); + protected Gson prettyGson = new GsonBuilder().setPrettyPrinting().create(); + + protected TestName testName = null; + protected Logger logger = null; + + protected static boolean displayException = false; + + public AttSdcTest(TestName testName, String className) { + super(); + + this.testName = testName; + this.logger = LoggerFactory.getLogger(className); + + String displayEx = System.getProperty("displayException"); + if (displayEx != null && Boolean.valueOf(displayEx).booleanValue()) { + displayException = true; + } + + } + + @Rule + public TestWatcher tw = new MyTestWatcher(this); + + @BeforeClass + public static void beforeClass() { + doc = new StringBuilder(); + doc.append( + "<Html><head><style>th{background-color: gray;color: white;height: 30px;}td {color: black;height: 30px;}.fail {background-color: #FF5555;width: 100px;text-align: center;}.success {background-color: #00FF00;width: 100px;text-align: center;}.name {width: 200px;background-color: #F0F0F0;}.message {width: 300px;background-color: #F0F0F0;}</style>"); + + doc.append("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">"); + doc.append( + "<link rel=\"stylesheet\" href=\"http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css\">"); + + doc.append("</head><body>"); + + doc.append("<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js\"></script>"); + doc.append("<script src=\"http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js\"></script>"); + + doc.append("<table>"); + + doc.append("<tr>"); + doc.append("<th>").append("Test Name").append("</th>"); + doc.append("<th>").append("Status").append("</th>"); + doc.append("<th>").append("Message").append("</th>"); + + if (displayException) { + doc.append("<th>").append("Exception").append("</th>"); + } + doc.append("</tr>"); + } + + @AfterClass + public static void afterClass() { + doc.append("<table>"); + // writeToFile("./" + ConfigAttOdlIt.REPORT_FILE , doc.toString()); + FileUtils.writeToFile( + Config.instance().getOutputFolder() + File.separator + file + System.currentTimeMillis() + ".html", + doc.toString()); + + } + + @Before + public void beforeTest() throws FileNotFoundException { + file = FileUtils.getFileName(this.getClass().getName()); + config = Utils.getConfig(); + assertTrue(config != null); + } + + @After + public void afterTest() throws FileNotFoundException { + + } + + public void addTestSummary(String testName, boolean isSuccess) { + addTestSummary(testName, isSuccess, null); + } + + public void addTestSummary(String testName, boolean isSuccess, Throwable exception) { + + String message = exception == null ? "" : exception.getMessage(); + + String result = (isSuccess) ? "success" : "fail"; + doc.append("<tr>"); + doc.append("<td class=\"name\">").append(testName).append("</td>"); + doc.append("<td class=\"" + result + "\">").append(result).append("</td>"); + doc.append("<td class=\"message\">").append(message).append("</td>"); + + if (displayException) { + // doc.append("<td + // class=\"message\">").append(convertExceptionToString(exception)).append("</td>"); + doc.append("<td class=\"message\">"); + + doc.append("<button type=\"button\" class=\"btn btn-info\" data-toggle=\"collapse\" data-target=\"#demo" + + testName + "\">Simple collapsible</button>"); + doc.append("<div id=\"demo" + testName + "\" class=\"collapse out\">"); + + doc.append(convertExceptionToString(exception)); + + doc.append("</div>"); + doc.append("</td>"); + } + + doc.append("</tr>"); + + if (isSuccess) { + logger.debug("Test {} {}",testName,(isSuccess ? " SUCCEEDED " : " FAILED with error " + message)); + } else { + logger.error("Test {} {}",testName,(isSuccess ? " SUCCEEDED " : " FAILED with error " + message)); + } + } + + private String convertExceptionToString(Throwable exception) { + + if (exception == null) { + return ""; + } + + StringWriter sw = new StringWriter(); + exception.printStackTrace(new PrintWriter(sw)); + String exceptionAsString = sw.toString(); + + return exceptionAsString; + } + + public Logger getLogger() { + return logger; + } + + protected boolean ignoreDueToBug(String bug) { + + List<String> bugs = config.getBugs(); + + if (bugs != null && bugs.size() > 0) { + for (String bugNumber : bugs) { + if (bugNumber.startsWith(bug)) { + return true; + } + } + } + + return false; + } + +} diff --git a/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api/ComponentBaseTest.java b/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api/ComponentBaseTest.java new file mode 100644 index 0000000000..8c238ce8ac --- /dev/null +++ b/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api/ComponentBaseTest.java @@ -0,0 +1,255 @@ +/*- + * ============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.ci.tests.api; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.LoggerContext; +import com.aventstack.extentreports.ExtentTest; +import com.aventstack.extentreports.Status; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; +import org.apache.commons.collections.CollectionUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; +import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; +import org.openecomp.sdc.be.model.Component; +import org.openecomp.sdc.be.model.Product; +import org.openecomp.sdc.be.model.Resource; +import org.openecomp.sdc.be.model.Service; +import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.ci.tests.config.Config; +import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +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.Utils; +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.FileHandling; +import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils; +import org.openecomp.sdc.ci.tests.utils.rest.CatalogRestUtils; +import org.openecomp.sdc.ci.tests.utils.rest.ProductRestUtils; +import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils; +import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; +import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils; +import org.slf4j.LoggerFactory; +import org.testng.ITestContext; +import org.testng.ITestResult; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.AfterSuite; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeSuite; + +public abstract class ComponentBaseTest { + + protected static Logger logger = LogManager.getLogger(ComponentBaseTest.class); + + protected static final String REPORT_FOLDER = "." + File.separator + "ExtentReport" + File.separator; + private static final String REPORT_FILE_NAME = "SDC_CI_Extent_Report.html"; + public static Config config; + protected static ITestContext myContext; + + + /**************** METHODS ****************/ + public static ExtentTest getExtendTest() { + SomeInterface testManager = new ExtentTestManager(); + return testManager.getTest(); + } + + public enum ComponentOperationEnum { + CREATE_COMPONENT, UPDATE_COMPONENT, GET_COMPONENT, DELETE_COMPONENT, CHANGE_STATE_CHECKIN, CHANGE_STATE_CHECKOUT, CHANGE_STATE_UNDO_CHECKOUT + } + + public ComponentBaseTest() { + LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); + lc.getLogger("com.thinkaurelius").setLevel(Level.INFO); + lc.getLogger("com.datastax").setLevel(Level.INFO); + lc.getLogger("io.netty").setLevel(Level.INFO); + lc.getLogger("c.d").setLevel(Level.INFO); + } + + public static String getReportFolder() { + return REPORT_FOLDER; + } + + @BeforeSuite(alwaysRun = true) + public void setupBeforeSuite(ITestContext context) throws Exception { + config = Utils.getConfig(); + myContext = context; + ExtentManager.initReporter(getReportFolder(), REPORT_FILE_NAME, context); + AtomicOperationUtils.createDefaultConsumer(true); + performClean(); + } + + @BeforeMethod(alwaysRun = true) + public void setupBeforeTest(java.lang.reflect.Method method, ITestContext context) throws Exception { + if (!"onboardVNFShotFlow".equals(method.getName()) && + !"onboardPNFFlow".equals(method.getName()) ) { + logger.info("ExtentReport instance started from BeforeMethod..."); + ExtentTestManager.startTest(method.getName()); + ExtentTestManager.assignCategory(this.getClass()); + + } else { + logger.debug("ExtentReport instance started from Test..."); + } + } + + @AfterMethod(alwaysRun = true) + public void quitAfterTest(ITestResult result, ITestContext context) throws Exception { + int status = result.getStatus(); + switch (status) { + case ITestResult.SUCCESS: + getExtendTest().log(Status.PASS, "Test Result : <span class='label success'>Success</span>"); + break; + + case ITestResult.FAILURE: + getExtendTest().log(Status.ERROR, "ERROR - The following exepction occured"); + getExtendTest().log(Status.ERROR, result.getThrowable()); + getExtendTest().log(Status.FAIL, "<span class='label failure'>Failure</span>"); + break; + + case ITestResult.SKIP: + getExtendTest().log(Status.SKIP, "SKIP - The following exepction occured"); + break; + default: + break; + } + ExtentTestManager.endTest(); + } + + @AfterSuite(alwaysRun = true) + public static void shutdownJanusGraph() throws Exception { + performClean(); + } + + public void setLog(String fromDataProvider) { + ExtentTestManager.startTest(Thread.currentThread().getStackTrace()[2].getMethodName() + " " + fromDataProvider); + ExtentTestManager.assignCategory(this.getClass()); + } + + protected static void performClean() throws Exception { + if (!config.getSystemUnderDebug()) { + deleteCreatedComponents(getCatalogAsMap()); + FileHandling.overWriteExistindDir("target/outputCsar"); + } else { + System.out.println("Accordindig to configuration components will not be deleted, in case to unable option to delete, please change systemUnderDebug parameter value to false ..."); + } + } + + private static void deleteCreatedComponents(Map<String, List<Component>> convertCatalogResponseToJavaObject) throws IOException { + final String userId = UserRoleEnum.DESIGNER.getUserId(); + + List<Component> resourcesArrayList = convertCatalogResponseToJavaObject.get(ComponentTypeEnum.RESOURCE_PARAM_NAME); + if (!CollectionUtils.isEmpty(resourcesArrayList)) { + List<String> collect = buildCollectionUniqueId(resourcesArrayList); + for (String uId : collect) { + ResourceRestUtils.markResourceToDelete(uId, userId); + } + ResourceRestUtils.deleteMarkedResources(userId); + } + + resourcesArrayList = convertCatalogResponseToJavaObject.get(ComponentTypeEnum.SERVICE_PARAM_NAME); + if (resourcesArrayList.size() > 0) { + List<String> collect = buildCollectionUniqueId(resourcesArrayList); + for (String uId : collect) { + ServiceRestUtils.markServiceToDelete(uId, userId); + } + ServiceRestUtils.deleteMarkedServices(userId); + } + } + + protected static List<String> buildCollectionUniqueId(List<Component> resourcesArrayList) { + + + List<String> genericCollection = new ArrayList<>(); + if(resourcesArrayList.get(0) != null) { + ComponentTypeEnum componentTypeEnum = resourcesArrayList.get(0).getComponentType(); + resourcesArrayList.stream().filter(Objects::nonNull). + filter(s -> s.getName().toLowerCase().startsWith("ci") && !s.getName().toLowerCase().equals("cindervolume")). + filter(f -> f.getUniqueId() != null). + map(Component::getUniqueId). + collect(Collectors.toList()). + forEach((i) -> buildCollectionBaseOnComponentType(componentTypeEnum, genericCollection, i)); + } + return genericCollection; + } + + public static void buildCollectionBaseOnComponentType(ComponentTypeEnum componentTypeEnum, + List<String> genericCollection, String i) { + try { + switch (componentTypeEnum) { + case RESOURCE: + RestResponse resource = ResourceRestUtils.getResource(i); + Resource convertResourceResponseToJavaObject = ResponseParser.convertResourceResponseToJavaObject(resource.getResponse()); + Map<String, String> allVersions = convertResourceResponseToJavaObject.getAllVersions(); + Collection<String> values = allVersions.values(); + genericCollection.addAll(values); + + break; + case SERVICE: + RestResponse service = ServiceRestUtils.getService(i); + Service convertServiceResponseToJavaObject = ResponseParser.convertServiceResponseToJavaObject(service.getResponse()); + allVersions = convertServiceResponseToJavaObject.getAllVersions(); + values = allVersions.values(); + genericCollection.addAll(values); + + break; + + + case PRODUCT: + RestResponse product = ProductRestUtils.getProduct(i); + Product convertProductResponseToJavaObject = ResponseParser.convertProductResponseToJavaObject(product.getResponse()); + allVersions = convertProductResponseToJavaObject.getAllVersions(); + values = allVersions.values(); + genericCollection.addAll(values); + + break; + } + } catch (Exception e1) { + e1.printStackTrace(); + } + } + + protected static Map<String, List<Component>> getCatalogAsMap() throws Exception { + RestResponse catalog = CatalogRestUtils.getCatalog(UserRoleEnum.DESIGNER.getUserId()); + return ResponseParser.convertCatalogResponseToJavaObject(catalog.getResponse()); + } + + protected Resource createVfFromCSAR(User sdncModifierDetails, String csarId) throws Exception { + // create new resource from Csar + ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource(); + + resourceDetails.setCsarUUID(csarId); + resourceDetails.setResourceType(ResourceTypeEnum.VF.name()); + RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, sdncModifierDetails); + BaseRestUtils.checkCreateResponse(createResource); + return ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse()); + } + + +} diff --git a/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api/ComponentInstanceBaseTest.java b/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api/ComponentInstanceBaseTest.java new file mode 100644 index 0000000000..678ebc4afe --- /dev/null +++ b/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api/ComponentInstanceBaseTest.java @@ -0,0 +1,728 @@ +/*- + * ============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.ci.tests.api; + +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.junit.rules.TestName; +import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; +import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; +import org.openecomp.sdc.be.model.*; +import org.openecomp.sdc.ci.tests.datatypes.*; +import org.openecomp.sdc.ci.tests.datatypes.enums.*; +import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; +import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; +import org.openecomp.sdc.ci.tests.utils.rest.*; +import org.testng.Assert; + +import java.io.IOException; +import java.util.*; +import java.util.Map.Entry; +import java.util.function.Function; +import java.util.stream.Collectors; + +import static org.testng.AssertJUnit.*; + +public class ComponentInstanceBaseTest extends ComponentBaseTest { + public static final String acceptHeaderData = "application/json"; + // Req/cap of container component + protected Map<String, List<CapabilityDefinition>> expectedContainerCapabilities; + protected Map<String, List<RequirementDefinition>> expectedContainerRequirements; + protected Map<String, Map<String, List<RequirementDefinition>>> removedRequirements; + protected Map<String, ImmutablePair<Map<String, List<CapabilityDefinition>>, Map<String, List<RequirementDefinition>>>> expectedContInstReqCap; + + protected User sdncPsDetails1; + protected User sdncPsDetails2; + protected User sdncPmDetails1; + protected User sdncPmDetails2; + protected User sdncDesignerDetails; + protected User sdncAdminDetails; + protected User sdncTesterDetails; + protected ResourceReqDetails resourceDetailsVFC_01; + protected ResourceReqDetails resourceDetailsVFC_02; + protected ResourceReqDetails resourceDetailsVF_01; + protected ResourceReqDetails resourceDetailsVF_02; + protected ResourceReqDetails resourceDetailsCP_01; + protected ResourceReqDetails resourceDetailsCP_02; + protected ResourceReqDetails resourceDetailsVL_01; + protected ResourceReqDetails resourceDetailsVL_02; + protected ServiceReqDetails serviceDetails_01; + protected ServiceReqDetails serviceDetails_02; + protected ServiceReqDetails serviceDetails_03; + protected ProductReqDetails productDetails_01; + protected ProductReqDetails productDetails_02; + + public void init() { + // Req/caps of inner componentInstances + expectedContainerCapabilities = new LinkedHashMap<>(); + expectedContainerRequirements = new LinkedHashMap<>(); + removedRequirements = new HashMap<>(); + expectedContInstReqCap = new HashMap<>(); + + sdncPsDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_STRATEGIST1); + sdncPsDetails2 = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_STRATEGIST2); + sdncPmDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_MANAGER1); + sdncPmDetails2 = ElementFactory.getDefaultUser(UserRoleEnum.PRODUCT_MANAGER2); + sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER); + sdncAdminDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN); + sdncTesterDetails = ElementFactory.getDefaultUser(UserRoleEnum.TESTER); + resourceDetailsVFC_01 = ElementFactory.getDefaultResourceByType("ciVFC100", NormativeTypesEnum.SOFTWARE_COMPONENT, ResourceCategoryEnum.GENERIC_DATABASE, sdncDesignerDetails.getUserId(), ResourceTypeEnum.VFC.toString()); // resourceType = VFC + resourceDetailsVFC_02 = ElementFactory.getDefaultResourceByType("ciVFC200", NormativeTypesEnum.COMPUTE, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, sdncDesignerDetails.getUserId(), ResourceTypeEnum.VFC.toString()); + resourceDetailsVF_01 = ElementFactory.getDefaultResourceByType("ciVF100", NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, sdncDesignerDetails.getUserId(), ResourceTypeEnum.VF.toString()); + resourceDetailsVF_02 = ElementFactory.getDefaultResourceByType("ciVF200", NormativeTypesEnum.ROOT, ResourceCategoryEnum.GENERIC_INFRASTRUCTURE, sdncDesignerDetails.getUserId(), ResourceTypeEnum.VF.toString()); + resourceDetailsCP_01 = ElementFactory.getDefaultResourceByType("ciCP100", NormativeTypesEnum.PORT, ResourceCategoryEnum.GENERIC_NETWORK_ELEMENTS, sdncDesignerDetails.getUserId(), ResourceTypeEnum.CP.toString()); + resourceDetailsCP_02 = ElementFactory.getDefaultResourceByType("ciCP200", NormativeTypesEnum.PORT, ResourceCategoryEnum.GENERIC_DATABASE, sdncDesignerDetails.getUserId(), ResourceTypeEnum.CP.toString()); + resourceDetailsVL_01 = ElementFactory.getDefaultResourceByType("ciVL100", NormativeTypesEnum.NETWORK, ResourceCategoryEnum.GENERIC_NETWORK_ELEMENTS, sdncDesignerDetails.getUserId(), ResourceTypeEnum.VL.toString()); + resourceDetailsVL_02 = ElementFactory.getDefaultResourceByType("ciVL200", NormativeTypesEnum.NETWORK, ResourceCategoryEnum.GENERIC_NETWORK_ELEMENTS, sdncDesignerDetails.getUserId(), ResourceTypeEnum.VL.toString()); + serviceDetails_01 = ElementFactory.getDefaultService("ciNewtestservice1", ServiceCategoriesEnum.MOBILITY, sdncDesignerDetails.getUserId(), ServiceInstantiationType.A_LA_CARTE.getValue()); + serviceDetails_02 = ElementFactory.getDefaultService("ciNewtestservice2", ServiceCategoriesEnum.MOBILITY, sdncDesignerDetails.getUserId(), ServiceInstantiationType.A_LA_CARTE.getValue()); + serviceDetails_03 = ElementFactory.getDefaultService("ciNewtestservice3", ServiceCategoriesEnum.MOBILITY, sdncDesignerDetails.getUserId(), ServiceInstantiationType.A_LA_CARTE.getValue()); + productDetails_01 = ElementFactory.getDefaultProduct("ciProduct01"); + productDetails_02 = ElementFactory.getDefaultProduct("ciProduct02"); + } + + public void verifyVFReqCap(String componentId) throws Exception { + RestResponse restResponse = ResourceRestUtils.getResource(componentId); + Resource resource = ResponseParser.parseToObject(restResponse.getResponse(), Resource.class); + verifyReqCap(resource); + } + + public void verifyServiceReqCap(String componentId) throws Exception { + RestResponse restResponse = ServiceRestUtils.getService(componentId, sdncDesignerDetails); + Service service = ResponseParser.parseToObject(restResponse.getResponse(), Service.class); + verifyReqCap(service); + } + + public void verifyProductReqCap(String componentId) throws Exception { + RestResponse restResponse = ProductRestUtils.getProduct(componentId, sdncPsDetails1.getUserId()); + Product product = ResponseParser.parseToObject(restResponse.getResponse(), Product.class); + verifyReqCap(product); + } + + public void verifyReqCap(Component actualComponent) { + verifyContainerReqCap(actualComponent); + verifyCompInstReqCap(actualComponent); + } + + public RestResponse changeServiceInstanceVersion(String componentUniqueId, String serviceInstanceToReplaceUniqueId, String serviceUniqueId, User sdncModifierDetails, ComponentTypeEnum componentType, boolean isHighestLevel) throws Exception { + RestResponse changeResourceInstanceVersion = ProductRestUtils.changeServiceInstanceVersion(componentUniqueId, serviceInstanceToReplaceUniqueId, serviceUniqueId, sdncModifierDetails, componentType); + if (changeResourceInstanceVersion.getErrorCode().equals(BaseRestUtils.STATUS_CODE_SUCCESS) && isHighestLevel) { + /* + * // Add RI Capabilities and Requirements to expected MAP --> expectedVfCapabilities and expectedVfRequirements + * + * ComponentInstance componentInstance = ResponseParser.parseToObjectUsingMapper( changeResourceInstanceVersion.getResponse(), ComponentInstance.class); addCompInstReqCapToExpected(componentInstance, componentType); + */ + } + return changeResourceInstanceVersion; + } + + protected void updateExpectedReqCapAfterChangeLifecycleState(String oldContainerUniqueIdToReplace, String newContainerUniqueId) { + + // Update of container req/cap + + Set<String> compInstKeysToChange = new HashSet<>(); + + for (String expKey : expectedContainerCapabilities.keySet()) { + List<CapabilityDefinition> expCapList = expectedContainerCapabilities.get(expKey); + for (CapabilityDefinition cap : expCapList) { + String ownerId = cap.getOwnerId(); + + if (ownerId.contains(oldContainerUniqueIdToReplace)) { + compInstKeysToChange.add(ownerId); + cap.setOwnerId(cap.getOwnerId().replaceAll(oldContainerUniqueIdToReplace, newContainerUniqueId)); + } + } + } + + for (String expKey : expectedContainerRequirements.keySet()) { + List<RequirementDefinition> expCapList = expectedContainerRequirements.get(expKey); + for (RequirementDefinition cap : expCapList) { + String ownerId = cap.getOwnerId(); + if (ownerId.contains(oldContainerUniqueIdToReplace)) { + compInstKeysToChange.add(ownerId); + cap.setOwnerId(cap.getOwnerId().replaceAll(oldContainerUniqueIdToReplace, newContainerUniqueId)); + } + } + } + + // Update of internal comp instances req/cap + for (String oldKey : compInstKeysToChange) { + ImmutablePair<Map<String, List<CapabilityDefinition>>, Map<String, List<RequirementDefinition>>> immutablePair = expectedContInstReqCap.get(oldKey); + if (immutablePair != null) { + expectedContInstReqCap.remove(oldKey); + String newKey = oldKey.replaceAll(oldContainerUniqueIdToReplace, newContainerUniqueId); + expectedContInstReqCap.put(newKey, immutablePair); + } + } + + // Update of removed req + for (String oldKey : compInstKeysToChange) { + Map<String, List<RequirementDefinition>> map = removedRequirements.get(oldKey); + if (map != null) { + removedRequirements.remove(oldKey); + String newKey = oldKey.replaceAll(oldContainerUniqueIdToReplace, newContainerUniqueId); + Collection<List<RequirementDefinition>> values = map.values(); + if (values != null) { + for (List<RequirementDefinition> list : values) { + for (RequirementDefinition reqDef : list) { + reqDef.setOwnerId(reqDef.getOwnerId().replaceAll(oldContainerUniqueIdToReplace, newContainerUniqueId)); + } + } + } + removedRequirements.put(newKey, map); + } + } + } + + private void verifyCompInstReqCap(Component actualComponent) { + List<ComponentInstance> componentInstances = actualComponent.getComponentInstances(); + if (componentInstances != null) { + assertEquals(expectedContInstReqCap.size(), componentInstances.size()); + for (ComponentInstance compInst : componentInstances) { + String uniqueId = compInst.getUniqueId(); + // System.out.println("Verifying req/cap of component instance + // "+ uniqueId); + Map<String, List<RequirementDefinition>> actualCompInstReq = compInst.getRequirements(); + if (actualCompInstReq == null) { + actualCompInstReq = new HashMap<>(); + } + Map<String, List<CapabilityDefinition>> actualCompInstCap = compInst.getCapabilities(); + if (actualCompInstCap == null) { + actualCompInstCap = new HashMap<>(); + } + ImmutablePair<Map<String, List<CapabilityDefinition>>, Map<String, List<RequirementDefinition>>> expReqCap = expectedContInstReqCap.get(uniqueId); + assertNotNull(expReqCap); + // System.out.println("expected instance requirements: + // "+expReqCap.right); + // System.out.println("expected instance capabilities: + // "+expReqCap.left); + // System.out.println("actual instance requirements: + // "+actualCompInstReq); + // System.out.println("actual instance capabilities: + // "+actualCompInstCap); + + // REQ comparison + compareReqCapMaps(expReqCap.right, actualCompInstReq); + + // CAP comparison + compareReqCapMaps(expReqCap.left, actualCompInstCap); + } + + } else { + assertTrue(expectedContInstReqCap.isEmpty()); + } + } + + private void verifyContainerReqCap(Component actualComponent) { + Map<String, List<RequirementDefinition>> actualContainerRequirements = actualComponent.getRequirements(); + if (actualContainerRequirements == null) { + actualContainerRequirements = new HashMap<>(); + } + Map<String, List<CapabilityDefinition>> actualContainerCapabilities = actualComponent.getCapabilities(); + if (actualContainerCapabilities == null) { + actualContainerCapabilities = new HashMap<>(); + } + // System.out.println("Verifying req/cap of container component "+ + // actualComponent.getUniqueId()); + // System.out.println("expected container requirements: + // "+expectedContainerRequirements); + // System.out.println("expected container capabilities: + // "+expectedContainerCapabilities); + // System.out.println("actual container requirements: + // "+actualContainerRequirements); + // System.out.println("actual container capabilities: + // "+actualContainerCapabilities); + + // REQ comparison + compareReqCapMaps(expectedContainerRequirements, actualContainerRequirements); + + // CAP comparison + compareReqCapMaps(expectedContainerCapabilities, actualContainerCapabilities); + } + + private <T> void compareReqCapMaps(Map<String, List<T>> expectedMap, Map<String, List<T>> actualMap) { + assertEquals(expectedMap.size(), actualMap.size()); + for (String expKey : expectedMap.keySet()) { + List<?> expCapList = expectedMap.get(expKey); + List<?> actCapList = actualMap.get(expKey); + assertEquals(expCapList.size(), actCapList.size()); + assertEquals(new HashSet<>(expCapList), new HashSet<>(actCapList)); + } + } + + public void addCompInstReqCapToExpected(ComponentInstance componentInstance, ComponentTypeEnum containerComponentType) throws Exception { + String uniqueId = componentInstance.getUniqueId(); + String name = componentInstance.getName(); + String originComponentId = componentInstance.getComponentUid(); + RestResponse getResponse = null; + ComponentTypeEnum compInstType = getCompInstTypeByContainerType(containerComponentType); + Component component = null; + if (compInstType == ComponentTypeEnum.RESOURCE) { + getResponse = ResourceRestUtils.getResource(sdncDesignerDetails, originComponentId); + ResourceRestUtils.checkSuccess(getResponse); + component = ResponseParser.parseToObjectUsingMapper(getResponse.getResponse(), Resource.class); + } else if (compInstType == ComponentTypeEnum.SERVICE) { + getResponse = ServiceRestUtils.getService(originComponentId, sdncDesignerDetails); + ResourceRestUtils.checkSuccess(getResponse); + component = ResponseParser.parseToObjectUsingMapper(getResponse.getResponse(), Service.class); + } else { + Assert.fail("Unsupported type - " + containerComponentType); + } + + Map<String, List<RequirementDefinition>> resourceRequirements = component.getRequirements(); + if (resourceRequirements == null) { + resourceRequirements = new HashMap<>(); + } + + Function<Entry<String, List<RequirementDefinition>>, List<RequirementDefinition>> requirementDefinitionMapper = e -> new ArrayList<>(e.getValue().stream().map(item -> new RequirementDefinition(item)).collect(Collectors.toList())); + Map<String, List<RequirementDefinition>> reqCopy = resourceRequirements.entrySet().stream().collect(Collectors.toMap(e -> e.getKey(), requirementDefinitionMapper)); + + Map<String, List<CapabilityDefinition>> resourceCapabilities = component.getCapabilities(); + if (resourceCapabilities == null) { + resourceCapabilities = new HashMap<>(); + } + + Function<? super Entry<String, List<CapabilityDefinition>>, List<CapabilityDefinition>> capabilityDefinitionMapper = e -> new ArrayList<>(e.getValue().stream().map(item -> new CapabilityDefinition(item)).collect(Collectors.toList())); + Map<String, List<CapabilityDefinition>> capCopy = resourceCapabilities.entrySet().stream().collect(Collectors.toMap(e -> e.getKey(), capabilityDefinitionMapper)); + + setupContainerExpectedReqCap(uniqueId, name, resourceRequirements, resourceCapabilities); + if (component.getComponentType().equals(ComponentTypeEnum.RESOURCE) && ((Resource) component).getResourceType() != ResourceTypeEnum.VF) { + setupConstInstExpectedReqCap(uniqueId, name, reqCopy, capCopy); + } + + // adding entry for expected componentInstance + ImmutablePair<Map<String, List<CapabilityDefinition>>, Map<String, List<RequirementDefinition>>> compInstReqCapPair = new ImmutablePair<Map<String, List<CapabilityDefinition>>, Map<String, List<RequirementDefinition>>>(capCopy, reqCopy); + expectedContInstReqCap.put(uniqueId, compInstReqCapPair); + } + + private void setupContainerExpectedReqCap(String uniqueId, String name, Map<String, List<RequirementDefinition>> componentRequirements, Map<String, List<CapabilityDefinition>> componentCapabilities) { + for (Entry<String, List<RequirementDefinition>> resReq : componentRequirements.entrySet()) { + List<RequirementDefinition> reqListToAdd = resReq.getValue(); + for (RequirementDefinition requirementDefinition : reqListToAdd) { + requirementDefinition.setOwnerId(uniqueId); + requirementDefinition.setOwnerName(name); + } + List<RequirementDefinition> expectedReqList = expectedContainerRequirements.get(resReq.getKey()); + if (expectedReqList == null) { + expectedReqList = reqListToAdd; + } else { + expectedReqList.addAll(reqListToAdd); + } + expectedContainerRequirements.put(resReq.getKey(), expectedReqList); + } + + for (Entry<String, List<CapabilityDefinition>> resCap : componentCapabilities.entrySet()) { + List<CapabilityDefinition> capListToAdd = resCap.getValue(); + for (CapabilityDefinition capDefinition : capListToAdd) { + capDefinition.setOwnerId(uniqueId); + capDefinition.setOwnerName(name); + } + List<CapabilityDefinition> expectedCapList = expectedContainerCapabilities.get(resCap.getKey()); + if (expectedCapList == null) { + expectedCapList = capListToAdd; + } else { + expectedCapList.addAll(capListToAdd); + } + expectedContainerCapabilities.put(resCap.getKey(), expectedCapList); + } + } + + private void setupConstInstExpectedReqCap(String uniqueId, String name, Map<String, List<RequirementDefinition>> componentRequirements, Map<String, List<CapabilityDefinition>> componentCapabilities) { + for (Entry<String, List<RequirementDefinition>> resReq : componentRequirements.entrySet()) { + List<RequirementDefinition> reqListToAdd = resReq.getValue(); + for (RequirementDefinition requirementDefinition : reqListToAdd) { + requirementDefinition.setOwnerId(uniqueId); + requirementDefinition.setOwnerName(name); + } + } + + for (Entry<String, List<CapabilityDefinition>> resCap : componentCapabilities.entrySet()) { + List<CapabilityDefinition> capListToAdd = resCap.getValue(); + for (CapabilityDefinition capDefinition : capListToAdd) { + capDefinition.setOwnerId(uniqueId); + capDefinition.setOwnerName(name); + } + } + } + + private ComponentTypeEnum getCompInstTypeByContainerType(ComponentTypeEnum componentType) { + switch (componentType) { + case RESOURCE: + return ComponentTypeEnum.RESOURCE; + case SERVICE: + return ComponentTypeEnum.RESOURCE; + case PRODUCT: + return ComponentTypeEnum.SERVICE; + default: + break; + } + return null; + } + + public void deleteCompInstReqCapFromExpected(String componentInstanceId) { + List<String> entriesRequirementsToRemove = new ArrayList<>(); + List<String> entriesCapabilitiesToRemove = new ArrayList<>(); + for (Entry<String, List<RequirementDefinition>> reqEntry : expectedContainerRequirements.entrySet()) { + List<RequirementDefinition> reqList = reqEntry.getValue(); + List<RequirementDefinition> reqListToDelete = new ArrayList<>(); + for (RequirementDefinition requirementDefinition : reqList) { + if (requirementDefinition.getOwnerId().equals(componentInstanceId)) { + reqListToDelete.add(requirementDefinition); + } + } + reqList.removeAll(reqListToDelete); + if (reqList.isEmpty()) { + entriesRequirementsToRemove.add(reqEntry.getKey()); + } + } + + for (String ekey : entriesRequirementsToRemove) { + expectedContainerRequirements.remove(ekey); + } + + for (Entry<String, List<CapabilityDefinition>> capEntry : expectedContainerCapabilities.entrySet()) { + List<CapabilityDefinition> capList = capEntry.getValue(); + List<CapabilityDefinition> capListToDelete = new ArrayList<>(); + for (CapabilityDefinition capabilityDefinition : capList) { + if (capabilityDefinition.getOwnerId().equals(componentInstanceId)) { + capListToDelete.add(capabilityDefinition); + } + } + capList.removeAll(capListToDelete); + if (capList.isEmpty()) { + entriesCapabilitiesToRemove.add(capEntry.getKey()); + } + } + for (String ekey : entriesCapabilitiesToRemove) { + expectedContainerCapabilities.remove(ekey); + } + + expectedContInstReqCap.remove(componentInstanceId); + + } + + // Automatically updates the expected req/cap of the container + protected RestResponse createAtomicInstanceForVF(ResourceReqDetails containerDetails, ResourceReqDetails compInstOriginDetails, User modifier) throws Exception { + return createComponentInstance(containerDetails, compInstOriginDetails, modifier, ComponentTypeEnum.RESOURCE, true); + } + + // Automatically updates the expected req/cap of the container + protected RestResponse createAtomicInstanceForService(ServiceReqDetails containerDetails, ResourceReqDetails compInstOriginDetails, User modifier) throws Exception { + return createComponentInstance(containerDetails, compInstOriginDetails, modifier, ComponentTypeEnum.SERVICE, true); + } + + // Automatically updates the expected req/cap of the container + protected RestResponse createVFInstance(ServiceReqDetails containerDetails, ResourceReqDetails compInstOriginDetails, User modifier) throws Exception { + return createComponentInstance(containerDetails, compInstOriginDetails, modifier, ComponentTypeEnum.SERVICE, true); + } + + // Automatically updates the expected req/cap of the container + protected RestResponse createServiceInstance(ProductReqDetails containerDetails, ServiceReqDetails compInstOriginDetails, User modifier) throws Exception { + return createComponentInstance(containerDetails, compInstOriginDetails, modifier, ComponentTypeEnum.PRODUCT, true); + } + + // Automatically updates the expected req/cap of the container + protected RestResponse deleteAtomicInstanceForVF(String compInstUniqueId, ResourceReqDetails containerDetails, User modifier) throws IOException, Exception { + return deleteComponentInstance(compInstUniqueId, containerDetails, modifier, ComponentTypeEnum.RESOURCE, true); + } + + // Automatically updates the expected req/cap of the container + protected RestResponse deleteAtomicInstanceForService(String compInstUniqueId, ServiceReqDetails containerDetails, User modifier) throws IOException, Exception { + return deleteComponentInstance(compInstUniqueId, containerDetails, modifier, ComponentTypeEnum.SERVICE, true); + } + + // Automatically updates the expected req/cap of the container + protected RestResponse deleteVFInstance(String compInstUniqueId, ServiceReqDetails containerDetails, User modifier) throws IOException, Exception { + return deleteComponentInstance(compInstUniqueId, containerDetails, modifier, ComponentTypeEnum.SERVICE, true); + + } + + // Automatically updates the expected req/cap of the container + protected RestResponse deleteServiceInstance(String compInstUniqueId, ProductReqDetails containerDetails, User modifier) throws IOException, Exception { + return deleteComponentInstance(compInstUniqueId, containerDetails, modifier, ComponentTypeEnum.PRODUCT, true); + } + + // Setup of lower components - Doesn't affect req/cap of the container (for + // example, setup of VF for testing a Product) + protected RestResponse createAtomicInstanceForVFDuringSetup(ResourceReqDetails containerDetails, ResourceReqDetails compInstOriginDetails, User modifier) throws Exception { + return createComponentInstance(containerDetails, compInstOriginDetails, modifier, ComponentTypeEnum.RESOURCE, false); + } + + // Setup of lower components - Doesn't affect req/cap of the container (for + // example, setup of VF for testing a Product) + protected RestResponse createAtomicInstanceForServiceDuringSetup(ServiceReqDetails containerDetails, ResourceReqDetails compInstOriginDetails, User modifier) throws Exception { + return createComponentInstance(containerDetails, compInstOriginDetails, modifier, ComponentTypeEnum.SERVICE, false); + } + + // Setup of lower components - Doesn't affect req/cap of the container (for + // example, setup of VF for testing a Product) + protected RestResponse createVFInstanceDuringSetup(ServiceReqDetails containerDetails, ResourceReqDetails compInstOriginDetails, User modifier) throws Exception { + return createComponentInstance(containerDetails, compInstOriginDetails, modifier, ComponentTypeEnum.SERVICE, false); + } + + // Setup of lower components - Doesn't affect req/cap of the container (for + // example, setup of VF for testing a Product) + protected RestResponse createServiceInstanceDuringSetup(ProductReqDetails containerDetails, ServiceReqDetails compInstOriginDetails, User modifier) throws Exception { + return createComponentInstance(containerDetails, compInstOriginDetails, modifier, ComponentTypeEnum.PRODUCT, false); + } + + // Setup of lower components - Doesn't affect req/cap of the container (for + // example, setup of VF for testing a Product) + protected RestResponse deleteAtomicInstanceForVFDuringSetup(String compInstUniqueId, ResourceReqDetails containerDetails, User modifier) throws IOException, Exception { + return deleteComponentInstance(compInstUniqueId, containerDetails, modifier, ComponentTypeEnum.RESOURCE, false); + } + + // Setup of lower components - Doesn't affect req/cap of the container (for + // example, setup of VF for testing a Product) + protected RestResponse deleteAtomicInstanceForServiceDuringSetup(String compInstUniqueId, ServiceReqDetails containerDetails, User modifier) throws IOException, Exception { + return deleteComponentInstance(compInstUniqueId, containerDetails, modifier, ComponentTypeEnum.SERVICE, false); + } + + // Setup of lower components - Doesn't affect req/cap of the container (for + // example, setup of VF for testing a Product) + protected RestResponse deleteVFInstanceDuringSetup(String compInstUniqueId, ServiceReqDetails containerDetails, User modifier) throws IOException, Exception { + return deleteComponentInstance(compInstUniqueId, containerDetails, modifier, ComponentTypeEnum.SERVICE, false); + + } + + // Setup of lower components - Doesn't affect req/cap of the container (for + // example, setup of VF for testing a Product) + protected RestResponse deleteServiceInstanceDuringSetup(String compInstUniqueId, ProductReqDetails containerDetails, User modifier) throws IOException, Exception { + return deleteComponentInstance(compInstUniqueId, containerDetails, modifier, ComponentTypeEnum.PRODUCT, false); + } + + protected Component getComponentAndValidateRIs(ComponentReqDetails componentDetails, int numberOfRIs, int numberOfRelations) throws IOException, Exception { + + RestResponse getResponse = null; + Component component = null; + if (componentDetails instanceof ResourceReqDetails) { + getResponse = ResourceRestUtils.getResource(sdncAdminDetails, componentDetails.getUniqueId()); + component = ResponseParser.parseToObjectUsingMapper(getResponse.getResponse(), Resource.class); + } else if (componentDetails instanceof ServiceReqDetails) { + getResponse = ServiceRestUtils.getService((ServiceReqDetails) componentDetails, sdncAdminDetails); + component = ResponseParser.parseToObjectUsingMapper(getResponse.getResponse(), Service.class); + } else if (componentDetails instanceof ProductReqDetails) { + getResponse = ProductRestUtils.getProduct(componentDetails.getUniqueId(), sdncAdminDetails.getUserId()); + component = ResponseParser.parseToObjectUsingMapper(getResponse.getResponse(), Product.class); + } else { + Assert.fail("Unsupported type of componentDetails - " + componentDetails.getClass().getSimpleName()); + } + ResourceRestUtils.checkSuccess(getResponse); + int numberOfActualRIs = component.getComponentInstances() != null ? component.getComponentInstances().size() : 0; + int numberOfActualRelations = component.getComponentInstancesRelations() != null ? component.getComponentInstancesRelations().size() : 0; + assertEquals("Check number of RIs meet the expected number", numberOfRIs, numberOfActualRIs); + assertEquals("Check number of RI relations meet the expected number", numberOfRelations, numberOfActualRelations); + verifyReqCap(component); + + return component; + } + + protected void getComponentAndValidateRIsAfterChangeLifecycleState(String oldComponentUniqueIdToReplace, ComponentReqDetails componentDetails, int numOfRIs, int numOfRelations) throws IOException, Exception { + updateExpectedReqCapAfterChangeLifecycleState(oldComponentUniqueIdToReplace, componentDetails.getUniqueId()); + getComponentAndValidateRIs(componentDetails, numOfRIs, numOfRelations); + } + + private RestResponse createComponentInstance(ComponentReqDetails containerDetails, ComponentReqDetails compInstOriginDetails, User modifier, ComponentTypeEnum containerComponentTypeEnum, boolean isHighestLevel) throws IOException, Exception { + ComponentInstanceReqDetails resourceInstanceReqDetails = ElementFactory.getComponentResourceInstance(compInstOriginDetails); + RestResponse createResourceInstanceResponse = ComponentInstanceRestUtils.createComponentInstance(resourceInstanceReqDetails, modifier, containerDetails.getUniqueId(), containerComponentTypeEnum); + if (createResourceInstanceResponse.getErrorCode().equals(BaseRestUtils.STATUS_CODE_CREATED) && isHighestLevel) { + // Add RI Capabilities and Requirements to expected MAP --> + // expectedVfCapabilities and expectedVfRequirements + ComponentInstance componentInstance = ResponseParser.parseToObjectUsingMapper(createResourceInstanceResponse.getResponse(), ComponentInstance.class); + addCompInstReqCapToExpected(componentInstance, containerComponentTypeEnum); + } + return createResourceInstanceResponse; + } + + private RestResponse deleteComponentInstance(String compInstUniqueId, ComponentReqDetails containerDetails, User modifier, ComponentTypeEnum componentTypeEnum, boolean isHighestLevel) throws Exception { + RestResponse deleteResourceInstanceResponse = ComponentInstanceRestUtils.deleteComponentInstance(modifier, containerDetails.getUniqueId(), compInstUniqueId, componentTypeEnum); + if (deleteResourceInstanceResponse.getErrorCode().equals(BaseRestUtils.STATUS_CODE_DELETE) && isHighestLevel) { + deleteCompInstReqCapFromExpected(compInstUniqueId); + } + return deleteResourceInstanceResponse; + } + + // Create Atomic resource ( VFC/CP/VL) + protected void createAtomicResource(ResourceReqDetails resourceDetails) throws Exception { + RestResponse createResourceResponse = ResourceRestUtils.createResource(resourceDetails, sdncDesignerDetails); + ResourceRestUtils.checkCreateResponse(createResourceResponse); + + } + + protected void createVF(ResourceReqDetails resourceDetails) throws Exception { + createVF(resourceDetails, sdncDesignerDetails); + + } + + protected void createVF(ResourceReqDetails resourceDetails, User sdncModifier) throws Exception { + RestResponse createVfResponse = ResourceRestUtils.createResource(resourceDetails, sdncModifier); + ResourceRestUtils.checkCreateResponse(createVfResponse); + } + + protected void createService(ServiceReqDetails serviceDetails) throws Exception { + createService(serviceDetails, sdncDesignerDetails); + } + + protected void createService(ServiceReqDetails serviceDetails, User sdncModifier) throws Exception { + RestResponse createServiceResponse = ServiceRestUtils.createService(serviceDetails, sdncModifier); + ResourceRestUtils.checkCreateResponse(createServiceResponse); + } + + protected void createProduct(ProductReqDetails productDetails) throws Exception { + createProduct(productDetails, sdncPmDetails1); + } + + protected void createProduct(ProductReqDetails productDetails, User sdncModifier) throws Exception { + RestResponse createProductResponse = ProductRestUtils.createProduct(productDetails, sdncModifier); + ResourceRestUtils.checkCreateResponse(createProductResponse); + } + + protected RestResponse associateComponentInstancesForService(RequirementCapabilityRelDef requirementDef, ComponentReqDetails containerDetails, User user) throws IOException { + + RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(requirementDef, user, containerDetails.getUniqueId(), ComponentTypeEnum.SERVICE); + ResourceRestUtils.checkSuccess(associateInstances); + deleteAssociatedFromExpected(requirementDef); + + return associateInstances; + } + + private void deleteAssociatedFromExpected(RequirementCapabilityRelDef requirementDef) { + // removing from requirements + RelationshipInfo relationship = requirementDef.getRelationships().get(0).getRelation(); + String type = relationship.getRelationship().getType(); + String fromId = requirementDef.getFromNode(); + List<RequirementDefinition> reqList = expectedContainerRequirements.get(type); + List<CapabilityDefinition> capList = expectedContainerCapabilities.get(type); + RequirementDefinition toDelete = null; + if (reqList != null) { + for (RequirementDefinition reqDef : reqList) { + if (reqDef.getOwnerId().equals(fromId)) { + toDelete = reqDef; + } + } + if (toDelete != null) { + reqList.remove(toDelete); + if (reqList.isEmpty()) { + expectedContainerRequirements.remove(type); + } + String ownerId = toDelete.getOwnerId(); + Map<String, List<RequirementDefinition>> map = removedRequirements.get(ownerId); + if (map == null) { + map = new HashMap<>(); + removedRequirements.put(ownerId, map); + } + List<RequirementDefinition> list = map.get(type); + if (list == null) { + list = new ArrayList<>(); + map.put(type, list); + } + list.add(toDelete); + } + } + + for (CapabilityDefinition capabilityDefinition : capList) { + if (capabilityDefinition.getType().equals(type)) { + int minOccurrences = Integer.parseInt(capabilityDefinition.getMinOccurrences()) - 1; + if (minOccurrences < 0) + minOccurrences = 0; + String minOccurrencesString = Integer.toString(minOccurrences); + capabilityDefinition.setMinOccurrences(minOccurrencesString); + if (!capabilityDefinition.getMaxOccurrences().equals("UNBOUNDED")) { + int maxOccurrences = Integer.parseInt(capabilityDefinition.getMaxOccurrences()) - 1; + if (maxOccurrences < 0) + maxOccurrences = 0; + String maxOccurrencesString = Integer.toString(maxOccurrences); + capabilityDefinition.setMaxOccurrences(maxOccurrencesString); + } + } + } + expectedContainerCapabilities.put(type, capList); + } + + protected void dissociateComponentInstancesForService(RequirementCapabilityRelDef requirementDef, ComponentReqDetails containerDetails, User user) throws IOException { + + RestResponse dissociateInstances = ComponentInstanceRestUtils.dissociateInstances(requirementDef, user, containerDetails.getUniqueId(), ComponentTypeEnum.SERVICE); + ResourceRestUtils.checkSuccess(dissociateInstances); + addDissociatedToExpected(requirementDef); + } + + protected void fulfillCpRequirement(ComponentReqDetails component, String cpCompInstId, String cpReqFulfillerCompInstId, String cpReqFulfillerOwnerId, User user, ComponentTypeEnum containerCompType) throws IOException { + // Fulfilling cp's "binding" requirement - US626240 + String requirementName = "binding"; + String capType = "tosca.capabilities.network.Bindable"; + RestResponse getResourceResponse = ComponentRestUtils.getComponentRequirmentsCapabilities(user, component); + ResourceRestUtils.checkSuccess(getResourceResponse); + CapReqDef capReqDef = ResponseParser.parseToObject(getResourceResponse.getResponse(), CapReqDef.class); + List<CapabilityDefinition> capList = capReqDef.getCapabilities().get(capType); + List<RequirementDefinition> reqList = capReqDef.getRequirements().get(capType); + RequirementCapabilityRelDef reqCapRelation = ElementFactory.getReqCapRelation(cpCompInstId, cpReqFulfillerCompInstId, cpCompInstId, cpReqFulfillerOwnerId, capType, requirementName, capList, reqList); + RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(reqCapRelation, user, component.getUniqueId(), containerCompType); + ResourceRestUtils.checkSuccess(associateInstances); + } + + protected void consumeVlCapability(ComponentReqDetails component, String vlCapConsumerCompInstId, String vlCompInstId, String vlCapConsumerOwnerId, User user, ComponentTypeEnum containerCompType) throws IOException { + // Consuming vl's "link" capability - US626240 + String requirementName = "link"; + String capType = "tosca.capabilities.network.Linkable"; + RestResponse getResourceResponse = ComponentRestUtils.getComponentRequirmentsCapabilities(user, component); + ResourceRestUtils.checkSuccess(getResourceResponse); + CapReqDef capReqDef = ResponseParser.parseToObject(getResourceResponse.getResponse(), CapReqDef.class); + List<CapabilityDefinition> capList = capReqDef.getCapabilities().get(capType); + List<RequirementDefinition> reqList = capReqDef.getRequirements().get(capType); + RequirementCapabilityRelDef reqCapRelation = ElementFactory.getReqCapRelation(vlCapConsumerCompInstId, vlCompInstId, vlCapConsumerOwnerId, vlCompInstId, capType, requirementName, capList, reqList); + RestResponse associateInstances = ComponentInstanceRestUtils.associateInstances(reqCapRelation, user, component.getUniqueId(), containerCompType); + ResourceRestUtils.checkSuccess(associateInstances); + } + + private void addDissociatedToExpected(RequirementCapabilityRelDef requirementDef) { + // adding to requirements + RelationshipInfo relationship = requirementDef.getRelationships().get(0).getRelation(); + String type = relationship.getRelationship().getType(); + String fromId = requirementDef.getFromNode(); + Map<String, List<RequirementDefinition>> map = removedRequirements.get(fromId); + if (map != null) { + List<RequirementDefinition> list = map.get(type); + if (list != null && !list.isEmpty()) { + List<RequirementDefinition> reqList = expectedContainerRequirements.get(type); + if (reqList == null) { + reqList = new ArrayList<>(); + expectedContainerRequirements.put(type, reqList); + } + reqList.add(list.remove(0)); + } + } + + List<CapabilityDefinition> capList = expectedContainerCapabilities.get(type); + + for (CapabilityDefinition capabilityDefinition : capList) { + if (capabilityDefinition.getType().equals(type)) { + int minOccurrences = Integer.parseInt(capabilityDefinition.getMinOccurrences()) + 1; + String minOccurrencesString = Integer.toString(minOccurrences); + capabilityDefinition.setMinOccurrences(minOccurrencesString); + if (!capabilityDefinition.getMaxOccurrences().equals("UNBOUNDED")) { + int maxOccurrences = Integer.parseInt(capabilityDefinition.getMaxOccurrences()) + 1; + String maxOccurrencesString = Integer.toString(maxOccurrences); + capabilityDefinition.setMaxOccurrences(maxOccurrencesString); + } + } + } + expectedContainerCapabilities.put(type, capList); + } +} diff --git a/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api/ExtentManager.java b/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api/ExtentManager.java new file mode 100644 index 0000000000..194966d699 --- /dev/null +++ b/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api/ExtentManager.java @@ -0,0 +1,161 @@ +/*- + * ============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.ci.tests.api; + +import com.aventstack.extentreports.ExtentReports; +import com.aventstack.extentreports.reporter.ExtentHtmlReporter; +import com.aventstack.extentreports.reporter.ExtentXReporter; +import com.aventstack.extentreports.reporter.configuration.Protocol; +import com.aventstack.extentreports.reporter.configuration.Theme; +import org.openecomp.sdc.ci.tests.config.Config; +import org.openecomp.sdc.ci.tests.utils.Utils; +import org.openecomp.sdc.ci.tests.utils.general.FileHandling; +import org.openecomp.sdc.ci.tests.utils.rest.AutomationUtils; +import org.testng.ITestContext; + +import java.io.File; + +public class ExtentManager { + + private static final String VERSIONS_INFO_FILE_NAME = "versions.info"; + private static ExtentReports extent; + private static ExtentHtmlReporter htmlReporter; + private static ExtentXReporter extentxReporter; + + public enum suiteNameXml { + + TESTNG_FAILED_XML_NAME("testng-failed.xml"); + + suiteNameXml(String value) { + this.value = value; + } + + private String value; + + public String getValue() { + return value; + } + + } + + public synchronized static ExtentReports setReporter(String filePath, String htmlFile, Boolean isAppend) throws Exception { + String dbIp = Utils.getConfig().getReportDBhost(); + int dbPort = Utils.getConfig().getReportDBport(); + + if (extent == null) { + extentxReporter = new ExtentXReporter(dbIp, dbPort); + extent = new ExtentReports(); + initAndSetExtentHtmlReporter(filePath, htmlFile, isAppend); + + if(extentxReporter.config().getReportObjectId() != null){ + setExtentXReporter(isAppend); + }else{ + extentxReporter.stop(); + } + } + return extent; + } + + public synchronized static void setExtentXReporter(Boolean isAppend){ + extentxReporter.setAppendExisting(isAppend); + extent.attachReporter(extentxReporter); + } + + public synchronized static void initAndSetExtentHtmlReporter(String filePath, String htmlFile, Boolean isAppend) throws Exception{ + htmlReporter = new ExtentHtmlReporter(filePath + htmlFile); + setConfiguration(htmlReporter); + htmlReporter.setAppendExisting(isAppend); + extent.attachReporter(htmlReporter); + } + + public synchronized static ExtentReports getReporter() { + return extent; + } + + public static void initReporter(String filepath, String htmlFile, ITestContext context) throws Exception { + + String onboardVersion = AutomationUtils.getOnboardVersion(); + String osVersion = AutomationUtils.getOSVersion(); + Config config = Utils.getConfig(); + String envData = config.getUrl(); + String suiteName = getSuiteName(context); + + if(suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())){ + if (config.getUseBrowserMobProxy()) + setTrafficCaptue(config); + + setReporter(filepath, htmlFile, true); + String suiteNameFromVersionInfoFile = FileHandling.getKeyByValueFromPropertyFormatFile(filepath + VERSIONS_INFO_FILE_NAME, "suiteName"); + reporterDataDefinition(onboardVersion, osVersion, envData, suiteNameFromVersionInfoFile); + }else{ + FileHandling.deleteDirectory(ComponentBaseTest.getReportFolder()); + FileHandling.createDirectory(filepath); + setReporter(filepath, htmlFile, false); + reporterDataDefinition(onboardVersion, osVersion, envData, suiteName); + AutomationUtils.createVersionsInfoFile(filepath + VERSIONS_INFO_FILE_NAME, onboardVersion, osVersion, envData, suiteName); + } + + } + + public static void reporterDataDefinition(String onboardVersion, String osVersion, String envData, String suiteNameFromVersionInfoFile) throws Exception { + extent.setSystemInfo("Onboard Version", onboardVersion); + extent.setSystemInfo("OS Version", osVersion); +// extent.setSystemInfo("Host Name Address", RestCDUtils.getExecutionHostAddress()); + extent.setSystemInfo("ExecutedOn", envData); + extent.setSystemInfo("SuiteName", suiteNameFromVersionInfoFile); + } + + public static String getSuiteName(ITestContext context) { + String suitePath = context.getSuite().getXmlSuite().getFileName(); + if(suitePath != null){ + File file = new File(suitePath); + String suiteName = file.getName(); + return suiteName; + } + return null; + } + + public synchronized static ExtentHtmlReporter setConfiguration(ExtentHtmlReporter htmlReporter) throws Exception { + + htmlReporter.config().setTheme(Theme.STANDARD); + htmlReporter.config().setEncoding("UTF-8"); + htmlReporter.config().setProtocol(Protocol.HTTPS); + htmlReporter.config().setDocumentTitle("SDC Automation Report"); + htmlReporter.config().setChartVisibilityOnOpen(true); +// htmlReporter.config().setReportName(AutomationUtils.getATTVersion()); + htmlReporter.config().setReportName("SDC Automation Report"); + htmlReporter.config().setChartVisibilityOnOpen(false); +// htmlReporter.config().setJS(icon); + return htmlReporter; + } + + public static void closeReporter(){ + extent.flush(); + } + + public static void setTrafficCaptue(Config config) { + boolean mobProxyStatus = config.getUseBrowserMobProxy(); + if (mobProxyStatus){ + config.setCaptureTraffic(true);; + } + } +} + diff --git a/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api/ExtentTestActions.java b/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api/ExtentTestActions.java new file mode 100644 index 0000000000..5cb5a5b442 --- /dev/null +++ b/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api/ExtentTestActions.java @@ -0,0 +1,112 @@ +/*- + * ============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.ci.tests.api; + +import com.aventstack.extentreports.ExtentTest; +import com.aventstack.extentreports.Status; +import com.aventstack.extentreports.markuputils.ExtentColor; +import com.aventstack.extentreports.markuputils.Markup; +import com.aventstack.extentreports.markuputils.MarkupHelper; + +import java.io.File; + + +public class ExtentTestActions { + + public static SomeInterface testManager = new ExtentTestManager(); + + public static void log(Status logStatus, Markup mark){ + ExtentTest test = testManager.getTest(); + test.log(logStatus, mark); + } + + public static void log(Status logStatus, String message){ + ExtentTest test = testManager.getTest(); + test.log(logStatus, message); + } + + public static void log(Status logStatus, String message, String duration){ + log(logStatus, message + addDurationTag(duration)); + } + + public static void log(Status logStatus, Throwable throwabel){ + ExtentTest test = testManager.getTest(); + test.log(logStatus, throwabel); + } + + public static void addTag(Status logStatus, String message){ + Markup m = null; + switch(logStatus){ + case PASS: + m = MarkupHelper.createLabel(message, ExtentColor.GREEN); + break; + case FAIL: + m = MarkupHelper.createLabel(message, ExtentColor.RED); + break; + case SKIP: + m = MarkupHelper.createLabel(message, ExtentColor.BLUE); + break; + case FATAL: + m = MarkupHelper.createLabel(message, ExtentColor.BROWN); + break; + default: + break; + } + + if (m != null){ + log(logStatus, m); + } + } + +// public static String addScreenshot(Status logStatus, String screenshotName, String message) throws IOException{ +// String imageFilePath = null; +// String uuid = UUID.randomUUID().toString(); +// String[] stringArray = uuid.split("-"); +// screenshotName = screenshotName + "-" + stringArray[stringArray.length - 1]; +// try { +// File imageFile = GeneralUIUtils.takeScreenshot(screenshotName, SetupCDTest.getScreenshotFolder()); +// imageFilePath = new File(SetupCDTest.getReportFolder()).toURI().relativize(imageFile.toURI()).getPath(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// +// ExtentTest test = ExtentTestManager.getTest(); +// test.log(logStatus, message, MediaEntityBuilder.createScreenCaptureFromPath(imageFilePath).build()); +// return imageFilePath; +// } + + private static String addDurationTag(String duration){ + return "<td width=\"80px\">" + duration + "</td>"; + } + + public static String addLinkTag(String fileName, String pathToFile){ + return String.format("<a download=\"%s\" href=\"%s\">HAR file</a>", fileName, pathToFile); + } + + public static void addFileToReportAsLink(File harFile, String pathToFileFromReportDirectory, String message) { + log(Status.INFO, message, addLinkTag(harFile.getName(), pathToFileFromReportDirectory)); + } + + + + + +} diff --git a/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api/ExtentTestManager.java b/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api/ExtentTestManager.java new file mode 100644 index 0000000000..810f6a6543 --- /dev/null +++ b/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api/ExtentTestManager.java @@ -0,0 +1,65 @@ +/*- + * ============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.ci.tests.api; + +import com.aventstack.extentreports.ExtentReports; +import com.aventstack.extentreports.ExtentTest; + +import java.util.HashMap; +public class ExtentTestManager implements SomeInterface{ + + private static HashMap<Long, ExtentTest> extentTestMap = new HashMap<Long, ExtentTest>(); + private static ExtentReports extent = ExtentManager.getReporter(); + + public ExtentTestManager(){ + } + + @Override + public synchronized ExtentTest getTest() { + return extentTestMap.get(Thread.currentThread().getId()); + } + + public static synchronized void endTest() { +// extent.endTest(extentTestMap.get(Thread.currentThread().getId())); + extent.flush(); + } + + public static synchronized ExtentTest startTest(String testName) { + return startTest(testName, ""); + } + + public static synchronized ExtentTest startTest(String testName, String desc) { + ExtentTest test = extent.createTest(testName, desc); + extentTestMap.put(Thread.currentThread().getId(), test); + + return test; + } + + public static synchronized <T> void assignCategory(Class<T> clazz){ + String[] parts = clazz.getName().split("\\."); + String lastOne1 = parts[parts.length-1]; + String lastOne2 = parts[parts.length-2]; + extentTestMap.get(Thread.currentThread().getId()).assignCategory(lastOne2 + "-" + lastOne1); + } + + +} + diff --git a/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api/SomeInterface.java b/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api/SomeInterface.java new file mode 100644 index 0000000000..ce679a9f87 --- /dev/null +++ b/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api/SomeInterface.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 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.ci.tests.api; + +import com.aventstack.extentreports.ExtentTest; + +public interface SomeInterface { + + abstract ExtentTest getTest(); + +} diff --git a/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api/Urls.java b/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api/Urls.java new file mode 100644 index 0000000000..956d9b1d8f --- /dev/null +++ b/integration-tests/src/test/java/org/openecomp/sdc/ci/tests/api/Urls.java @@ -0,0 +1,429 @@ +/*- + * ============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.ci.tests.api; + + +import org.openecomp.sdc.ci.tests.utils.Utils; + +public interface Urls { + + + final static String SDC_HTTP_METHOD = Utils.getConfigHandleException() == null ? "http" : Utils.getConfigHandleException().getSdcHttpMethod(); + final String AMDOCS_HTTP_METHOD = SDC_HTTP_METHOD; + + + final String UPLOAD_ZIP_URL = SDC_HTTP_METHOD + "://%s:%s/sdc1/rest/v1/catalog/resources"; + final String GET_IMAGE_DATA_FROM_ES = SDC_HTTP_METHOD + "://%s:%s/resources/imagedata/_search?q=resourceName:%s&pretty=true&size=1000"; + final String GET_SCRIPT_DATA_FROM_ES = SDC_HTTP_METHOD + "://%s:%s/resources/artifactdata/_search?q=resourceName:%s&pretty=true&size=1000"; + final String GET_ID_LIST_BY_INDEX_FROM_ES = SDC_HTTP_METHOD + "://%s:%s/%s/%s/_search?fields=_id&size=1000"; + + final String ES_URL = SDC_HTTP_METHOD + "://%s:%s"; + final String GET_SERVICE_CSAR_API1 = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/services/%s/%s"; + final String GET_SERVICE_CSAR_API2 = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/services/%s/%s/csar"; + + final String GET_SERVICE_CSAR_FE_PROXY_API1 = SDC_HTTP_METHOD + "://%s:%s/sdc1/portal/rest/services/%s/%s"; + final String GET_CSAR_USING_SIMULATOR = SDC_HTTP_METHOD + "://%s:%s/onboardingci/onbrest/onboarding-api/v1.0/vendor-software-products/packages/%s"; + final String COPY_CSAR_USING_SIMULATOR = SDC_HTTP_METHOD + "://%s:%s/onboardingci/onbrest/onboarding-api/v1.0/vendor-software-products/packages/%s/%s"; + + final String GET_HEALTH_CHECK_VIA_PROXY = SDC_HTTP_METHOD + "://%s:%s/sdc1/rest/healthCheck"; + + // Get back-end config http://172.20.43.132:8080/sdc2/rest/configmgr/get + final String GET_CONFIG_MANAGER = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/configmgr/get"; + + // Get latest version of all non-abstract resources + final String GET_RESOURCE_lATEST_VERSION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/latestversion/notabstract"; + + final String GET_SERVICE_lATEST_VERSION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/latestversion/notabstract"; + + // Get resource artifact list: + // http://172.20.43.124:8080/sdc2/rest/v1/catalog/resources/alien.nodes.Apache/2.0.0-SNAPSHOT/artifacts + final String GET_RESOURCE_ARTIFACTS_LIST = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s/artifacts"; + + // get resource artifact metadata (creation, MD5, etc): + // http://172.20.43.124:8080/sdc2/rest/v1/catalog/resources/alien.nodes.Apache/2.0.0-SNAPSHOT/artifacts/install_apache.sh/metadata + final String GET_RESOURCE_ARTIFACT_METADATA = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s/artifacts/%s/metadata"; + + // resource artifact payload: + // http://172.20.43.124:8080/sdc2/rest/v1/catalog/resources/alien.nodes.Apache/2.0.0-SNAPSHOT/artifacts/install_apache.sh + final String GET_RESOURCE_ARTIFACT_PAYLOAD = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s/artifacts/%s"; + + final String GET_RESOURCE_ARTIFACT_PAYLOAD_FE_PROXY = SDC_HTTP_METHOD + "://%s:%s/sdc1/portal/rest/v1/catalog/resources/%s/%s/artifacts/%s"; + + // Get service artifact list: + // http://172.20.43.124:8080/sdc2/rest/v1/catalog/services/alien.nodes.Apache/0.0.1/artifacts + final String GET_SERVICE_ARTIFACTS_LIST = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/%s/artifacts"; + + // get service artifact metadata (creation, MD5, etc): + // http://172.20.43.124:8080/sdc2/rest/v1/catalog/services/alien.nodes.Apache/0.0.1/artifacts/install_apache.sh/metadata + final String GET_SERVICE_METADATA = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/%s/artifacts/%s/metadata"; + + // service artifact payload: + // http://172.20.43.124:8080/sdc2/rest/v1/catalog/services/alien.nodes.Apache/0.0.1/artifacts/install_apache.sh + final String GET_SERVICE_ARTIFACT_PAYLOAD = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/%s/artifacts/%s"; + + final String GET_SEARCH_DATA_FROM_ES = SDC_HTTP_METHOD + "://%s:%s/%s"; + + // ****************************************************USER + // URLs******************************************************** + final String GET_USER = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/user/%s"; + + final String GET_USER_ROLE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/user/%s/role"; + + final String CREATE_USER = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/user"; + + final String UPDATE_USER = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/user/%s"; + + final String UPDATE_USER_ROLE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/user/%s/role"; + + String DELETE_USER = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/user/%s"; + + String GET_ALL_ADMIN_USERS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/user/admins"; + + final String AUTHORIZE_USER = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/user/authorize"; + + final String GET_ALL_TAGS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/tags"; + + final String AUTH_USER = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/user/authorize"; + + final String GET_ALL_NOT_ABSTRACT_RESOURCES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/certified/notabstract"; + + final String GET_ALL_ABSTRACT_RESOURCES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/certified/abstract"; + + final String QUERY_NEO4J = SDC_HTTP_METHOD + "://%s:%s/db/data/transaction"; + final String CHANGE_IN_NEO4J = SDC_HTTP_METHOD + "://%s:%s/db/data/transaction/commit"; + + final String GET_ALL_ADMINS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/user/admins"; + + final String GET_USERS_BY_ROLES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/user/users?roles=%s"; + + final String GET_ALL_USERS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/user/users?roles/"; + + // *****************************************ECOMP User + // URL's***************************************************** + final String ECOMP_PUSH_USER = SDC_HTTP_METHOD + "://%s:%s/api/v2/user"; + + final String ECOMP_EDIT_USER = SDC_HTTP_METHOD + "://%s:%s/api/v2/user/%s"; + + final String ECOMP_GET_USER = SDC_HTTP_METHOD + "://%s:%s/api/v2/user/%s"; + + final String ECOMP_GET_ALL_USERS = SDC_HTTP_METHOD + "://%s:%s/api/v2/users"; + + final String ECOMP_GET_ALL_AVAILABLE_ROLES = SDC_HTTP_METHOD + "://%s:%s/api/v2/roles"; + + final String ECOMP_PUSH_USER_ROLES = SDC_HTTP_METHOD + "://%s:%s/api/v2/user/%s/roles"; + + final String ECOMP_GET_USER_ROLES = SDC_HTTP_METHOD + "://%s:%s/api/v2/user/%s/roles"; + + // *****************************************Elements************************************************************* + final String GET_TAGS_LIST = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/tags"; + + final String GET_PROPERTY_SCOPES_LIST = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/propertyScopes"; + + final String GET_CONFIGURATION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/configuration/ui"; + + final String GET_ALL_ARTIFACTS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/artifactTypes"; + + final String GET_FOLLWED_LIST = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/followed"; + + final String GET_CATALOG_DATA = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/screen/?excludeTypes=VFCMT&excludeTypes=Configuration"; + + // *****************************************Resources + // ********************************************************************** + final String GET_LIST_CERTIFIED_RESOURCE_TEMPLATES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/resoourceTemplates"; + + final String CREATE_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources"; + final String UPDATE_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s"; + + final String IMPORT_RESOURCE_NORMATIVE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/upload/multipart"; + + final String IMPORT_USER_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/upload/user-resource"; + + final String IMPORT_CAPABILITY_TYPE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/uploadType/capability"; + final String IMPORT_CATEGORIES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/uploadType/categories"; + final String IMPORT_GROUP_TYPE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/uploadType/grouptypes"; + + // last %s is resourceId, resourceId = resourceName.resourceVersion + final String GET_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s"; + final String GET_RESOURCE_BY_NAME_AND_VERSION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/resourceName/%s/resourceVersion/%s"; + final String GET_RESOURCE_BY_CSAR_UUID = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/csar/%s"; + final String GET_COMPONENT_REQUIRMENTS_CAPABILITIES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/requirmentsCapabilities"; + + final String DELETE_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s"; + final String DELETE_RESOURCE_BY_NAME_AND_VERSION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s"; + final String DELETE_SERVICE_BY_NAME_AND_VERSION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/%s"; + + final String DELETE_MARKED_RESOURCES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/inactiveComponents/resource"; + final String DELETE_MARKED_SERVICES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/inactiveComponents/service"; + + final String GET_FOLLOWED_RESOURCES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/followed/resources/%s"; + final String CHANGE_RESOURCE_LIFECYCLE_STATE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/lifecycleState/%s"; + final String CHANGE_SERVICE_LIFECYCLE_STATE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/lifecycleState/%s"; + final String CHANGE_PRODUCT_LIFECYCLE_STATE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/products/%s/lifecycleState/%s"; + final String CHANGE_COMPONENT_LIFECYCLE_STATE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/lifecycleState/%s"; + + final String CREATE_PROPERTY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/properties"; + String CREATE_SERVICE_PROPERTY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/properties"; + final String DECLARE_PROPERTIES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/create/inputs"; + final String UPDATE_INPUT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/update/inputs"; + + final String UPDATE_RESOURCE_METADATA = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/metadata"; + + // ***********************************External API's + // (AssetData)**************************************** + + final String DELETE_EXTRNAL_API_DELETE_ARTIFACT_OF_ASSET = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/%s/%s/artifacts/%s"; + final String DELETE_EXTRNAL_API_DELETE_ARTIFACT_OF_COMPONENTINSTANCE_ON_ASSET = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/%s/%s/resourceInstances/%s/artifacts/%s"; + + final String POST_EXTERNAL_API_UPDATE_ARTIFACT_OF_ASSET = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/%s/%s/artifacts/%s"; + final String POST_EXTERNAL_API_UPDATE_ARTIFACT_OF_COMPONENTINSTANCE_ON_ASSET = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/%s/%s/resourceInstances/%s/artifacts/%s"; + + final String POST_EXTERNAL_API_UPLOAD_ARTIFACT_OF_ASSET = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/%s/%s/artifacts"; + final String POST_EXTERNAL_API_UPLOAD_ARTIFACT_OF_COMPONENTINSTANCE_ON_ASSET = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/%s/%s/resourceInstances/%s/artifacts"; + + final String GET_DOWNLOAD_RESOURCE_ARTIFACT_OF_ASSET = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/resources/%s/artifacts/%s"; + final String GET_DOWNLOAD_SERVICE_ARTIFACT_OF_ASSET = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/services/%s/artifacts/%s"; + + final String GET_DOWNLOAD_RESOURCE_ARTIFACT_OF_COMPONENT_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/resources/%s/resourceInstances/%s/artifacts/%s"; + final String GET_DOWNLOAD_SERVICE_ARTIFACT_OF_COMPONENT_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/services/%s/resourceInstances/%s/artifacts/%s"; + + final String GET_ASSET_LIST = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/%s"; + final String GET_FILTERED_ASSET_LIST = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/%s?%s"; + final String GET_TOSCA_MODEL = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/%s/%s/toscaModel"; + // https://{serverRoot}/sdc/v1/catalog/{assetType}/{uuid}/metadata, where + // assetType in {resources, services} + final String GET_ASSET_METADATA = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/%s/%s/metadata"; + final String POST_AUTHORIZATION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/consumers"; + final String GET_DOWNLOAD_SERVICE_RI_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/services/%s/resourceInstances/%s/artifacts/%s"; + final String GET_DOWNLOAD_SERVICE_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/services/%s/artifacts/%s"; + + final String POST_EXTERNAL_API_CREATE_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/resources"; + + // Change LifeCycle of Resource + // https://{serverRoot}:{port}/sdc/v1/catalog/{resources|services}/{uuid}/lifecycleState/{lifecycle state} + final String POST_EXTERNAL_API_CHANGE_LIFE_CYCLE_OF_ASSET = SDC_HTTP_METHOD + "://%s:%s/sdc/v1/catalog/%s/%s/lifecycleState/%s"; + + + // ***************************************************************************************************** + + final String ADD_ARTIFACT_TO_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/artifacts"; + final String UPDATE_OR_DELETE_ARTIFACT_OF_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/artifacts/%s"; + final String ADD_ARTIFACT_TO_SERVICE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/artifacts"; + final String UPDATE_OR_DELETE_ARTIFACT_OF_SERVICE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/artifacts/%s"; + + final String UPLOAD_DELETE_ARTIFACT_OF_COMPONENT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/artifacts"; + final String UPDATE_ARTIFACT_OF_COMPONENT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/artifacts/%s"; + final String UPLOAD_HEAT_ENV_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/%s/artifacts/%s"; + // ***************************************************************************************************** + final String UPLOAD_ARTIFACT_BY_INTERFACE_TO_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s/%s/artifacts/"; + final String UPDATE_OR_DELETE_ARTIFACT_BY_INTERFACE_TO_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s/%s/artifacts/%s"; + + final String UPLOAD_ARTIFACT_BY_INTERFACE_TO_COMPONENT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s/%s/artifacts/"; + final String UPDATE_OR_DELETE_ARTIFACT_BY_INTERFACE_TO_COMPONENT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/%s/%s/artifacts/%s"; + + // ***************************************************************************************************** + // "/sdc2/v1/services/<serviceName>/<0.1>/artifacts/aaa.hh" + final String DISTRIB_DOWNLOAD_SERVICE_ARTIFACT = "/sdc2/rest/v1/catalog/services/%s/%s/artifacts/%s"; + // "/sdc2/v1/services/<serviceName>/<0.1>/resources/{resourceName}/{resourceVersion}/artifacts/<opeartion_name>_aaa.hh" + final String DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT = "/sdc2/rest/v1/catalog/services/%s/%s/resources/%s/%s/artifacts/%s"; + final String DISTRIB_DOWNLOAD_SERVICE_ARTIFACT_RELATIVE_URL = "/sdc/v1/catalog/services/%s/%s/artifacts/%s"; + final String DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL = "/sdc/v1/catalog/services/%s/%s/resources/%s/%s/artifacts/%s"; + final String DOWNLOAD_SERVICE_ARTIFACT_FULL_URL = SDC_HTTP_METHOD + "://%s:%s%s"; + final String DOWNLOAD_RESOURCE_ARTIFACT_FULL_URL = SDC_HTTP_METHOD + "://%s:%s%s"; + // ********************************************************************************** + final String UI_DOWNLOAD_RESOURCE_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/artifacts/%s"; + final String UI_DOWNLOAD_SERVICE_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/artifacts/%s"; + + // ********************************************************************************************************** + final String UPDATE_PROPERTY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/properties/%s"; + + final String DELETE_PROPERTY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/properties/%s"; + + final String GET_PROPERTY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/properties/%s"; + + // ***************************************************************************************************** + + final String VALIDATE_RESOURCE_NAME = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/validate-name/%s"; + + final String CREATE_SERVICE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services"; + final String DELETE_SERVICE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s"; + final String GET_SERVICE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s"; + final String GET_SERVICE_BY_NAME_AND_VERSION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/serviceName/%s/serviceVersion/%s"; + + final String GET_SERVICES_REQUIRMENTS_CAPABILITIES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/requirmentsCapabilities/services/%s"; + final String GET_INSTANCE_REQUIRMENTS_CAPABILITIES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/filteredDataByParams?include=requirements&include=capabilities"; + + final String CREATE_COMPONENT_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance"; + final String DELETE_COMPONENT_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/%s"; + final String UPDATE_COMPONENT_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/%s"; + final String GET_COMPONENT_INSTANCES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/componentInstances"; + // Tal New API + final String UPDATE_MULTIPLE_COMPONENT_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/multipleComponentInstance"; + + final String CHANGE__RESOURCE_INSTANCE_VERSION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/%s/changeVersion"; + + final String CREATE_AND_ASSOCIATE_RESOURCE_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/resourceInstance/createAndAssociate"; + final String ASSOCIATE__RESOURCE_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/associate"; + final String DISSOCIATE__RESOURCE_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/dissociate"; + + final String DISTRIBUTION_INIT = SDC_HTTP_METHOD + "://%s:%s/init"; + final String DISTRIBUTION_INIT_RESET = SDC_HTTP_METHOD + "://%s:%s/initReset"; + final String APPROVE_DISTRIBUTION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/distribution-state/approve"; + final String REJECT_DISTRIBUTION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/distribution-state/reject"; + final String DISTRIBUTION_DOWNLOAD_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/download"; + final String ACTIVATE_DISTRIBUTION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/distribution/%s/activate"; + final String DISTRIBUTION_SERVICE_LIST = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/distribution"; + final String DISTRIBUTION_SERVICE_MONITOR = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/distribution/%s"; + + final String DEPLOY_SERVICE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/distribution/%s/markDeployed"; + final String UPDATE_SERVICE_METADATA = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/metadata"; + + // Andrey changed name from ADD_PROPERTY_TO_RESOURCE_INSTANCE to + // UPDATE_PROPERTY_TO_RESOURCE_INSTANCE + final String UPDATE_PROPERTY_TO_RESOURCE_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/%s/property"; + final String DELETE_PROPERTY_FROM_RESOURCE_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/resourceInstance/%s/property/%s"; + final String UPDATE_RESOURCE_INSTANCE_HEAT_ENV_PARAMS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/resourceInstance/%s/artifacts/%s/heatParams"; + + // Actions on artifact in resource instance + final String ADD_RESOURCE_INSTANCE_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/resourceInstance/%s/artifacts"; + final String UPDATE_RESOURCE_INSTANCE_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/resourceInstance/%s/artifacts/%s"; + final String DELETE_RESOURCE_INSTANCE_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/resourceInstance/%s/artifacts/%s"; + + // Attributes On Resource instance + public static final String UPDATE_ATTRIBUTE_ON_RESOURCE_INSTANCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/%s/attribute"; + + // ("/services/{serviceId}/resourceInstances/{resourceInstanceId}/artifacts/{artifactId}") + final String DOWNLOAD_COMPONENT_INSTANCE_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/resourceInstances/%s/artifacts/%s"; + + // -------------------------------service api + // artifact----------------------------------------------------- + final String UPDATE_DELETE_SERVICE_API_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/artifacts/api/%s"; + + final String CREATE_ADDITIONAL_INFORMATION_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/additionalinfo"; + final String UPDATE_ADDITIONAL_INFORMATION_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/additionalinfo/%s"; + final String DELETE_ADDITIONAL_INFORMATION_RESOURCE = UPDATE_ADDITIONAL_INFORMATION_RESOURCE; + final String GET_ADDITIONAL_INFORMATION_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/additionalinfo/%s"; + final String GET_ALL_ADDITIONAL_INFORMATION_RESOURCE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/additionalinfo"; + + final String CREATE_ADDITIONAL_INFORMATION_SERVICE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/additionalinfo"; + final String UPDATE_ADDITIONAL_INFORMATION_SERVICE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/additionalinfo/%s"; + final String DELETE_ADDITIONAL_INFORMATION_SERVICE = UPDATE_ADDITIONAL_INFORMATION_SERVICE; + final String GET_ADDITIONAL_INFORMATION_SERVICE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/additionalinfo/%s"; + final String GET_ALL_ADDITIONAL_INFORMATION_SERVICE = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/additionalinfo"; + + final String GET_COMPONENT_AUDIT_RECORDS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/audit-records/%s/%s"; + + // CONSUMER + final String CREATE_CONSUMER = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/consumers"; + final String GET_CONSUMER = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/consumers/%s"; + final String DELETE_CONSUMER = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/consumers/%s"; + + // Categories + final String CREATE_CATEGORY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/category/%s"; + final String GET_ALL_CATEGORIES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/categories/%s"; + final String GET_ALL_CATEGORIES_FE = SDC_HTTP_METHOD + "://%s:%s/sdc1/feProxy/rest/v1/categories/%s"; + final String DELETE_CATEGORY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/category/%s/%s"; + final String CREATE_SUB_CATEGORY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/category/%s/%s/subCategory"; + final String DELETE_SUB_CATEGORY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/category/%s/%s/subCategory/%s"; + final String CREATE_GROUPING = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/category/%s/%s/subCategory/%s/grouping"; + final String DELETE_GROUPING = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/category/%s/%s/subCategory/%s/grouping/%s"; + + // product + final String CREATE_PRODUCT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/products"; + final String DELETE_PRODUCT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/products/%s"; + // last %s is resourceId, productId + final String GET_PRODUCT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/products/%s"; + final String UPDATE_PRODUCT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/products/%s/metadata"; + final String GET_PRODUCT_BY_NAME_AND_VERSION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/products/productName/%s/productVersion/%s"; + + // groups + final String GET_GROUP_BY_ID = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/groups/%s"; + //module property + final String RESOURCE_GROUP_PROPERTY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/groups/%s/properties"; + // modules + final String GET_MODULE_BY_ID = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/groups/%s"; + + // inputs + final String UPDATE_INPUTS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/update/inputs"; + final String ADD_INPUTS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/create/inputs"; //{componentType}/{componentId}/create/inputs + final String DELETE_INPUT_BY_ID = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/delete/%s/input"; //{componentType}/{componentId}/delete/{inputId}/input + final String GET_COMPONENT_INPUTS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/inputs"; //services/{componentId}/inputs + final String GET_COMPONENT_INSTANCE_INPUTS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/componentInstances/%s/%s/inputs"; //{componentType}/{componentId}/componentInstances/{instanceId}/{originComonentUid}/inputs + final String GET_INPUTS_FOR_COMPONENT_INPUT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/resources/%s/groups/%s"; //{componentType}/{componentId}/inputs/{inputId}/inputs + + // check version + final String ONBOARD_VERSION = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/docs/build-info.json"; + final String OS_VERSION = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/version"; + +// amdocs APIs + final String GET_VENDOR_SOFTWARE_PRODUCT = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/packages/%s"; + final String UPLOAD_SNMP_POLL_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s/components/%s/uploads/types/SNMP_POLL"; + final String UPLOAD_SNMP_TRAP_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s/components/%s/uploads/types/SNMP_TRAP"; + final String UPLOAD_VES_EVENTS_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s/components/%s/uploads/types/VES_EVENTS"; + final String UPLOAD_AMDOCS_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s/components/%s/uploads/types/%s"; + final String DELETE_AMDOCS_ARTIFACT_BY_TYPE = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s/components/%s/monitors/%s"; + final String GET_VSP_COMPONENTS = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s/components"; + final String CREATE_VENDOR_LISENCE_MODELS = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-license-models"; + final String CREATE_VENDOR_LISENCE_AGREEMENT = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-license-models/%s/versions/%s/license-agreements"; + final String CREATE_VENDOR_LISENCE_FEATURE_GROUPS = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-license-models/%s/versions/%s/feature-groups"; + final String CREATE_VENDOR_LISENCE_ENTITLEMENT_POOL = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-license-models/%s/versions/%s/entitlement-pools"; + final String CREATE_VENDOR_LISENCE_KEY_GROUPS = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-license-models/%s/versions/%s/license-key-groups"; + final String CREATE_METHOD = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/%s/%s/versions/%s/"; + final String CREATE_VENDOR_SOFTWARE_PRODUCT = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products"; + final String VALIDATE_UPLOAD = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s/orchestration-template-candidate/process"; + final String UPLOAD_HEAT_PACKAGE = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s/orchestration-template-candidate"; + final String ACTION_ON_COMPONENT = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/%s/%s/versions/%s/actions"; + final String UPDATE_VSP = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s"; + final String GET_VSP_COMPONENT_BY_VERSION = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/%s"; + final String GET_VLM_COMPONENT_BY_VERSION = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/vendor-license-models/%s/versions/%s"; + final String ACTION_ARCHIVE_RESTORE_COMPONENT = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/%s/%s/actions"; + String CREATE_SERVICE_FILTER = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s/resourceInstances/%s/nodeFilter"; + String UPDATE_SERVICE_FILTER = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s" + + "/resourceInstances/%s/nodeFilter/"; + String DELETE_SERVICE_FILTER = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/services/%s" + + "/resourceInstances/%s/nodeFilter/%s"; + String MARK_AS_DEPENDENT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/resourceInstance/%s"; + + // Interface Lifecycle Types + final String GET_All_INTERFACE_LIFECYCLE_TYPES = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/interfaceLifecycleTypes"; + + // Interface Operation + final String ADD_INTERFACE_OPERATIONS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/interfaceOperations"; + final String UPDATE_INTERFACE_OPERATIONS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/interfaceOperations"; + final String GET_INTERFACE_OPERATIONS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/interfaces/%s/operations/%s"; + final String DELETE_INTERFACE_OPERATIONS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/interfaces/%s/operations/%s"; + final String UPLOAD_INTERFACE_OPERATION_ARTIFACT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/interfaces/%s/operations/%s/artifacts/%s"; + + //Requirements + String CREATE_REQUIREMENT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/requirements"; + String UPDATE_REQUIREMENT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/requirements"; + String DELETE_REQUIREMENT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/requirements/%s"; + String GET_REQUIREMENT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/requirements/%s"; + //Capabilities + String CREATE_CAPABILITY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/capabilities"; + String UPDATE_CAPABILITY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/capabilities"; + String DELETE_CAPABILITY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/capabilities/%s"; + String GET_CAPABILITY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/capabilities/%s"; + + //VSP Validation Operation + final String VSP_VALIDATION_CONFIGURATION = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/externaltesting/config"; + final String GET_INSTANCE_TOSCA_ARTIFACTS = SDC_HTTP_METHOD + + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/filteredDataByParams?include=toscaArtifacts"; +} |