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));
}
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);
}
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);
}
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));
}
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();
}
}
Aggregations