Commit 5c9a7ac764000ff972291c88d930a813c5c494bd
1 parent
96785b5d
Exists in
master
Aumento da cobertura de testes na classe PaginationContextImpl.
Showing
1 changed file
with
25 additions
and
2 deletions
Show diff stats
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/PaginationContextImplTest.java
... | ... | @@ -36,34 +36,40 @@ |
36 | 36 | */ |
37 | 37 | package br.gov.frameworkdemoiselle.internal.implementation; |
38 | 38 | |
39 | +import static org.easymock.EasyMock.expect; | |
39 | 40 | import static org.junit.Assert.assertEquals; |
40 | 41 | import static org.junit.Assert.assertNotNull; |
41 | 42 | import static org.junit.Assert.assertNull; |
43 | +import static org.powermock.api.easymock.PowerMock.mockStatic; | |
44 | +import static org.powermock.api.easymock.PowerMock.replayAll; | |
42 | 45 | |
43 | 46 | import java.util.HashMap; |
44 | 47 | import java.util.Map; |
45 | 48 | |
46 | 49 | import org.easymock.EasyMock; |
47 | 50 | import org.junit.After; |
48 | -import org.junit.Before; | |
49 | 51 | import org.junit.Test; |
50 | 52 | import org.junit.runner.RunWith; |
51 | 53 | import org.powermock.api.easymock.PowerMock; |
54 | +import org.powermock.core.classloader.annotations.PrepareForTest; | |
52 | 55 | import org.powermock.modules.junit4.PowerMockRunner; |
53 | 56 | import org.powermock.reflect.Whitebox; |
54 | 57 | |
55 | 58 | import br.gov.frameworkdemoiselle.internal.configuration.PaginationConfig; |
56 | 59 | import br.gov.frameworkdemoiselle.pagination.Pagination; |
57 | 60 | import br.gov.frameworkdemoiselle.pagination.PaginationContext; |
61 | +import br.gov.frameworkdemoiselle.util.Beans; | |
58 | 62 | |
59 | 63 | @RunWith(PowerMockRunner.class) |
64 | +@PrepareForTest(Beans.class) | |
60 | 65 | public class PaginationContextImplTest { |
61 | 66 | |
62 | 67 | private PaginationContext context; |
63 | 68 | |
69 | + private PaginationConfig config = new PaginationConfig(); | |
70 | + | |
64 | 71 | private Pagination pagination; |
65 | 72 | |
66 | - @Before | |
67 | 73 | public void setUp() { |
68 | 74 | context = new PaginationContextImpl(); |
69 | 75 | |
... | ... | @@ -87,21 +93,38 @@ public class PaginationContextImplTest { |
87 | 93 | |
88 | 94 | return map; |
89 | 95 | } |
96 | + | |
97 | + @Test | |
98 | + public void testNullPaginationConfig() { | |
99 | + context = new PaginationContextImpl(); | |
100 | + | |
101 | + mockStatic(Beans.class); | |
102 | + expect(Beans.getReference(PaginationConfig.class)).andReturn(config).anyTimes(); | |
103 | + replayAll(Beans.class); | |
104 | + | |
105 | + assertNotNull(context.getPagination(Object.class, true)); | |
106 | + } | |
90 | 107 | |
91 | 108 | @Test |
92 | 109 | public void testGetPaginationWithoutCreateParameter() { |
110 | + setUp(); | |
111 | + | |
93 | 112 | assertEquals(pagination, context.getPagination(getClass())); |
94 | 113 | assertNull(context.getPagination(Object.class)); |
95 | 114 | } |
96 | 115 | |
97 | 116 | @Test |
98 | 117 | public void testGetPaginationWithCreateParameterTrueValued() { |
118 | + setUp(); | |
119 | + | |
99 | 120 | assertEquals(pagination, context.getPagination(getClass(), true)); |
100 | 121 | assertNotNull(context.getPagination(Object.class, true)); |
101 | 122 | } |
102 | 123 | |
103 | 124 | @Test |
104 | 125 | public void testGetPaginationWithCreateParameterFalseValued() { |
126 | + setUp(); | |
127 | + | |
105 | 128 | assertEquals(pagination, context.getPagination(getClass(), false)); |
106 | 129 | assertNull(context.getPagination(Object.class, false)); |
107 | 130 | } | ... | ... |