Martin Mucha has posted comments on this change. Change subject: core: refactored NetworkAttachmentCompleter + tests. ......................................................................
Patch Set 37: (6 comments) 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 Done 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 Done 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 { > testCompleteNetworkAttachmentWhenWhenBothIdAndNameDoesNotReferenceExistingN Done 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' Done 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 NicName Done 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. Done 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