public static SuggestBuilder randomSuggestBuilder() { SuggestBuilder builder = new SuggestBuilder(); if (randomBoolean()) { builder.setGlobalText(randomAsciiOfLengthBetween(1, 20)); } final int numSuggestions = randomIntBetween(1, 5); for (int i = 0; i < numSuggestions; i++) { builder.addSuggestion(randomAsciiOfLengthBetween(5, 10), randomSuggestionBuilder()); } return builder; }
@Override protected SuggestBuilder createMutation(SuggestBuilder original) throws IOException { SuggestBuilder mutation = new SuggestBuilder().setGlobalText(original.getGlobalText()); for (Entry<String, SuggestionBuilder<?>> suggestionBuilder : original.getSuggestions().entrySet()) { mutation.addSuggestion(suggestionBuilder.getKey(), suggestionBuilder.getValue()); } if (randomBoolean()) { mutation.setGlobalText(randomAsciiOfLengthBetween(5, 60)); } else { mutation.addSuggestion( randomAsciiOfLength(10), PhraseSuggestionBuilderTests.randomPhraseSuggestionBuilder()); } return mutation; }