JpaUtils { public static String nativeEventsTableName(final StreamId streamId) { if (streamId instanceof JpaStreamId) { final JpaStreamId jpaId = (JpaStreamId) streamId; return jpaId.getNativeTableName(); } if (streamId.isProjection()) { return camel2Underscore(streamId.getName()); } if (streamId.getParameters().size() == 0) { return NoParamsEvent.NO_PARAMS_EVENTS_TABLE; } return camel2Underscore(streamId.getName()) + "_events"; } private  JpaUtils(); static String streamEntityName(final StreamId streamId); static String nativeEventsTableName(final StreamId streamId); static String camel2Underscore(@Nullable final String name);  }
@Test public void testNativeEventsTableNameJpaStreamId() { final String entityName = "MyTable"; final String nativeTableName = "any_name"; final StreamId streamId = new SimpleJpaStreamId(entityName, nativeTableName); final String result = JpaUtils.nativeEventsTableName(streamId); assertThat(result).isEqualTo(nativeTableName); }
@Test public void testNativeEventsTableNameProjection() { final String entityName = "MyOwn"; final StreamId streamId = new ProjectionStreamId(entityName); final String result = JpaUtils.nativeEventsTableName(streamId); assertThat(result).isEqualTo("my_own"); }
@Test public void testNativeEventsTableNameWithArgs() { final String entityName = "Customer"; final StreamId streamId = new AggregateStreamId(entityName, "customerId", UUID.randomUUID().toString()); final String result = JpaUtils.nativeEventsTableName(streamId); assertThat(result).isEqualTo("customer_events"); }
@Test public void testNativeEventsTableNameNoArgs() { final String entityName = "MyOwn"; final StreamId streamId = new SimpleStreamId(entityName); final String result = JpaUtils.nativeEventsTableName(streamId); assertThat(result).isEqualTo(NoParamsEvent.NO_PARAMS_EVENTS_TABLE); }