use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class PercentageBasedMissionHealthCheckEvaluatorTest method testBurnInThresholdsAreWorkingWhenPreparationStepsAreUsed.
@ParameterizedTest
@MethodSource("countdownEvaluatorProvider")
void testBurnInThresholdsAreWorkingWhenPreparationStepsAreUsed(final int burnInCount, final int countdownFailure, final int countdownComplete, final int failureCount, final boolean expectedCountdownAbort) {
// given
final MissionHealthCheckMatcher anyClass = mock(MissionHealthCheckMatcher.class);
final PercentageBasedMissionHealthCheckEvaluator underTest = PercentageBasedMissionHealthCheckEvaluator.builder(anyClass, new MissionStatisticsCollector(anyClass)).abortThreshold(1).burnInTestCount(burnInCount).build();
// when
IntStream.range(0, countdownFailure).parallel().forEach(i -> underTest.countdownLogger().logAndIncrement(failure()));
IntStream.range(0, failureCount).parallel().forEach(i -> underTest.missionLogger().logAndIncrement(failure()));
IntStream.range(0, countdownComplete).parallel().forEach(i -> underTest.countdownLogger().logAndIncrement(success()));
final boolean actual = underTest.shouldAbortCountdown();
// then
assertEquals(expectedCountdownAbort, actual);
assertEquals(burnInCount, underTest.getBurnInTestCount());
}
use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class PercentageBasedMissionHealthCheckEvaluatorTest method testShouldAbortCountdownShouldNotCallInternalMethodWhenDisarmed.
@Test
void testShouldAbortCountdownShouldNotCallInternalMethodWhenDisarmed() {
// given
final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
final PercentageBasedMissionHealthCheckEvaluator underTest = spy(PercentageBasedMissionHealthCheckEvaluator.builder(matcher, new MissionStatisticsCollector(matcher)).abortThreshold(1).build());
doReturn(true).when(underTest).isDisarmed(eq(ABORT_MISSION_DISARM_COUNTDOWN));
// when
underTest.shouldAbortCountdown();
// then
verify(underTest, never()).shouldAbortCountdownInternal();
}
use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class ReportOnlyMissionHealthCheckEvaluatorTest method testShouldAbortShouldAlwaysReturnFalseWhenCalled.
@ParameterizedTest
@MethodSource("launchEvaluatorProvider")
void testShouldAbortShouldAlwaysReturnFalseWhenCalled(final int countdownComplete, final int failureCount, final int successCount) {
// given
final MissionHealthCheckMatcher anyClass = mock(MissionHealthCheckMatcher.class);
final ReportOnlyMissionHealthCheckEvaluator underTest = MissionControl.reportOnlyEvaluator(anyClass).build();
// when
IntStream.range(0, failureCount).parallel().forEach(i -> underTest.missionLogger().logAndIncrement(with(StageResult.FAILURE)));
IntStream.range(0, successCount).parallel().forEach(i -> underTest.missionLogger().logAndIncrement(with(StageResult.SUCCESS)));
IntStream.range(0, countdownComplete).parallel().forEach(i -> underTest.countdownLogger().logAndIncrement(with(StageResult.SUCCESS)));
final boolean actual = underTest.shouldAbort();
// then
assertFalse(actual);
}
use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class ReportOnlyMissionHealthCheckEvaluatorTest method testShouldAbortCountdownShouldAlwaysReturnFalseWhenCalled.
@ParameterizedTest
@MethodSource("countdownEvaluatorProvider")
void testShouldAbortCountdownShouldAlwaysReturnFalseWhenCalled(final int countdownFailure, final int countdownComplete, final int failureCount) {
// given
final MissionHealthCheckMatcher anyClass = mock(MissionHealthCheckMatcher.class);
final ReportOnlyMissionHealthCheckEvaluator underTest = MissionControl.reportOnlyEvaluator(anyClass).build();
// when
IntStream.range(0, countdownFailure).parallel().forEach(i -> underTest.countdownLogger().logAndIncrement(with(StageResult.FAILURE)));
IntStream.range(0, failureCount).parallel().forEach(i -> underTest.missionLogger().logAndIncrement(with(StageResult.FAILURE)));
IntStream.range(0, countdownComplete).parallel().forEach(i -> underTest.countdownLogger().logAndIncrement(with(StageResult.SUCCESS)));
final boolean actual = underTest.shouldAbortCountdown();
// then
assertFalse(actual);
}
use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class ClassMatcherTest method testMatchesShouldMatchFullyQualifiedClassNameToRegexpWhenCalledWithClass.
@ParameterizedTest
@MethodSource("inputProvider")
void testMatchesShouldMatchFullyQualifiedClassNameToRegexpWhenCalledWithClass(final boolean matches, final String pattern) {
// given
final MissionHealthCheckMatcher underTest = MissionHealthCheckMatcherBuilder.builder().classNamePattern(pattern).build();
// when
final boolean actual = underTest.matches(this.getClass());
// then
assertEquals(matches, actual);
}
Aggregations