### Question:
StreamUtil { @SuppressWarnings("unchecked") public static Stream<Object> concat(Object... objects) { return Arrays.stream(objects) .flatMap(obj -> { if (obj instanceof Stream) { return (Stream) obj; } else if (obj instanceof Object[]) { return Arrays.stream((Object[]) obj); } else if (obj instanceof Collection) { return ((Collection) obj).stream(); } else { return Stream.of(obj); } }); }  @SuppressWarnings("unchecked") static Stream<Object> concat(Object... objects); static Collector<T, ?, LinkedHashSet<T>> toLinkedHashSet();  }### Answer:
@Test void concat_noArgs_emptyStream() { assertThat(StreamUtil.concat()).isEmpty(); }
@Test void concat_objectsOnly_streamOfArgs() { Object[] args = { 1, null, new Object() }; assertThat(StreamUtil.concat(args)).containsExactly(args); }
@Test void concat_containsStream_flattensStream() { Object[] args = { Stream.of(1, 2, 3), Stream.of(null, "str") }; assertThat(StreamUtil.concat(args)).containsExactly(1, 2, 3, null, "str"); }
@Test void concat_containsObjectArray_flattensArray() { Object[][] args = { { "1", "2" }, { "3", "4" } }; assertThat(StreamUtil.concat((Object[]) args)).containsExactly("1", "2", "3", "4"); }
@Test void concat_containsPrimitiveArray_noFlatten() { int[][] args = { { 1, 2 } }; assertThat(StreamUtil.concat((Object[]) args)).containsExactly((Object) (new int[] { 1, 2 })); }
@Test void concat_containsCollection_flattensCollection() { Object[] args = { Arrays.asList(1, 2), Arrays.asList(3, 4) }; assertThat(StreamUtil.concat(args)).containsExactly(1, 2, 3, 4); }