io.cucumber.java.en.Given Java Examples
The following examples show how to use
io.cucumber.java.en.Given.
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: TopicFeature.java From hedera-mirror-node with Apache License 2.0 | 6 votes |
@Given("I successfully create a new topic id") @Retryable(value = {StatusRuntimeException.class}, exceptionExpression = "#{message.contains('UNAVAILABLE') || " + "message.contains('RESOURCE_EXHAUSTED')}") public void createNewTopic() throws HederaStatusException { testInstantReference = Instant.now(); submitKey = Ed25519PrivateKey.generate(); Ed25519PublicKey submitPublicKey = submitKey.publicKey; log.debug("Topic creation PrivateKey : {}, PublicKey : {}", submitKey, submitPublicKey); TransactionReceipt receipt = topicClient .createTopic(topicClient.getSdkClient().getPayerPublicKey(), submitPublicKey); assertNotNull(receipt); ConsensusTopicId topicId = receipt.getConsensusTopicId(); assertNotNull(topicId); consensusTopicId = topicId; mirrorConsensusTopicQuery = new MirrorConsensusTopicQuery() .setTopicId(consensusTopicId) .setStartTime(Instant.EPOCH); log.debug("Set mirrorConsensusTopicQuery with topic: {}, startTime: {}", consensusTopicId, Instant.EPOCH); }
Example #2
Source File: TopicFeature.java From hedera-mirror-node with Apache License 2.0 | 6 votes |
@Given("I successfully create a new open topic") @Retryable(value = {StatusRuntimeException.class}, exceptionExpression = "#{message.contains('UNAVAILABLE') || " + "message.contains('RESOURCE_EXHAUSTED')}") public void createNewOpenTopic() throws HederaStatusException { testInstantReference = Instant.now(); TransactionReceipt receipt = topicClient .createTopic(topicClient.getSdkClient().getPayerPublicKey(), null); assertNotNull(receipt); ConsensusTopicId topicId = receipt.getConsensusTopicId(); assertNotNull(topicId); consensusTopicId = topicId; mirrorConsensusTopicQuery = new MirrorConsensusTopicQuery() .setTopicId(consensusTopicId) .setStartTime(Instant.EPOCH); log.debug("Set mirrorConsensusTopicQuery with topic: {}, startTime: {}", consensusTopicId, Instant.EPOCH); }
Example #3
Source File: AthenaQuerySteps.java From realworld-serverless-application with Apache License 2.0 | 6 votes |
@Given("^a user has an application$") @When("^(?:a|the) user creates (?:an|another) application$") public void a_user_creates_an_application() { CreateApplicationInput input = new CreateApplicationInput() .applicationId("applicationId-" + UUID.randomUUID().toString()) .author("author-" + UUID.randomUUID().toString()) .description("description-" + UUID.randomUUID().toString()) .homePageUrl("https://github.com/awslabs/" + UUID.randomUUID().toString()); CreateApplicationRequest request = new CreateApplicationRequest() .createApplicationInput(input); Application application = appRepo.createApplication(request).getApplication(); assertThat(TestEnv.getLastException()).isNull(); assertThat(application.getApplicationId()).isEqualTo(input.getApplicationId()); assertThat(application.getAuthor()).isEqualTo(input.getAuthor()); assertThat(application.getDescription()).isEqualTo(input.getDescription()); assertThat(application.getHomePageUrl()).isEqualTo(input.getHomePageUrl()); assertThat(application.getCreationTime()).isNotBlank(); }
Example #4
Source File: OrderStepdefs.java From exchange-core with Apache License 2.0 | 6 votes |
@Given("New client {user} has a balance:") public void newClientAHasABalance(long clientId, List<List<String>> balance) { final List<ApiCommand> cmds = new ArrayList<>(); cmds.add(ApiAddUser.builder().uid(clientId).build()); int transactionId = 0; for (List<String> entry : balance) { transactionId++; cmds.add(ApiAdjustUserBalance.builder().uid(clientId).transactionId(transactionId) .amount(Long.parseLong(entry.get(1))) .currency(TestConstants.getCurrency(entry.get(0))) .build()); } container.getApi().submitCommandsSync(cmds); }
Example #5
Source File: CartesianProductStepDefs.java From demo with MIT License | 6 votes |
@Given("lists as follows:") public void listsAsFollows(DataTable randomLists) { final List<String> oldLists = randomLists.asList(); setOfSets = new HashSet<>(); for (int i = 0; i < oldLists.size(); i++) { StringTokenizer defaultTokenizer = new StringTokenizer(oldLists.get(i)); final Set<String> tempSet = new HashSet<>(); while (defaultTokenizer.hasMoreTokens()) { tempSet.add(defaultTokenizer.nextToken()); } setOfSets.add(tempSet); } }
Example #6
Source File: AddDeleteListSearchBooksAndBorrowersStepDefs.java From demo with MIT License | 5 votes |
@Given("a book, {string}, is currently loaned out") public void aBookIsCurrentlyLoanedOut(String bookTitle) { initializeEmptyDatabaseAndUtility(); libraryUtils.registerBorrower(ALICE); libraryUtils.registerBook(bookTitle); myBookTitle = bookTitle; libraryUtils.lendBook(bookTitle, ALICE, JAN_1ST); }
Example #7
Source File: BookCheckOutStepDefs.java From demo with MIT License | 5 votes |
@Given("a borrower, {string}, has one book, {string}, already borrowed") public void a_borrower_has_one_book_already_borrowed(String borrowerName, String bookTitle) { initializeEmptyDatabaseAndUtility(); myBookTitle = bookTitle; myBorrowerName = borrowerName; libraryUtils.registerBook(myBookTitle); libraryUtils.registerBorrower(borrowerName); libraryUtils.lendBook(bookTitle, borrowerName, JAN_1ST); }
Example #8
Source File: OpenApiSteps.java From yaks with Apache License 2.0 | 5 votes |
@Given("^inbound dictionary$") public void createInboundDictionary(DataTable dataTable) { Map<String, String> mappings = dataTable.asMap(String.class, String.class); for (Map.Entry<String, String> mapping : mappings.entrySet()) { inboundDictionary.getMappings().put(mapping.getKey(), mapping.getValue()); } }
Example #9
Source File: OpenApiSteps.java From yaks with Apache License 2.0 | 5 votes |
@Given("^outbound dictionary$") public void createOutboundDictionary(DataTable dataTable) { Map<String, String> mappings = dataTable.asMap(String.class, String.class); for (Map.Entry<String, String> mapping : mappings.entrySet()) { outboundDictionary.getMappings().put(mapping.getKey(), mapping.getValue()); } }
Example #10
Source File: JmsSteps.java From yaks with Apache License 2.0 | 5 votes |
@Given("^(?:JMS|jms) connection factory$") public void setConnection(DataTable properties) throws ClassNotFoundException { List<List<String>> cells = properties.cells(); Map<String, String> connectionSettings = new LinkedHashMap<>(); cells.forEach(row -> connectionSettings.put(row.get(0), row.get(1))); connectionFactory = ConnectionFactoryCreator.lookup(connectionSettings.get("type")) .create(connectionSettings); }
Example #11
Source File: JdbcSteps.java From yaks with Apache License 2.0 | 5 votes |
@Given("^(?:D|d)ata source: ([^\"\\s]+)$") public void setDataSource(String id) { if (!citrus.getCitrusContext().getReferenceResolver().isResolvable(id)) { throw new CitrusRuntimeException("Unable to find data source for id: " + id); } dataSource = citrus.getCitrusContext().getReferenceResolver().resolve(id, DataSource.class); }
Example #12
Source File: BookCheckOutStepDefs.java From demo with MIT License | 5 votes |
@Given("^and a book, \"([^\"]*)\" is already checked out to \"([^\"]*)\"$") public void andABookIsAlreadyCheckedOutTo(String title, String borrower_b) { libraryUtils.registerBorrower(borrower_b); libraryUtils.registerBook(title); final Book book = libraryUtils.searchForBookByTitle(title); final Borrower borrower = libraryUtils.searchForBorrowerByName(borrower_b); // a previous person already checked it out. libraryUtils.lendBook(book, borrower, JAN_1ST); // now we try to check it out. It should indicate BOOK_CHECKED_OUT. libraryActionResults = libraryUtils.lendBook(book, myBorrower, JAN_2ND); }
Example #13
Source File: OpenApiSteps.java From yaks with Apache License 2.0 | 5 votes |
@Given("^OpenAPI specification: ([^\\s]+)$") @Given("^OpenAPI resource: ([^\\s]+)$") public void loadOpenApiResource(String resource) { if (resource.startsWith("http")) { try { URL url = new URL(resource); if (resource.startsWith("https")) { openApiDoc = OpenApiResourceLoader.fromSecuredWebResource(url); } else { openApiDoc = OpenApiResourceLoader.fromWebResource(url); } clientSteps.setUrl(String.format("%s://%s%s%s", url.getProtocol(), url.getHost(), url.getPort() > 0 ? ":" + url.getPort() : "", OasModelHelper.getBasePath(openApiDoc))); } catch (MalformedURLException e) { throw new IllegalStateException("Failed to retrieve Open API specification as web resource: " + resource, e); } } else { openApiDoc = OpenApiResourceLoader.fromFile(resource); String schemeToUse = Optional.ofNullable(OasModelHelper.getSchemes(openApiDoc)) .orElse(Collections.singletonList("http")) .stream() .filter(s -> s.equals("http") || s.equals("https")) .findFirst() .orElse("http"); clientSteps.setUrl(String.format("%s://%s%s", schemeToUse, OasModelHelper.getHost(openApiDoc), OasModelHelper.getBasePath(openApiDoc))); } }
Example #14
Source File: JmsSteps.java From yaks with Apache License 2.0 | 5 votes |
@Given("^(?:JMS|jms) destination: (.+)$") public void jmsEndpoint(String destination) { jmsEndpoint = new JmsEndpointBuilder() .connectionFactory(connectionFactory) .destination(destination) .build(); }
Example #15
Source File: AddDeleteListSearchBooksAndBorrowersStepDefs.java From demo with MIT License | 5 votes |
@Given("some books are checked out") public void some_books_are_checked_out() { initializeEmptyDatabaseAndUtility(); // register a, b, and c libraryUtils.registerBook("a"); libraryUtils.registerBook("b"); libraryUtils.registerBook("c"); libraryUtils.registerBorrower("someone"); // loan out b libraryUtils.lendBook("b", "someone", JAN_1ST); }
Example #16
Source File: CamelSteps.java From yaks with Apache License 2.0 | 5 votes |
@Given("^New Spring Camel context$") public void camelContext(String beans) { destroyCamelContext(); try { ApplicationContext ctx = new GenericXmlApplicationContext(new ByteArrayResource(beans.getBytes(StandardCharsets.UTF_8))); camelContext = ctx.getBean(SpringCamelContext.class); camelContext.start(); } catch (Exception e) { throw new IllegalStateException("Failed to start Spring Camel context", e); } }
Example #17
Source File: AddDeleteListSearchBooksAndBorrowersStepDefs.java From demo with MIT License | 5 votes |
@Given("a library with the following borrowers registered: a, b, c") public void a_library_with_the_following_borrowers_registered() { initializeEmptyDatabaseAndUtility(); libraryUtils.registerBorrower("a"); libraryUtils.registerBorrower("b"); libraryUtils.registerBorrower("c"); }
Example #18
Source File: CamelKSteps.java From yaks with Apache License 2.0 | 5 votes |
@Given("^new integration with name ([a-z0-9_]+\\.[a-z0-9_]+)$") public void createNewIntegration(String name, String source) throws IOException { runner.run(createIntegration() .client(client()) .integrationName(name) .source(source)); }
Example #19
Source File: RegistrationStepDefs.java From demo with MIT License | 5 votes |
@Given("^a username of \"([^\"]*)\" is registered$") public void aUsernameOfIsRegistered(String username) { initializeDatabaseAccess(); registrationUtils.processRegistration(username, TYPICAL_PASSWORD); Assert.assertTrue(userIsRegistered(username)); myUsername = username; }
Example #20
Source File: HttpClientSteps.java From yaks with Apache License 2.0 | 5 votes |
@Given("^HTTP client \"([^\"\\s]+)\"$") public void setClient(String id) { if (!citrus.getCitrusContext().getReferenceResolver().isResolvable(id)) { throw new CitrusRuntimeException("Unable to find http client for id: " + id); } httpClient = citrus.getCitrusContext().getReferenceResolver().resolve(id, HttpClient.class); }
Example #21
Source File: HttpClientSteps.java From yaks with Apache License 2.0 | 5 votes |
@Given("^(?:URL|url): ([^\\s]+)$") public void setUrl(String url) { if (url.startsWith("https")) { httpClient.getEndpointConfiguration().setRequestFactory(sslRequestFactory()); } this.requestUrl = url; }
Example #22
Source File: RpnCalculatorSteps.java From extentreports-cucumber4-adapter with Apache License 2.0 | 5 votes |
@Given("the previous entries:") public void thePreviousEntries(List<Entry> entries) { for (Entry entry : entries) { calc.push(entry.first); calc.push(entry.second); calc.push(entry.operation); } }
Example #23
Source File: AddDeleteListSearchBooksAndBorrowersStepDefs.java From demo with MIT License | 5 votes |
@Given("a book is loaned to {string}") public void aBookIsLoanedTo(String borrowerName) { myBorrowerName = borrowerName; initializeEmptyDatabaseAndUtility(); libraryUtils.registerBook(DEVOPS_HANDBOOK); libraryUtils.registerBorrower(borrowerName); libraryUtils.lendBook(DEVOPS_HANDBOOK, borrowerName, JAN_2ND); myBook = libraryUtils.searchForBookByTitle(DEVOPS_HANDBOOK); }
Example #24
Source File: HttpClientSteps.java From yaks with Apache License 2.0 | 5 votes |
@Given("^wait for (GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS|TRACE) on (?:URL|url|path) ([^\\s]+) to return (\\d+)(?: [^\\s]+)?$") public void waitForHttpStatusUsingMethod(String method, String urlOrPath, Integer statusCode) { runner.given(Wait.Builder.waitFor().http() .milliseconds(timeout) .method(method) .interval(timeout / 10) .status(statusCode) .url(getRequestUrl(urlOrPath))); }
Example #25
Source File: HttpClientSteps.java From yaks with Apache License 2.0 | 5 votes |
@Given("^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 #26
Source File: TopicFeature.java From hedera-mirror-node with Apache License 2.0 | 5 votes |
@Given("I provide a starting timestamp {string} and ending timestamp {string} and a number of messages {int} I " + "want to receive") public void setTopicListenParams(String startTimestamp, String endTimestamp, int numMessages) { messageSubscribeCount = numMessages; Instant startTime = FeatureInputHandler.messageQueryDateStringToInstant(startTimestamp, testInstantReference); Instant endTime = FeatureInputHandler.messageQueryDateStringToInstant(endTimestamp, Instant.now()); log.trace("Set mirrorConsensusTopicQuery with topic: {}, startTime : {}. endTime : {}", consensusTopicId, startTime, endTime); mirrorConsensusTopicQuery .setStartTime(startTime) .setEndTime(endTime); }
Example #27
Source File: HttpServerSteps.java From yaks with Apache License 2.0 | 5 votes |
@Given("^HTTP server \"([^\"\\s]+)\"$") public void setServer(String id) { if (!citrus.getCitrusContext().getReferenceResolver().isResolvable(id)) { throw new CitrusRuntimeException("Unable to find http server for id: " + id); } httpServer = citrus.getCitrusContext().getReferenceResolver().resolve(id, HttpServer.class); }
Example #28
Source File: TopicFeature.java From hedera-mirror-node with Apache License 2.0 | 5 votes |
@Given("I provide a starting timestamp {string} and a number of messages {int} I want to receive") public void setTopicListenParams(String startTimestamp, int numMessages) { messageSubscribeCount = numMessages; Instant startTime = FeatureInputHandler.messageQueryDateStringToInstant(startTimestamp, testInstantReference); log.debug("Subscribe mirrorConsensusTopicQuery startTime : {}", startTime); mirrorConsensusTopicQuery .setStartTime(startTime); log.debug("Set mirrorConsensusTopicQuery with topic: {}, startTime: {}", consensusTopicId, startTime); }
Example #29
Source File: HttpServerSteps.java From yaks with Apache License 2.0 | 5 votes |
@Given("^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 #30
Source File: TopicFeature.java From hedera-mirror-node with Apache License 2.0 | 5 votes |
@Given("I provide a topic id {string}") public void setTopicIdParam(String topicId) { testInstantReference = Instant.now(); mirrorConsensusTopicQuery = new MirrorConsensusTopicQuery(); Long topicNum = topicId.isEmpty() ? acceptanceProps.getExistingTopicNum() : Long.parseLong(topicId); consensusTopicId = new ConsensusTopicId(0, 0, topicNum); mirrorConsensusTopicQuery .setTopicId(consensusTopicId) .setStartTime(Instant.EPOCH); log.debug("Set mirrorConsensusTopicQuery with topic: {}, StartTime: {}", consensusTopicId, Instant.EPOCH); messageSubscribeCount = 0; }