package com.arondor.common.reflection.gwt.server;

import java.util.Collection;
import java.util.Map;

import org.apache.log4j.Logger;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import com.arondor.common.reflection.gwt.server.samples.TestClass;
import com.arondor.common.reflection.gwt.server.samples.TestClassTer;
import com.arondor.common.reflection.gwt.server.samples.TestInterface;
import com.arondor.common.reflection.model.java.AccessibleClass;
import com.arondor.common.reflection.model.java.AccessibleField;

public class TestDefaultGWTReflectionService
{
    private static final Logger LOG = Logger.getLogger(TestDefaultGWTReflectionService.class);

    private DefaultGWTReflectionService gwtReflectionService;

    @Before
    public void init()
    {
        gwtReflectionService = new DefaultGWTReflectionService();
    }

    @Test
    public void testImplementingClasses()
    {
        Collection<AccessibleClass> result = gwtReflectionService.getImplementingAccessibleClasses(TestInterface.class
                .getName());
        Assert.assertEquals(2, result.size());
        Assert.assertTrue(result.contains(gwtReflectionService.getAccessibleClass(TestClass.class.getName())));
        Assert.assertTrue(result.contains(gwtReflectionService.getAccessibleClass(TestClassTer.class.getName())));

        Collection<AccessibleClass> allResults = gwtReflectionService
                .getImplementingAccessibleClasses(java.lang.Object.class.getName());

        LOG.info("All classes parsed : " + allResults.size());
    }

    @Test
    public void testAccessibleField()
    {

        AccessibleClass testClass = gwtReflectionService.getAccessibleClass(TestClass.class.getName());

        Map<String, AccessibleField> fieldMap = testClass.getAccessibleFields();
        Assert.assertNotNull(fieldMap);
        Assert.assertEquals(5, fieldMap.size());
        AccessibleField stringField = fieldMap.get("aStringProperty");
        Assert.assertNotNull(stringField);
        Assert.assertEquals("This is a string property and it is mandatory", stringField.getDescription());
        Assert.assertTrue(stringField.isMandatory());
        Assert.assertTrue(fieldMap.containsKey("aLongProperty"));
        Assert.assertTrue(fieldMap.containsKey("subClass"));
        Assert.assertTrue(fieldMap.containsKey("aBooleanProperty"));
        Assert.assertTrue(fieldMap.containsKey("anEnumProperty"));
        // Assert.assertTrue(fieldMap.get("anEnumProperty").isEnumProperty());
        //
        // Map<String, List<String>> enumMap = testClass.getAccessibleEnums();
        // Assert.assertNotNull(enumMap);
        // Assert.assertEquals(1, enumMap.size());
        // List<String> testEnumValues = enumMap.get(TestEnum.class.getName());
        // Assert.assertEquals(2, testEnumValues);
        // Assert.assertTrue(testEnumValues.contains(TestEnum.VALUE1.name()));
        // Assert.assertTrue(testEnumValues.contains(TestEnum.VALUE2.name()));
    }
}

@@ -55,28 +55,186 @@
 ort 
-java.util.Collection
+static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertNotNull;%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport java.util.Collection;%0Aimport java.util.List
 ;%0Aim
@@ -290,33 +290,8 @@
 er;%0A
-import org.junit.Assert;%0A
 impo
@@ -468,24 +468,90 @@
 stClassTer;%0A
+import com.arondor.common.reflection.gwt.server.samples.TestEnum;%0A
 import com.a
@@ -1266,39 +1266,32 @@
 ame());%0A        
-Assert.
 assertEquals(2, 
@@ -1306,39 +1306,32 @@
 ize());%0A        
-Assert.
 assertTrue(resul
@@ -1411,39 +1411,32 @@
 e())));%0A        
-Assert.
 assertTrue(resul
@@ -1987,39 +1987,32 @@
 elds();%0A        
-Assert.
 assertNotNull(fi
@@ -2020,24 +2020,25 @@
 ldMap);%0A
+%0A
         
 Assert.a
@@ -2021,39 +2021,35 @@
 dMap);%0A%0A        
-Assert.
+// 
 assertEquals(5, 
@@ -2141,31 +2141,24 @@
 %22);%0A        
-Assert.
 assertNotNul
@@ -2177,31 +2177,24 @@
 d);%0A        
-Assert.
 assertEquals
@@ -2274,39 +2274,32 @@
 ion());%0A        
-Assert.
 assertTrue(strin
@@ -2321,39 +2321,32 @@
 ory());%0A        
-Assert.
 assertTrue(field
@@ -2380,39 +2380,32 @@
 rty%22));%0A        
-Assert.
 assertTrue(field
@@ -2434,39 +2434,32 @@
 ass%22));%0A        
-Assert.
 assertTrue(field
@@ -2504,23 +2504,16 @@
         
-Assert.
 assertTr
@@ -2560,34 +2560,24 @@
 ));%0A        
-// Assert.
 assertTrue(f
@@ -2643,19 +2643,16 @@
 %0A       
- //
  Map%3CStr
@@ -2716,34 +2716,24 @@
 ();%0A        
-// Assert.
 assertNotNul
@@ -2748,34 +2748,24 @@
 p);%0A        
-// Assert.
 assertEquals
@@ -2792,19 +2792,16 @@
 %0A       
- //
  List%3CSt
@@ -2866,34 +2866,24 @@
 ));%0A        
-// Assert.
 assertEquals
@@ -2900,16 +2900,23 @@
 umValues
+.size()
 );%0A     
@@ -2914,34 +2914,24 @@
 ));%0A        
-// Assert.
 assertTrue(t
@@ -2991,18 +2991,8 @@
     
-// Assert.
 asse

Fix unit test for DefaultGWTReflectionService