@ParameterizedTest @EnumSource(StatsdFlavor.class) void counterLineProtocol(StatsdFlavor flavor) { String line = null; switch (flavor) { case Etsy: line = "myCounter.myTag.val.statistic.count:2|c"; break; case Datadog: line = "my.counter:2|c|#statistic:count,my.tag:val"; break; case Telegraf: line = "my_counter,statistic=count,my_tag=val:2|c"; } assertLines(r -> r.counter("my.counter", "my.tag", "val").increment(2.1), flavor, line); }
@ParameterizedTest @EnumSource(StatsdFlavor.class) void gaugeLineProtocol(StatsdFlavor flavor) { String line = null; switch (flavor) { case Etsy: line = "myGauge.myTag.val.statistic.value:2|g"; break; case Datadog: line = "my.gauge:2|g|#statistic:value,my.tag:val"; break; case Telegraf: line = "my_gauge,statistic=value,my_tag=val:2|g"; break; } Integer n = 2; assertLines(r -> r.gauge("my.gauge", Tags.zip("my.tag", "val"), n), flavor, line); }
@ParameterizedTest @EnumSource(StatsdFlavor.class) void timerLineProtocol(StatsdFlavor flavor) { String line = null; switch (flavor) { case Etsy: line = "myTimer.myTag.val:1|ms"; break; case Datadog: line = "my.timer:1|ms|#my.tag:val"; break; case Telegraf: line = "my_timer,my_tag=val:1|ms"; } assertLines(r -> r.timer("my.timer", "my.tag", "val").record(1, TimeUnit.MILLISECONDS), flavor, line); }
@ParameterizedTest @EnumSource(StatsdFlavor.class) void summaryLineProtocol(StatsdFlavor flavor) { String line = null; switch (flavor) { case Etsy: line = "mySummary.myTag.val:1|h"; break; case Datadog: line = "my.summary:1|h|#my.tag:val"; break; case Telegraf: line = "my_summary,my_tag=val:1|h"; } assertLines(r -> r.summary("my.summary", "my.tag", "val").record(1), flavor, line); }
@ParameterizedTest @EnumSource(TimeUnit.class) void testWithExplicitArgumentConversion( @ConvertWith(CustomArgumentsConverter.class) String argument) { System.out.println("Argument " + argument + " is a type of " + argument.getClass()); assertNotNull(argument); }
@ParameterizedTest @EnumSource(value = TimeUnit.class, names = { "DAYS", "HOURS" }) void testWithFilteredEnum(TimeUnit argument) { System.out.println("Parameterized test with some (TimeUnit) argument: " + argument); assertNotNull(argument); }
@ParameterizedTest @EnumSource(value = TimeUnit.class, mode = EXCLUDE, names = { "DAYS", "HOURS" }) void testWithExcludeEnum(TimeUnit argument) { System.out.println( "Parameterized test with excluded (TimeUnit) argument: " + argument); assertNotNull(argument); }
@ParameterizedTest @EnumSource(value = TimeUnit.class, mode = MATCH_ALL, names = "^(M|N).+SECONDS$") void testWithRegexEnum(TimeUnit argument) { System.out.println( "Parameterized test with regex filtered (TimeUnit) argument: " + argument); assertNotNull(argument); }
@ParameterizedTest @EnumSource(TimeUnit.class) void testWithEnum(TimeUnit argument) { System.out.println( "Parameterized test with (TimeUnit) argument: " + argument); assertNotNull(argument); }
@ParameterizedTest @EnumSource(QueryType.class) void allQueriesShouldHandleNullValueForUnary(final QueryType queryType) { final DatabaseValidation validation = new DatabaseValidation(context, queries.get(queryType)); final ValidationResult result = validation.validate(getValidUnaryWithNulls()); assertThat(result.isValid()).isTrue(); }
@ParameterizedTest @EnumSource(QueryType.class) void allQueriesShouldSkipTupleWithNullGivenNary(final QueryType queryType) { final DatabaseValidation validation = new DatabaseValidation(context, queries.get(queryType)); final ValidationResult result = validation.validate(getValidNaryWithNulls()); assertThat(result.isValid()).isTrue(); }
@ParameterizedTest @EnumSource(StatsdFlavor.class) void longTaskTimerLineProtocol(StatsdFlavor flavor) { final Function<MeterRegistry, LongTaskTimer> ltt = r -> r.more().longTaskTimer("my.long.task", "my.tag", "val"); StepVerifier .withVirtualTime(() -> { String[] lines = null; switch (flavor) { case Etsy: lines = new String[]{ "myLongTask.myTag.val.statistic.activetasks:1|c", "myLongTaskDuration.myTag.val.statistic.value:1|c", }; break; case Datadog: lines = new String[]{ "my.long.task:1|c|#statistic:activetasks,myTag:val", "my.long.task:1|c|#statistic:duration,myTag:val", }; break; case Telegraf: lines = new String[]{ "myLongTask,statistic=activetasks,myTag=val:1|c", "myLongTask,statistic=duration,myTag=val:1|c", }; } assertLines(r -> ltt.apply(r).start(), flavor, lines); return null; }) .then(() -> mockClock.add(10, TimeUnit.MILLISECONDS)) .thenAwait(Duration.ofMillis(10)); }
@DisplayName("Command without params should be called with non null DeviceParams object") @ParameterizedTest(name = "Command is {0}") @EnumSource(DeviceParamsProducingCommand.class) void commandsEmptyParamsNonNullResult(DeviceParamsProducingCommand source) throws Exception { DevicesParams value = runDeviceParamsTest(source, ""); assertNotNull(value); }
@DisplayName("Command without params should be called with an empty DeviceParams object") @ParameterizedTest(name = "Command is {0}") @EnumSource(DeviceParamsProducingCommand.class) void commandsEmptyParamsNullableFields(DeviceParamsProducingCommand source) throws Exception { DevicesParams value = runDeviceParamsTest(source, ""); assertNull(value.getAbi()); assertNull(value.getNameFilterDescription()); assertNull(value.getProviderFilterDescription()); assertNull(value.getSerialFilterDescription()); assertEquals(0, value.getApiVersion()); assertEquals(0, value.getMaxApiVersion()); assertEquals(0, value.getMinApiVersion()); assertEquals(0, value.getCount()); assertFalse(value.isAllDevices()); }
@DisplayName("test_abi is parsed in command") @ParameterizedTest(name = "Command is {0}") @EnumSource(DeviceParamsProducingCommand.class) void testReadAbiFromValidString(DeviceParamsProducingCommand source) throws Exception { DevicesParams params = runDeviceParamsTest(source, "-abi test_abi"); assertEquals("test_abi", params.getAbi()); }
@DisplayName("test_abi is parsed in command") @ParameterizedTest(name = "Command is {0}") @EnumSource(DeviceParamsProducingCommand.class) void testAllDevicesEnabledByFlag(DeviceParamsProducingCommand source) throws Exception { DevicesParams params = runDeviceParamsTest(source, "--all"); assertTrue(params.isAllDevices()); }
@DisplayName("Unspecified api in command will set it to 0") @ParameterizedTest(name = "Command is {0}") @EnumSource(DeviceParamsProducingCommand.class) void testApiVersionIsZeroInUnrelatedString(DeviceParamsProducingCommand source) throws Exception { DevicesParams devicesParams = runDeviceParamsTest(source, ""); assertEquals(0, devicesParams.getApiVersion()); }
@DisplayName("Specified api in command will set it up") @ParameterizedTest(name = "Command is {0}") @EnumSource(DeviceParamsProducingCommand.class) void testApiVersionIsValidInParameter(DeviceParamsProducingCommand source) throws Exception { DevicesParams params = runDeviceParamsTest(source, "-api 19"); assertEquals(19, params.getApiVersion()); }
@DisplayName("Min api = 19 is parsed in command") @ParameterizedTest(name = "Command is {0}") @EnumSource(DeviceParamsProducingCommand.class) void testMinApiVersionIsValidInParameter(DeviceParamsProducingCommand source) throws Exception { DevicesParams params = runDeviceParamsTest(source, "-minApi 19"); assertEquals(19, params.getMinApiVersion()); }
@DisplayName("Max api = 19 is parsed in command") @ParameterizedTest(name = "Command is {0}") @EnumSource(DeviceParamsProducingCommand.class) void testMaxApiVersionIsValidInParameter(DeviceParamsProducingCommand source) throws Exception { DevicesParams params = runDeviceParamsTest(source, "-maxApi 19"); assertEquals(19, params.getMaxApiVersion()); }
@DisplayName("Count = 10 is parsed in command") @ParameterizedTest(name = "Command is {0}") @EnumSource(DeviceParamsProducingCommand.class) void testCountPropertyIsValid(DeviceParamsProducingCommand source) throws Exception { DevicesParams params = runDeviceParamsTest(source, "-count 10"); assertEquals(10, params.getCount()); }
@DisplayName("Name = name is parsed in command") @ParameterizedTest(name = "Command is {0}") @EnumSource(DeviceParamsProducingCommand.class) void testNamePropertyIsValid(DeviceParamsProducingCommand source) throws Exception { DevicesParams deviceParams = runDeviceParamsTest(source, "-name name"); StringsFilterDescription description = deviceParams.getNameFilterDescription(); assertLinesMatch(singletonList("name"), description.getTemplates()); }
@DisplayName("Name = name1,name2 is parsed in command") @ParameterizedTest(name = "Command is {0}") @EnumSource(DeviceParamsProducingCommand.class) void testFewNamesPropertyIsValid(DeviceParamsProducingCommand source) throws Exception { DevicesParams deviceParams = runDeviceParamsTest(source, "-name name1,name2"); StringsFilterDescription description = deviceParams.getNameFilterDescription(); assertLinesMatch(asList("name1", "name2"), description.getTemplates()); }
@DisplayName("Provider = p1 is parsed in command") @ParameterizedTest(name = "Command is {0}") @EnumSource(DeviceParamsProducingCommand.class) void testProviderDescriptionNotNullWithParameter(DeviceParamsProducingCommand source) throws Exception { DevicesParams params = runDeviceParamsTest(source, "-provider p1"); assertNotNull(params.getProviderFilterDescription()); }
@DisplayName("Serial = serial1,serial2 is parsed in command") @ParameterizedTest(name = "Command is {0}") @EnumSource(DeviceParamsProducingCommand.class) void testSerialNumberDescriptionNotNullWithParameter(DeviceParamsProducingCommand source) throws IOException, UnknownCommandException { DevicesParams params = runDeviceParamsTest(source, "-serial serial1,serial2"); assertNotNull(params.getSerialFilterDescription()); }
@ParameterizedTest @EnumSource(Color.Preset.class) void testPresets(Color.Preset preset) { Color color = Color.of(preset); assertValid(color); assertTrue(color.isPreset()); assertThat(color.asPreset(), is(equalTo(preset))); }
@ParameterizedTest @EnumSource(Color.Preset.class) void testPresetStrings(Color.Preset preset) { Color color = Color.of(preset.toString()); assertValid(color); assertTrue(color.isPreset()); assertThat(color.asPreset(), is(equalTo(preset))); }
@DisplayName("Max api = not_a_number is failed to be parsed in command") @ParameterizedTest(name = "Command is {0}") @EnumSource(DeviceParamsProducingCommand.class) void testExceptionIsThrownWhenApiIsInvalid(DeviceParamsProducingCommand source) throws Exception { assertThrows(ParameterException.class, test(source, "-api not_a_number")); }
@DisplayName("Count = not_a_number is failed to be parsed in command") @ParameterizedTest(name = "Command is {0}") @EnumSource(DeviceParamsProducingCommand.class) void testInvalidCountPropertyThrowsAnException(DeviceParamsProducingCommand source) throws Exception { assertThrows(ParameterException.class, test(source, "-count not_a_number")); }
@DisplayName("Void count is failed to be parsed in command") @ParameterizedTest(name = "Command is {0}") @EnumSource(DeviceParamsProducingCommand.class) void testVoidCountPropertyThrowsAnException(DeviceParamsProducingCommand source) throws Exception { assertThrows(Exception.class, test(source, "-count -l")); }
@DisplayName("Void name is null in command") @ParameterizedTest(name = "Command is {0}") @EnumSource(DeviceParamsProducingCommand.class) void testVoidNameThrowsAnException(DeviceParamsProducingCommand source) throws Exception { assertThrows(Exception.class, test(source, "-n")); }
@ParameterizedTest @EnumSource(ParseMode.class) void testParseModeToString(ParseMode parseMode) { assertTrue(isLowerCase(parseMode.toString())); }
@ParameterizedTest @EnumSource(ParseMode.class) void testOfCaseInsensitive(ParseMode parseMode) { assertThat(ParseMode.of(parseMode.toString().toUpperCase()), is(equalTo(parseMode))); }
@ParameterizedTest @EnumSource(Abilities.class) void isMappedBySc2ApiAbilityId(Ability ability) { assertThat(Abilities.from(ability.toSc2Api())).as("ability mapped from ability id").isEqualTo(ability); }
@ParameterizedTest @EnumSource(Effects.class) void isMappedBySc2ApiEffectId(Effect effect) { assertThat(Effects.from(effect.getEffectId())).as("effect mapped from effect id").isEqualTo(effect); }