package net.argius.java8.seq;

import static org.junit.Assert.fail;
import java.lang.reflect.*;
import java.util.*;
import org.junit.*;

public final class MetaTest {

    // TODO add unimplemented methods
    static final String[] methodList1 = { "of", "seq", "empty", "size", "at", "subSequence", "filter", "head", "tail",
            "map", "forEach", "fold", "reduce", "distinct", "reverse", "sort", "sortWith", "concat", "stream",
            "toArray", "toString", };
    // all, any,

    static final String[] methodListForNumber = { "max", "min", "sum", };

    @Test
    public void testSequenceImpl() {
        checkMethods(SequenceImpl.class, methodList1);
    }

    static void checkMethods(Class<?> c, String[]... lists) {
        for (String[] list : lists)
            for (final String methodName : list)
                if (!TestUtils.hasMethod(c, methodName))
                    fail(String.format("class %s does not have [%s] method", c.getSimpleName(), methodName));
    }

    @Test
    public void testIntSequenceImpl() {
        checkMethods(IntSequenceImpl.class, methodList1);
        checkMethods(IntSequenceImpl.class, methodListForNumber);
    }

    @Test
    public void testLongSequenceImpl() {
        checkMethods(LongSequenceImpl.class, methodList1);
        checkMethods(LongSequenceImpl.class, methodListForNumber);
    }

    @Test
    public void testDoubleSequenceImpl() {
        checkMethods(DoubleSequenceImpl.class, methodList1);
        checkMethods(DoubleSequenceImpl.class, methodListForNumber);
    }

    @Test
    public void testPrivateCtors() throws Exception {
        for (Class<?> c : Arrays.asList(SequenceFactory.class, IntSequenceFactory.class, LongSequenceFactory.class,
            DoubleSequenceFactory.class)) {
            Constructor<?> ctor = c.getDeclaredConstructor();
            ctor.setAccessible(true);
            ctor.newInstance();
        }
    }

}

@@ -165,46 +165,8 @@
  %7B%0A%0A
-    // TODO add unimplemented methods%0A
     
@@ -418,39 +418,10 @@
 y%22, 
-%22toString%22, %7D;%0A    // all, any,
+%7D;
 %0A%0A  
@@ -492,120 +492,241 @@
 um%22,
+ %22mapToObj%22,
  %7D;%0A
-%0A
     
-@Test%0A    public void testSequenceImpl() %7B%0A        checkMethods(SequenceImpl.class, methodList1);%0A   
+static final String%5B%5D methodListExceptInt = %7B%7D; // %22mapToInt%22, %7D;%0A    static final String%5B%5D methodListExceptLong = %7B%7D; // %22mapToLong%22, %7D;%0A    static final String%5B%5D methodListExceptDouble = %7B%7D; // %22mapToDouble%22,
  %7D
+;
 %0A%0A  
@@ -1074,19 +1074,16 @@
 oid test
-Int
 Sequence
@@ -1103,42 +1103,143 @@
     
-checkMethods(IntSequenceImpl.class
+Class%3C?%3E c = Sequence.class;%0A        checkMethods(c, methodList1);%0A        checkMethods(c, methodListExceptInt);%0A        checkMethods(c
 , me
@@ -1238,33 +1238,42 @@
 ds(c, methodList
-1
+ExceptLong
 );%0A        check
@@ -1284,50 +1284,310 @@
 ods(
-IntSequenceImpl.class, methodListForNumber
+c, methodListExceptDouble);%0A    %7D%0A%0A    @Test%0A    public void testIntSequenceImpl() %7B%0A        Class%3C?%3E c = IntSequence.class;%0A        checkMethods(c, methodList1);%0A        checkMethods(c, methodListForNumber);%0A        checkMethods(c, methodListExceptLong);%0A        checkMethods(c, methodListExceptDouble
 );%0A 
@@ -1647,37 +1647,37 @@
 ) %7B%0A        
-checkMethods(
+Class%3C?%3E c = 
 LongSequence
@@ -1672,34 +1672,54 @@
 LongSequence
-Impl
 .class
+;%0A        checkMethods(c
 , methodList
@@ -1747,51 +1747,125 @@
 ods(
-LongSequenceImpl.class, methodListForNumber
+c, methodListForNumber);%0A        checkMethods(c, methodListExceptInt);%0A        checkMethods(c, methodListExceptDouble
 );%0A 
@@ -1927,37 +1927,37 @@
 ) %7B%0A        
-checkMethods(
+Class%3C?%3E c = 
 DoubleSequen
@@ -1954,34 +1954,54 @@
 ubleSequence
-Impl
 .class
+;%0A        checkMethods(c
 , methodList
@@ -2029,32 +2029,101 @@
 ods(
-DoubleSequenceImpl.class
+c, methodListForNumber);%0A        checkMethods(c, methodListExceptInt);%0A        checkMethods(c
 , me
@@ -2126,33 +2126,34 @@
 , methodList
-ForNumber
+ExceptLong
 );%0A    %7D%0A%0A  

Add lists