View Javadoc

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