import org.onap.sdc.frontend.ci.tests.execute.setup.DriverFactory;
import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions;
import org.onap.sdc.frontend.ci.tests.execute.setup.SetupCDTest;
+import org.onap.sdc.frontend.ci.tests.flow.AddComponentInputFlow;
import org.onap.sdc.frontend.ci.tests.flow.AddComponentPropertyFlow;
import org.onap.sdc.frontend.ci.tests.flow.AddNodeToCompositionFlow;
import org.onap.sdc.frontend.ci.tests.flow.CreateDirectiveNodeFilterFlow;
import org.onap.sdc.frontend.ci.tests.flow.CreateSubstitutionFilterFlow;
import org.onap.sdc.frontend.ci.tests.flow.CreateVfFlow;
import org.onap.sdc.frontend.ci.tests.flow.CreateVfcFlow;
-import org.onap.sdc.frontend.ci.tests.flow.DownloadCsarArtifactFlow;
import org.onap.sdc.frontend.ci.tests.flow.DownloadToscaTemplateFlow;
+import org.onap.sdc.frontend.ci.tests.flow.DownloadCsarArtifactFlow;
import org.onap.sdc.frontend.ci.tests.flow.EditComponentPropertiesFlow;
import org.onap.sdc.frontend.ci.tests.flow.composition.CreateRelationshipFlow;
import org.onap.sdc.frontend.ci.tests.flow.exception.UiTestFlowRuntimeException;
import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionDetailSideBarComponent;
import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionDetailSideBarComponent.CompositionDetailTabName;
import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionInformationTab;
-import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionInterfaceOperationsModal;
+import org.onap.sdc.frontend.ci.tests.pages.component.workspace.InterfaceDefinitionOperationsModal;
import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionInterfaceOperationsTab;
import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionPage;
import org.onap.sdc.frontend.ci.tests.pages.component.workspace.RelationshipWizardInterfaceOperation.InterfaceOperationsData;
private ComponentPage componentPage;
private Map<String, String> propertiesToBeAddedMap;
private ResourceCreatePage resourceCreatePage;
+ private Map<String, String> inputsToBeAddedMap;
private final List<ServiceDependencyProperty> substitutionFilterProperties = new ArrayList<>();
private final String interfaceName = "Standard";
private final String interfaceOperationName = "create";
downloadAndVerifyCsarPackage(componentPage);
}
+ @Test(dependsOnMethods = "addRelationshipTemplate")
+ public void createMetadataForServiceProperty() throws Exception {
+ homePage.isLoaded();
+ componentPage = (ComponentPage) homePage.clickOnComponent(vfResourceCreateData.getName());
+ componentPage.isLoaded();
+ final ResourcePropertiesAssignmentPage propertiesAssignmentPage = componentPage.goToPropertiesAssignment();
+
+ propertiesAssignmentPage.isLoaded();
+ propertiesAssignmentPage.selectInputTab();
+ final var propertyName = propertiesAssignmentPage.getInputPropertyNames().get(0);
+ final var key = "Key";
+ final var value = "Test";
+ propertiesAssignmentPage.setInputPropertyMetadata(propertyName, key, value);
+
+ final var topologyTemplate = getMapEntry(downloadToscaTemplate(), "topology_template");
+ final var inputs = getMapEntry(topologyTemplate, "inputs");
+ final var serviceProperty = getMapEntry(inputs, propertyName);
+ final var servicePropertyMetadata = getMapEntry(serviceProperty, "metadata");
+ assertNotNull(servicePropertyMetadata, String.format("Metadata not found for property %s", propertyName));
+ assertEquals(servicePropertyMetadata.get(key), value, "Created service property metadata has invalid value");
+ }
+
@Test(dependsOnMethods = "addRelationshipTemplate")
public void addOutputsToVF_test() throws UnzipException, IOException {
homePage.isLoaded();
compositionPage.isLoaded();
ExtentTestActions.addScreenshot(Status.INFO, "select-VFC-node", "Selecting Node on composition");
compositionPage.selectNode(vfcs.get(1).getName());
- final CompositionInterfaceOperationsModal.InterfaceOperationsData interfaceOperationsData =
- new CompositionInterfaceOperationsModal.InterfaceOperationsData("IT for updating an Interface Operation",
+ final InterfaceDefinitionOperationsModal.InterfaceOperationsData interfaceOperationsData =
+ new InterfaceDefinitionOperationsModal.InterfaceOperationsData("IT for updating an Interface Operation",
"MyIntegrationTestImplementationName", "My_IT_InputName", "My_IT_InputValue");
updateInterfaceOperation(compositionPage, interfaceOperationsData);
componentPage = compositionPage.goToGeneral();
componentPage.isLoaded();
final ResourcePropertiesPage vfcPropertiesPage = componentPage.goToProperties();
vfcPropertiesPage.isLoaded();
- final List<String> propertyNames = vfcPropertiesPage.getPropertyNames();
- final ServiceDependencyProperty serviceDependencyProperty = new ServiceDependencyProperty(propertyNames.get(0), value, operator);
+ final Map<String, String> propertyNamesAndTypes = vfcPropertiesPage.getPropertyNamesAndTypes();
+ final List<String> propertyNames = propertyNamesAndTypes.keySet().stream().collect(Collectors.toList());
+ final ServiceDependencyProperty serviceDependencyProperty =
+ new ServiceDependencyProperty(propertyNames.get(0), propertyNamesAndTypes.get(propertyNames.get(0)), value, operator);
homePage.getTopNavComponent().clickOnHome();
homePage.isLoaded();
verifyToscaTemplateHasDirectiveNodeFilter(yaml, serviceDependencyProperty, vfcNameInComposition);
}
+ @Test(dependsOnMethods = "addComponentProperty")
+ public void declareInputFromProperties() throws Exception {
+ componentPage = (ComponentPage) homePage.clickOnComponent(vfResourceCreateData.getName());
+ componentPage.isLoaded();
+
+ ResourcePropertiesAssignmentPage propertiesAssignmentPage = componentPage.goToPropertiesAssignment();
+ propertiesAssignmentPage.isLoaded();
+
+ declareInputToBaseService(propertiesAssignmentPage, "property1");
+ declareInputToInstanceProperties(propertiesAssignmentPage, "resourceSubtype");
+ verifyToscaTemplateHasDeclareInput(downloadToscaTemplate());
+ }
+
+ @Test(dependsOnMethods = "createBaseService")
+ public void addComponentInputs() throws Exception {
+ inputsToBeAddedMap = loadInputsToAdd();
+ addInput(inputsToBeAddedMap);
+ verifyToscaTemplateAddInput(downloadToscaTemplate());
+ }
+
private void checkMetadata(final Map<String, Object> map, final ResourceCreateData createdData) {
final Map<String, Object> metadata = getMapEntry(map, "metadata");
* @throws IOException
*/
private void updateInterfaceOperation(final CompositionPage compositionPage,
- final CompositionInterfaceOperationsModal.InterfaceOperationsData interfaceOperationsData) throws IOException {
+ final InterfaceDefinitionOperationsModal.InterfaceOperationsData interfaceOperationsData) throws IOException {
final CompositionDetailSideBarComponent detailSideBar = compositionPage.getDetailSideBar();
detailSideBar.isLoaded();
final CompositionInterfaceOperationsTab compositionInterfaceOperationsTab =
ExtentTestActions.takeScreenshot(Status.INFO, "compositionInterfaceOperationsTab",
"Composition Interface Operations Tab loaded");
assertTrue(compositionInterfaceOperationsTab.isOperationPresent(interfaceOperationName));
- final CompositionInterfaceOperationsModal compositionInterfaceOperationsModal = compositionInterfaceOperationsTab
+ final InterfaceDefinitionOperationsModal compositionInterfaceOperationsModal = compositionInterfaceOperationsTab
.clickOnOperation(interfaceOperationName);
compositionInterfaceOperationsModal.isLoaded();
ExtentTestActions.takeScreenshot(Status.INFO, "update-interface-operation-modal", "Loading Interface Operations Modal");
* @param interfaceOperationsData The Updated Interface Definition
*/
private void validateUpdatedInterfaceOperation(final CompositionDetailSideBarComponent detailSideBar,
- final CompositionInterfaceOperationsModal.InterfaceOperationsData interfaceOperationsData) {
+ final InterfaceDefinitionOperationsModal.InterfaceOperationsData interfaceOperationsData) {
final CompositionInterfaceOperationsTab compositionInterfaceOperationsTab = (CompositionInterfaceOperationsTab) detailSideBar
.selectTab(CompositionDetailTabName.INTERFACE_OPERATIONS);
compositionInterfaceOperationsTab.isLoaded();
assertTrue(compositionInterfaceOperationsTab.isOperationPresent(interfaceOperationName));
assertTrue(compositionInterfaceOperationsTab.isDescriptionPresent());
- final CompositionInterfaceOperationsModal compositionInterfaceOperationsModal = compositionInterfaceOperationsTab
+ final InterfaceDefinitionOperationsModal compositionInterfaceOperationsModal = compositionInterfaceOperationsTab
.clickOnOperation(interfaceOperationName);
compositionInterfaceOperationsModal.isLoaded();
ExtentTestActions.takeScreenshot(Status.INFO, "validate-updated-interface-operation",
}
private void verifyToscaTemplateHasUpdatedInterfaceOperation(final Map<?, ?> toscaTemplateYaml,
- final CompositionInterfaceOperationsModal.InterfaceOperationsData interfaceOperationsData) {
+ final InterfaceDefinitionOperationsModal.InterfaceOperationsData interfaceOperationsData) {
assertNotNull(toscaTemplateYaml, "No contents in TOSCA Template");
final Map<String, Object> topologyTemplateTosca = getMapEntry((Map<String, Object>) toscaTemplateYaml, "topology_template");
return loadYamlObject(filesFromZip.get(resourceEntryOpt.get()));
}
+ private void declareInputToBaseService(ResourcePropertiesAssignmentPage propertiesAssignmentPage, String propertyName){
+ propertiesAssignmentPage.selectProperty(propertyName);
+ propertiesAssignmentPage.clickOnDeclareInput();
+ propertiesAssignmentPage.clickInputTab(propertyName);
+ propertiesAssignmentPage.isInputPresent(vfResourceCreateData.getName() + "_" + propertyName);
+ }
+
+ private void declareInputToInstanceProperties(ResourcePropertiesAssignmentPage propertiesAssignmentPage, String propertyName){
+ propertiesAssignmentPage.selectPropertiesTab();
+ propertiesAssignmentPage.loadCompositionTab();
+ propertiesAssignmentPage.loadComponentInstanceProperties(vfcs.get(0).getName().concat(" 0"));
+ propertiesAssignmentPage.selectProperty(propertyName);
+ propertiesAssignmentPage.clickOnDeclareInput();
+ propertiesAssignmentPage.clickInputTab(propertyName);
+ propertiesAssignmentPage.isInputPresent(vfResourceCreateData.getName() + "_" + vfcs.get(0).getName());
+ }
+
private CreateVfFlow createVF() {
final ResourceCreateData vfCreateData = createVfFormData();
final CreateVfFlow createVfFlow = new CreateVfFlow(webDriver, vfCreateData);
addComponentPropertyFlow.run(componentPage.goToPropertiesAssignment());
}
+ /**
+ * Adds a input to the base service
+ * @param inputMap map of inputs to be added
+ */
+ private void addInput(final Map<String, String> inputMap) {
+ componentPage = (ComponentPage) homePage.clickOnComponent(vfResourceCreateData.getName());
+ componentPage.isLoaded();
+ final AddComponentInputFlow addComponentInputFlow = new AddComponentInputFlow(webDriver, inputMap);
+ addComponentInputFlow.run(componentPage.goToPropertiesAssignment());
+ }
+
/**
* Edits a property to add a value
* @param propertyMap map of properties to be edited
return expectedDefinitionFolderFileList;
}
- private Map<String, Object> getMapEntry(final Map<String, Object> yamlObj, final String entryName) {
+ private void verifyToscaTemplateHasDeclareInput(Map<?, ?> yaml) {
+ assertNotNull(yaml, "No contents in TOSCA Template");
+ final Map<String, Object> toscaYaml = (Map<String, Object>) yaml;
+ final Map<String, Object> topologyTemplateTosca = getMapEntry(toscaYaml, "topology_template");
+ assertThat(String.format("'%s' should contain a topology_template entry", toscaYaml), topologyTemplateTosca,
+ notNullValue());
+ final Map<String, Object> inputsTosca = getMapEntry(topologyTemplateTosca, "inputs");
+ assertThat(String.format("'%s' should contain a inputs entry", toscaYaml), inputsTosca, notNullValue());
+ assertEquals(2, inputsTosca.keySet().stream()
+ .filter(s -> (s.contains("resourceSubtype") || s.contains("property1"))).count());
+ final Map<String, Object> substitutionMapping = getMapEntry(topologyTemplateTosca, "substitution_mappings");
+ assertThat(String.format("'%s' should contain a substitution_mappings entry", toscaYaml), substitutionMapping,
+ notNullValue());
+ final Map<String, Object> substitutionMappingProperties = getMapEntry(substitutionMapping, "properties");
+ assertThat(String.format("'%s' should contain a properties entry", toscaYaml), substitutionMappingProperties,
+ notNullValue());
+ assertEquals(2, substitutionMappingProperties.keySet().stream()
+ .filter(s -> (s.contains("resourceSubtype") || s.contains("property1"))).count());
+ }
+
+ private void verifyToscaTemplateAddInput(Map<?, ?> yaml) {
+ final Map<String, String> inputMap = loadInputsToAdd();
+ assertNotNull(yaml, "No contents in TOSCA Template");
+ final Map<String, Object> toscaYaml = (Map<String, Object>) yaml;
+ final Map<String, Object> topologyTemplateTosca = getMapEntry(toscaYaml, "topology_template");
+ assertThat(String.format("'%s' should contain a topology_template entry", toscaYaml), topologyTemplateTosca,
+ notNullValue());
+ final Map<String, Object> inputsTosca = getMapEntry(topologyTemplateTosca, "inputs");
+ assertThat(String.format("'%s' should contain a inputs entry", toscaYaml), inputsTosca, notNullValue());
+ assertEquals(3, inputsTosca.keySet().stream()
+ .filter(s -> inputMap.containsKey(s)).count());
+ }
+
+ private Map<String, Object> getMapEntry(final Map<?, ?> yamlObj, final String entryName) {
try {
return (Map<String, Object>) yamlObj.get(entryName);
} catch (final Exception e) {
return propertyMap;
}
+ private Map<String, String> loadInputsToAdd() {
+ final Map<String, String> inputMap = new HashMap<>();
+ inputMap.put("input1", "string");
+ inputMap.put("input2", "integer");
+ inputMap.put("input3", "boolean");
+ return inputMap;
+ }
+
private void loadSubstitutionFilterProperties() {
final ResourcePropertiesAssignmentPage propertiesPage = componentPage.goToPropertiesAssignment();
propertiesPage.isLoaded();
assertThat(String.format("The Component '%s' should have properties", vfResourceCreateData.getName()), propertyNamesAndTypes,
not(anEmptyMap()));
propertyNamesAndTypes.forEach((name, type)
- -> substitutionFilterProperties.add(new ServiceDependencyProperty(name, getPropertyValueByType(type), LogicalOperator.EQUALS)));
+ -> substitutionFilterProperties.add(new ServiceDependencyProperty(name, type, getPropertyValueByType(type), LogicalOperator.EQUALS)));
}
private String getPropertyValueByType(final String type) {
case "boolean":
return "TRUE";
case "list":
- return "[value1, value2]";
+ return "[\"value1\", \"value2\"]";
case "map":
- return "MyKey: MyValue";
+ return "{\"MyKey\": \"MyValue\"}";
default:
throw new UnsupportedOperationException("Not yet implemented for " + type);
}
substitutionFilterMap.containsKey(substitutionFilterProperty.getName()));
final Map<?, ?> substitutionFilterValue = (Map<?, ?>) ((List<?>) substitutionFilterMap.get(substitutionFilterProperty.getName())).get(0);
assertThat("Substitution Filter Value should not be empty", substitutionFilterMap, not(anEmptyMap()));
- final String expectedSubstitutionPropertyValue = substitutionFilterProperty.getValue();
+ final String expectedSubstitutionPropertyValue = substitutionFilterProperty.getValue().replaceAll("[\"{}]", "");
final String actualSubstitutionPropertyValue = substitutionFilterValue.values().stream().findFirst().get() instanceof Map
? substitutionFilterValue.values().stream().findFirst().get().toString().replace("=", ": ")
.replaceAll("\\{(.*?)\\}", "$1").trim()