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,6 +53,12 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { | ||
53 | 53 | ||
54 | private transient C delegate; | 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 | @Override | 62 | @Override |
57 | public void delete(final I id) { | 63 | public void delete(final I id) { |
58 | if (isRunningTransactionalOperations()) { | 64 | if (isRunningTransactionalOperations()) { |
@@ -71,6 +77,12 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { | @@ -71,6 +77,12 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { | ||
71 | getDelegate().delete(id); | 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 | public void delete(final List<I> ids) { | 86 | public void delete(final List<I> ids) { |
75 | if (isRunningTransactionalOperations()) { | 87 | if (isRunningTransactionalOperations()) { |
76 | transactionalDelete(ids); | 88 | transactionalDelete(ids); |
@@ -91,6 +103,11 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { | @@ -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 | @Override | 111 | @Override |
95 | public List<T> findAll() { | 112 | public List<T> findAll() { |
96 | return getDelegate().findAll(); | 113 | return getDelegate().findAll(); |
@@ -112,6 +129,12 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { | @@ -112,6 +129,12 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { | ||
112 | return this.delegateClass; | 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 | @Override | 138 | @Override |
116 | public void insert(final T bean) { | 139 | public void insert(final T bean) { |
117 | if (isRunningTransactionalOperations()) { | 140 | if (isRunningTransactionalOperations()) { |
@@ -130,11 +153,22 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { | @@ -130,11 +153,22 @@ public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> { | ||
130 | getDelegate().insert(bean); | 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 | @Override | 161 | @Override |
134 | public T load(final I id) { | 162 | public T load(final I id) { |
135 | return getDelegate().load(id); | 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 | @Override | 172 | @Override |
139 | public void update(final T bean) { | 173 | public void update(final T bean) { |
140 | if (isRunningTransactionalOperations()) { | 174 | if (isRunningTransactionalOperations()) { |
impl/core/src/test/java/br/gov/frameworkdemoiselle/util/BeansTest.java
@@ -35,7 +35,7 @@ | @@ -35,7 +35,7 @@ | ||
35 | * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | 35 | * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. |
36 | */ | 36 | */ |
37 | package br.gov.frameworkdemoiselle.util; | 37 | package br.gov.frameworkdemoiselle.util; |
38 | -import org.junit.Ignore; | 38 | + |
39 | import static junit.framework.Assert.assertEquals; | 39 | import static junit.framework.Assert.assertEquals; |
40 | import static org.easymock.EasyMock.expect; | 40 | import static org.easymock.EasyMock.expect; |
41 | import static org.powermock.api.easymock.PowerMock.replayAll; | 41 | import static org.powermock.api.easymock.PowerMock.replayAll; |
@@ -50,19 +50,18 @@ import javax.enterprise.inject.spi.Bean; | @@ -50,19 +50,18 @@ import javax.enterprise.inject.spi.Bean; | ||
50 | import javax.enterprise.inject.spi.BeanManager; | 50 | import javax.enterprise.inject.spi.BeanManager; |
51 | 51 | ||
52 | import org.easymock.EasyMock; | 52 | import org.easymock.EasyMock; |
53 | -import org.junit.Ignore; | ||
54 | import org.junit.Test; | 53 | import org.junit.Test; |
55 | import org.junit.runner.RunWith; | 54 | import org.junit.runner.RunWith; |
56 | import org.powermock.api.easymock.PowerMock; | 55 | import org.powermock.api.easymock.PowerMock; |
57 | import org.powermock.core.classloader.annotations.PrepareForTest; | 56 | import org.powermock.core.classloader.annotations.PrepareForTest; |
58 | import org.powermock.modules.junit4.PowerMockRunner; | 57 | import org.powermock.modules.junit4.PowerMockRunner; |
59 | -@Ignore | 58 | + |
60 | @RunWith(PowerMockRunner.class) | 59 | @RunWith(PowerMockRunner.class) |
61 | @PrepareForTest({ BeanManager.class, Bean.class }) | 60 | @PrepareForTest({ BeanManager.class, Bean.class }) |
62 | public class BeansTest { | 61 | public class BeansTest { |
63 | 62 | ||
64 | - @Ignore | ||
65 | @SuppressWarnings("unchecked") | 63 | @SuppressWarnings("unchecked") |
64 | + @Test | ||
66 | public void testGetReferenceByClass() { | 65 | public void testGetReferenceByClass() { |
67 | BeanManager beanManager = PowerMock.createMock(BeanManager.class); | 66 | BeanManager beanManager = PowerMock.createMock(BeanManager.class); |
68 | 67 | ||
@@ -74,9 +73,10 @@ public class BeansTest { | @@ -74,9 +73,10 @@ public class BeansTest { | ||
74 | 73 | ||
75 | expect(beanManager.createCreationalContext(EasyMock.anyObject(Contextual.class))).andReturn(null); | 74 | expect(beanManager.createCreationalContext(EasyMock.anyObject(Contextual.class))).andReturn(null); |
76 | expect(beanManager.getBeans(EasyMock.anyObject(Class.class))).andReturn(collection); | 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 | EasyMock.anyObject(CreationalContext.class))).andReturn(object); | 77 | EasyMock.anyObject(CreationalContext.class))).andReturn(object); |
78 | + | ||
79 | + expect(bean.getBeanClass()).andReturn(null); | ||
80 | 80 | ||
81 | replayAll(beanManager, bean); | 81 | replayAll(beanManager, bean); |
82 | 82 | ||
@@ -103,8 +103,7 @@ public class BeansTest { | @@ -103,8 +103,7 @@ public class BeansTest { | ||
103 | expect(bean.getBeanClass()).andReturn(null); | 103 | expect(bean.getBeanClass()).andReturn(null); |
104 | expect(beanManager.createCreationalContext(EasyMock.anyObject(Contextual.class))).andReturn(null); | 104 | expect(beanManager.createCreationalContext(EasyMock.anyObject(Contextual.class))).andReturn(null); |
105 | expect(beanManager.getBeans("something")).andReturn(collection); | 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 | EasyMock.anyObject(CreationalContext.class))).andReturn(object); | 107 | EasyMock.anyObject(CreationalContext.class))).andReturn(object); |
109 | 108 | ||
110 | replayAll(beanManager, bean); | 109 | replayAll(beanManager, bean); |