Alona Kaplan has posted comments on this change. Change subject: engine: introduce HostNicVfsConfigHelper ......................................................................
Patch Set 1: (7 comments) https://gerrit.ovirt.org/#/c/37720/1/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/HostNicVfsConfigHelperImpl.java File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/HostNicVfsConfigHelperImpl.java: Line 22: private final InterfaceDao interfaceDao; Line 23: private final HostDeviceDao hostDeviceDao; Line 24: private final HostNicVfsConfigDao hostNicVfsConfigDao; Line 25: Line 26: @Inject > couldn't you have an empty c'tor and instead passing the daos, simply intia It is problematic for the tests, I will have to add getter for the dbFacade and override it to return the mock. For each dao, I will also have to add- doReturn(xDao).when(dbFacade).getXDao(); IMO, the way is it implemented now is more elegant. Line 27: HostNicVfsConfigHelperImpl(InterfaceDao interfaceDao, Line 28: HostDeviceDao hostDeviceDao, Line 29: HostNicVfsConfigDao hostNicVfsConfigDao) { Line 30: this.interfaceDao = interfaceDao; Line 153: public boolean areAllVfsFree(VdsNetworkInterface nic) { Line 154: List<HostDevice> deviceList = getDevicesByHostId(nic.getVdsId()); Line 155: HostDevice pciDevice = getPciDeviceByNic(nic, deviceList); Line 156: Line 157: if (!isSriovDevice(pciDevice)) { > Findbugs/Coverity will honour you with NPE potential error here. Done Line 158: throw new UnsupportedOperationException(); Line 159: } Line 160: Line 161: List<HostDevice> vfs = getVfs(pciDevice, deviceList); Line 154: List<HostDevice> deviceList = getDevicesByHostId(nic.getVdsId()); Line 155: HostDevice pciDevice = getPciDeviceByNic(nic, deviceList); Line 156: Line 157: if (!isSriovDevice(pciDevice)) { Line 158: throw new UnsupportedOperationException(); > no need to log this one ? or provide a description to the error ? or if thi Done- provided a description to the error. It shouldn't be brought up to the user's intention since you'll get the exception just if you have a bug. Line 159: } Line 160: Line 161: List<HostDevice> vfs = getVfs(pciDevice, deviceList); Line 162: https://gerrit.ovirt.org/#/c/37720/1/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/network/host/HostNicVfsConfigHelperImplTest.java File backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/network/host/HostNicVfsConfigHelperImplTest.java: Line 28: Line 29: @RunWith(MockitoJUnitRunner.class) Line 30: public class HostNicVfsConfigHelperImplTest { Line 31: Line 32: private static final String NIC_NAME = "eth1"; > the names can be randomize instead using static value. i.e. Done Line 33: private static final Guid NIC_ID = Guid.newGuid(); Line 34: private static final Guid HOST_ID = Guid.newGuid(); Line 35: private static final String NET_DEVICE_NAME = "net_device"; Line 36: private static final String PCI_DEVICE_NAME = "pci_device"; Line 60: private HostNicVfsConfigHelperImpl hostNicVfsConfigHelper; Line 61: Line 62: @Before Line 63: public void setUp() { Line 64: hostNicVfsConfigHelper = spy(new HostNicVfsConfigHelperImpl(interfaceDao, hostDeviceDao, hostNicVfsConfigDao)); > spying the helper isn't required for all of the tests. Done Line 65: Line 66: when(netDevice.getHostId()).thenReturn(HOST_ID); Line 67: when(netDevice.getDeviceName()).thenReturn(NET_DEVICE_NAME); Line 68: when(netDevice.getNetworkInterfaceName()).thenReturn(NIC_NAME); Line 124: } Line 125: Line 126: @Test Line 127: public void isNetworkDevicePossitive() { Line 128: assertEquals(false, isNetworkDevice(pciDevice)); > please remove isNetworkDevice and replace it with a direct call to the meth Done Line 129: } Line 130: Line 131: @Test Line 132: public void isNetworkDeviceNegtive() { Line 129: } Line 130: Line 131: @Test Line 132: public void isNetworkDeviceNegtive() { Line 133: assertEquals(true, isNetworkDevice(netDevice)); > same Done Line 134: } Line 135: Line 136: @Test Line 137: public void updateHostNicVfsConfigWithNumVfsData() { -- To view, visit https://gerrit.ovirt.org/37720 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I588d619a296cb894f86cce6491337351206e21c2 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Alona Kaplan <alkap...@redhat.com> Gerrit-Reviewer: Alona Kaplan <alkap...@redhat.com> Gerrit-Reviewer: Moti Asayag <masa...@redhat.com> Gerrit-Reviewer: automat...@ovirt.org Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: Yes _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches