Martin Mucha has posted comments on this change. Change subject: core: MacPool related Commands ......................................................................
Patch Set 27: (9 comments) more answers. http://gerrit.ovirt.org/#/c/28705/27/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/MacPoolValidatorTest.java File backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/MacPoolValidatorTest.java: Line 91: private ValidationResult callHasUniqueName(boolean sameId, boolean sameName, Guid newId, String newName) { Line 92: final Guid macPool1Id = Guid.newGuid(); Line 93: final Guid macPool2Id = sameId ? macPool1Id : newId; Line 94: final String macPool1Name = "macPool1"; Line 95: final String macPool2Name = sameName ? macPool1Name : newName; > This all should be decided outside this method, probably in the one calling Done Line 96: Line 97: final MacPool existingMacPool = createMacPool(macPool1Id, macPool1Name); Line 98: Line 99: when(macPoolDaoMock.getAll()).thenReturn(Arrays.asList( Line 93: final Guid macPool2Id = sameId ? macPool1Id : newId; Line 94: final String macPool1Name = "macPool1"; Line 95: final String macPool2Name = sameName ? macPool1Name : newName; Line 96: Line 97: final MacPool existingMacPool = createMacPool(macPool1Id, macPool1Name); > This should be inlined Done Line 98: Line 99: when(macPoolDaoMock.getAll()).thenReturn(Arrays.asList( Line 100: existingMacPool Line 101: )); Line 99: when(macPoolDaoMock.getAll()).thenReturn(Arrays.asList( Line 100: existingMacPool Line 101: )); Line 102: Line 103: final MacPool newMacPool = createMacPool(macPool2Id, macPool2Name); > This should be inlined Done Line 104: return new MacPoolValidator(newMacPool).hasUniqueName(); Line 105: } Line 106: Line 107: private MacPool createMacPool(Guid macPool1Id, String macPool1Name) { Line 104: return new MacPoolValidator(newMacPool).hasUniqueName(); Line 105: } Line 106: Line 107: private MacPool createMacPool(Guid macPool1Id, String macPool1Name) { Line 108: final MacPool macPool1 = new MacPool(); > No need for "1" in variable name Done Line 109: macPool1.setName(macPool1Name); Line 110: macPool1.setId(macPool1Id); Line 111: return macPool1; Line 112: } Line 135: Line 136: protected void notRemovingUsedPool(boolean used) { Line 137: macPool.setId(Guid.newGuid()); Line 138: int usageCount = used ? 1 : 0; Line 139: when(macPoolDaoMock.getDcUsageCount(eq(macPool.getId()))).thenReturn(usageCount); > This mocking should be in a method that receives "usageCount". Done Line 140: Line 141: final ValidationResult validationResult = new MacPoolValidator(macPool).notRemovingUsedPool(); Line 142: if (used) { Line 143: hasMessage(validationResult, VdcBllMessages.ACTION_TYPE_FAILED_CANNOT_REMOVE_STILL_USED_MAC_POOL); Line 138: int usageCount = used ? 1 : 0; Line 139: when(macPoolDaoMock.getDcUsageCount(eq(macPool.getId()))).thenReturn(usageCount); Line 140: Line 141: final ValidationResult validationResult = new MacPoolValidator(macPool).notRemovingUsedPool(); Line 142: if (used) { > This test logic should be in the tests themselves, just the mocking is shar Done Line 143: hasMessage(validationResult, VdcBllMessages.ACTION_TYPE_FAILED_CANNOT_REMOVE_STILL_USED_MAC_POOL); Line 144: } else { Line 145: valid(validationResult); Line 146: } Line 157: valid(new MacPoolValidator(macPool).macPoolExists()); Line 158: } Line 159: Line 160: //should be replaced with custom matches Line 161: static void valid(ValidationResult actual) { > You should use ValidationResultMatchers.isValid (See example in NetworkVali Done Line 162: Assert.assertThat(actual.getMessage(), is(ValidationResult.VALID.getMessage())); Line 163: } Line 164: Line 165: //should be replaced with custom matches Line 162: Assert.assertThat(actual.getMessage(), is(ValidationResult.VALID.getMessage())); Line 163: } Line 164: Line 165: //should be replaced with custom matches Line 166: static void hasMessage(ValidationResult actual, VdcBllMessages message) { > You should use ValidationResultMatchers.failsWith (See example in NetworkVa Done Line 167: Assert.assertThat(actual.getMessage(), is(message)); Line 168: } Line 169: http://gerrit.ovirt.org/#/c/28705/27/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java File frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java: Line 58: @DefaultStringValue("Mac pool cannot be removed. Either it's used or it's default mac pool.") Line 59: String MAC_POOL_CANNOT_BE_REMOVED(); Line 60: Line 61: @DefaultStringValue("Mac pool does not exist.") Line 62: String MAC_POOL_DOES_NOT_EXIST(); > You should sync the messages from the other files.. What that means? Line 63: Line 64: @DefaultStringValue("Mac pool cannot be created. Shared MAC pools must have names.") Line 65: String MAC_POOL_MUST_HAVE_NAME(); Line 66: -- To view, visit http://gerrit.ovirt.org/28705 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I9c0c3657e3e53699bcafa375befdce848b01a2f3 Gerrit-PatchSet: 27 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Martin Mucha <mmu...@redhat.com> Gerrit-Reviewer: Lior Vernia <lver...@redhat.com> Gerrit-Reviewer: Martin Mucha <mmu...@redhat.com> Gerrit-Reviewer: Mike Kolesnik <mkole...@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