use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class AbortMissionCommandOpsTest method testRegisterHealthCheckShouldThrowExceptionWhenCalledTwiceWithTheSame.
@Test
void testRegisterHealthCheckShouldThrowExceptionWhenCalledTwiceWithTheSame() {
// given
final AbortMissionCommandOps underTest = AbortMissionCommandOps.newInstance();
final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
final MissionHealthCheckEvaluator evaluator = mock(MissionHealthCheckEvaluator.class);
when(evaluator.getMatcher()).thenReturn(matcher);
// when
underTest.registerHealthCheck(evaluator);
Assertions.assertThrows(IllegalStateException.class, () -> underTest.registerHealthCheck(evaluator));
// then exception
}
use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project yippee-ki-json by nagyesta.
the class MissionOutlineDefinition method defineOutline.
@Override
protected Map<String, Consumer<AbortMissionCommandOps>> defineOutline() {
MissionHealthCheckMatcher integrationTestMatcher = matcher().classNamePattern(".+IntegrationTest").build();
PercentageBasedMissionHealthCheckEvaluator evaluator = percentageBasedEvaluator(integrationTestMatcher).abortThreshold(ABORT_THRESHOLD).build();
ReportOnlyMissionHealthCheckEvaluator noop = reportOnlyEvaluator(matcher().anyClass().build()).build();
return Map.of(MissionOutline.SHARED_CONTEXT, ops -> {
ops.registerHealthCheck(evaluator);
ops.registerHealthCheck(noop);
});
}
use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class MissionOutlineDefinition method callableConfig.
private static void callableConfig(final AbortMissionCommandOps ops) {
final MissionHealthCheckMatcher simpleMatcher = MissionHealthCheckMatcherBuilder.builder().classNamePattern(SimpleCallableMissionTemplateSupportTest.class.getName()).build();
ops.registerHealthCheck(PercentageBasedMissionHealthCheckEvaluator.builder(simpleMatcher, new MissionStatisticsCollector(simpleMatcher)).build());
final MissionHealthCheckMatcher matcher = MissionHealthCheckMatcherBuilder.builder().classNamePattern(CallableMissionTemplateSupportTest.class.getName()).build();
ops.registerHealthCheck(PercentageBasedMissionHealthCheckEvaluator.builder(matcher, new MissionStatisticsCollector(matcher)).build());
}
use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class MissionOutlineDefinition method runnableConfig.
private static void runnableConfig(final AbortMissionCommandOps ops) {
final MissionHealthCheckMatcher simpleMatcher = MissionHealthCheckMatcherBuilder.builder().classNamePattern(SimpleRunnableMissionTemplateSupportTest.class.getName()).build();
ops.registerHealthCheck(PercentageBasedMissionHealthCheckEvaluator.builder(simpleMatcher, new MissionStatisticsCollector(simpleMatcher)).build());
final MissionHealthCheckMatcher matcher = MissionHealthCheckMatcherBuilder.builder().classNamePattern(RunnableMissionTemplateSupportTest.class.getName()).build();
ops.registerHealthCheck(PercentageBasedMissionHealthCheckEvaluator.builder(matcher, new MissionStatisticsCollector(matcher)).build());
}
use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class EnvironmentMatcherTest 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);
}
Aggregations