package slieb.soy.converters;

import com.google.template.soy.data.SoyMapData;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
public class ClassConverterTest {

    private class User {
    }

    private class Cheese {
    }

    @Mock
    private Cheese mockCheese;

    @Mock
    private User mockUser;

    @Mock
    private SoyMapData mockMapData;

    @Mock
    private SoyDataMapConverter mockSoyDataMapConverter;

    private ClassConverter classConverter;

    @Before
    public void setup() {
        when(mockSoyDataMapConverter.convert(mockUser)).thenReturn(mockMapData);
        classConverter = new ClassConverter<>(User.class, mockSoyDataMapConverter);
    }

    @Test
    public void testConvert() throws Exception {
        assertEquals(mockMapData, classConverter.convert(mockUser));
    }

    @Test
    public void testConvertNullValue() throws Exception {
        assertNull(classConverter.convert(null));
    }

    @Test
    public void testConvertOtherClass() throws Exception {
        assertNull(classConverter.convert(mockCheese));
    }
}

@@ -72,16 +72,37 @@
 apData;%0A
+import example.User;%0A
 import o
@@ -450,116 +450,8 @@
  %7B%0A%0A
-    private class User %7B%0A    %7D%0A%0A    private class Cheese %7B%0A    %7D%0A%0A    @Mock%0A    private Cheese mockCheese;%0A%0A
     
@@ -1117,137 +1117,6 @@
  %7D%0A%0A
-    @Test%0A    public void testConvertOtherClass() throws Exception %7B%0A        assertNull(classConverter.convert(mockCheese));%0A    %7D%0A
 %7D%0A

update class converter test