package de.zalando.toga.provider; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import java.io.File; import java.util.HashMap; import java.util.Map; import static java.util.regex.Pattern.compile; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; public class ProviderRuleGenerationTest { @Rule public ExampleProviderRule rule = new ExampleProviderRule(new File("src/test/resources/generator/string/single_string_in.json"), new File("target/providerTest"), compile("single_string")); private static Map<String, Integer> counts = new HashMap<>(); @BeforeClass public static void setup() { counts.clear(); } @Test public void shouldIterate() { String example = rule.getExampleJson(); Integer count = counts.containsKey(example) ? counts.get(example) : 0; counts.put(example, count + 1); } @AfterClass public static void countResults() { int sum = counts.values().stream().mapToInt(Integer::intValue).sum(); assertThat(sum, is(4)); } }