io.cucumber.java.en.Then Java Examples

The following examples show how to use io.cucumber.java.en.Then. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ListApplicationsSteps.java    From realworld-serverless-application with Apache License 2.0 6 votes vote down vote up
@Then("all applications should be listed")
public void all_applications_should_be_listed() {
  assertThat(TestEnv.getLastException()).isNull();
  Preconditions.checkState(!TestEnv.getApplications().isEmpty(), "Step assumes previous applications exist");
  Preconditions.checkState(TestEnv.getApplicationList() != null, "Step assumes listApplications has been called");

  List<ApplicationSummary> expectedApplicationSummaries = TestEnv.getApplications().stream()
        .map(app -> new ApplicationSummary()
              .applicationId(app.getApplicationId())
              .description(app.getDescription())
              .creationTime(app.getCreationTime()))
        .collect(Collectors.toList());

  assertThat(TestEnv.getApplicationList().getApplications()).containsAll(expectedApplicationSummaries);
  assertThat(TestEnv.getApplicationList().getNextToken()).isNull();
}
 
Example #2
Source File: ApiKeysStepsDefinitions.java    From apm-agent-java with Apache License 2.0 6 votes vote down vote up
@Then("the Authorization header is {string}")
public void checkExpectedHeader(String expectedHeaderValue) {
    ApmServerClient apmServerClient = new ApmServerClient(configuration);
    apmServerClient.start();

    try {
        apmServerClient.execute("/", new ApmServerClient.ConnectionHandler<Object>() {
            @Nullable
            @Override
            public Object withConnection(HttpURLConnection connection) throws IOException {
                assertThat(connection.getResponseCode())
                    .describedAs("unexpected response code from server")
                    .isEqualTo(200);


                String body = HttpUtils.readToString(connection.getInputStream());
                assertThat(body).isEqualTo(expectedHeaderValue);

                return null;
            }
        });
    } catch (Exception e) {
        fail(e.getMessage(), e);
    }
}
 
Example #3
Source File: HomeSteps.java    From justtestlah with Apache License 2.0 5 votes vote down vote up
@Then("I can see the question icon")
public void matchQuestionIcon() {
  // The first assertion would be sufficient. We run some more checks to show-case the template
  // matching.
  assertThat(home.hasImage("questionIcon.png")).as("Question icon is visible").isEqualTo(true);
  assertThat(home.hasImage("questionIcon_blurred.png")).as("Question icon is visible (blurred)")
      .isEqualTo(true);
  assertThat(home.hasImage("questionIcon_distorted.png", 0.75))
      .as("Question icon is visible (distorted)").isEqualTo(true);
  assertThat(home.hasImage("questionIcon_rotated.png", 0.85))
      .as("Question icon is visible (rotated)").isEqualTo(true);
}
 
Example #4
Source File: CamelKSteps.java    From yaks with Apache License 2.0 5 votes vote down vote up
@Then("^integration ([a-z0-9-.]+) should not print (.*)$")
public void shouldNotPrint(String name, String message) throws InterruptedException {
    runner.run(assertException()
            .exception(ActionTimeoutException.class)
            .when(verifyIntegration()
                .client(client())
                .isRunning(name)
                .waitForLogMessage(message)));
}
 
Example #5
Source File: CamelKSteps.java    From yaks with Apache License 2.0 5 votes vote down vote up
@Then("^integration ([a-z0-9-.]+) should print (.*)$")
public void shouldPrint(String name, String message) throws InterruptedException {
    runner.run(verifyIntegration()
            .client(client())
            .isRunning(name)
            .waitForLogMessage(message));
}
 
Example #6
Source File: HttpServerSteps.java    From yaks with Apache License 2.0 5 votes vote down vote up
@Then("^(?:expect|verify) HTTP request header: ([^\\s]+)(?:=| is )\"(.+)\"$")
public void addRequestHeader(String name, String value) {
    if (name.equals(HttpHeaders.CONTENT_TYPE)) {
        requestMessageType = getMessageType(value);
    }

    requestHeaders.put(name, value);
}
 
Example #7
Source File: TopicFeature.java    From hedera-mirror-node with Apache License 2.0 5 votes vote down vote up
@Then("I subscribe with a filter to retrieve messages")
public void retrieveTopicMessages() throws Throwable {
    assertNotNull(consensusTopicId, "consensusTopicId null");
    assertNotNull(mirrorConsensusTopicQuery, "mirrorConsensusTopicQuery null");

    subscriptionResponse = subscribeWithBackgroundMessageEmission();
}
 
Example #8
Source File: HttpClientSteps.java    From yaks with Apache License 2.0 5 votes vote down vote up
@Then("^(?:expect|verify) HTTP response header ([^\\s]+)(?:=| is )\"(.+)\"$")
public void addResponseHeader(String name, String value) {
    if (name.equals(HttpHeaders.CONTENT_TYPE)) {
        responseMessageType = getMessageType(value);
    }

    responseHeaders.put(name, value);
}
 
