@Test public void shouldTreatKeyAndValueParametersInterchangeablyForDefaultValues() { String obtainedFromSystemPropertyViaValue = service.produceStringSystemProperty( mockInjectionPoint(TEST_PROPERTY, "foo")); String obtainedFromSystemPropertyViaKey = service.produceStringSystemProperty( mockInjectionPoint(TEST_PROPERTY, NOT_SET, "foo")); assertThat(obtainedFromSystemPropertyViaKey).isEqualTo("foo"); assertThat(obtainedFromSystemPropertyViaValue).isEqualTo("foo"); }
@Produces @SystemProperty public String produceStringSystemProperty(InjectionPoint ip) { SystemProperty configAnnotation = getConfigAnnotation(ip); String propertyName = getPropertyKeyName(configAnnotation); String propertyValue = System.getProperty(propertyName, getDefaultValue(configAnnotation)); if (propertyValue == null) { throw new RuntimeException(format("Required system property '%s' is not set.", propertyName)); } return propertyValue; }
SystemPropertyProducer { @Produces @SystemProperty public String produceStringSystemProperty(InjectionPoint ip) { SystemProperty configAnnotation = getConfigAnnotation(ip); String propertyName = getPropertyKeyName(configAnnotation); String propertyValue = System.getProperty(propertyName, getDefaultValue(configAnnotation)); if (propertyValue == null) { throw new RuntimeException(format("Required system property '%s' is not set.", propertyName)); } return propertyValue; } }
SystemPropertyProducer { @Produces @SystemProperty public String produceStringSystemProperty(InjectionPoint ip) { SystemProperty configAnnotation = getConfigAnnotation(ip); String propertyName = getPropertyKeyName(configAnnotation); String propertyValue = System.getProperty(propertyName, getDefaultValue(configAnnotation)); if (propertyValue == null) { throw new RuntimeException(format("Required system property '%s' is not set.", propertyName)); } return propertyValue; }  }
SystemPropertyProducer { @Produces @SystemProperty public String produceStringSystemProperty(InjectionPoint ip) { SystemProperty configAnnotation = getConfigAnnotation(ip); String propertyName = getPropertyKeyName(configAnnotation); String propertyValue = System.getProperty(propertyName, getDefaultValue(configAnnotation)); if (propertyValue == null) { throw new RuntimeException(format("Required system property '%s' is not set.", propertyName)); } return propertyValue; }  @Produces @SystemProperty String produceStringSystemProperty(InjectionPoint ip); @Produces @SystemProperty Boolean produceBooleanSystemProperty(InjectionPoint ip); @Produces @SystemProperty Integer produceIntegerSystemProperty(InjectionPoint ip); @Produces @SystemProperty Double produceDoubleSystemProperty(InjectionPoint ip); @Produces @SystemProperty BigDecimal produceBigDecimalSystemProperty(InjectionPoint ip); }
SystemPropertyProducer { @Produces @SystemProperty public String produceStringSystemProperty(InjectionPoint ip) { SystemProperty configAnnotation = getConfigAnnotation(ip); String propertyName = getPropertyKeyName(configAnnotation); String propertyValue = System.getProperty(propertyName, getDefaultValue(configAnnotation)); if (propertyValue == null) { throw new RuntimeException(format("Required system property '%s' is not set.", propertyName)); } return propertyValue; }  @Produces @SystemProperty String produceStringSystemProperty(InjectionPoint ip); @Produces @SystemProperty Boolean produceBooleanSystemProperty(InjectionPoint ip); @Produces @SystemProperty Integer produceIntegerSystemProperty(InjectionPoint ip); @Produces @SystemProperty Double produceDoubleSystemProperty(InjectionPoint ip); @Produces @SystemProperty BigDecimal produceBigDecimalSystemProperty(InjectionPoint ip);  }