### Question:
SystemProperty { @SuppressWarnings("unchecked") public T getValue() { final T value = (T) FROM_STRING.get(getConverterClass()).apply(JiveGlobals.getProperty(key), this); if (value == null || (Collection.class.isAssignableFrom(value.getClass()) && ((Collection) value).isEmpty())) { return defaultValue; } if (minValue != null && ((Comparable) minValue).compareTo(value) > 0) { LOGGER.warn("Configured value of {} is less than the minimum value of {} for the SystemProperty {} - will use default value of {} instead", value, minValue, key, defaultValue); return defaultValue; } if (maxValue != null && ((Comparable) maxValue).compareTo(value) < 0) { LOGGER.warn("Configured value of {} is more than the maximum value of {} for the SystemProperty {} - will use default value of {} instead", value, maxValue, key, defaultValue); return defaultValue; } return value; } private  SystemProperty(final Builder<T> builder); static Collection<SystemProperty> getProperties(); @SuppressWarnings("WeakerAccess") static void removePropertiesForPlugin(final String plugin); static Optional<SystemProperty> getProperty(final String key); @SuppressWarnings("unchecked") T getValue(); String getValueAsSaved(); String getDisplayValue(); boolean hasValueChanged(); String getDefaultDisplayValue(); void setValue(final T value); String getPlugin(); boolean isDynamic(); boolean isEncrypted(); boolean isRestartRequired(); void addListener(final Consumer<T> listener); void removeListener(final Consumer<T> listener); String getKey(); String getDescription(); T getDefaultValue();  }### Answer:
@Test public void willNotReturnAnotherClass() { final SystemProperty<Class> classProperty = SystemProperty.Builder.ofType(Class.class) .setKey("another-subclass-property") .setDefaultValue(DefaultAuthProvider.class) .setBaseClass(AuthProvider.class) .setDynamic(false) .build(); JiveGlobals.setProperty("another-subclass-property", "java.lang.Object"); assertThat(classProperty.getValue(), is(equalTo(DefaultAuthProvider.class))); }
@Test public void willNotReturnAMissingClass() { final SystemProperty<Class> classProperty = SystemProperty.Builder.ofType(Class.class) .setKey("a-missing-subclass-property") .setDefaultValue(DefaultAuthProvider.class) .setBaseClass(AuthProvider.class) .setDynamic(false) .build(); JiveGlobals.setProperty("a-missing-subclass-property", "this.class.is.missing"); assertThat(classProperty.getValue(), is(equalTo(DefaultAuthProvider.class))); }
@Test public void willCreateAnInstantPropertyWithADefaultValue() { final String key = "test.instant.property.with.default"; final Instant defaultValue = Instant.now().truncatedTo(ChronoUnit.MILLIS); final SystemProperty<Instant> property = SystemProperty.Builder.ofType(Instant.class) .setKey(key) .setDefaultValue(defaultValue) .setDynamic(true) .build(); assertThat(property.getValue(), is(defaultValue)); }
@Test public void willReturnNullForInvalidJID() { final String jidString = "@test-domain"; final String key = "an invalid jid property"; final SystemProperty<JID> property = SystemProperty.Builder.ofType(JID.class) .setKey(key) .setDynamic(true) .build(); assertThat(property.getValue(),is(nullValue())); JiveGlobals.setProperty(key, jidString); assertThat(property.getValue(),is(nullValue())); }