package org.aaron1011.whowas.core;

import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import java.io.ByteArrayInputStream;
import java.util.UUID;

import static org.powermock.api.mockito.PowerMockito.*;

@RunWith(PowerMockRunner.class)
@PrepareForTest({ PlayerNameHistoryFetcher.class })
public class PlayerNameHistoryFetcherTest {

    private final static String API_DATA = "[{'name':'Djinnibone'},{'name':'Djinnibutt','changedToAt':1413217187000},{'name':'Djinnibone','changedToAt':1413217202000}]";

    @Test
    public void testGetPlayerNameHistory() throws Exception {
        stub(method(PlayerNameHistoryFetcher.class, "getAPIResponse")).toReturn(new ByteArrayInputStream(API_DATA.getBytes()));

        UUID uuid = UUID.randomUUID();

        PlayerNameHistory history = PlayerNameHistoryFetcher.getPlayerNameHistory(uuid);
        assertEquals("UUIDS are not equal", uuid, history.getUuid());
    }
}

@@ -29,16 +29,56 @@
 .core;%0A%0A
+import com.google.common.base.Optional;%0A
 import o
@@ -88,24 +88,24 @@
 junit.Test;%0A
-
 import org.j
@@ -316,16 +316,62 @@
 Stream;%0A
+import java.util.Date;%0Aimport java.util.List;%0A
 import j
@@ -1073,16 +1073,75 @@
 (uuid);%0A
+        List%3CTimestampedName%3E names = history.getNames();%0A%0A
         
@@ -1201,16 +1201,575 @@
 Uuid());
+%0A%0A        TimestampedName first = names.get(0);%0A        TimestampedName second = names.get(1);%0A        TimestampedName third = names.get(2);%0A%0A        assertEquals(%22Djinnibone%22, first.getName());%0A        assertEquals(Optional.absent(), first.getChangedToAt());%0A%0A        assertEquals(%22Djinnibutt%22, second.getName());%0A        assertEquals(Optional.fromNullable(new Date(1413217187000L)), second.getChangedToAt());%0A%0A        assertEquals(%22Djinnibone%22, third.getName());%0A        assertEquals(Optional.fromNullable(new Date(1413217202000L)), third.getChangedToAt());
 %0A    %7D%0A%7D

Expand test