1   package com.atlassian.plugins.rest.common.expand.resolver;
2   
3   import com.atlassian.plugins.rest.common.expand.entity.ListWrapper;
4   import static org.junit.Assert.*;
5   import org.junit.Before;
6   import org.junit.Test;
7   
8   /**
9    * Testing {@link ListWrapperEntityExpanderResolver}
10   */
11  public class ListWrapperEntityExpanderResolverTest
12  {
13      private ListWrapperEntityExpanderResolver resolver;
14  
15      @Before
16      public void setUp() throws Exception
17      {
18          resolver = new ListWrapperEntityExpanderResolver();
19      }
20  
21      @Test
22      public void testHasExpanderWithNullClass()
23      {
24          try
25          {
26              final Class clazz = null;
27              resolver.hasExpander(clazz);
28              fail();
29          }
30          catch (NullPointerException e)
31          {
32              // expected
33          }
34      }
35  
36      @Test
37      public void testGetExpanderWithNullClass()
38      {
39          try
40          {
41              final Class clazz = null;
42              resolver.getExpander(clazz);
43              fail();
44          }
45          catch (NullPointerException e)
46          {
47              // expected
48          }
49      }
50  
51      @Test
52      public void testHasExpanderWithClassForNonListWrapper()
53      {
54          assertFalse(resolver.hasExpander(Object.class));
55      }
56  
57      @Test
58      public void testGetExpanderWithClassForNonListWrapper()
59      {
60          assertNull(resolver.getExpander(Object.class));
61      }
62  
63      @Test
64      public void testHasExpanderWithClassForListWrapper()
65      {
66          assertTrue(resolver.hasExpander(ListWrapper.class));
67      }
68  
69      @Test
70      public void testGetExpanderWithClassForListWrapper()
71      {
72          assertEquals(ListWrapperEntityExpanderResolver.EXPANDER, resolver.getExpander(ListWrapper.class));
73      }
74  }