Search in sources :

Example 61 with Given

use of io.cucumber.java.en.Given in project open-smart-grid-platform by OSGP.

the class ConnectionSteps method givenIec60870DeviceIsConnected.

@Given("an existing connection with IEC60870 device {string} of type {deviceType}")
public void givenIec60870DeviceIsConnected(final String deviceIdentification, final DeviceType deviceType) throws Exception {
    LOGGER.debug("Given an existing connection with IEC60870 device {} of type {}", deviceIdentification, deviceType);
    // Make sure the connection event listener works as expected
    this.connectionParameters = this.initConnectionParameters(deviceIdentification);
    final ResponseMetadata responseMetadata = this.initResponseMetadata(deviceIdentification, deviceType);
    this.connectionEventListener = new ClientConnectionEventListener.Builder().withDeviceIdentification(deviceIdentification).withClientAsduHandlerRegistry(this.clientAsduHandlerRegistry).withClientConnectionCache(this.connectionCacheSpy).withLoggingService(this.loggingService).withLogItemFactory(this.logItemFactory).withResponseMetadata(responseMetadata).withResponseMetadataFactory(this.responseMetadataFactory).build();
    // Make sure a connection could be retrieved from the cache
    // Only needed for scenarios sending requests to a device
    // final Connection connection = mock(Connection.class);
    this.connectionCacheSpy.addConnection(deviceIdentification, new DeviceConnection(this.connection, this.connectionParameters));
}
Also used : DeviceConnection(org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.DeviceConnection) ResponseMetadata(org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.ResponseMetadata) ClientConnectionEventListener(org.opensmartgridplatform.adapter.protocol.iec60870.domain.services.ClientConnectionEventListener) Given(io.cucumber.java.en.Given)

Example 62 with Given

use of io.cucumber.java.en.Given in project syndesis-qe by syndesisio.

the class CommonSteps method loginAfterLogOut.

@Given("^log into the Syndesis after logout$")
public void loginAfterLogOut() {
    if (OpenShiftUtils.isOSD()) {
        // when SSO is used, the session needs to be deleted on KeyCloak too in order to fill credentials again.
        WebDriver driver = WebDriverRunner.getWebDriver();
        // open new tab and use it
        JavascriptExecutor jse = (JavascriptExecutor) driver;
        jse.executeScript("window.open()");
        ArrayList<String> tabs = new ArrayList<>(driver.getWindowHandles());
        driver.switchTo().window(tabs.get(1));
        String keyCloakLogoutUrl = String.format("https://keycloak-%s.%s/auth/realms/%s/protocol/openid-connect/logout", TestConfiguration.keycloakNamespace(), TestConfiguration.openShiftRouteSuffix(), TestConfiguration.keyCloakSyndesisRealm());
        driver.navigate().to(keyCloakLogoutUrl);
        TestUtils.sleepForJenkinsDelayIfHigher(3);
        driver.close();
        driver.switchTo().window(tabs.get(0));
    }
    doLogin(true);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) ArrayList(java.util.ArrayList) Given(io.cucumber.java.en.Given)

Example 63 with Given

use of io.cucumber.java.en.Given in project syndesis-qe by syndesisio.

the class TodoSteps method setCredentials.

@Given("^Set Todo app credentials$")
public void setCredentials() {
    Account todoAppAccount = new Account();
    todoAppAccount.setService("todo");
    Map<String, String> accountParameters = new HashMap<>();
    accountParameters.put("username", "test");
    accountParameters.put("password", "test");
    todoAppAccount.setProperties(accountParameters);
    AccountsDirectory.getInstance().addAccount("todo", todoAppAccount);
}
Also used : Account(io.syndesis.qe.account.Account) HashMap(java.util.HashMap) Given(io.cucumber.java.en.Given)

Example 64 with Given

use of io.cucumber.java.en.Given in project syndesis-qe by syndesisio.

the class UtilitySteps method changeDatashapeTo.

@Given("change {string} datashape of previous step to {string} type with specification {string}")
public void changeDatashapeTo(String direction, String type, String specification) {
    Step lastStep = super.getSteps().getLastStepDefinition().getStep();
    Step withDatashape = new Step.Builder().createFrom(lastStep).action(super.withCustomDatashape(lastStep.getAction().get(), super.getConnectorDescriptor(lastStep.getAction().get(), lastStep.getConfiguredProperties(), lastStep.getConnection().get().getId().get()), direction, DataShapeKinds.valueOf(type), specification)).build();
    StepsStorage steps = super.getSteps();
    steps.getStepDefinitions().remove(steps.getStepDefinitions().size() - 1);
    steps.getStepDefinitions().add(new StepDefinition(withDatashape));
}
Also used : StepsStorage(io.syndesis.qe.storage.StepsStorage) StepDefinition(io.syndesis.qe.entities.StepDefinition) Step(io.syndesis.common.model.integration.Step) Given(io.cucumber.java.en.Given)

