本文整理匯總了Java中cucumber.api.java.en.When類的典型用法代碼示例。如果您正苦於以下問題:Java When類的具體用法?Java When怎麽用?Java When使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
When類屬於cucumber.api.java.en包,在下文中一共展示了When類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: replace
import cucumber.api.java.en.When; //導入依賴的package包/類
@When("^replace (\\w+)$")
public void replace(String name, DataTable table) {
name = name.trim();
String text = getVarAsString(name);
List<Map<String, String>> list = table.asMaps(String.class, String.class);
String replaced = Script.replacePlaceholders(text, list, context);
context.vars.put(name, replaced);
}
示例2: sendMalformedLldpPacket
import cucumber.api.java.en.When; //導入依賴的package包/類
@When("^send malformed lldp packet$")
public void sendMalformedLldpPacket() throws Throwable {
System.out.println("=====> Send malformed packet");
long current = System.currentTimeMillis();
Client client = ClientBuilder.newClient(new ClientConfig());
Response result = client
.target(trafficEndpoint)
.path("/send_malformed_packet")
.request()
.post(null);
System.out.println(String.format("======> Response = %s", result.toString()));
System.out.println(String.format("======> Send malformed packet Time: %,.3f", getTimeDuration(current)));
assertEquals(200, result.getStatus());
}
示例3: on
import cucumber.api.java.en.When; //導入依賴的package包/類
@When("^client_one does a PUT on (.*?) with (.*?) in zone 1$")
public void client_one_does_a_PUT_on_identifier_in_test_zone(final String api, final String identifier)
throws Throwable {
OAuth2RestTemplate acsTemplate = this.acsZone1Template;
try {
switch (api) {
case "subject":
this.privilegeHelper.putSubject(acsTemplate, this.subject, this.acsUrl, this.zone1Headers,
this.privilegeHelper.getDefaultAttribute());
break;
case "resource":
this.privilegeHelper.putResource(acsTemplate, this.resource, this.acsUrl, this.zone1Headers,
this.privilegeHelper.getDefaultAttribute());
break;
case "policy-set":
this.testPolicyName = "single-action-defined-policy-set";
this.policyHelper.createPolicySet("src/test/resources/single-action-defined-policy-set.json",
acsTemplate, this.zone1Headers);
break;
default:
Assert.fail("Api " + api + " does not match/is not yet implemented for this test code.");
}
} catch (HttpClientErrorException e) {
Assert.fail("Unable to PUT identifier: " + identifier + " for api: " + api);
}
}
示例4: isValidBidRequest
import cucumber.api.java.en.When; //導入依賴的package包/類
@When("^an openRtb validator version \"([^\"]*)\" runs validation on given bid request$")
public void isValidBidRequest(String version) throws Throwable {
getVersion(version);
System.out.println("version"+version);
System.out.println(openRtbVersion);
validator = OpenRtbValidatorFactory.getValidator(OpenRtbInputType.BID_REQUEST, openRtbVersion);
result = validator.validate(JsonLoader.fromResource(resource));
logger.info("validation result: " + result);
}
示例5: having
import cucumber.api.java.en.When; //導入依賴的package包/類
@When("^I click on element having (id|name|class|xpath|css) \"([^\"]*)\" and text \"([^\"]*)\"$")
public void clickElementHaving(String type, String element, String text) {
List<WebElement> webElements = getWebElements(type, element);
for (WebElement el : webElements)
if (text.trim().equals(el.getText().trim()))
click(el);
}
示例6: iPOSTItToTheTemplatesEndpoint
import cucumber.api.java.en.When; //導入依賴的package包/類
@When("^I POST it to the /templates endpoint$")
public void iPOSTItToTheTemplatesEndpoint() throws Throwable {
try {
lastApiResponse = api.createTemplateWithHttpInfo(template);
lastApiCallThrewException = false;
lastApiException = null;
lastStatusCode = lastApiResponse.getStatusCode();
} catch (ApiException e) {
lastApiCallThrewException = true;
lastApiResponse = null;
lastApiException = e;
lastStatusCode = lastApiException.getCode();
}
}
示例7: logOutOfJHipsterSampleApp
import cucumber.api.java.en.When; //導入依賴的package包/類
/**
* Logout of JHipsterSampleApp.
*
* @throws FailureException
* if the scenario encounters a functional error.
* @throws TechnicalException
* is thrown if you have a technical error (format, configuration, datas, ...) in NoraUi.
*/
@When("I log out of JHIPSTERSAMPLEAPP")
public void logOutOfJHipsterSampleApp() throws FailureException, TechnicalException {
if (Auth.isConnected()) {
getDriver().switchTo().defaultContent();
clickOn(jHipsterSampleAppPage.accountMenu);
Context.waitUntil(ExpectedConditions.presenceOfElementLocated(Utilities.getLocator(jHipsterSampleAppPage.signoutMenu))).click();
}
}
示例8: jennyDeletesAnImage
import cucumber.api.java.en.When; //導入依賴的package包/類
@When("^Jenny deletes an image$")
public void jennyDeletesAnImage() throws Throwable {
String userAuthorization = "Basic " + Base64.getEncoder().encodeToString(("user" + ":" + "default").getBytes());
response = mockMvc.perform(get("http://localhost:8080/imageClassifier/deleteImage")
.header("Authorization", userAuthorization)
.param("email", "[email protected]")
.param("fileName", "ChihuahuaOrMuffin")
.accept(MediaType.APPLICATION_JSON));
}
示例9: whenICreateANewPublication
import cucumber.api.java.en.When; //導入依賴的package包/類
@When("^I create a new publication$")
public void whenICreateANewPublication() throws Throwable {
final Publication publication = TestDataFactory.createValidPublication().build();
testDataRepo.setPublication(publication);
assertThat("New publication created.", contentPage.newPublication(publication), is(true));
}
示例10: a_link_is_added_in_the_middle
import cucumber.api.java.en.When; //導入依賴的package包/類
@When("^a link is added in the middle$")
public void a_link_is_added_in_the_middle() throws Exception {
List<IslInfoData> links = LinksUtils.dumpLinks();
IslInfoData middleLink = getMiddleLink(links);
String srcSwitch = getSwitchName(middleLink.getPath().get(0).getSwitchId());
String dstSwitch = getSwitchName(middleLink.getPath().get(1).getSwitchId());
assertTrue("Link is not added", LinksUtils.addLink(srcSwitch, dstSwitch));
TimeUnit.SECONDS.sleep(2);
}
示例11: with
import cucumber.api.java.en.When; //導入依賴的package包/類
@When("^flow (.*) creation request with (.*) (\\d+) (\\d+) and (.*) (\\d+) (\\d+) and (\\d+) is successful$")
public void successfulFlowCreation(final String flowId, final String sourceSwitch, final int sourcePort,
final int sourceVlan, final String destinationSwitch, final int destinationPort,
final int destinationVlan, final int bandwidth) throws Exception {
flowPayload = new FlowPayload(FlowUtils.getFlowName(flowId),
new FlowEndpointPayload(sourceSwitch, sourcePort, sourceVlan),
new FlowEndpointPayload(destinationSwitch, destinationPort, destinationVlan),
bandwidth, flowId, null);
FlowPayload response = FlowUtils.putFlow(flowPayload);
assertNotNull(response);
response.setLastUpdated(null);
assertEquals(flowPayload, response);
}
示例12: sheOrdersA
import cucumber.api.java.en.When; //導入依賴的package包/類
@When("^(?:.*) (?:orders|has ordered) an? (.*)$")
public void sheOrdersA(String order) throws Throwable {
orderReceipt = customer.placesAnOrderFor(1, order);
Serenity.setSessionVariable("orderReceipt").to(orderReceipt);
}
示例13: importDetails
import cucumber.api.java.en.When; //導入依賴的package包/類
@When("^she see details about imported extension$")
public void importDetails() throws Throwable {
//TODO Deeper validation
assertThat(techExtensionsImportPage.validate(), is(true));
techExtensionsImportPage.getButton("Import Extension").shouldBe(visible);
techExtensionsImportPage.getButton("Cancel").shouldBe(visible);
}
示例14: sheMakesARequestToUsergoalDeleteUserGoal
import cucumber.api.java.en.When; //導入依賴的package包/類
@When("^she makes a request to usergoal/addUserGoal$")
public void sheMakesARequestToUsergoalDeleteUserGoal() throws Throwable {
String userAuthorization = "Basic " + Base64.getEncoder().encodeToString(("user" + ":" + "default").getBytes());
response = mockMvc.perform(get("http://localhost:8080/userGoal/deleteUserGoal")
.header("Authorization", userAuthorization)
.param("email", "[email protected]")
.accept(MediaType.APPLICATION_JSON));
}
示例15: selectPointsForMetricWithTagBetweenAnd
import cucumber.api.java.en.When; //導入依賴的package包/類
@When("^select points for metric \"([^\"]*)\" with tag \"([^\"]*)\" = \"([^\"]*)\" between \"([^\"]*)\" and \"([^\"]*)\"$")
public void selectPointsForMetricWithTagBetweenAnd(String metricName, String tagName, String tagValue, String fromTimeString, String toTimeString) throws Throwable {
Tag tag = Tag.of(tagName, tagValue);
Interval interval = Interval.until(parseTime(toTimeString)).from(parseTime(fromTimeString));
actualMetricsPoints = granularity == null
? pugTSDB.selectMetricsPoints(metricName, interval, tag)
: pugTSDB.selectMetricsPoints(metricName, granularity, interval, tag);
}