package com.bugsnag;

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.junit.Test;

import java.util.List;

public class ThreadStateTest {

    @Test
    public void testThreadStateDoesNotContainCurrentThread() {
        List<ThreadState> threadStates = ThreadState.getLiveThreads(new Configuration("apikey"));

        for (ThreadState thread : threadStates) {
            if (thread.getId() == Thread.currentThread().getId()) {
                fail();
            }
        }

        // Just test that there is at least one thread
        assertTrue(threadStates.size() > 1);
    }
}

@@ -15,16 +15,62 @@
 gsnag;%0A%0A
+import static org.junit.Assert.assertNotNull;%0A
 import s
@@ -163,14 +163,67 @@
 nit.
-Test;%0A
+Before;%0Aimport org.junit.Test;%0A%0Aimport java.lang.Exception;
 %0Aimp
@@ -283,34 +283,21 @@
     
-@Test%0A    public void te
+private Li
 st
+%3C
 Thre
@@ -307,147 +307,391 @@
 tate
-DoesNotContainC
+%3E threadStates;%0A%0A    /**%0A     * Generates a list of c
 urrent
-T
+ t
 hread
-() %7B%0A        List%3CT
+ states%0A     *%0A     * @throws Exception if the t
 hread
-S
+ s
 tate
-%3E threadStates = ThreadState.getLiveThreads(new Configuration(%22apikey%22));%0A%0A   
+ could not be constructed%0A     */%0A    @Before%0A    public void setUp() throws Exception %7B%0A        threadStates = ThreadState.getLiveThreads(new Configuration(%22apikey%22));%0A    %7D%0A%0A    @Test%0A    public void testThreadStateDoesNotContainCurrentThread() %7B%0A%0A
      
+   
 for 
@@ -950,11 +950,411 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testThreadName() %7B%0A        for (ThreadState threadState : threadStates) %7B%0A            assertNotNull(threadState.getName());%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void testThreadStacktrace() %7B%0A        for (ThreadState threadState : threadStates) %7B%0A            List%3CStackframe%3E stacktrace = threadState.getStacktrace();%0A            assertNotNull(stacktrace);%0A        %7D%0A    %7D
 %0A%7D%0A

test serialisation of thread state properties