Example #9
Source File: AddDeleteListSearchBooksAndBorrowersStepDefs.java    From demo with MIT License 5 votes vote down vote up
@Then("the system responds with only the available books")
public void the_system_responds_with_only_the_available_books() {
    List<Book> expectedBooks = new ArrayList<>();
    expectedBooks.add(new Book(1, "a"));
    expectedBooks.add(new Book(3, "c"));
    assertEquals(expectedBooks, allBooks);
}
 
Example #10
Source File: TopicFeature.java    From hedera-mirror-node with Apache License 2.0 5 votes vote down vote up
@Then("the network should successfully observe these messages")
public void verifyTopicMessageSubscription() throws Exception {
    assertNotNull(subscriptionResponse, "subscriptionResponse is null");
    assertFalse(subscriptionResponse.errorEncountered(), "Error encountered");

    assertEquals(messageSubscribeCount, subscriptionResponse.getMessages().size());
    subscriptionResponse.validateReceivedMessages();
    mirrorClient.unSubscribeFromTopic(subscriptionResponse.getSubscription());
}
 
Example #11
Source File: JdbcSteps.java    From yaks with Apache License 2.0 5 votes vote down vote up
@Then("^verify column ([^\"\\s]+)=(.+)$")
public void verifyColumn(String name, String value) {
    runner.run(query(dataSource)
                                 .statements(sqlQueryStatements)
                                 .validate(name, value));
    sqlQueryStatements.clear();
}
 
Example #12
Source File: RegistrationStepDefs.java    From demo with MIT License 5 votes vote down vote up
@Then("^they fail to register and the system indicates a response: (.*)$")
public void theyFailToRegisterAndTheSystemIndicatesAResponse(String response) {
    Assert.assertTrue(myRegistrationResult.toString()
            .toLowerCase()
            .replace("_", " ")
            .contains(response));
}
 
Example #13
Source File: TopicFeature.java    From hedera-mirror-node with Apache License 2.0 5 votes vote down vote up
@Then("the network should successfully observe {long} messages")
public void verifyTopicMessageSubscription(long expectedMessageCount) throws Exception {
    assertNotNull(subscriptionResponse, "subscriptionResponse is null");
    assertFalse(subscriptionResponse.errorEncountered(), "Error encountered");

    assertEquals(expectedMessageCount, subscriptionResponse.getMessages().size());
    subscriptionResponse.validateReceivedMessages();
    mirrorClient.unSubscribeFromTopic(subscriptionResponse.getSubscription());
}
 
Example #14
Source File: CreateApplicationSteps.java    From realworld-serverless-application with Apache License 2.0 5 votes vote down vote up
@Then("^a new application should be created|the application should be updated$")
public void a_new_application_should_be_created() {
  assertThat(TestEnv.getLastException()).isNull();
  Preconditions.checkState(TestEnv.getApplicationId() != null, "Step assumes previous application id exists");

  GetApplicationResult result = appRepo.getApplication(new GetApplicationRequest().applicationId(TestEnv.getApplicationId()));
  assertThat(result.getApplication())
        .isNotNull()
        .isEqualTo(TestEnv.getApplication());
}
 
Example #15
Source File: AthenaQuerySteps.java    From realworld-serverless-application with Apache License 2.0 5 votes vote down vote up
@Then("^a new application should be created|the application should be updated$")
public void a_new_application_should_be_created() {
  assertThat(TestEnv.getLastException()).isNull();
  Preconditions.checkState(TestEnv.getApplicationId() != null, "Step assumes previous application id exists");

  GetApplicationResult result = appRepo.getApplication(new GetApplicationRequest().applicationId(TestEnv.getApplicationId()));
  assertThat(result.getApplication())
      .isNotNull()
      .isEqualTo(TestEnv.getApplication());
}
 
Example #16
Source File: AlcoholStepDefs.java    From demo with MIT License 5 votes vote down vote up
@Then("I get the following results:")
public void iGetTheFollowingResults(DataTable expectedData) {
    final Map<String, String> data = expectedData.asMaps().get(0);
    AlcoholResult expectedResult = new AlcoholResult(
            Double.parseDouble(data.get("total food price")),
            Double.parseDouble(data.get("total alcohol price")),
            Double.parseDouble(data.get("food ratio")));
    Assert.assertEquals(alcoholResult, expectedResult);
}
 
Example #17
Source File: AddDeleteListSearchBooksAndBorrowersStepDefs.java    From demo with MIT License 4 votes vote down vote up
@Then("the system reports an error indicating that the borrower is already registered")
public void the_system_reports_an_error_indicating_that_the_borrower_is_already_registered() {
    assertEquals(LibraryActionResults.ALREADY_REGISTERED_BORROWER, libraryActionResults);
}
 
