QuickFixJConfigResourceCondition extends ResourceCondition { @Override protected ConditionOutcome getResourceOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { if (System.getProperty(configSystemProperty) != null) { return ConditionOutcome.match(startConditionMessage() .because("System property '" + configSystemProperty + "' is set.")); } return super.getResourceOutcome(context, metadata); } QuickFixJConfigResourceCondition(String configSystemProperty, String prefix, String propertyName, String... resourceLocations);   }
@Test public void testGetResourceOutcomeForSystemProperty() { System.setProperty("anyProperty", "anyValue"); QuickFixJConfigResourceCondition resourceCondition = new ClientConfigAvailableCondition("anyProperty"); ConditionOutcome conditionOutcome = resourceCondition.getResourceOutcome(mock(ConditionContext.class), mock(AnnotatedTypeMetadata.class)); assertThat(conditionOutcome).isNotNull(); assertThat(conditionOutcome.getMessage()).contains("ResourceCondition (quickfixj.client) System property 'anyProperty' is set."); }
@Test public void testGetResourceOutcomeForSystemPropertyNotSet() { QuickFixJConfigResourceCondition resourceCondition = new ClientConfigAvailableCondition("any"); ConditionContext context = mock(ConditionContext.class); AnnotatedTypeMetadata metadata = mock(AnnotatedTypeMetadata.class); ConditionOutcome conditionOutcome = resourceCondition.getResourceOutcome(context, metadata); assertThat(conditionOutcome).isNotNull(); assertThat(conditionOutcome.getMessage()).contains("ResourceCondition (quickfixj.client) did not find resource"); }