@SuppressWarnings("unused") @IfProfileValue(name = NAME, values = { "foo", VALUE, "bar" }) private static class EnabledAnnotatedMultiValue { public void nonAnnotatedMethod() { } @IfProfileValue(name = NAME, value = VALUE) public void enabledAnnotatedMethod() { } @IfProfileValue(name = NAME, value = VALUE + "X") public void disabledAnnotatedMethod() { } }
String environmentValue = profileValueSource.get(ifProfileValue.name()); String[] annotatedValues = ifProfileValue.values(); if (StringUtils.hasLength(ifProfileValue.value())) { Assert.isTrue(annotatedValues.length == 0, () -> "Setting both the 'value' and 'values' attributes " + "of @IfProfileValue is not allowed: choose one or the other."); annotatedValues = new String[] { ifProfileValue.value() };
@IfProfileValue(name = NAME, value = VALUE + "X") public void disabledAnnotatedMethod() { } }
String environmentValue = profileValueSource.get(ifProfileValue.name()); String[] annotatedValues = ifProfileValue.values(); if (StringUtils.hasLength(ifProfileValue.value())) { Assert.isTrue(annotatedValues.length == 0, () -> "Setting both the 'value' and 'values' attributes " + "of @IfProfileValue is not allowed: choose one or the other."); annotatedValues = new String[] { ifProfileValue.value() };
@SuppressWarnings("unused") @IfProfileValue(name = NAME, value = VALUE) private static class EnabledAnnotatedSingleValue { public void nonAnnotatedMethod() { } @IfProfileValue(name = NAME, value = VALUE) public void enabledAnnotatedMethod() { } @IfProfileValue(name = NAME, value = VALUE + "X") public void disabledAnnotatedMethod() { } }
String environmentValue = profileValueSource.get(ifProfileValue.name()); String[] annotatedValues = ifProfileValue.values(); if (StringUtils.hasLength(ifProfileValue.value())) { if (annotatedValues.length > 0) { throw new IllegalArgumentException("Setting both the 'value' and 'values' attributes " + "of @IfProfileValue is not allowed: choose one or the other."); annotatedValues = new String[] { ifProfileValue.value() };
@SuppressWarnings("unused") @IfProfileValue(name = NAME, values = { "foo", "bar" }) private static class DisabledAnnotatedMultiValue { public void nonAnnotatedMethod() { } @IfProfileValue(name = NAME, value = VALUE) public void enabledAnnotatedMethod() { } @IfProfileValue(name = NAME, value = VALUE + "X") public void disabledAnnotatedMethod() { } }
@IfProfileValue(name = NAME, value = VALUE + "X") public void disabledAnnotatedMethod() { } }
@IfProfileValue(name = NAME, value = "42") private static class EnabledWithCustomProfileValueSourceOnTestInterface implements CustomProfileValueSourceTestInterface { }
@SuppressWarnings("unused") @IfProfileValue(name = NAME, value = VALUE + "X") private static class DisabledAnnotatedSingleValue { public void nonAnnotatedMethod() { } @IfProfileValue(name = NAME, value = VALUE) public void enabledAnnotatedMethod() { } @IfProfileValue(name = NAME, value = VALUE + "X") public void disabledAnnotatedMethod() { } }
@IfProfileValue(name = NAME, value = VALUE) public void enabledAnnotatedMethod() { }
@IfProfileValue(name = NAME, value = VALUE + "X") public void disabledAnnotatedMethod() { } }
@IfProfileValue(name = NAME, value = VALUE + "X") public void disabledAnnotatedMethod() { } }
@IfProfileValue(name = NAME, value = VALUE + "X") private interface IfProfileValueTestInterface { }
@IfProfileValue(name = NAME, value = VALUE) public void enabledAnnotatedMethod() { }
@IfProfileValue(name = NAME, value = VALUE) public void enabledAnnotatedMethod() { }
@IfProfileValue(name = NAME, value = VALUE) public void enabledAnnotatedMethod() { }
@Test @IfProfileValue(name = NAME, value = VALUE) public void testIfProfileValueEnabledViaSingleValue() { numTestsExecuted++; }
@Test @IfProfileValue(name = NAME, values = { "foo", VALUE, "bar" }) public void testIfProfileValueEnabledViaMultipleValues() { numTestsExecuted++; }
@Test @IfProfileValue(name = NAME, value = VALUE + "X") public void testIfProfileValueDisabled() { numTestsExecuted++; fail("The body of a disabled test should never be executed!"); }