// Path: src/main/java/org/fest/util/Strings.java
// public static @NotNull String concat(@NotNull Object... objects) {
//   checkNotNull(objects);
//   StringBuilder b = new StringBuilder();
//   for (Object o : objects) {
//     b.append(o);
//   }
//   return b.toString();
// }


import org.junit.Before;
import org.junit.Test;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
import static java.lang.Thread.currentThread;
import static org.fest.util.Strings.concat;
import static org.junit.Assert.assertEquals;
    exceptionReference = new AtomicReference<RuntimeException>();
  }

  @Test
  public void should_add_stack_trace_of_current_thread() {
    final CountDownLatch latch = new CountDownLatch(1);
    new Thread() {
      @Override
      public void run() {
        RuntimeException e = new RuntimeException("Thrown on purpose");
        exceptionReference.set(e);
        latch.countDown();
      }
    }.start();
    try {
      latch.await();
    } catch (InterruptedException e) {
      currentThread().interrupt();
    }
    RuntimeException thrown = exceptionReference.get();
    Throwables.appendStackTraceInCurentThreadToThrowable(thrown, "should_add_stack_trace_of_current_thread");
    StackTraceElement[] stackTrace = thrown.getStackTrace();
    assertEquals("org.fest.util.Throwables_appendCurrentThreadStackTraceToThrowable_Test$1.run",
        asString(stackTrace[0]));
    assertEquals(
        "org.fest.util.Throwables_appendCurrentThreadStackTraceToThrowable_Test.should_add_stack_trace_of_current_thread",
        asString(stackTrace[1]));
  }

  private String asString(StackTraceElement e) {
// Path: src/main/java/org/fest/util/Strings.java
// public static @NotNull String concat(@NotNull Object... objects) {
//   checkNotNull(objects);
//   StringBuilder b = new StringBuilder();
//   for (Object o : objects) {
//     b.append(o);
//   }
//   return b.toString();
// }


// Path: src/test/java/org/fest/util/Throwables_appendCurrentThreadStackTraceToThrowable_Test.java
import org.junit.Before;
import org.junit.Test;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
import static java.lang.Thread.currentThread;
import static org.fest.util.Strings.concat;
import static org.junit.Assert.assertEquals;

    exceptionReference = new AtomicReference<RuntimeException>();
  }

  @Test
  public void should_add_stack_trace_of_current_thread() {
    final CountDownLatch latch = new CountDownLatch(1);
    new Thread() {
      @Override
      public void run() {
        RuntimeException e = new RuntimeException("Thrown on purpose");
        exceptionReference.set(e);
        latch.countDown();
      }
    }.start();
    try {
      latch.await();
    } catch (InterruptedException e) {
      currentThread().interrupt();
    }
    RuntimeException thrown = exceptionReference.get();
    Throwables.appendStackTraceInCurentThreadToThrowable(thrown, "should_add_stack_trace_of_current_thread");
    StackTraceElement[] stackTrace = thrown.getStackTrace();
    assertEquals("org.fest.util.Throwables_appendCurrentThreadStackTraceToThrowable_Test$1.run",
        asString(stackTrace[0]));
    assertEquals(
        "org.fest.util.Throwables_appendCurrentThreadStackTraceToThrowable_Test.should_add_stack_trace_of_current_thread",
        asString(stackTrace[1]));
  }

  private String asString(StackTraceElement e) {
    return concat(e.getClassName(), ".", e.getMethodName());