use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class PercentageBasedMissionHealthCheckEvaluatorTest method testBurnInThresholdsAreWorkingWhenNoPreparationStepsAreUsed.
@ParameterizedTest
@MethodSource("launchEvaluatorProvider")
void testBurnInThresholdsAreWorkingWhenNoPreparationStepsAreUsed(final int burnInCount, final int countdownComplete, final int failureCount, final int successCount, final boolean expectedCountdownAbort) {
// given
final MissionHealthCheckMatcher anyClass = mock(MissionHealthCheckMatcher.class);
final PercentageBasedMissionHealthCheckEvaluator underTest = PercentageBasedMissionHealthCheckEvaluator.builder(anyClass, new MissionStatisticsCollector(anyClass)).abortThreshold(ABORT_IF_HALF_FAILED).burnInTestCount(burnInCount).build();
// when
IntStream.range(0, failureCount).parallel().forEach(i -> underTest.missionLogger().logAndIncrement(failure()));
IntStream.range(0, successCount).parallel().forEach(i -> underTest.missionLogger().logAndIncrement(success()));
IntStream.range(0, countdownComplete).parallel().forEach(i -> underTest.countdownLogger().logAndIncrement(success()));
final boolean actual = underTest.shouldAbort();
// then
assertEquals(expectedCountdownAbort, actual);
assertEquals(burnInCount, underTest.getBurnInTestCount());
assertEquals(ABORT_IF_HALF_FAILED, underTest.getAbortThreshold());
}
use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class PercentageBasedMissionHealthCheckEvaluatorTest method testBurnInTestCountShouldThrowExceptionWhenCalledWithInvalidValue.
@ParameterizedTest
@ValueSource(ints = { -2, -1 })
void testBurnInTestCountShouldThrowExceptionWhenCalledWithInvalidValue(final int input) {
// given
final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
// when
assertThrows(IllegalArgumentException.class, () -> PercentageBasedMissionHealthCheckEvaluator.builder(matcher, new MissionStatisticsCollector(matcher)).burnInTestCount(input));
// then exception
}
use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class AndMatcherTest method testMatchesRequiresAllOperandsToMatchWhenCalled.
@ParameterizedTest
@MethodSource("inputProvider")
void testMatchesRequiresAllOperandsToMatchWhenCalled(final boolean matches, final Collection<String> operands) {
// given
final MissionHealthCheckMatcherBuilder builder = (MissionHealthCheckMatcherBuilder) builder();
for (final String regex : operands) {
builder.and(builder().classNamePattern(regex).build());
}
final MissionHealthCheckMatcher underTest = builder.build();
// when
final boolean actual = underTest.matches(this.getClass());
// then
assertEquals(matches, actual);
}
use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class ClassMatcherTest method testMatchesShouldMatchFullyQualifiedClassNameToRegexpWhenCalledWithMethod.
@ParameterizedTest
@MethodSource("inputProvider")
void testMatchesShouldMatchFullyQualifiedClassNameToRegexpWhenCalledWithMethod(final boolean matches, final String pattern) {
// given
final MissionHealthCheckMatcher underTest = MissionHealthCheckMatcherBuilder.builder().classNamePattern(pattern).build();
// when
final boolean actual = underTest.matches(this.getClass().getDeclaredMethods()[0]);
// then
assertEquals(matches, actual);
}
use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class ClassMatcherTest method testMatchesShouldThrowExceptionWhenCalledWithUnsupportedInput.
@ParameterizedTest
@NullSource
@MethodSource("unsupportedComponentProvider")
void testMatchesShouldThrowExceptionWhenCalledWithUnsupportedInput(final Object invalidInput) {
// given
final MissionHealthCheckMatcher underTest = MissionHealthCheckMatcherBuilder.builder().classNamePattern(".*").build();
// when
final boolean actual = underTest.matches(invalidInput);
// then
assertFalse(actual);
}
Aggregations