Example #18
Source File: AddDeleteListSearchBooksAndBorrowersStepDefs.java    From demo with MIT License 4 votes vote down vote up
@Then("the loan is deleted as well")
public void theLoanIsDeletedAsWell() {
    final Loan loan = libraryUtils.searchForLoanByBook(myBook);
    Assert.assertTrue(loan.isEmpty());
}
 
Example #19
Source File: AddDeleteListSearchBooksAndBorrowersStepDefs.java    From demo with MIT License 4 votes vote down vote up
@Then("the whole list of books is returned")
public void the_whole_list_of_books_is_returned() {
    final List<Book> expectedBooks = generateListOfBooks(new String[]{"a", "b", "c"});
    assertEquals(expectedBooks, allBooks);
}
 
Example #20
Source File: LoginStepDefs.java    From demo with MIT License 4 votes vote down vote up
@Then("^The system decides that they are not authenticated, because .*$")
public void theSystemDecidesThatTheyAreNotAuthenticated() {
    Assert.assertFalse(isRegisteredUser);
}
 
Example #21
Source File: BookCheckOutStepDefs.java    From demo with MIT License 4 votes vote down vote up
@Then("^the system indicates the book is loaned to them on that date$")
public void theSystemIndicatesTheBookIsLoanedToThemOnThatDate() {
    final Loan loan = libraryUtils.searchForLoanByBook(myBook);
    Assert.assertEquals(Date.valueOf("2018-01-31"), loan.checkoutDate);
}
 
Example #22
Source File: AddDeleteListSearchBooksAndBorrowersStepDefs.java    From demo with MIT License 4 votes vote down vote up
@Then("the whole list of borrowers is returned")
public void the_whole_list_of_borrowers_is_returned() {
    final List<Borrower> expectedBorrowers = generateListOfBorrowers(new String[]{"a", "b", "c"});
    assertEquals(expectedBorrowers, allBorrowers);
}
 
Example #23
Source File: CommonSteps.java    From realworld-serverless-application with Apache License 2.0 4 votes vote down vote up
@Then("^the call should fail because of bad request$")
public void the_call_should_fail_because_of_bad_request() {
  assertThat(TestEnv.getLastException())
        .isNotNull()
        .isInstanceOf(BadRequestException.class);
}
 
Example #24
Source File: TopicFeature.java    From hedera-mirror-node with Apache License 2.0 4 votes vote down vote up
@Then("I unsubscribe from a topic")
public void verifyUnSubscribeFromChannelConnection() {
    mirrorClient.unSubscribeFromTopic(subscriptionResponse.getSubscription());
}
 
Example #25
Source File: AccountFeature.java    From hedera-mirror-node with Apache License 2.0 4 votes vote down vote up
@Then("the result should be greater than or equal to {long}")
public void isGreaterOrEqualThan(long threshold) {
    assertTrue(balance >= threshold);
}
 
Example #26
Source File: OrderStepdefs.java    From exchange-core with Apache License 2.0 4 votes vote down vote up
@Then("An {symbol} order book is:")
public void an_order_book_is(CoreSymbolSpecification symbol, L2MarketDataHelper orderBook) {
    assertEquals(orderBook.build(), container.requestCurrentOrderBook(symbol.symbolId));
}
 
Example #27
Source File: BookCheckOutStepDefs.java    From demo with MIT License 4 votes vote down vote up
@Then("they cannot borrow it because it is already checked out")
public void they_cannot_borrow_it_because_it_is_already_checked_out() {
    Assert.assertEquals(LibraryActionResults.BOOK_CHECKED_OUT, libraryActionResults);
}
 
Example #28
Source File: UpdateApplicationSteps.java    From realworld-serverless-application with Apache License 2.0 4 votes vote down vote up
@Then("^the call should fail because there is no update$")
public void the_call_should_fail_because_there_is_no_update() {
  assertThat(TestEnv.getLastException())
        .isNotNull()
        .isInstanceOf(BadRequestException.class);
}
 
Example #29
Source File: CommonSteps.java    From realworld-serverless-application with Apache License 2.0 4 votes vote down vote up
@Then("^the call should fail because of access denied$")
public void the_call_should_fail_because_of_access_denied() {
  assertThat(TestEnv.getLastException())
        .isNotNull()
        .isInstanceOf(UnauthorizedException.class);
}
 
Example #30
Source File: AddDeleteListSearchBooksAndBorrowersStepDefs.java    From demo with MIT License 4 votes vote down vote up
@Then("the system reports that there are no borrowers with that id")
public void the_system_reports_that_there_are_no_borrowers_with_that_id() {
    Assert.assertTrue(myBorrower.isEmpty());
}