github.com/jaylevin/jenkins-library@v1.230.4/integration/testdata/TestGaugeIntegration/gauge-java/src/test/java/StepImplementation.java (about) 1 import com.thoughtworks.gauge.Step; 2 import com.thoughtworks.gauge.Table; 3 import com.thoughtworks.gauge.TableRow; 4 5 import java.util.HashSet; 6 7 import static org.assertj.core.api.Assertions.assertThat; 8 9 public class StepImplementation { 10 11 private HashSet<Character> vowels; 12 13 @Step("Vowels in English language are <vowelString>.") 14 public void setLanguageVowels(String vowelString) { 15 vowels = new HashSet<>(); 16 for (char ch : vowelString.toCharArray()) { 17 vowels.add(ch); 18 } 19 } 20 21 @Step("The word <word> has <expectedCount> vowels.") 22 public void verifyVowelsCountInWord(String word, int expectedCount) { 23 int actualCount = countVowels(word); 24 assertThat(expectedCount).isEqualTo(actualCount); 25 } 26 27 @Step("Almost all words have vowels <wordsTable>") 28 public void verifyVowelsCountInMultipleWords(Table wordsTable) { 29 for (TableRow row : wordsTable.getTableRows()) { 30 String word = row.getCell("Word"); 31 int expectedCount = Integer.parseInt(row.getCell("Vowel Count")); 32 int actualCount = countVowels(word); 33 34 assertThat(expectedCount).isEqualTo(actualCount); 35 } 36 } 37 38 private int countVowels(String word) { 39 int count = 0; 40 for (char ch : word.toCharArray()) { 41 if (vowels.contains(ch)) { 42 count++; 43 } 44 } 45 return count; 46 } 47 }