diff options
Diffstat (limited to 'integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/AddNodeToCompositionFlow.java')
-rw-r--r-- | integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/AddNodeToCompositionFlow.java | 61 |
1 files changed, 42 insertions, 19 deletions
diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/AddNodeToCompositionFlow.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/AddNodeToCompositionFlow.java index 4ecbbc1f8c..07d54299a5 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/AddNodeToCompositionFlow.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/AddNodeToCompositionFlow.java @@ -3,43 +3,66 @@ package org.onap.sdc.frontend.ci.tests.flow; import com.aventstack.extentreports.Status; import java.util.Objects; import java.util.Optional; -import org.onap.sdc.frontend.ci.tests.datatypes.ResourceCreateData; +import org.onap.sdc.frontend.ci.tests.datatypes.ComponentData; import org.onap.sdc.frontend.ci.tests.pages.ComponentPage; import org.onap.sdc.frontend.ci.tests.pages.PageObject; import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionPage; +import org.openecomp.sdc.be.model.ComponentInstance; import org.openqa.selenium.WebDriver; public class AddNodeToCompositionFlow extends AbstractUiTestFlow { - private final ResourceCreateData destination; - private final ResourceCreateData resource; + private final ComponentData parentComponent; + private final ComponentData componentToAdd; private CompositionPage compositionPage; - private ComponentPage componentPage; + private ComponentInstance createdComponentInstance; - public AddNodeToCompositionFlow(final WebDriver webDriver, final ResourceCreateData destination, final ResourceCreateData resource) { + public AddNodeToCompositionFlow(final WebDriver webDriver, final ComponentData parentComponent, final ComponentData componentToAdd) { super(webDriver); - this.destination = destination; - this.resource = resource; + this.parentComponent = parentComponent; + this.componentToAdd = componentToAdd; } @Override public Optional<? extends PageObject> run(final PageObject... pageObjects) { - Objects.requireNonNull(destination); - Objects.requireNonNull(resource); - extendTest.log(Status.INFO, String.format("Adding Resource '%s' to VF/Service '%s'", resource.getName(), destination.getName())); + Objects.requireNonNull(parentComponent); + Objects.requireNonNull(parentComponent.getComponentType()); + Objects.requireNonNull(componentToAdd); + extendTest.log(Status.INFO, String.format("Adding Resource '%s' to VF/Service '%s'", componentToAdd.getName(), parentComponent.getName())); - componentPage = findParameter(pageObjects, ComponentPage.class); + compositionPage = findParameter(pageObjects, CompositionPage.class); + compositionPage.isLoaded(); + addNodeToComposition(); + final ComponentPage componentPage = compositionPage.goToGeneral(); componentPage.isLoaded(); - compositionPage = componentPage.goToComposition(); - compositionPage.isLoaded(); - compositionPage.addNodeToResourceCompositionUsingApi(destination.getName(), "0.1", resource.getName(), "1.0"); - compositionPage.goToGeneral(); - return Optional.of(compositionPage); + return Optional.of(this.compositionPage); + } + + private void addNodeToComposition() { + switch (parentComponent.getComponentType()) { + case SERVICE: + createdComponentInstance = compositionPage + .addNodeToServiceCompositionUsingApi(parentComponent.getName(), parentComponent.getVersion(), componentToAdd.getName(), + componentToAdd.getVersion()); + break; + case RESOURCE: + createdComponentInstance = compositionPage + .addNodeToResourceCompositionUsingApi(parentComponent.getName(), parentComponent.getVersion(), componentToAdd.getName(), + componentToAdd.getVersion()); + break; + default: + throw new UnsupportedOperationException( + String.format("Add node in a %s not yet supported", parentComponent.getComponentType().getValue())); + } } @Override - public Optional<? extends PageObject> getLandedPage() { - return Optional.ofNullable(componentPage); + public Optional<CompositionPage> getLandedPage() { + return Optional.ofNullable(compositionPage); + } + + public Optional<ComponentInstance> getCreatedComponentInstance() { + return Optional.ofNullable(createdComponentInstance); } -} +}
\ No newline at end of file |