JpaUtils { public static String camel2Underscore(@Nullable final String name) { if (name == null) { return null; } return name.replaceAll("(.)(\\p{Upper})", "$1_$2").toLowerCase(); } private  JpaUtils(); static String streamEntityName(final StreamId streamId); static String nativeEventsTableName(final StreamId streamId); static String camel2Underscore(@Nullable final String name);  }
@Test public void testCamelCaseToUnderscore() { assertThat(JpaUtils.camel2Underscore(null)).isEqualTo(null); assertThat(JpaUtils.camel2Underscore("")).isEqualTo(""); assertThat(JpaUtils.camel2Underscore("a")).isEqualTo("a"); assertThat(JpaUtils.camel2Underscore("ab")).isEqualTo("ab"); assertThat(JpaUtils.camel2Underscore("A")).isEqualTo("a"); assertThat(JpaUtils.camel2Underscore("AB")).isEqualTo("a_b"); assertThat(JpaUtils.camel2Underscore("Ab")).isEqualTo("ab"); assertThat(JpaUtils.camel2Underscore("aB")).isEqualTo("a_b"); assertThat(JpaUtils.camel2Underscore("aBcDeF")).isEqualTo("a_bc_de_f"); }