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 import static org.junit.Assert.*;
6 import org.junit.Before;
7 import org.junit.Test;
8
9
10
11
12 public class ExpandConstraintEntityExpanderResolverTest
13 {
14 private ExpandConstraintEntityExpanderResolver resolver;
15
16 @Before
17 public void setUp() throws Exception
18 {
19 resolver = new ExpandConstraintEntityExpanderResolver();
20 }
21
22 @Test
23 public void testHasExpanderWithNullClass()
24 {
25 try
26 {
27 final Class clazz = null;
28 resolver.hasExpander(clazz);
29 fail();
30 }
31 catch (NullPointerException e)
32 {
33
34 }
35 }
36
37 @Test
38 public void testGetExpanderWithNullClass()
39 {
40 try
41 {
42 final Class clazz = null;
43 resolver.getExpander(clazz);
44 fail();
45 }
46 catch (NullPointerException e)
47 {
48
49 }
50 }
51
52 @Test
53 public void testHasExpanderWithClassForObjectWithNoConstraintMethod()
54 {
55 assertFalse(resolver.hasExpander(Object.class));
56 }
57
58 @Test
59 public void testGetExpanderWithClassForObjectWithNoConstraintMethod()
60 {
61 assertNull(resolver.getExpander(Object.class));
62 }
63
64 @Test
65 public void testHasExpanderWithClassForClassWithConstraintMethod()
66 {
67 assertTrue(resolver.hasExpander(ClassWithConstraintMethod.class));
68 }
69
70 @Test
71 public void testGetExpanderWithClassForClassWithConstraintMethod()
72 {
73 assertNotNull(resolver.getExpander(ClassWithConstraintMethod.class));
74 }
75
76 public static class ClassWithConstraintMethod
77 {
78 @ExpandConstraint
79 public void expand(Indexes indexes)
80 {
81 }
82 }
83 }