SQLParams implements LogParam { @Override public void append(StringBuilder builder, Set<String> maskedFields, int maxParamLength) { if (params == null) { builder.append("null"); } else { builder.append('['); int length = params.length; for (int i = 0; i < length; i++) { if (i > 0) builder.append(", "); builder.append(value(params[i], mapper)); } builder.append(']'); } } SQLParams(EnumDBMapper mapper, Object... params); @Override void append(StringBuilder builder, Set<String> maskedFields, int maxParamLength);  }
@Test void appendWithEnum() { var mapper = new EnumDBMapper(); mapper.registerEnumClass(TestEnum.class); var params = new SQLParams(mapper, "String", 1, TestEnum.V2, LocalDate.of(2018, 6, 1)); var builder = new StringBuilder(); params.append(builder, Set.of(), 1000); assertThat(builder.toString()) .isEqualTo("[String, 1, DB_V2, 2018-06-01]"); }
@Test void appendWithUnregisteredEnum() { var params = new SQLParams(new EnumDBMapper(), TestEnum.V1); var builder = new StringBuilder(); params.append(builder, Set.of(), 1000); assertThat(builder.toString()) .isEqualTo("[V1]"); }
@Test void appendWithEmpty() { var params = new SQLParams(null); var builder = new StringBuilder(); params.append(builder, Set.of(), 1000); assertThat(builder.toString()).isEqualTo("[]"); }
@Test void appendWithNull() { var params = new SQLParams(null, (Object[]) null); var builder = new StringBuilder(); params.append(builder, Set.of(), 1000); assertThat(builder.toString()) .isEqualTo("null"); }