Alona Kaplan has posted comments on this change.

Change subject: core: refactored NetworkAttachmentCompleter + tests.
......................................................................


Patch Set 37:

(7 comments)

https://gerrit.ovirt.org/#/c/36142/37//COMMIT_MSG
Commit Message:

Line 6: 
Line 7: core: refactored NetworkAttachmentCompleter + tests.
Line 8: 
Line 9: • added unit tests
Line 10: • unfied implementation so both methods uses BusinessEntityMap
s/unfied/unified
Line 11: • added tests for id<-->name coherence in case that user sets both.
Line 12: • added completation of id in case that user specifies name of
Line 13: existing bond/nic but does not specify id.
Line 14: 


https://gerrit.ovirt.org/#/c/36142/37/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/NicNameNicIdCompleter.java
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/NicNameNicIdCompleter.java:

Line 11: 
Line 12: /**
Line 13:  * Network interface can be provided as a parameter and identified 
either by ID or by name.<br>
Line 14:  * Class {@code NetworkAttachmentCompleter} populates the interface 
name or id if it was omitted from the
Line 15:  * {@link NetworkAttachment} entity or from {@link Bond} entity. If 
both was set, their coherence is verified.
s/If both was set/ If both were set
Line 16:  */
Line 17: public class NicNameNicIdCompleter {
Line 18: 
Line 19:     private BusinessEntityMap<VdsNetworkInterface> existingNicsMap;


https://gerrit.ovirt.org/#/c/36142/37/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/UpdateNetworkAttachmentCommand.java
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/UpdateNetworkAttachmentCommand.java:

Line 54:                 && validateHostInterface()
Line 55:                 && validateCrossAttachments();
Line 56:     }
Line 57: 
Line 58:     private NicNameNicIdCompleter getNetworkAttachmentCompleter() {
s/getNetworkAttachmentCompleter/getNicNameNicIdCompleter
Line 59:         if (completer == null) {
Line 60:             completer = new NicNameNicIdCompleter(getHostInterfaces());
Line 61:         }
Line 62: 


https://gerrit.ovirt.org/#/c/36142/37/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/network/host/NicNameNicIdCompleterTest.java
File 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/network/host/NicNameNicIdCompleterTest.java:

Line 46:         verify(networkAttachmentWithoutNameOrIdSet, 
never()).setNicId(any(Guid.class));
Line 47:     }
Line 48: 
Line 49:     @Test
Line 50:     public void 
testCompleteNetworkAttachmentWhenWhenBothIdAndNameDoesNotReferenceExistingNic() 
throws Exception {
testCompleteNetworkAttachmentWhenWhenBothIdAndNameDoesNotReferenceExistingNic/testCompleteNetworkAttachmentWhenBothIdAndNameDoesNotReferenceExistingNic
 (WhenWhen)
Line 51:         NetworkAttachment networkAttachment = 
mock(NetworkAttachment.class);
Line 52: 
Line 53:         Guid guidOfNotExistingNic = Guid.newGuid();
Line 54:         
Mockito.when(networkAttachment.getNicId()).thenReturn(guidOfNotExistingNic);


Line 50:     public void 
testCompleteNetworkAttachmentWhenWhenBothIdAndNameDoesNotReferenceExistingNic() 
throws Exception {
Line 51:         NetworkAttachment networkAttachment = 
mock(NetworkAttachment.class);
Line 52: 
Line 53:         Guid guidOfNotExistingNic = Guid.newGuid();
Line 54:         
Mockito.when(networkAttachment.getNicId()).thenReturn(guidOfNotExistingNic);
Please statically import the 'when'
Line 55:         
Mockito.when(networkAttachment.getNicName()).thenReturn("notAExistingNicName");
Line 56: 
Line 57:         completer.completeNetworkAttachment(networkAttachment);
Line 58:         verify(networkAttachment, never()).setNicName(anyString());


Line 86:         networkAttachment.setNicId(Guid.newGuid());
Line 87:         networkAttachment.setNicName(nic.getName());
Line 88: 
Line 89:         expectedException.expect(IllegalArgumentException.class);
Line 90:         expectedException.expectMessage("Both nicId and nicName was 
specified, but they does not denote same nic.");
1.Please extract the String to a public final static member  in the 
NicNameNicIdCompleter and  reuse it here.
2. Both nicId and nicName were specified, but they do not denote same nic.
Line 91:         completer.completeNetworkAttachment(networkAttachment);
Line 92:     }
Line 93: 
Line 94:     //-----------copy pasted for bond-------- //TODO MM: could be 
refactored not to duplicate code at a cost of Parameterized tests and slightly 
more complex class. Can I do it?


Line 90:         expectedException.expectMessage("Both nicId and nicName was 
specified, but they does not denote same nic.");
Line 91:         completer.completeNetworkAttachment(networkAttachment);
Line 92:     }
Line 93: 
Line 94:     //-----------copy pasted for bond-------- //TODO MM: could be 
refactored not to duplicate code at a cost of Parameterized tests and slightly 
more complex class. Can I do it?
Can you?:) Please fix the code and remove the comment.
Line 95: 
Line 96:         @Test
Line 97:         public void testCompleteBondWhenUnsetIdAndName() throws 
Exception {
Line 98:             Bond bondWithoutNameOrIdSet = mock(Bond.class);


-- 
To view, visit https://gerrit.ovirt.org/36142
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I933333afdcb11bfcf9f761572229f7a7a7814381
Gerrit-PatchSet: 37
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Martin Mucha <mmu...@redhat.com>
Gerrit-Reviewer: Alona Kaplan <alkap...@redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Martin Mucha <mmu...@redhat.com>
Gerrit-Reviewer: Moti Asayag <masa...@redhat.com>
Gerrit-Reviewer: automat...@ovirt.org
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to