JpaUtils { public static String streamEntityName(final StreamId streamId) { if (streamId instanceof JpaStreamId) { final JpaStreamId jpaId = (JpaStreamId) streamId; return jpaId.getEntityName(); } if (streamId.isProjection()) { return streamId.getName(); } if (streamId.getParameters().size() == 0) { return NoParamsStream.class.getSimpleName(); } return streamId.getName() + "Stream"; } private  JpaUtils(); static String streamEntityName(final StreamId streamId); static String nativeEventsTableName(final StreamId streamId); static String camel2Underscore(@Nullable final String name);  }
@Test public void testStreamEntityNameJpaStreamId() { final String entityName = "MyEntity"; final String nativeTableName = "any_name"; final StreamId streamId = new SimpleJpaStreamId(entityName, nativeTableName); final String result = JpaUtils.streamEntityName(streamId); assertThat(result).isEqualTo(entityName); }
@Test public void testStreamEntityNameProjection() { final String entityName = "MyProjection"; final StreamId streamId = new ProjectionStreamId(entityName); final String result = JpaUtils.streamEntityName(streamId); assertThat(result).isEqualTo(entityName); }
@Test public void testStreamEntityNameWithArgs() { final String entityName = "Customer"; final StreamId streamId = new AggregateStreamId(entityName, "customerId", UUID.randomUUID().toString()); final String result = JpaUtils.streamEntityName(streamId); assertThat(result).isEqualTo(entityName + "Stream"); }
@Test public void testStreamEntityNameNoArgs() { final String entityName = "MyOwn"; final StreamId streamId = new SimpleStreamId(entityName); final String result = JpaUtils.streamEntityName(streamId); assertThat(result).isEqualTo(NoParamsStream.class.getSimpleName()); }