package no.stelar7.api.l4j8.tests.champion;

import java.util.Map;

import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;

import javafx.util.Pair;
import no.stelar7.api.l4j8.basic.DataCall;
import no.stelar7.api.l4j8.basic.DataCall.DataCallBuilder;
import no.stelar7.api.l4j8.basic.DataCall.ResponseType;
import no.stelar7.api.l4j8.basic.Server;
import no.stelar7.api.l4j8.basic.URLEndpoint;
import no.stelar7.api.l4j8.tests.SecretFile;

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ChampionByIdTest
{

    DataCallBuilder builder = DataCall.builder();

    @Before
    public void init()
    {
        System.err.println("TESTING CHAMPION BY ID");
        this.builder.withAPIKey(SecretFile.API_KEY);
        this.builder.withServer(Server.EUW);
        this.builder.withEndpoint(URLEndpoint.CHAMPION_BY_ID);
    }

    public void parseResult(final Pair<ResponseType, Object> result)
    {
        switch (result.getKey())
        {
            case OK:
            {
                if (result.getValue() instanceof Map)
                {
                    ((Map<?, ?>) result.getValue()).keySet().forEach(k -> {
                        System.out.println(k);
                        System.out.println("\t" + ((Map<?, ?>) result.getValue()).get(k));
                    });
                } else
                {
                    System.out.println(result.getValue());
                }
                break;
            }
            default:
            {
                System.out.println(result.getKey());
                System.out.println(result.getValue());
                break;
            }
        }
    }

    @Test
    public void testMany()
    {
        System.err.println("TESTING MANY");
        this.builder.withURLData("{championId}", "");
        final Pair<ResponseType, Object> summonerCall = this.builder.build();
        this.parseResult(summonerCall);
    }

    @Test
    public void testManyWithParam()
    {
        System.err.println("TESTING MANY WITH PARAMS");

        this.builder.withURLData("{championId}", "");
        this.builder.withURLParameter("freeToPlay", "true");

        final Pair<ResponseType, Object> summonerCall = this.builder.build();
        this.parseResult(summonerCall);
    }

    @Test
    public void testSingle()
    {
        System.err.println("TESTING SINGLE");
        this.builder.withURLData("{championId}", "266");
        final Pair<ResponseType, Object> summonerCall = this.builder.build();
        this.parseResult(summonerCall);
    }
}

@@ -59,13 +59,39 @@
 til.
-Map;%0A
+List;%0A%0Aimport org.junit.Assert;
 %0Aimp
@@ -479,16 +479,67 @@
 dpoint;%0A
+import no.stelar7.api.l4j8.pojo.champion.Champion;%0A
 import n
@@ -973,823 +973,8 @@
  %7D%0A%0A
-    public void parseResult(final Pair%3CResponseType, Object%3E result)%0A    %7B%0A        switch (result.getKey())%0A        %7B%0A            case OK:%0A            %7B%0A                if (result.getValue() instanceof Map)%0A                %7B%0A                    ((Map%3C?, ?%3E) result.getValue()).keySet().forEach(k -%3E %7B%0A                        System.out.println(k);%0A                        System.out.println(%22%5Ct%22 + ((Map%3C?, ?%3E) result.getValue()).get(k));%0A                    %7D);%0A                %7D else%0A                %7B%0A                    System.out.println(result.getValue());%0A                %7D%0A                break;%0A            %7D%0A            default:%0A            %7B%0A                System.out.println(result.getKey());%0A                System.out.println(result.getValue());%0A                break;%0A            %7D%0A        %7D%0A    %7D%0A%0A
     
@@ -1016,52 +1016,8 @@
   %7B%0A
-        System.err.println(%22TESTING MANY%22);%0A
     
@@ -1103,32 +1103,28 @@
 pe, Object%3E 
-summoner
+data
 Call = this.
@@ -1152,37 +1152,144 @@
     
-this.parseResult(summonerCall
+List%3CChampion%3E champs = (List%3CChampion%3E) dataCall.getValue();%0A%0A        Assert.assertTrue(%22Less than 100 champions?%22, champs.size() %3E 100
 );%0A 
@@ -1350,65 +1350,8 @@
   %7B%0A
-        System.err.println(%22TESTING MANY WITH PARAMS%22);%0A%0A
     
@@ -1461,17 +1461,16 @@
 true%22);%0A
-%0A
         
@@ -1498,32 +1498,28 @@
 pe, Object%3E 
-summoner
+data
 Call = this.
@@ -1547,37 +1547,161 @@
     
-this.parseResult(summonerCall
+List%3CChampion%3E champs = (List%3CChampion%3E) dataCall.getValue();%0A%0A        champs.forEach(c -%3E Assert.assertTrue(%22Free to play is false?!%22, c.isFreeToPlay())
 );%0A 
@@ -1755,54 +1755,8 @@
   %7B%0A
-        System.err.println(%22TESTING SINGLE%22);%0A
     
@@ -1849,24 +1849,20 @@
 Object%3E 
-summoner
+data
 Call = t
@@ -1894,37 +1894,241 @@
     
-this.parseResult(summonerCall
+List%3CChampion%3E champs = (List%3CChampion%3E) dataCall.getValue();%0A%0A        Assert.assertTrue(%22More than 1 champion with id 266?%22, champs.size() == 1);%0A        Assert.assertTrue(%22Champion id is not 266?%22, champs.get(0).getId().equals(266)
 );%0A 

Update the ChampionById test