### Question:
EmbedVersion implements VersionEmbedder { @Inject public EmbedVersion(NodeVersion version) { this(version.getVersion()); } @Inject  EmbedVersion(NodeVersion version);  EmbedVersion(String version); @Override Runnable embedVersion(Runnable runnable); @Override Callable<T> embedVersion(Callable<T> callable); static EmbedVersion testingVersionEmbedder();  }### Answer:
@Test public void testEmbedVersionInRunnable() { AtomicInteger counter = new AtomicInteger(); embedVersion.embedVersion((Runnable) counter::incrementAndGet).run(); assertEquals(counter.get(), 1); assertThatThrownBy(() -> embedVersion.embedVersion((Runnable) () -> { throw new RuntimeException("Zonky zonk"); }).run()) .isInstanceOf(RuntimeException.class) .hasMessage("Zonky zonk") .hasStackTraceContaining("at io.prestosql.$gen.Presto_123_some_test_version____"); }
@Test public void testEmbedVersionInCallable() throws Exception { AtomicInteger counter = new AtomicInteger(); String value = embedVersion.embedVersion(() -> { return "abc" + counter.incrementAndGet(); }).call(); assertEquals(value, "abc1"); assertEquals(counter.get(), 1); assertThatThrownBy(() -> embedVersion.embedVersion((Callable<String>) () -> { throw new RuntimeException("Zonky zonk"); }).call()) .isInstanceOf(RuntimeException.class) .hasMessage("Zonky zonk") .hasStackTraceContaining("at io.prestosql.$gen.Presto_123_some_test_version____") .hasNoCause(); assertThatThrownBy(() -> embedVersion.embedVersion((Callable<String>) () -> { throw new IOException("a checked exception"); }).call()) .isInstanceOf(IOException.class) .hasMessage("a checked exception") .hasStackTraceContaining("at io.prestosql.$gen.Presto_123_some_test_version____") .hasNoCause(); }