cucumber.api.DataTable Java Examples
The following examples show how to use
cucumber.api.DataTable.
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: PreparationStep.java From data-prep with Apache License 2.0 | 6 votes |
@Then("^The preparation \"(.*)\" should have the following invalid characteristics on the row number \"(.*)\":$") public void thePreparationShouldHaveThefollowingInvalidCells(String preparationName, String columnNumber, DataTable dataTable) throws Exception { Response response = api.getPreparationContent(context.getPreparationId(suffixName(preparationName)), VERSION_HEAD, HEAD_ID, StringUtils.EMPTY); response.then().statusCode(OK.value()); DatasetContent datasetContent = response.as(DatasetContent.class); final Map<String, String> parameters = dataTable.asMap(String.class, String.class); String invalidCells = parameters.get("invalidCells"); HashMap values = (HashMap<String, String>) datasetContent.records.get(Integer.parseInt(columnNumber)); if (!invalidCells.equals(StringUtils.EMPTY)) { assertEquals(invalidCells, values.get(TDP_INVALID_MARKER)); } else { // there is no invalid cell assertNull(values.get(TDP_INVALID_MARKER)); } }
Example #2
Source File: PreparationStep.java From data-prep with Apache License 2.0 | 6 votes |
/** * Check if an existing preparation contains the same actions as the one given in parameters. * Be careful ! If your preparation contains lookup actions, you'll need to load your dataset by restoring a Mongo * dump, else the lookup_ds_id won't be the same in actions' parameter value. * * @param dataTable step parameters. * @throws IOException in case of exception. */ @Given("^A preparation with the following parameters exists :$") public void checkPreparation(DataTable dataTable) throws IOException { Map<String, String> params = dataTable.asMap(String.class, String.class); String suffixedPrepName = getSuffixedPrepName(params.get(PREPARATION_NAME)); String prepPath = util.extractPathFromFullName(params.get(PREPARATION_NAME)); String prepId = context.getPreparationId(suffixedPrepName, prepPath); PreparationDetails prepDet = getPreparationDetails(prepId); Assert.assertNotNull(prepDet); assertEquals(prepDet.dataSetId, context.getDatasetId(suffixName(params.get(DATASET_NAME)))); assertEquals(Integer.toString(prepDet.steps.size() - 1), params.get(NB_STEPS)); if (params.get("actionsList") != null) { List<Action> actionsList = prepDet.actions; checkActionsListOfPrepa(actionsList, params.get("actionsList").toString()); } }
Example #3
Source File: CukeUtils.java From objectlabkit with Apache License 2.0 | 6 votes |
private static <T> String convertToString(final List<T> actualRowValues, final List<String> propertiesToCompare) { final List<List<Object>> rawRows = new ArrayList<>(); rawRows.add(propertiesToCompare.stream().collect(Collectors.toList())); for (final T actualRow : actualRowValues) { final BeanWrapper src = new BeanWrapperImpl(actualRow); rawRows.add(propertiesToCompare.stream().map(p -> { final Object propertyValue = src.getPropertyValue(p); if (propertyValue == null) { return ""; } else if (src.getPropertyTypeDescriptor(p).getObjectType().isAssignableFrom(BigDecimal.class)) { return ((BigDecimal) propertyValue).stripTrailingZeros().toPlainString(); } return propertyValue; }).collect(Collectors.toList())); } return DataTable.create(rawRows).toString(); }
Example #4
Source File: TableServiceTest.java From senbot with MIT License | 6 votes |
@Test public void testCompareTable_rowIncludeAndIgnore() throws Throwable { seleniumNavigationService.navigate_to_url(MockReferenceDatePopulator.TABLE_TEST_PAGE_URL); WebElement table = seleniumElementService.translateLocatorToWebElement("Table locator"); List<List<String>> expectedRows = new ArrayList<List<String>>(); final List<String> row3 = Arrays.asList(new String[]{"Table cell 5", "Table cell 6"}); expectedRows = new ArrayList<List<String>>() { { add(row3); } }; DataTable expectedContent = mock(DataTable.class); when(expectedContent.raw()).thenReturn(expectedRows); ExpectedTableDefinition expectedTableDefinition = new ExpectedTableDefinition(expectedContent); expectedTableDefinition.getIncludeOnlyRowsMatching().add(By.className("odd")); expectedTableDefinition.getIgnoreRowsMatching().add(By.id("row1")); seleniumTableService.compareTable(expectedTableDefinition, table); }
Example #5
Source File: ThenSpec.java From Decision with Apache License 2.0 | 6 votes |
@Then("^the stream '(.*?)' has this columns \\(with name and type\\):$") public void assertStreamColumns(String streamName, DataTable data) throws StratioEngineOperationException { commonspec.getLogger().info("Verifying stream columns"); List<ColumnNameTypeValue> columns = commonspec.getStratioStreamingAPI() .columnsFromStream(streamName); List<ColumnNameTypeValue> expectedColumns = new ArrayList<ColumnNameTypeValue>(); for (List<String> row : data.raw()) { ColumnNameTypeValue expectedCol = new ColumnNameTypeValue( row.get(0), ColumnType.valueOf(row.get(1).toUpperCase()), null); expectedColumns.add(expectedCol); } assertThat(commonspec.getStratioStreamingAPI().columnsFromStream(streamName)) .as("Unexpected column count at stream " + streamName).hasSize(data.raw().size()); assertThat(columns).as("Unexpected columns at stream " + streamName).isEqualTo(expectedColumns); }
Example #6
Source File: WhenSpec.java From Decision with Apache License 2.0 | 6 votes |
@When("^I insert into a stream with name '(.*?)' this data:$") public void insertData( @Transform(NullableStringConverter.class) String streamName, DataTable table) { commonspec.getLogger().info("Inserting into stream {}", streamName); List<ColumnNameValue> streamData = new ArrayList<ColumnNameValue>(); for (List<String> row : table.raw()) { ColumnNameValue columnValue = new ColumnNameValue(row.get(0), row.get(1)); streamData.add(columnValue); } try { commonspec.getStratioStreamingAPI().insertData(streamName, streamData); } catch (Exception e) { commonspec.getExceptions().add(e); commonspec .getLogger() .info("Caught an exception whilst inserting data into the stream {} : {}", streamName, e); } }
Example #7
Source File: PreparationStep.java From data-prep with Apache License 2.0 | 6 votes |
@Then("^The preparation \"(.*)\" should have the following quality bar characteristics on the column number \"(.*)\":$") public void thePreparationShouldHaveThefollowingQualityBar(String preparationName, String columnNumber, DataTable dataTable) throws Exception { Response response = api.getPreparationContent(context.getPreparationId(suffixName(preparationName)), VERSION_HEAD, HEAD_ID, StringUtils.EMPTY); response.then().statusCode(OK.value()); DatasetContent datasetContent = response.as(DatasetContent.class); final Map<String, String> parameters = dataTable.asMap(String.class, String.class); Integer validExpected = Integer.parseInt(parameters.get(VALID_CELL)); Integer invalidExpected = Integer.parseInt(parameters.get(INVALID_CELL)); Integer emptyExpected = Integer.parseInt(parameters.get(EMPTY_CELL)); ContentMetadataColumn columnMetadata = datasetContent.metadata.columns.get(Integer.parseInt(columnNumber)); assertEquals(validExpected, columnMetadata.quality.get(VALID_CELL)); assertEquals(invalidExpected, columnMetadata.quality.get(INVALID_CELL)); assertEquals(emptyExpected, columnMetadata.quality.get(EMPTY_CELL)); }
Example #8
Source File: ActionStep.java From data-prep with Apache License 2.0 | 6 votes |
@Given("^I update the first action with name \"(.*)\" on the preparation \"(.*)\" with the following parameters :$") public void updateFirstActionFoundWithName(String actionName, String prepName, DataTable dataTable) throws IOException { Map<String, String> params = dataTable.asMap(String.class, String.class); String prepId = context.getPreparationId(suffixName(prepName)); Action foundAction = getFirstActionWithName(prepId, actionName); assertTrue("No action with name \"" + actionName + "\" on the preparation named \"" + prepName + "\".", foundAction != null); // Update action Action action = new Action(); action.action = actionName; action.id = foundAction.id; action.parameters = new HashMap<>(foundAction.parameters); action.parameters.putAll(util.mapParamsToActionParameters(params)); Response response = api.updateAction(prepId, action.id, action); response.then().statusCode(200); }
Example #9
Source File: BasicUcitsSteps.java From objectlabkit with Apache License 2.0 | 6 votes |
@Given("^an existing portfolio for affiliate \"(.*?)\" and partyCode \"(.*?)\" and currency \"(.*?)\" like$") public void existingPortfolioImport(final String affiliateCode, final String partyCode, final String ccy, final DataTable dataTable) throws Throwable { portfolio = new BasicPortfolio(); portfolio.setAffiliateCode(affiliateCode); portfolio.setPartyCode(partyCode); portfolio.setPortfolioCcy(ccy); final List<BasicLine> details = dataTable.asList(BasicLine.class); final List<ExistingPortfolioLine> lines = new ArrayList<>(); lines.addAll(details); portfolio.setLines(lines); portfolio.setPortfolioValue(lines.stream().map(t -> t.getValueInPortfolioCcy()).reduce(BigDecimal.ZERO, (a, b) -> b != null ? a.add(b) : a)); }
Example #10
Source File: TableServiceTest.java From senbot with MIT License | 6 votes |
@Test public void testCompareTable_rowIgnore() throws Throwable { seleniumNavigationService.navigate_to_url(MockReferenceDatePopulator.TABLE_TEST_PAGE_URL); WebElement table = seleniumElementService.translateLocatorToWebElement("Table locator"); List<List<String>> expectedRows = new ArrayList<List<String>>(); final List<String> row1 = Arrays.asList(new String[]{"Table cell 1", "Table cell 2"}); final List<String> row3 = Arrays.asList(new String[]{"Table cell 5", "Table cell 6"}); expectedRows = new ArrayList<List<String>>() { { add(row1); add(row3); } }; DataTable expectedContent = mock(DataTable.class); when(expectedContent.raw()).thenReturn(expectedRows); ExpectedTableDefinition expectedTableDefinition = new ExpectedTableDefinition(expectedContent); expectedTableDefinition.getIgnoreRowsMatching().add(By.className("even")); expectedTableDefinition.getIgnoreRowsMatching().add(By.id("headerRow")); seleniumTableService.compareTable(expectedTableDefinition, table); }
Example #11
Source File: StepDefinitions.java From blog with MIT License | 6 votes |
@Given("^L'entrepôt contient les Personnes suivantes$") public void l_entrepôt_contient_les_Personnes_suivantes(DataTable expected) throws Throwable { givenPersonSize = personRepositoryToTest.count(); // L'entrepôt contient les Personnes suivantes List<PersonModel> actual = personRepositoryToTest.readAll(); for (final PersonModel exp : expected.asList(PersonModel.class)) { assertThat(actual).haveExactly(1, new Condition<PersonModel>() { @Override public boolean matches(PersonModel act) { return act.getId().equals(exp.getId()) // && act.getPrenom().equals(exp.getPrenom()) // && act.getNom().equals(exp.getNom()) // && act.getNaissance().equals(exp.getNaissance()); } }); } }
Example #12
Source File: StepDefSupport.java From servicecomb-pack with Apache License 2.0 | 6 votes |
protected void dataMatches(String address, DataTable dataTable, Consumer<Map<String, String>[]> dataProcessor, boolean checkOrder) { List<Map<String, String>> expectedMaps = dataTable.asMaps(String.class, String.class); List<Map<String, String>> actualMaps = new ArrayList<>(); await().atMost(10, SECONDS).until(() -> { actualMaps.clear(); Collections.addAll(actualMaps, retrieveDataMaps(address, dataProcessor)); // write the log if the Map size is not same boolean result = expectedMaps.size() == actualMaps.size(); if (!result) { LOG.warn("The response message size is not we expected. ExpectedMap size is {}, ActualMap size is {}", expectedMaps.size(), actualMaps.size()); } return expectedMaps.size() == actualMaps.size(); }); if (expectedMaps.isEmpty() && actualMaps.isEmpty()) { return; } LOG.info("Retrieved data {} from service", actualMaps); if (checkOrder) { dataTable.diff(DataTable.create(actualMaps)); } else { dataTable.unorderedDiff(DataTable.create(actualMaps)); } }
Example #13
Source File: PackStepdefs.java From servicecomb-pack with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private void dataMatches(String address, DataTable dataTable, Consumer<Map<String, String>[]> dataProcessor) { List<Map<String, String>> expectedMaps = dataTable.asMaps(String.class, String.class); List<Map<String, String>> actualMaps = new ArrayList<>(); await().atMost(5, SECONDS).until(() -> { actualMaps.clear(); Collections.addAll(actualMaps, retrieveDataMaps(address, dataProcessor)); // write the log if the Map size is not same boolean result = expectedMaps.size() == actualMaps.size(); if (!result) { LOG.warn("The response message size is not we expected. ExpectedMap size is {}, ActualMap size is {}", expectedMaps.size(), actualMaps.size()); } return expectedMaps.size() == actualMaps.size(); }); if (expectedMaps.isEmpty() && actualMaps.isEmpty()) { return; } LOG.info("Retrieved data {} from service", actualMaps); dataTable.diff(DataTable.create(actualMaps)); }
Example #14
Source File: ApiSteps.java From akita with Apache License 2.0 | 6 votes |
/** * В json строке, сохраннённой в переменной, происходит поиск значений по jsonpath из первого столбца таблицы. * Полученные значения сохраняются в переменных. Название переменной указывается во втором столбце таблицы. * Шаг работает со всеми типами json элементов: объекты, массивы, строки, числа, литералы true, false и null. */ @Тогда("^значения из json (?:строки|файла) \"([^\"]*)\", найденные по jsonpath из таблицы, сохранены в переменные$") @Then("^values from json (?:string|file) named \"([^\"]*)\" has been found via jsonpaths from the table and saved to the variables$") public void getValuesFromJsonAsString(String jsonVar, DataTable dataTable) { String strJson = loadValueFromFileOrPropertyOrVariableOrDefault(jsonVar); Gson gsonObject = new Gson(); ReadContext ctx = JsonPath.parse(strJson, createJsonPathConfiguration()); boolean error = false; for (List<String> row : dataTable.raw()) { String jsonPath = row.get(0); String varName = row.get(1); JsonElement jsonElement; try { jsonElement = gsonObject.toJsonTree(ctx.read(jsonPath)); } catch (PathNotFoundException e) { error = true; continue; } akitaScenario.setVar(varName, jsonElement.toString()); akitaScenario.write("JsonPath: " + jsonPath + ", значение: " + jsonElement + ", записано в переменную: " + varName); } if (error) throw new RuntimeException("В json не найдено значение по заданному jsonpath"); }
Example #15
Source File: JsonApiStepsTest.java From akita with Apache License 2.0 | 6 votes |
@Test void shouldGetValuesInJsonAsString() { List<String> row1 = new ArrayList<>(Arrays.asList("$.object2.number", "numberValue")); List<String> row2 = new ArrayList<>(Arrays.asList("$.object2.string", "stringValue")); List<String> row3 = new ArrayList<>(Arrays.asList("$.object2.boolean", "booleanValue")); List<String> row4 = new ArrayList<>(Arrays.asList("$.object2.nullName", "nullValue")); List<List<String>> allLists = new ArrayList<>(); allLists.add(row1); allLists.add(row2); allLists.add(row3); allLists.add(row4); DataTable dataTable = dataTableFromLists(allLists); api.getValuesFromJsonAsString("strJson", dataTable); assertEquals(createJsonElementAndReturnString("0.003"), akitaScenario.getVar("numberValue")); assertEquals(createJsonElementAndReturnString("stringValue"), akitaScenario.getVar("stringValue")); assertEquals(createJsonElementAndReturnString("true"), akitaScenario.getVar("booleanValue")); assertEquals(createJsonElementAndReturnString("null"), akitaScenario.getVar("nullValue")); }
Example #16
Source File: FilterStep.java From data-prep with Apache License 2.0 | 6 votes |
@Then("^The characteristics of the dataset \"(.*)\" match:$") public void checkFilterAppliedOnDataSet(String datasetName, DataTable dataTable) throws Exception { Map<String, String> expected = dataTable.asMap(String.class, String.class); DatasetContent datasetContent = (DatasetContent) context.getObject("dataSetContent"); if (datasetContent == null) { datasetContent = getDatasetContent(context.getDatasetId(suffixName(datasetName)), null); } if (expected.get("records") != null) { checkRecords(datasetContent.records, expected.get("records")); } if (expected.get("sample_records_count") != null) { checkSampleRecordsCount(datasetContent.metadata.records, expected.get("sample_records_count")); } if (expected.get("quality") != null) { checkQualityPerColumn(datasetContent.metadata.columns, expected.get("quality")); } }
Example #17
Source File: WebHome.java From xframium-java with GNU General Public License v3.0 | 6 votes |
@Then( "^I call method one$") public void cucumberMethodOne( WebDriver webDriver, DataTable dT ) { try { System.out.println( "DT: " + dT ); WebHomePage wPage = (WebHomePage) createPage( WebHomePage.class, (DeviceWebDriver) webDriver ); String beforeClick = wPage.getElement( WebHomePage.TOGGLE_VALUE ).getValue(); wPage.getElement( WebHomePage.TOGGLE_BUTTON ).click(); String afterClick = wPage.getElement( WebHomePage.TOGGLE_VALUE ).getValue(); Assert.assertNotEquals( afterClick, beforeClick, "Expected counter to not be equal after click" ); String typeAttribute = wPage.getElement( WebHomePage.TOGGLE_BUTTON ).getAttribute( "type" ); Assert.assertFalse( wPage.getElement( WebHomePage.DELETE_BUTTON ).isVisible(), "Expected DELETE to be invisible"); wPage.getElement( WebHomePage.ACCORDIAN_OPEN ).click(); Assert.assertTrue( wPage.getElement( WebHomePage.DELETE_BUTTON ).waitForVisible( 12, TimeUnit.SECONDS ), "Expected DELETE to be visible" ); if ( dT != null ) { for ( DataTableRow r : dT.getGherkinRows() ) executeStep( "REPORT", WebHomePage.class.getName(), "", new String[] { r.getCells().get( 0 ),r.getCells().get( 1 ) }, (DeviceWebDriver) webDriver, r.getCells().get( 0 ) + " set to " + r.getCells().get( 1 ), null ); } } catch( Exception e ) { e.printStackTrace(); } }
Example #18
Source File: BuyingAndSellingSharesStepDefinitions.java From bdd-trader with Apache License 2.0 | 5 votes |
@Then("^(.*) should have the following positions:$") public void should_have_the_following_positions(String traderName, DataTable expectedPositionTable) { String[] relevantFields = relevantFieldsInTable(expectedPositionTable); List<Position> expectedPositions = expectedPositionTable.asList(Position.class); Actor trader = OnStage.theActorCalled(traderName); Client registeredClient = trader.recall("registeredClient"); List<Position> clientPositons = trader.asksFor(ThePortfolio.positionsForClient(registeredClient)); assertThat(clientPositons) .usingElementComparatorOnFields(relevantFields) .containsAll(expectedPositions); }
Example #19
Source File: AggregateStep.java From data-prep with Apache License 2.0 | 5 votes |
private void aggregationFailed(String preparationName, String dataSetName, DataTable dataTable, int value) throws Exception { Map<String, String> params = new HashMap<>(dataTable.asMap(String.class, String.class)); if (preparationName != null) { params.put(PREPARATION_ID, context.getPreparationId(suffixName(preparationName))); } if (dataSetName != null) { params.put(DATA_SET_ID, context.getDatasetId(suffixName(dataSetName))); } Aggregate aggregate = createAggregate(params); Response response = api.applyAggragate(aggregate); response.then().statusCode(value); }
Example #20
Source File: AggregateStep.java From data-prep with Apache License 2.0 | 5 votes |
@When("^I apply an aggregation \"(.*)\" on the preparation \"(.*)\" with parameters :$") public void applyAnAggregationOnPreparation(String aggregationName, String preparationName, DataTable dataTable) throws Exception { Map<String, String> params = new HashMap<>(dataTable.asMap(String.class, String.class)); params.put(PREPARATION_ID, context.getPreparationId(suffixName(preparationName))); Aggregate aggregate = createAggregate(params); Response response = api.applyAggragate(aggregate); response.then().statusCode(OK.value()); context.storeObject(suffixName(aggregationName), objectMapper.readValue(response.body().print(), new TypeReference<List<AggregateResult>>() { })); }
Example #21
Source File: ActionStep.java From data-prep with Apache License 2.0 | 5 votes |
@Then("^I update the first step like \"(.*)\" on the preparation \"(.*)\" with the following parameters :$") public void updateStep(String stepName, String prepName, DataTable dataTable) throws IOException { Map<String, String> params = dataTable.asMap(String.class, String.class); String prepId = context.getPreparationId(suffixName(prepName)); Action storedAction = context.getAction(stepName); assertTrue("No Action on the step named \"" + stepName + "\" has been retrieve in the context.", storedAction != null); List<Action> actions = getActionsFromStoredAction(prepId, storedAction); assertTrue("Action list on the preparation named \"" + prepName + "\" is empty.", actions.size() > 0); // update stored action parameters storedAction.parameters.putAll(util.mapParamsToActionParameters(params)); storedAction.id = actions.get(0).id; Response response = api.updateAction(prepId, storedAction.id, storedAction); response.then().statusCode(200); }
Example #22
Source File: JsonApiStepsTest.java From akita with Apache License 2.0 | 5 votes |
@Test void shouldGetArray2ValuesInJsonAsString() { List<String> row1 = new ArrayList<>(Arrays.asList("$.object1.array", "array")); List<List<String>> allLists = new ArrayList<>(); allLists.add(row1); DataTable dataTable = dataTableFromLists(allLists); api.getValuesFromJsonAsString("strJson", dataTable); assertEquals(createJsonElementAndReturnString("[\"stringInArray\",0.003,true, false,null]"), akitaScenario.getVar("array")); }
Example #23
Source File: SeleniumTableSteps.java From senbot with MIT License | 5 votes |
@Then("^the table \"(.*)\" should contain the columns$") public void the_table_x_should_contain_columns(String tableDescriptor, DataTable expectedContent) throws Throwable { WebElement table = seleniumElementService.translateLocatorToWebElement(tableDescriptor); ExpectedTableDefinition expected = new ExpectedTableDefinition(expectedContent); expected.setMatchOnlyPassedInColumns(true); seleniumTableService.compareTable(expected, table); }
Example #24
Source File: RedisSteps.java From redisq with MIT License | 5 votes |
@And("^with these values:$") public void with_these_values(DataTable expected) throws Throwable { Map<String, String> actuals = currentCheckedHash; List<List<String>> keyValues = expected.raw(); for (List<String> keyValue : keyValues) { String lookupKey = keyValue.get(0); String expectedValue = keyValue.get(1); assertThat(actuals, hasEntry(lookupKey, expectedValue)); } }
Example #25
Source File: AggregateStep.java From data-prep with Apache License 2.0 | 5 votes |
@Then("^The aggregation \"(.*)\" results with the operator \"(.*)\" is :$") public void testAggregate(String aggregationName, String operator, DataTable dataTable) throws Exception { Map<String, String> params = dataTable.asMap(String.class, String.class); List<AggregateResult> aggregateResults = (List<AggregateResult>) (context.getObject(suffixName(aggregationName))); assertEquals(toAggregateResult(params, operator), aggregateResults); }
Example #26
Source File: AggregateStep.java From data-prep with Apache License 2.0 | 5 votes |
@When("^I apply an aggregation \"(.*)\" on the dataSet \"(.*)\" with parameters :$") public void applyAnAggregationOnDataSet(String aggregationName, String dataSetName, DataTable dataTable) throws Exception { Map<String, String> params = new HashMap<>(dataTable.asMap(String.class, String.class)); params.put(DATA_SET_ID, context.getDatasetId(suffixName(dataSetName))); Aggregate aggregate = createAggregate(params); Response response = api.applyAggragate(aggregate); response.then().statusCode(OK.value()); context.storeObject(suffixName(aggregationName), objectMapper.readValue(response.body().print(), new TypeReference<List<AggregateResult>>() { })); }
Example #27
Source File: FilterStep.java From data-prep with Apache License 2.0 | 5 votes |
@Then("^The characteristics of the preparation \"(.*)\" match:$") public void checkFilterAppliedOnPreparation(String preparationName, DataTable dataTable) throws Exception { PreparationContent preparationContent = (PreparationContent) context.getObject("preparationContent"); if (preparationContent == null) { preparationContent = getPreparationContent(preparationName, null); } checkContent(preparationContent, dataTable); }
Example #28
Source File: GetMessagesMethodStepdefs.java From james-project with Apache License 2.0 | 5 votes |
@Then("^\"([^\"]*)\" should see message \"([^\"]*)\" in mailboxes:$") public void assertMailboxesOfMessage(String user, String messageId, DataTable userMailboxes) throws Exception { userStepdefs.execWithUser(user, () -> postWithAListOfIds(ImmutableList.of(messageId))); List<String> mailboxIds = userMailboxes.asMap(String.class, String.class).entrySet().stream() .map(Throwing.function(userMailbox -> mainStepdefs .getMailboxId(userMailbox.getKey(), userMailbox.getValue()) .serialize())) .distinct() .collect(Guavate.toImmutableList()); assertThat(httpClient.jsonPath.<JSONArray>read(FIRST_MESSAGE + ".mailboxIds")) .containsExactlyInAnyOrder(mailboxIds.toArray()); }
Example #29
Source File: TableServiceTest.java From senbot with MIT License | 5 votes |
@Test public void testCompareTable_withNameSpacing() throws Throwable { seleniumNavigationService.navigate_to_url(MockReferenceDatePopulator.TABLE_NAMESPACE_TEST_PAGE_URL); String unNamespacenizedString = SenBotReferenceService.NAME_SPACE_PREFIX + "Table cell 3"; String namespacenizedString = SenBotContext.getSenBotContext().getReferenceService().namespaceString(unNamespacenizedString); List<List<String>> expectedRows = new ArrayList<List<String>>(); final List<String> header = Arrays.asList(new String[]{"Table header 1", "Table header 2"}); final List<String> row1 = Arrays.asList(new String[]{"Table cell 1", "Table cell 2"}); final List<String> row2 = Arrays.asList(new String[]{unNamespacenizedString, "Table cell 4"}); final List<String> row3 = Arrays.asList(new String[]{"Table cell 5", "Table cell 6"}); expectedRows = new ArrayList<List<String>>() { { add(header); add(row1); add(row2); add(row3); } }; DataTable expectedContent = mock(DataTable.class); when(expectedContent.raw()).thenReturn(expectedRows); ExpectedTableDefinition expectedTableDefinition = new ExpectedTableDefinition(expectedContent); expectedTableDefinition.setMatchOnlyPassedInColumns(true); WebDriver driver = SenBotContext.getSeleniumDriver(); WebElement inputField = driver.findElement(By.id("textField")); inputField.sendKeys(namespacenizedString); seleniumElementService.findExpectedElement(By.xpath(".//*[@id='button']")).click(); WebElement table = driver.findElement(By.id("exampleTable")); seleniumTableService.compareTable(expectedTableDefinition, table); this.toString(); }
Example #30
Source File: GraphGlue.java From vertexium with Apache License 2.0 | 5 votes |
@Given("^parameters are:$") public void givenParametersAre(DataTable parameters) { for (List<String> parameterRow : parameters.raw()) { String key = parameterRow.get(0); String valueString = parameterRow.get(1); Object value = parseParameterValue(valueString); ctx.setParameter(key, value); } }