### Question:
JsonValues { public static JsonValue firstOf(final JsonValue config, final String... names) { if (names != null) { for (final String name : names) { if (config.isDefined(name)) { return config.get(name); } } } return new JsonValue(null); } private  JsonValues(); static Class<?> asClass(JsonValue value); @SuppressWarnings("unchecked") static T asNewInstance(JsonValue value, Class<T> type); static Expression<T> asExpression(JsonValue value, Class<T> expectedType); static String evaluate(JsonValue value); static JsonValue evaluate(final JsonValue value, final Logger logger); static JsonValue evaluateJsonStaticExpression(final JsonValue value); static JsonValue firstOf(final JsonValue config, final String... names); static Function<JsonValue, Expression<String>, HeapException> ofExpression(); static Function<JsonValue, T, HeapException> ofRequiredHeapObject(final Heap heap,
                                                                                 final Class<T> type); static Function<JsonValue, T, HeapException> ofEnum(final Class<T> enumType); static JsonValue getWithDeprecation(JsonValue config, Logger logger, String name,
            String... deprecatedNames); static void warnForDeprecation(final JsonValue config, final Logger logger,
            final String name, final String deprecatedName);  }### Answer:
@Test public void shouldFirstOfReturnsNullWithNullNamesParameter() { JsonValue config = json(object( field("syn3", "plethora"), field("syn2", "overabundance"), field("syn1", "excess"))); assertThat(firstOf(config, (String[]) null).isNull()).isTrue(); }
@Test public void shouldFirstOfSucceed() { JsonValue config = json(object( field("syn3", "plethora"), field("syn2", "overabundance"), field("syn1", "excess"))); assertThat(firstOf(config, "syn1", "syn3").asString()).isEqualTo("excess"); assertThat(firstOf(config, "syn3", "syn1").asString()).isEqualTo("plethora"); }
@Test public void shouldFirstOfSucceedWhenNullFieldInConfig() { JsonValue config = json(object( field("syn3", null), field("syn2", "overabundance"), field("syn1", "excess"))); assertThat(firstOf(config, "syn3", "syn1").isNull()).isTrue(); }
@Test public void shouldFirstOfReturnsNullWhenNoMatch() { JsonValue config = json(object( field("syn3", "plethora"), field("syn2", "overabundance"), field("syn1", "excess"))); assertThat(firstOf(config, "old", "ancient").isNull()).isTrue(); }