package com.episode6.hackit.mockspresso.reflect;

import com.episode6.hackit.mockspresso.DefaultTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.fest.assertions.api.Assertions.assertThat;

/**
 * Tests the TypeToken class
 */
@RunWith(DefaultTestRunner.class)
public class TypeTokenTest {

  @Test
  public void testNormalClassesWithConstructors() {
    TypeToken<String> stringToken = new TypeToken<String>() {};
    TypeToken<Integer> intToken = new TypeToken<Integer>() {};


    assertThat(stringToken.getType())
        .isEqualTo(String.class);
    assertThat((Class)stringToken.getRawType())
        .isEqualTo(String.class);
    assertThat(intToken.getType())
        .isEqualTo(Integer.class);
    assertThat((Class)intToken.getRawType())
        .isEqualTo(Integer.class);
  }

  @Test
  public void testNormalClassesWithStaticOfMethod() {
    TypeToken<String> stringToken = TypeToken.of(String.class);
    TypeToken<Integer> intToken = TypeToken.of(Integer.class);


    assertThat(stringToken.getType())
        .isEqualTo(String.class);
    assertThat((Class)stringToken.getRawType())
        .isEqualTo(String.class);
    assertThat(intToken.getType())
        .isEqualTo(Integer.class);
    assertThat((Class)intToken.getRawType())
        .isEqualTo(Integer.class);
  }
}

@@ -158,16 +158,169 @@
 nWith;%0A%0A
+import java.lang.reflect.ParameterizedType;%0Aimport java.lang.reflect.Type;%0Aimport java.util.ArrayList;%0Aimport java.util.HashMap;%0Aimport java.util.List;%0A%0A
 import s
@@ -1470,11 +1470,993 @@
 ss);%0A  %7D
+%0A%0A  @Test%0A  public void testSimpleGenerics() %7B%0A    TypeToken%3CList%3CString%3E%3E stringListToken = new TypeToken%3CList%3CString%3E%3E() %7B%7D;%0A    TypeToken%3CHashMap%3CString, Integer%3E%3E hashmapTypeToken = new TypeToken%3CHashMap%3CString, Integer%3E%3E() %7B%7D;%0A%0A    assertThat(stringListToken.getType()).isInstanceOf(ParameterizedType.class);%0A    Type%5B%5D stringListTypeArgs = ((ParameterizedType)stringListToken.getType()).getActualTypeArguments();%0A    assertThat(stringListTypeArgs)%0A        .hasSize(1)%0A        .containsExactly(String.class);%0A    assertThat((Class)stringListToken.getRawType())%0A        .isEqualTo(List.class);%0A%0A    assertThat(hashmapTypeToken.getType()).isInstanceOf(ParameterizedType.class);%0A    Type%5B%5D hashmapTypeArgs = ((ParameterizedType)hashmapTypeToken.getType()).getActualTypeArguments();%0A    assertThat(hashmapTypeArgs)%0A        .hasSize(2)%0A        .containsExactly(String.class, Integer.class);%0A    assertThat((Class)hashmapTypeToken.getRawType())%0A        .isEqualTo(HashMap.class);%0A  %7D
 %0A%7D%0A

add TypeToken test to ensure generics are accurately represented