Example 65 with Given

use of io.cucumber.java.en.Given in project syndesis-qe by syndesisio.

the class OperatorValidationSteps method createPv.

@Given("create test persistent volumes with {string} storage class name")
public void createPv(String className) {
    // Create 3 PVs, two with higher capacity that will be used by meta and prometheus, because the binding of PV is FCFS,
    // so they theoretically can steal the test-pv from db
    // These volumes won't work, but they will be available to bind
    Map<String, Quantity> capacity = new HashMap<>();
    capacity.put("storage", new Quantity("3Gi"));
    if (!"".equals(className) && OpenShiftUtils.getInstance().storage().storageClasses().withName(className).get() == null) {
        log.info("Creating storage class " + className);
        OpenShiftUtils.getInstance().storage().storageClasses().createOrReplaceWithNew().withNewMetadata().withName(className).endMetadata().withProvisioner("kubernetes.io/cinder").done();
    }
    PersistentVolumeFluent.SpecNested<DoneablePersistentVolume> pv = OpenShiftUtils.getInstance().persistentVolumes().createOrReplaceWithNew().withNewMetadata().withName(TEST_PV_NAME).withLabels(TestUtils.map("operator", "test")).endMetadata().withNewSpec().withAccessModes("ReadOnlyMany", "ReadWriteOnce", "ReadWriteMany").withCapacity(capacity).withNewNfs().withNewServer("testServer").withNewPath("/testPath").endNfs();
    // The default storage class for OCP3 is empty, for OCP4 is "standard", so if the className is empty, we should use the default one
    if ("".equals(className)) {
        if (!OpenShiftUtils.isOpenshift3()) {
            if (OpenShiftUtils.isOSD()) {
                pv.withStorageClassName("gp2");
            } else {
                pv.withStorageClassName("standard");
            }
        }
    } else {
        pv.withStorageClassName(className);
    }
    pv.endSpec().done();
    capacity.put("storage", new Quantity("5Gi"));
    for (int i = 1; i < 3; i++) {
        pv = OpenShiftUtils.getInstance().persistentVolumes().createOrReplaceWithNew().withNewMetadata().withName(TEST_PV_NAME + "-" + i).endMetadata().withNewSpec().withAccessModes("ReadWriteOnce").withCapacity(capacity).withNewNfs().withNewServer("testServer").withNewPath("/testPath").endNfs();
        if (!OpenShiftUtils.isOpenshift3()) {
            // This should always be the default value despite the actual value of className - that is used only in "test-pv" intentionally
            if (OpenShiftUtils.isOSD()) {
                pv.withStorageClassName("gp2");
            } else {
                pv.withStorageClassName("standard");
            }
        }
        pv.endSpec().done();
    }
}
Also used : HashMap(java.util.HashMap) Quantity(io.fabric8.kubernetes.api.model.Quantity) DoneablePersistentVolume(io.fabric8.kubernetes.api.model.DoneablePersistentVolume) IntegrationsEndpoint(io.syndesis.qe.endpoint.IntegrationsEndpoint) PersistentVolumeFluent(io.fabric8.kubernetes.api.model.PersistentVolumeFluent) Given(io.cucumber.java.en.Given)

Aggregations

Given (io.cucumber.java.en.Given)125 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)27 ArrayList (java.util.ArrayList)11 Transactional (org.springframework.transaction.annotation.Transactional)11 Ssld (org.opensmartgridplatform.domain.core.entities.Ssld)8 Date (java.util.Date)7 DeviceOutputSetting (org.opensmartgridplatform.domain.core.entities.DeviceOutputSetting)6 ActivityCalendar (org.opensmartgridplatform.cucumber.platform.smartmetering.support.ws.smartmetering.bundle.activitycalendar.ActivityCalendar)5 Device (org.opensmartgridplatform.domain.core.entities.Device)5 RelayType (org.opensmartgridplatform.domain.core.valueobjects.RelayType)5 ByteString (com.google.protobuf.ByteString)4 Account (io.syndesis.qe.account.Account)4 File (java.io.File)4 List (java.util.List)4 ElementsCollection (com.codeborne.selenide.ElementsCollection)3 Field (java.lang.reflect.Field)3 HashMap (java.util.HashMap)3 ResponseData (org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData)3 ResponseDataBuilder (org.opensmartgridplatform.cucumber.platform.glue.steps.database.ws.ResponseDataBuilder)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2