How to use locations method of com.galenframework.tests.parser.ExpectationsTest class

Best Galen code snippet using com.galenframework.tests.parser.ExpectationsTest.locations

Source:ExpectationsTest.java Github

copy

Full Screen

...195 row("top left bottom ", sides(Side.TOP, Side.LEFT, Side.BOTTOM))196 };197 }198 199 @Test(dataProvider = "locationsTestData")200 public void expectLocations(TestData<List<Location>> testData) {201 StringCharReader stringCharReader = new StringCharReader(testData.textForParsing);202 List<Location> sides = new ExpectLocations().read(stringCharReader);203 204 Location[] expected = testData.expected.toArray(new Location[testData.expected.size()]);205 assertThat(sides.size(), is(expected.length));206 assertThat(sides, contains(expected));207 }208 209 @DataProvider210 public Object[][] locationsTestData() {211 return new Object[][]{212 row("10 px left right, 10 to 20 px top bottom", locations(new Location(Range.exact(10), sides(Side.LEFT, Side.RIGHT)), new Location(Range.between(10, 20), sides(Side.TOP, Side.BOTTOM)))),213 row("10 px left, 10 to 20 px top bottom, 30px right", locations(new Location(Range.exact(10), sides(Side.LEFT)),214 new Location(Range.between(10, 20), sides(Side.TOP, Side.BOTTOM)),215 new Location(Range.exact(30), sides(Side.RIGHT)))),216 row(" 10 px left right , 10 to 20 px top bottom ", locations(new Location(Range.exact(10), sides(Side.LEFT, Side.RIGHT)), new Location(Range.between(10, 20), sides(Side.TOP, Side.BOTTOM)))),217 row("\t10 px left right\t,\t10 to 20 px\ttop\tbottom \t \t \t", locations(new Location(Range.exact(10), sides(Side.LEFT, Side.RIGHT)), new Location(Range.between(10, 20), sides(Side.TOP, Side.BOTTOM)))),218 };219 }220 221 @Test(dataProvider = "provideBadLocations")222 public void shouldGiveError_forIncorrectLocations(String text, String expectedErrorMessage) {223 StringCharReader stringCharReader = new StringCharReader(text);224 225 SyntaxException exception = null;226 try {227 new ExpectLocations().read(stringCharReader);228 }229 catch (SyntaxException e) {230 exception = e;231 }232 233 assertThat("Exception should be", exception, is(notNullValue()));234 assertThat("Exception message should be", exception.getMessage(), is(expectedErrorMessage));235 }236 237 @DataProvider238 public Object[][] provideBadLocations() {239 return new Object[][]{240 {"left", "Cannot parse range value: \"\""},241 {"10px qwe", "Unknown side: \"qwe\""},242 {"10 to 30px qwe", "Unknown side: \"qwe\""},243 {"10 to 30% of screen/width qwe", "Unknown side: \"qwe\""},244 {"10px left qwe", "Unknown side: \"qwe\""},245 {"10px left, 20px qwe", "Unknown side: \"qwe\""},246 {"10px left, 20px left qwe", "Unknown side: \"qwe\""},247 {"10px left, right, top", "Cannot parse range value: \"\""},248 };249 }250 @Test251 public void shouldParse_commaSeparatedKeyValue() {252 String text = ",param1 1, param2 v a l u e 2, booleanParam, param3 2.3, param1 2";253 List<Pair<String, String>> params = new ExpectCommaSeparatedKeyValue().read(new StringCharReader(text));254 assertThat(params.size(), is(5));255 assertThat(params.get(0).getKey(), is("param1"));256 assertThat(params.get(0).getValue(), is("1"));257 assertThat(params.get(1).getKey(), is("param2"));258 assertThat(params.get(1).getValue(), is("v a l u e 2"));259 assertThat(params.get(2).getKey(), is("booleanParam"));260 assertThat(params.get(2).getValue(), is(""));261 assertThat(params.get(3).getKey(), is("param3"));262 assertThat(params.get(3).getValue(), is("2.3"));263 assertThat(params.get(4).getKey(), is("param1"));264 assertThat(params.get(4).getValue(), is("2"));265 }266 @Test267 public void shouldParse_commaSeparatedKeyValue_2() {268 String text = "param1 1, param2 2";269 List<Pair<String, String>> params = new ExpectCommaSeparatedKeyValue().read(new StringCharReader(text));270 assertThat(params.size(), is(2));271 assertThat(params.get(0).getKey(), is("param1"));272 assertThat(params.get(0).getValue(), is("1"));273 assertThat(params.get(1).getKey(), is("param2"));274 assertThat(params.get(1).getValue(), is("2"));275 }276 277 278 private List<Location> locations(Location...locations) {279 return Arrays.asList(locations);280 }281 private List<Side> sides(Side...sides) {282 return Arrays.asList(sides);283 }284 private <T> Object[] row(String textForParsing, T expectedRange) {285 return new Object[]{new TestData<>(textForParsing, expectedRange)};286 }287 private class TestData<T> {288 private String textForParsing;289 private T expected;290 291 public TestData(String textForParsing, T expected) {292 this.textForParsing = textForParsing;293 this.expected = expected;...

Full Screen

Full Screen

locations

Using AI Code Generation

copy

Full Screen

1def locations = com.galenframework.tests.parser.ExpectationsTest.locations()2def locations = com.galenframework.tests.parser.ExpectationsTest.locations()3def locations = com.galenframework.tests.parser.ExpectationsTest.locations()4def locations = com.galenframework.tests.parser.ExpectationsTest.locations()5def locations = com.galenframework.tests.parser.ExpectationsTest.locations()6def locations = com.galenframework.tests.parser.ExpectationsTest.locations()7def locations = com.galenframework.tests.parser.ExpectationsTest.locations()8def locations = com.galenframework.tests.parser.ExpectationsTest.locations()9def locations = com.galenframework.tests.parser.ExpectationsTest.locations()10def locations = com.galenframework.tests.parser.ExpectationsTest.locations()11def locations = com.galenframework.tests.parser.ExpectationsTest.locations()12def locations = com.galenframework.tests.parser.ExpectationsTest.locations()

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful