package org.hildan.livedoc.springmvc.issues.invisible;

import java.util.Collections;
import java.util.List;

import org.hildan.livedoc.core.LivedocReader;
import org.hildan.livedoc.core.model.doc.ApiDoc;
import org.hildan.livedoc.core.model.doc.ApiOperationDoc;
import org.hildan.livedoc.core.model.doc.Livedoc;
import org.hildan.livedoc.core.model.doc.Livedoc.MethodDisplay;
import org.hildan.livedoc.core.model.doc.types.ApiTypeDoc;
import org.hildan.livedoc.core.model.groups.Group;
import org.hildan.livedoc.springmvc.SpringLivedocReaderFactory;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class InterfaceApiTypeTest {

    @Test
    public void testInvisible() {
        List<String> packages = Collections.singletonList("org.hildan.livedoc.springmvc.issues.invisible");
        LivedocReader builder = SpringLivedocReaderFactory.getReader(packages);
        Livedoc livedoc = builder.read("version", "basePath", true, MethodDisplay.URI);
        List<Group<ApiTypeDoc>> typeGroups = livedoc.getTypes();
        assertEquals(1, typeGroups.size());
        for (Group<ApiTypeDoc> typeGroup : typeGroups) {
            assertEquals(2, typeGroup.getElements().size());
        }
        Group<ApiDoc> apiDocGroup = livedoc.getApis().get(0);
        assertEquals("", apiDocGroup.getGroupName());
        for (ApiDoc apiDoc : apiDocGroup.getElements()) {
            for (ApiOperationDoc apiOperationDoc : apiDoc.getOperations()) {
                assertEquals("Resource Interface", apiOperationDoc.getResponseBodyType().getOneLineText());
            }
        }

    }

}

@@ -971,16 +971,17 @@
 y.URI);%0A
+%0A
         
@@ -1077,32 +1077,33 @@
 ps.size());%0A
+%0A
         
 for (Group%3CA
@@ -1090,21 +1090,16 @@
         
-for (
 Group%3CAp
@@ -1118,17 +1118,17 @@
 peGroup 
-:
+=
  typeGro
@@ -1130,30 +1130,33 @@
 peGroups
-) %7B%0A  
+.get(0);%0A
         
   assert
@@ -1139,34 +1139,32 @@
 get(0);%0A        
-  
 assertEquals(2, 
@@ -1196,25 +1196,16 @@
 ize());%0A
-        %7D
 %0A       
@@ -1197,32 +1197,37 @@
 ze());%0A%0A        
+List%3C
 Group%3CApiDoc%3E ap
@@ -1223,28 +1223,27 @@
 %3CApiDoc%3E
+%3E
  api
-Doc
 Group
+s
  = lived
@@ -1254,16 +1254,104 @@
 etApis()
+;%0A        assertEquals(1, apiGroups.size());%0A%0A        Group%3CApiDoc%3E apiGroup = apiGroups
 .get(0);
@@ -1375,27 +1375,24 @@
 uals(%22%22, api
-Doc
 Group.getGro
@@ -1402,24 +1402,25 @@
 ame());%0A
+%0A
         
 for (Api
@@ -1415,35 +1415,34 @@
     
-for (
+List%3C
 ApiDoc
+%3E
  apiDoc
- :
+s =
  api
-Doc
 Grou
@@ -1456,24 +1456,157 @@
 ements()
-) %7B%0A    
+;%0A        assertEquals(1, apiDocs.size());%0A%0A        ApiDoc apiDoc = apiDocs.get(0);%0A        assertEquals(2, apiDoc.getOperations().size());%0A%0A
         
@@ -1666,28 +1666,24 @@
 ations()) %7B%0A
-    
             
@@ -1786,24 +1786,9 @@
     
-    %7D%0A        %7D%0A
+%7D
 %0A   

Improve test for "invisible" subclasses