use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class NotMatcherTest method testMatchesShouldNegateWrappedMatcherWhenCalledWithValidComponent.
@ParameterizedTest
@MethodSource("inputProvider")
void testMatchesShouldNegateWrappedMatcherWhenCalledWithValidComponent(final boolean matches, final String dependency) {
// given
final MissionHealthCheckMatcher underTest = MissionHealthCheckMatcherBuilder.builder().not(STRING_MATCHER).build();
// when
final boolean actual = underTest.matches(dependency);
// then
assertEquals(matches, actual);
}
use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class OrMatcherTest method testMatchesRequiresOnlyOneOperandToMatchWhenCalled.
@ParameterizedTest
@MethodSource("inputProvider")
void testMatchesRequiresOnlyOneOperandToMatchWhenCalled(final boolean matches, final Collection<String> operands) {
// given
final MissionHealthCheckMatcherBuilder builder = (MissionHealthCheckMatcherBuilder) builder();
for (final String regex : operands) {
builder.or(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 SystemPropertyMatcherTest method testMatchesShouldWorkRegardlessOfTheInput.
@ParameterizedTest
@MethodSource("validInputProvider")
void testMatchesShouldWorkRegardlessOfTheInput(final String envName, final String regex, final Object component, final boolean expected) {
// given
final MissionHealthCheckMatcher underTest = MissionHealthCheckMatcherBuilder.builder().envVariable(envName).valuePattern(regex).build();
assertTrue(underTest instanceof EnvironmentMatcher);
// when
final boolean actual = underTest.matches(component);
// then
assertEquals(expected, actual);
}
use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class PercentageBasedMissionHealthCheckEvaluatorTest method testAbortThresholdShouldThrowExceptionWhenCalledWithInvalidValue.
@ParameterizedTest
@ValueSource(ints = { -2, -1, 100, 101 })
void testAbortThresholdShouldThrowExceptionWhenCalledWithInvalidValue(final int input) {
// given
final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
// when
assertThrows(IllegalArgumentException.class, () -> {
PercentageBasedMissionHealthCheckEvaluator.builder(matcher, new MissionStatisticsCollector(matcher)).abortThreshold(input);
});
// then exception
}
use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class PercentageBasedMissionHealthCheckEvaluatorTest method testShouldAbortShouldNotCallInternalMethodWhenDisarmed.
@Test
void testShouldAbortShouldNotCallInternalMethodWhenDisarmed() {
// 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_MISSION));
// when
underTest.shouldAbort();
// then
verify(underTest, never()).shouldAbortInternal();
}
Aggregations