Commit 385c7857ce3e38074ced591acc16a7effb4739ee
Exists in
master
Merge branch '2.3' of https://github.com/demoiselle/framework.git into 2.3
Showing
2 changed files
with
41 additions
and
8 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/template/DelegateCrud.java
... | ... | @@ -53,6 +53,12 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { |
53 | 53 | |
54 | 54 | private transient C delegate; |
55 | 55 | |
56 | + /** | |
57 | + * Removes a instance from delegate. | |
58 | + * | |
59 | + * @param id | |
60 | + * Entity with the given identifier | |
61 | + */ | |
56 | 62 | @Override |
57 | 63 | public void delete(final I id) { |
58 | 64 | if (isRunningTransactionalOperations()) { |
... | ... | @@ -71,6 +77,12 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { |
71 | 77 | getDelegate().delete(id); |
72 | 78 | } |
73 | 79 | |
80 | + /** | |
81 | + * Removes a list of instances from delegate. | |
82 | + * | |
83 | + * @param ids | |
84 | + * List of entities identifiers | |
85 | + */ | |
74 | 86 | public void delete(final List<I> ids) { |
75 | 87 | if (isRunningTransactionalOperations()) { |
76 | 88 | transactionalDelete(ids); |
... | ... | @@ -91,6 +103,11 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { |
91 | 103 | } |
92 | 104 | } |
93 | 105 | |
106 | + /** | |
107 | + * Gets the results from delegate. | |
108 | + * | |
109 | + * @return The list of matched query results. | |
110 | + */ | |
94 | 111 | @Override |
95 | 112 | public List<T> findAll() { |
96 | 113 | return getDelegate().findAll(); |
... | ... | @@ -112,6 +129,12 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { |
112 | 129 | return this.delegateClass; |
113 | 130 | } |
114 | 131 | |
132 | + /** | |
133 | + * Delegates the insert operation of the given instance. | |
134 | + * | |
135 | + * @param bean | |
136 | + * A entity to be inserted by the delegate | |
137 | + */ | |
115 | 138 | @Override |
116 | 139 | public void insert(final T bean) { |
117 | 140 | if (isRunningTransactionalOperations()) { |
... | ... | @@ -130,11 +153,22 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { |
130 | 153 | getDelegate().insert(bean); |
131 | 154 | } |
132 | 155 | |
156 | + /** | |
157 | + * Returns the instance of the given entity with the given identifier | |
158 | + * | |
159 | + * @return The instance | |
160 | + */ | |
133 | 161 | @Override |
134 | 162 | public T load(final I id) { |
135 | 163 | return getDelegate().load(id); |
136 | 164 | } |
137 | 165 | |
166 | + /** | |
167 | + * Delegates the update operation of the given instance. | |
168 | + * | |
169 | + * @param bean | |
170 | + * The instance containing the updated state. | |
171 | + */ | |
138 | 172 | @Override |
139 | 173 | public void update(final T bean) { |
140 | 174 | if (isRunningTransactionalOperations()) { | ... | ... |
impl/core/src/test/java/br/gov/frameworkdemoiselle/util/BeansTest.java
... | ... | @@ -35,7 +35,7 @@ |
35 | 35 | * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. |
36 | 36 | */ |
37 | 37 | package br.gov.frameworkdemoiselle.util; |
38 | -import org.junit.Ignore; | |
38 | + | |
39 | 39 | import static junit.framework.Assert.assertEquals; |
40 | 40 | import static org.easymock.EasyMock.expect; |
41 | 41 | import static org.powermock.api.easymock.PowerMock.replayAll; |
... | ... | @@ -50,19 +50,18 @@ import javax.enterprise.inject.spi.Bean; |
50 | 50 | import javax.enterprise.inject.spi.BeanManager; |
51 | 51 | |
52 | 52 | import org.easymock.EasyMock; |
53 | -import org.junit.Ignore; | |
54 | 53 | import org.junit.Test; |
55 | 54 | import org.junit.runner.RunWith; |
56 | 55 | import org.powermock.api.easymock.PowerMock; |
57 | 56 | import org.powermock.core.classloader.annotations.PrepareForTest; |
58 | 57 | import org.powermock.modules.junit4.PowerMockRunner; |
59 | -@Ignore | |
58 | + | |
60 | 59 | @RunWith(PowerMockRunner.class) |
61 | 60 | @PrepareForTest({ BeanManager.class, Bean.class }) |
62 | 61 | public class BeansTest { |
63 | 62 | |
64 | - @Ignore | |
65 | 63 | @SuppressWarnings("unchecked") |
64 | + @Test | |
66 | 65 | public void testGetReferenceByClass() { |
67 | 66 | BeanManager beanManager = PowerMock.createMock(BeanManager.class); |
68 | 67 | |
... | ... | @@ -74,9 +73,10 @@ public class BeansTest { |
74 | 73 | |
75 | 74 | expect(beanManager.createCreationalContext(EasyMock.anyObject(Contextual.class))).andReturn(null); |
76 | 75 | expect(beanManager.getBeans(EasyMock.anyObject(Class.class))).andReturn(collection); |
77 | - expect( | |
78 | - beanManager.getReference(EasyMock.anyObject(Bean.class), EasyMock.anyObject(Class.class), | |
76 | + expect(beanManager.getReference(EasyMock.anyObject(Bean.class), EasyMock.anyObject(Class.class), | |
79 | 77 | EasyMock.anyObject(CreationalContext.class))).andReturn(object); |
78 | + | |
79 | + expect(bean.getBeanClass()).andReturn(null); | |
80 | 80 | |
81 | 81 | replayAll(beanManager, bean); |
82 | 82 | |
... | ... | @@ -103,8 +103,7 @@ public class BeansTest { |
103 | 103 | expect(bean.getBeanClass()).andReturn(null); |
104 | 104 | expect(beanManager.createCreationalContext(EasyMock.anyObject(Contextual.class))).andReturn(null); |
105 | 105 | expect(beanManager.getBeans("something")).andReturn(collection); |
106 | - expect( | |
107 | - beanManager.getReference(EasyMock.anyObject(Bean.class), EasyMock.anyObject(Class.class), | |
106 | + expect(beanManager.getReference(EasyMock.anyObject(Bean.class), EasyMock.anyObject(Class.class), | |
108 | 107 | EasyMock.anyObject(CreationalContext.class))).andReturn(object); |
109 | 108 | |
110 | 109 | replayAll(beanManager, bean); | ... | ... |