Mike Kolesnik has posted comments on this change.

Change subject: core, restapi: Remove double ReapedMaps
......................................................................


Patch Set 2: (3 inline comments)

....................................................
File 
backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/ReapedMapTest.java
Line 132:         ReferenceQueue<Integer> queue = mock(ReferenceQueue.class);
Line 133:         map = new ReapedMap<String, Integer>(10000, false, queue);
Line 134: 
Line 135:         final IdAwareReference ref = mock(IdAwareReference.class);
Line 136:         when(ref.getKey()).thenReturn("three", new Object[] { null });
Why not just pass null in second parameter?

Alternatively, you can use ongoing stubbing to write it as:

when(ref.getKey()).thenReturn("three").thenReturn(null);
Line 137: 
Line 138:         // the gcAfter queue poll simulates a GC event and triggers 
deletion
Line 139:         // on the reapable map
Line 140:         when(queue.poll()).thenAnswer(new 
Answer<Reference<Integer>>() {


Line 142: 
Line 143:             @Override
Line 144:             public Reference<Integer> answer(InvocationOnMock 
invocation) throws Throwable {
Line 145:                 if (times == gcAfter) {
Line 146:                     ++times;
You can use times++ avoid the duplication, and also write like this:

return (times++ == gcAfter) ? ref : null;
Line 147:                     return ref;
Line 148:                 }
Line 149: 
Line 150:                 ++times;


Line 156:     @SuppressWarnings("unchecked")
Line 157:     private void setUpAccessBaseAgingExpectations() {
Line 158:         ReferenceQueue<Integer> queue = mock(ReferenceQueue.class);
Line 159:         map = new ReapedMap<String, Integer>(1000, true, queue);
Line 160:         when(queue.poll()).thenReturn(null);
Why is this necessary? This is the default behaviour for mocked Object 
returning methods.
Line 161:     }
Line 162: 
Line 163:     private void populate(Integer ... values) {
Line 164:         for (Integer v: values) {


--
To view, visit http://gerrit.ovirt.org/12722
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I924355a495945a063b8e15f233188fc236df2432
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Allon Mureinik <[email protected]>
Gerrit-Reviewer: Allon Mureinik <[email protected]>
Gerrit-Reviewer: Michael Pasternak <[email protected]>
Gerrit-Reviewer: Mike Kolesnik <[email protected]>
Gerrit-Reviewer: Yair Zaslavsky <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to