auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private ProcessOvfUpdateForStorageDomainCommandParameters createProcessOvfUpdateForDomainParams() { ProcessOvfUpdateForStorageDomainCommandParameters params = new ProcessOvfUpdateForStorageDomainCommandParameters(getParameters().getStoragePoolId(), getParameters().getStorageDomainId()); params.setSkipDomainChecks(getParameters().isSkipDomainChecks()); params.setParentCommand(getParameters().getParentCommand()); START params.setSkipDomainChecks(getParameters().isSkipDomainChecks()); END params.setParentParameters(getParameters().getParentParameters()); return params; } This set was done already in line 115

Target:
private ProcessOvfUpdateForStorageDomainCommandParameters createProcessOvfUpdateForDomainParams() { ProcessOvfUpdateForStorageDomainCommandParameters params = new ProcessOvfUpdateForStorageDomainCommandParameters(getParameters().getStoragePoolId(), getParameters().getStorageDomainId()); params.setSkipDomainChecks(getParameters().isSkipDomainChecks()); params.setParentCommand(getParameters().getParentCommand()); params.setParentParameters(getParameters().getParentParameters()); return params; }
Source:
protected WebsocketProxyConfig getConfig() { if (config != null) { START new WebsocketProxyConfig( END (String) AsyncDataProvider.getInstance().getConfigValuePreConverted(ConfigurationValues.WebSocketProxy), getVncHost()); } return config; } did you mean config = ... ? :)

Target:
protected WebsocketProxyConfig getConfig() { if (config != null) { config = new WebsocketProxyConfig((String) AsyncDataProvider.getInstance().getConfigValuePreConverted(ConfigurationValues.WebSocketProxy), getVncHost()); } return config; }
Source:
public List<GlusterGeoRepSession> getAllSessions() { START return getCallsHandler().executeReadList("GetAllGlusterGeoRepSessions", georepSessionRowMapper, getCustomMapSqlParameterSource().addValue("user_id", null).addValue("is_filtered", false)); END } user_id and is_filtered parameters not required

Target:
public List<GlusterGeoRepSession> getAllSessions() { return getCallsHandler().executeReadList("GetAllGlusterGeoRepSessions", georepSessionRowMapper, getCustomMapSqlParameterSource()); }
Source:
public void setup() { START qos = mock(HostNetworkQos.class); END validator = new HostNetworkQosValidator(qos); nullValidator = new HostNetworkQosValidator(null); } You can add @RunWith(MockitoJUnitRunner.class) to the class, and then you"ll be able to use @mock on the declaration instead of this initialization. But it is just a matter of style, so as you wish.

Target:
public void setup() { validator = new HostNetworkQosValidator(qos); nullValidator = new HostNetworkQosValidator(null); }
Source:
protected StorageDomainValidator getStorageDomainValidator(DiskImage diskImage) { START if (storageDomainValidator == null) { END StorageDomain storageDomain = getStorageDomainDAO().getForStoragePool( diskImage.getStorageIds().get(0), diskImage.getStoragePoolId()); storageDomainValidator = new StorageDomainValidator(storageDomain); } return storageDomainValidator; } If you have a parameter, caching the validator doesn't make sense - the API seems as though you can pass a DiskImage and get a validator for it, when in practice you'll get the same validator regardless of the param.

Target:
protected StorageDomainValidator getStorageDomainValidator(DiskImage diskImage) { StorageDomain storageDomain = getStorageDomainDAO().getForStoragePool( diskImage.getStorageIds().get(0), diskImage.getStoragePoolId()); return new StorageDomainValidator(storageDomain); }
Source:
private boolean isDomainExistAndActive() { START if (!validate(getStorageDomainValidator().isDomainExistAndActive())) { END return false; } return true; } you replace this code with return validate(getStorageDomainValidator().isDomainExistAndActive()).

Target:
private boolean isDomainExistAndActive() { return (validate(getStorageDomainValidator().isDomainExistAndActive())); }
Source:
public void testJsonNullDiskDescription() throws IOException { START String jsonDescription = null; END jsonDescription = ImagesHandler.getJsonDiskDescription("DiskAlias", null); assertTrue("Should be map of disk alias and disk description", jsonDescription.equals("{\"DiskDescription\":\"\",\"DiskAlias\":\"DiskAlias\"}")); } please just define on the next row.

Target:
public void testJsonNullDiskDescription() throws IOException { String jsonDescription = ImagesHandler.getJsonDiskDescription("DiskAlias", null); assertTrue("Should be map of disk alias and disk description", jsonDescription.equals("{\"DiskDescription\":\"\",\"DiskAlias\":\"DiskAlias\"}")); }
Source:
private static void checkMessages() { AuditLogType[] values = AuditLogType.values(); if (values.length != messages.size()) { for (AuditLogType value : values) { if (!messages.containsKey(value)) { START log.info("AuditLogType: '{}' not exist in string table", value.toString()); END } } } } drop toString()

Target:
private static void checkMessages() { AuditLogType[] values = AuditLogType.values(); if (values.length != messages.size()) { for (AuditLogType value : values) { if (!messages.containsKey(value)) { log.info("AuditLogType: '{}' not exist in string table", value); } } } }
Source:
public SubTabVirtualMachineGeneralView(DetailModelProvider<VmListModel, VmGeneralModel> modelProvider, ApplicationConstants constants) { super(modelProvider); this.form = new VmGeneralModelForm(modelProvider, constants); // Inject a reference to the resources: resources = ClientGinjectorProvider.getApplicationResources(); initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); clearAlerts(); generateIds(); START this.form.setElementIdPrefixes(); END } Instead of manually invoking form.setElementIdPrefixes(), you could make AbstractModelBoundFormWidget implement HasElementId interface, with implementation doing following: * get widget's DOM element and set ID on it * execute code in setElementIdPrefixes (no need for separate method now) This way, manually invoking form.setElementIdPrefixes() wouldn't be needed anymore, because HasElementId.setElementId() is called as part of generateIds().

Target:
public SubTabVirtualMachineGeneralView(DetailModelProvider<VmListModel, VmGeneralModel> modelProvider, ApplicationConstants constants) { super(modelProvider); this.form = new VmGeneralModelForm(modelProvider, constants); // Inject a reference to the resources: resources = ClientGinjectorProvider.getApplicationResources(); initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); clearAlerts(); generateIds(); }
Source:
public static PermitType map(ActionGroup entity, PermitType template) { try { return PermitType.valueOf(entity); } catch (IllegalArgumentException e) { log.error("Missing mapping '{}' --> '{}': {}", entity, PermitType.class.getName(), e.getMessage()); START log.debug("Exception", e); END return null; } } The stack trace should use the same level than the message.

Target:
public static PermitType map(ActionGroup entity, PermitType template) { try { return PermitType.valueOf(entity); } catch (IllegalArgumentException e) { log.error("Missing mapping '{}' --> '{}': {}", entity, PermitType.class.getName(), e.getMessage()); log.error("Exception", e); return null; } }
Source:
public void discoverGeoRepData() { // get all clusters List<VDSGroup> clusters = getClusterDao().getAll(); // for every cluster that supports geo-rep monitoring for (VDSGroup cluster : clusters) { START discoverGeoRepDataInCluster(cluster, null); END } } Please consider having a method overloading for the case there is no volume name.

Target:
public void discoverGeoRepData() { // get all clusters List<VDSGroup> clusters = getClusterDao().getAll(); // for every cluster that supports geo-rep monitoring for (VDSGroup cluster : clusters) { discoverGeoRepDataInCluster(cluster); } }
Source:
public int hashCode() { int result = Objects.hashCode(id); START return result; END } There's no need for result attribute: @Override public int hashCode() { return Objects.hashCode(id); }

Target:
public int hashCode() { return Objects.hashCode(id); }
Source:
public boolean equals(Object obj) { if (this == obj) START return true; END if (this == obj) { return true; } if (!(obj instanceof JobSubjectEntityId)) { return false; } JobSubjectEntityId other = (JobSubjectEntityId) obj; return Objects.equals(entityId, other.entityId) && Objects.equals(jobId, other.jobId); } repeated twice

Target:
public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof JobSubjectEntityId)) { return false; } JobSubjectEntityId other = (JobSubjectEntityId) obj; return Objects.equals(entityId, other.entityId) && Objects.equals(jobId, other.jobId); }
Source:
public String getSysprepFileName(int osId, Version version) { START return EngineLocalConfig.getInstance().expandString(getValueByVersion(idToUnameLookup.get(osId), "sysprepFileName", version)); END } remove the use of EngineLocalConfig.getInstance().expandString. just return getValueByVersion...

Target:
public String getSysprepFileName(int osId, Version version) { return getValueByVersion(idToUnameLookup.get(osId), "sysprepFileName", version); }
Source:
START protected void fillMacAddressIfMissing(VmNic iface) { END if (StringUtils.isEmpty(iface.getMacAddress()) && getMacPool().getAvailableMacsCount() > 0) { iface.setMacAddress(getMacPool().allocateNewMac()); } } is it shared? or going to be? if not, probably need to be private

Target:
private void fillMacAddressIfMissing(VmNic iface) { if (StringUtils.isEmpty(iface.getMacAddress()) && getMacPool().getAvailableMacsCount() > 0) { iface.setMacAddress(getMacPool().allocateNewMac()); } }
Source:
public GlusterVolumeSnapshotCreatePopupView(EventBus eventBus, ApplicationResources resources, ApplicationConstants constants, ApplicationMessages messages, CommonApplicationTemplates templates) { super(eventBus, resources); this.messages = messages; this.constants = constants; this.templates = templates; START initEditors(); END initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); ViewIdHandler.idHandler.generateAndSetIds(this); localize(); driver.initialize(this); setTitle(constants.newSnapshot()); } Please remove initEditors

Target:
public GlusterVolumeSnapshotCreatePopupView(EventBus eventBus, ApplicationResources resources, ApplicationConstants constants, ApplicationMessages messages, CommonApplicationTemplates templates) { super(eventBus, resources); this.messages = messages; this.constants = constants; this.templates = templates; initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); ViewIdHandler.idHandler.generateAndSetIds(this); localize(); driver.initialize(this); setTitle(constants.newSnapshot()); }
Source:
public void getVolumeSnapshotSchedule(AsyncQuery aQuery, Guid volumeId) { aQuery.converterCallback = new IAsyncConverter() { @Override public Object Convert(Object source, AsyncQuery asyncQuery) { START return source != null ? source : null; END } }; Frontend.getInstance().runQuery(VdcQueryType.GetGlusterVolumeSnapshotScheduleByVolumeId, new IdQueryParameters(volumeId), aQuery); } This converter does not have any effect

Target:
public void getVolumeSnapshotSchedule(AsyncQuery aQuery, Guid volumeId) { aQuery.converterCallback = new IAsyncConverter() { @Override public Object Convert(Object source, AsyncQuery asyncQuery) { return source; } }; Frontend.getInstance().runQuery(VdcQueryType.GetGlusterVolumeSnapshotScheduleByVolumeId, new IdQueryParameters(volumeId), aQuery); }
Source:
private void updateActionAvailability() { boolean allowCreateSnapshot = true; if (getEntity() == null || getEntity().getStatus() == GlusterStatus.DOWN) { allowCreateSnapshot = false; } getNewSnapshotCommand().setIsAvailable(allowCreateSnapshot); START boolean allowEditSnapshotSchedule = false; END if (getEntity() != null && getEntity().getStatus() == GlusterStatus.UP && getEntity().getSnapshotScheduled()) { allowEditSnapshotSchedule = true; } getEditSnapshotScheduleCommand().setIsAvailable(allowEditSnapshotSchedule); } can you please this declaration above near boolean allowCreateSnapshot = true;

Target:
private void updateActionAvailability() { boolean allowCreateSnapshot = true; boolean allowEditSnapshotSchedule = false; if (getEntity() == null || getEntity().getStatus() == GlusterStatus.DOWN) { allowCreateSnapshot = false; } if (getEntity() != null && getEntity().getStatus() == GlusterStatus.UP && getEntity().getSnapshotScheduled()) { allowEditSnapshotSchedule = true; } getNewSnapshotCommand().setIsAvailable(allowCreateSnapshot); getEditSnapshotScheduleCommand().setIsAvailable(allowEditSnapshotSchedule); }
Source:
public void edit(final GlusterVolumeSnapshotModel object) { driver.edit(object); forceWarningLabel.setVisible(object.getForceCreate().getEntity()); START object.getForceCreate().getEntityChangedEvent().addListener(new IEventListener<EventArgs>() { END @Override public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) { forceWarningLabel.setVisible(object.getForceCreate().getEntity()); } }); } View.edit(model) should not add new listeners to model object. This should be the responsibility of associated presenter - for example, in GlusterVolumeSnapshotCreatePopupPresenterWidget: @Override public void init(final GlusterVolumeSnapshotModel model) { super.init(model); model.getForceCreate().getEntityChangedEvent().addListener(...); } View.edit() is responsible for populating UI from model data and can be potentially called multiple times. Model listener registration therefore doesn't belong here, but in AbstractModelBoundPopupPresenterWidget.init(model) method override.

Target:
public void edit(final GlusterVolumeSnapshotModel object) { driver.edit(object); forceWarningLabel.setVisible(object.getForceCreate().getEntity()); }
Source:
public void postOnCreateSnapshot(VdcReturnValueBase returnValue, GlusterVolumeSnapshotEntity snapshot, GlusterVolumeSnapshotModel snapshotModel) { START getWindow(); END if (returnValue != null && returnValue.getSucceeded()) { setWindow(null); } } please remove this

Target:
public void postOnCreateSnapshot(VdcReturnValueBase returnValue, GlusterVolumeSnapshotEntity snapshot, GlusterVolumeSnapshotModel snapshotModel) { if (returnValue != null && returnValue.getSucceeded()) { setWindow(null); } }
Source:
public void checkPrefixFormatValidation() { assertEquals("Failed to validate prefix's Format: " + mask, START isMaskValid && isPrefixValid, MaskValidator.getInstance().isPrefixValid(mask)); END } The isMaskValid parameter is irrelevant here. This test only checks that the input is in valid prefix format.

Target:
public void checkPrefixFormatValidation() { assertEquals("Failed to validate prefix's Format: " + mask, isPrefixValid, MaskValidator.getInstance().isPrefixValid(mask)); }
Source:
public static Collection<Object[]> data() { return Arrays.asList(new Object[][] { { "255.255.255.255", 0xffffffffL }, { "1.1.1.1", 0x01010101 }, { "1.255.4.255", 0x01ff04ff }, { "0.128.0.7", 0x00800007 }, { "1.2.3.4", 0x01020304 }, START { "127.63.31.7", 0x7f3f1f07 }, END { "0.0.0.1", 0x00000001 }, { "1.1.1.1", 0x01010101 }, }); } In my opinion, this test case is useless - there's no way to verify this is valid with a human eye...

Target:
public static Collection<Object[]> data() { return Arrays.asList(new Object[][] { { "255.255.255.255", 0xffffffffL }, { "1.1.1.1", 0x01010101 }, { "1.255.4.255", 0x01ff04ff }, { "0.128.0.7", 0x00800007 }, { "1.2.3.4", 0x01020304 }, { "0.0.0.1", 0x00000001 }, { "1.1.1.1", 0x01010101 }, }); }
Source:
public Collection<Guid> getRoleIds() { if (roleIds == null) { roleIds = Collections.emptyList(); } START return new ArrayList<Guid>(roleIds); END } As written before - not that critical but consider set (just to ensure nobody will be making a mistake of adding twice the same UUID - i mean, if they do add , you still should have only one copy).

Target:
public Collection<Guid> getRoleIds() { if (roleIds == null) { roleIds = Collections.emptyList(); } return new HashSet<Guid>(roleIds); }
Source:
START protected void addCanDoActionMessages(VdcBllMessages... messages) { END for (VdcBllMessages msg : messages) { addCanDoActionMessage(msg); } } final method?

Target:
protected final void addCanDoActionMessages(VdcBllMessages... messages) { for (VdcBllMessages msg : messages) { addCanDoActionMessage(msg); } }
Source:
public static void storeSubTabHeight(ClientStorage clientStorage, IsWidget widget) { START clientStorage.setLocalItem(SubTabHelper.SUB_TAB_HEIGHT_KEY, END String.valueOf(widget.asWidget().getOffsetHeight())); } s/SubTabHelper.SUB_TAB_HEIGHT_KEY/SUB_TAB_HEIGHT_KEY/ :-)

Target:
public static void storeSubTabHeight(ClientStorage clientStorage, IsWidget widget) { clientStorage.setLocalItem(SUB_TAB_HEIGHT_KEY, String.valueOf(widget.asWidget().getOffsetHeight())); }
Source:
START protected void invokeCommands(ArrayList<VdcReturnValueBase> returnValues) { END if (canRunActions(returnValues)) { if (isWaitForResult) { invokeSyncCommands(); } else { invokeCommands(); } } } please make this method private

Target:
private void invokeCommands(ArrayList<VdcReturnValueBase> returnValues) { if (canRunActions(returnValues)) { if (isWaitForResult) { invokeSyncCommands(); } else { invokeCommands(); } } }
Source:
private void discoverHostName_SelectedItemChanged() { ExternalDiscoveredHost dhost = (ExternalDiscoveredHost) getExternalDiscoveredHosts().getSelectedItem(); ExternalHostGroup dhg = (ExternalHostGroup) getExternalHostGroups().getSelectedItem(); VDS vds = new VDS(); if (dhost != null && dhg != null) { START vds.setVdsName(dhost.getName() + "." + dhg.getDomainName()); //$NON-NLS-1$ END vds.setHostName(dhost.getIp()); } updateModelFromVds(vds, null, false, null); } so the name will be mac.domain? Is it changable?

Target:
private void discoverHostName_SelectedItemChanged() { ExternalDiscoveredHost dhost = (ExternalDiscoveredHost) getExternalDiscoveredHosts().getSelectedItem(); ExternalHostGroup dhg = (ExternalHostGroup) getExternalHostGroups().getSelectedItem(); VDS vds = new VDS(); if (dhost != null && dhg != null) { vds.setVdsName(dhost.getName()); vds.setHostName(dhost.getName() + "." + dhg.getDomainName()); //$NON-NLS-1$ } updateModelFromVds(vds, null, false, null); }
Source:
private void init() { setMasterVolume(new EntityModel<String>()); setSlaveVolume(new EntityModel<String>()); setSlaveHost(new EntityModel<String>()); setForce(new EntityModel<Boolean>()); START setMessage("");//$NON-NLS-1$ END getForce().setEntity(false); } This is not required since you are checking for null in view

Target:
private void init() { setMasterVolume(new EntityModel<String>()); setSlaveVolume(new EntityModel<String>()); setSlaveHost(new EntityModel<String>()); setForce(new EntityModel<Boolean>()); getForce().setEntity(false); }
Source:
public void edit(final GlusterVolumeGeoRepActionConfirmationModel object) { driver.edit(object); START forceEditor.setLabel(object.getForceLabel() == null ? constants.notAvailableLabel() : object.getMessage()); END messageLabel.setText(object.getMessage() == null ? constants.notAvailableLabel() : object.getMessage()); } Why is this required? It should bind automatically

Target:
public void edit(final GlusterVolumeGeoRepActionConfirmationModel object) { driver.edit(object); }
Source:
public void getEngineTimeStamp(AsyncQuery aQuery) { START aQuery.setHandleFailure(true); END Frontend.getInstance().runQuery(VdcQueryType.GetEngineTimestamp, new VdcQueryParametersBase(), aQuery); } 1. Not sure if its ok to error on failure to get engine time stamp. 2. Failure to touch base with engine might essentially mean that the subsequent commands also fail and there's no use of asking for user intervention or things of that nature and somehow attempting to proceed with normal flow of snapshot creation. 3. Given 1 and 2 I still feel handling the failure manually in code is better atleast in order to close any other previous window(ex: snapshot create window) Let me know what you opine

Target:
public void getEngineTimeStamp(AsyncQuery aQuery) { Frontend.getInstance().runQuery(VdcQueryType.GetEngineTimestamp, new VdcQueryParametersBase(), aQuery); }
Source:
START private static List<String> getMountPointsFilter() { END return Arrays.asList(Config.<String> getValue(ConfigValues.MountPointsToIgoreInGlusterStorageList).split(",")); } the static modifier could go away

Target:
private List<String> getMountPointsFilter() { return Arrays.asList(Config.<String> getValue(ConfigValues.MountPointsToIgoreInGlusterStorageList).split(",")); }
Source:
private void updateActionAvailability() { VDS vds = getEntity(); START getSyncStorageDevicesCommand().setIsExecutionAllowed(VDSStatus.Up.equals(vds.getStatus())); END } vds.getStatus() == VDSStatus.Up

Target:
private void updateActionAvailability() { VDS vds = getEntity(); getSyncStorageDevicesCommand().setIsExecutionAllowed(vds.getStatus() == VDSStatus.Up); }
Source:
private void persistEngineSession(String sessionId) { SessionInfo sessionInfo = getSessionInfo(sessionId); if (sessionInfo != null) { EngineSession engineSession = new EngineSession(getUser(sessionId, false)); START engineSession.setEngineSessionId(sessionId); END sessionInfo.contentOfSession.put(ENGINE_SESSION_SEQ_ID, getDbFacade().getEngineSessionDao().save(engineSession)); } } instead of setEngineSessionId - why not having it at ctor?

Target:
private void persistEngineSession(String sessionId) { SessionInfo sessionInfo = getSessionInfo(sessionId); if (sessionInfo != null) { sessionInfo.contentOfSession.put(ENGINE_SESSION_SEQ_ID, getDbFacade().getEngineSessionDao().save(new EngineSession(getUser(sessionId, false), sessionId))); } }
Source:
private ValidationResult validateRangePart(String rangePart) { START rangePart.toLowerCase(); END boolean matches = MAC_ADDRESS_PATTERN.matcher(rangePart).matches(); if (!matches) { return new ValidationResult(false, "The range start/end is an invalid MAC address. " + rangePart + " should be in a format of AA:AA:AA:AA:AA:AA"); } else { return new ValidationResult(true); } } no assignment ?? is there any importance to the case sensitivity?

Target:
private ValidationResult validateRangePart(String rangePart) { boolean matches = MAC_ADDRESS_PATTERN.matcher(rangePart).matches(); if (!matches) { return new ValidationResult(false, "The range start/end is an invalid MAC address. " + rangePart + " should be in a format of AA:AA:AA:AA:AA:AA"); } else { return new ValidationResult(true); } }
Source:
protected void START addMacsFromDbToPool() END { List<VmNic> interfaces = getVmNicInterfacesFromDb(); for (VmNic iface : interfaces) { if (iface.getMacAddress() != null) { forceAddMacWithoutLocking(iface.getMacAddress()); } } } could this be private ?

Target:
private void addMacsFromDbToPool() { List<VmNic> interfaces = getVmNicInterfacesFromDb(); for (VmNic iface : interfaces) { if (iface.getMacAddress() != null) { forceAddMacWithoutLocking(iface.getMacAddress()); } } }
Source:
protected boolean canDoAction() { return isImageExist() && checkOperationIsCorrect() && canFindVmOrTemplate() && isDiskUsedAsOvfStore() && isImageNotLocked() && isSourceAndDestTheSame() && validateSourceStorageDomain() && validateDestStorage() && checkTemplateInDestStorageDomain() && validateSpaceRequirements() && checkCanBeMoveInVm() && checkIfNeedToBeOverride() && setAndValidateDiskProfiles() START && verifyShareableDisksMoving(); END } /s/verifyShareableDisksMoving/validateShareableNotMovedToGluserDomain() regardless i think that this check should reside in validateDestStorage() method

Target:
protected boolean canDoAction() { return isImageExist() && checkOperationIsCorrect() && canFindVmOrTemplate() && isDiskUsedAsOvfStore() && isImageNotLocked() && isSourceAndDestTheSame() && validateSourceStorageDomain() && validateDestStorage() && checkTemplateInDestStorageDomain() && validateSpaceRequirements() && checkCanBeMoveInVm() && checkIfNeedToBeOverride() && setAndValidateDiskProfiles(); }
Source:
protected boolean canDoAction() { if (getParameters().getParametersList().isEmpty()) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_NO_DISKS_SPECIFIED); START } else { END return verifyShareableDisksMoving(); } } The else is redundant - unwrap it (project's style)

Target:
protected boolean canDoAction() { if (getParameters().getParametersList().isEmpty()) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_NO_DISKS_SPECIFIED); } return verifyShareableDisksMoving(); }
Source:
public void canDoActionFailedUpdateReadOnly() { START VmDevice device = createVmDevice(diskImageGuid, vmId); END // make sure that device is plugged assertEquals(true, device.getIsPlugged()); when(diskDao.get(diskImageGuid)).thenReturn(createDiskImage()); UpdateVmDiskParameters parameters = createParameters(); parameters.getDiskInfo().setReadOnly(true); initializeCommand(parameters, Collections.singletonList(createVm(VMStatus.Up))); CanDoActionTestUtils.runAndAssertCanDoActionFailure(command, VdcBllMessages.ACTION_TYPE_FAILED_VM_IS_NOT_DOWN); } So can't we completely remove this device now? It seems unsued

Target:
public void canDoActionFailedUpdateReadOnly() { when(diskDao.get(diskImageGuid)).thenReturn(createDiskImage()); UpdateVmDiskParameters parameters = createParameters(); parameters.getDiskInfo().setReadOnly(true); initializeCommand(parameters, Collections.singletonList(createVm(VMStatus.Up))); CanDoActionTestUtils.runAndAssertCanDoActionFailure(command, VdcBllMessages.ACTION_TYPE_FAILED_VM_IS_NOT_DOWN); }
Source:
private void setupVdsNetworkInterfaceDao() { List<VdsNetworkInterface> expectedVdsNetworkInterface = Collections.singletonList(vdsNetworkInterface); InterfaceDao vdsNetworkInterfaceDaoMock = mock(InterfaceDao.class); when(vdsNetworkInterfaceDaoMock.getVdsInterfacesByNetworkId(networkId)).thenReturn(expectedVdsNetworkInterface); when(getDbFacadeMockInstance().getInterfaceDao()).thenReturn(vdsNetworkInterfaceDaoMock); START NetworkDao networkDaoMock = mock(NetworkDao.class); END when(getDbFacadeMockInstance().getNetworkDao()).thenReturn(networkDaoMock); } I would: 1. Put this in a separate method. 2. Create a mock network to be returned by the networkDao - otherwise it doesn't reflect proper behavior... It'll return null for a network, which shouldn't really happen in real-life scenarios. 3. Also mock qosDao (in a separate method). The out-of-sync functionality should already be tested in NetworkUtilsTest, so not necessary to test it here.

Target:
private void setupVdsNetworkInterfaceDao() { when(getDbFacadeMockInstance().getInterfaceDao()).thenReturn(vdsNetworkInterfaceDaoMock); List<VdsNetworkInterface> expectedVdsNetworkInterface = Collections.singletonList(vdsNetworkInterface); when(vdsNetworkInterfaceDaoMock.getVdsInterfacesByNetworkId(networkId)).thenReturn( expectedVdsNetworkInterface); }
Source:
public boolean isNetworkError() { START if (getMessage().startsWith(NETWORK_ERROR_MSG) || getMessage().startsWith(CONNECTION_ISSUES_MSG)) { END return true; } else { return false; } } Consider explaining this change in commit message as well or extract to another patch..

Target:
public boolean isNetworkError() { if (getMessage().startsWith(NETWORK_ERROR_MSG)) { return true; } else { return false; } }
Source:
private static String findActiveNicName(VDS vds, Map<String, Map<String, Object>> bridges) { final String hostIp = NetworkUtils.getHostByIp(vds); // by now, if the host is communicating with engine over a valid interface, // the interface will have the host's engine IP final VdsNetworkInterface activeIface = resolveActiveNic(vds, hostIp); String hostActiveNic = (activeIface == null) ? null : activeIface.getName(); START final String activeBridge = findActiveBridge(hostIp, bridges); END if (activeBridge != null) { hostActiveNic = activeBridge; } return hostActiveNic; } why not to reverse the order of the conditions by their importance ? { if (has bridge with host id) { return bridge name; } activeNic = resolveActiveNic(); return ... }

Target:
private static String findActiveNicName(VDS vds, Map<String, Map<String, Object>> bridges) { final String hostIp = NetworkUtils.getHostByIp(vds); final String activeBridge = findActiveBridge(hostIp, bridges); if (activeBridge != null) { return activeBridge; } // by now, if the host is communicating with engine over a valid interface, // the interface will have the host's engine IP final VdsNetworkInterface activeIface = resolveActiveNic(vds, hostIp); String hostActiveNic = (activeIface == null) ? null : activeIface.getName(); return hostActiveNic; }
Source:
private List<DiskImage> initializeListForCopiedImage() { START List<DiskImage> clonedDiskImages = (ArrayList)getImages().clone(); END ArrayList<Guid> storageDomains = new ArrayList<>(); for (DiskImage clonedDiskImage : clonedDiskImages) { clonedDiskImage.setStorageIds(storageDomains); } return clonedDiskImages; } Yikes. Why not just new ArrayList<>(getImages()) ?

Target:
private List<DiskImage> initializeListForCopiedImage() { List<DiskImage> clonedDiskImages = new ArrayList<>(getImages()); ArrayList<Guid> storageDomains = new ArrayList<>(); for (DiskImage clonedDiskImage : clonedDiskImages) { clonedDiskImage.setStorageIds(storageDomains); } return clonedDiskImages; }
Source:
public int hashCode() { final int prime = 31; int result = 1; result = prime * result + sessionId.hashCode(); START result = prime * result + allowedValues.hashCode(); END result = prime * result + super.hashCode(); return result; } remove from here as well

Target:
public int hashCode() { final int prime = 31; int result = 1; result = prime * result + sessionId.hashCode(); result = prime * result + super.hashCode(); return result; }
Source:
public boolean equals(Object obj) { return obj != null && obj instanceof GlusterGeoRepSessionConfiguration && ObjectUtils.objectsEqual(getId(), ((GlusterGeoRepSessionConfiguration) obj).getId()) START && ObjectUtils.haveSameElements(allowedValues, END ((GlusterGeoRepSessionConfiguration) obj).getAllowedValues()) && super.equals(obj); } Should allowedValues be considered for object equality?

Target:
public boolean equals(Object obj) { return obj != null && obj instanceof GlusterGeoRepSessionConfiguration && ObjectUtils.objectsEqual(getId(), ((GlusterGeoRepSessionConfiguration) obj).getId()) && super.equals(obj); }
Source:
public void saveOrUpdateDetailsInBatch(List<GlusterGeoRepSessionDetails> geoRepSessionDetailsObjs) { List<GlusterGeoRepSessionDetails> insertList = new ArrayList<>(); List<GlusterGeoRepSessionDetails> updateList = new ArrayList<>(); for (GlusterGeoRepSessionDetails details : geoRepSessionDetailsObjs) START if (getGeoRepSessionDetails(details.getSessionId(), details.getMasterBrickId()) == null) END insertList.add(details); else updateList.add(details); saveDetailsInBatch(insertList); updateDetailsInBatch(updateList); } Apply default formatter

Target:
public void saveOrUpdateDetailsInBatch(List<GlusterGeoRepSessionDetails> geoRepSessionDetailsObjs) { List<GlusterGeoRepSessionDetails> insertList = new ArrayList<>(); List<GlusterGeoRepSessionDetails> updateList = new ArrayList<>(); for (GlusterGeoRepSessionDetails details : geoRepSessionDetailsObjs) { if (getGeoRepSessionDetails(details.getSessionId(), details.getMasterBrickId()) == null) { insertList.add(details); } else { updateList.add(details); } } saveDetailsInBatch(insertList); updateDetailsInBatch(updateList); }
Source:
public AuditLogType getAuditLogTypeValue() { START if (getSucceeded()) END return AuditLogType.GLUSTER_GEOREP_CONFIG_SET_DEFAULT; else return errorType == null ? AuditLogType.GLUSTER_GEOREP_CONFIG_SET_DEFAULT_FAILED : errorType; } the default standard is to use curly braces

Target:
public AuditLogType getAuditLogTypeValue() { if (getSucceeded()) { return AuditLogType.GLUSTER_GEOREP_CONFIG_SET_DEFAULT; } else { return errorType == null ? AuditLogType.GLUSTER_GEOREP_CONFIG_SET_DEFAULT_FAILED : errorType; } }
Source:
protected boolean canDoAction() { START setGlusterVolumeId(getGeoRepSession().getMasterVolumeId()); END return super.canDoAction(); } Shouldn't the volumeId be set in constructor only?

Target:
protected boolean canDoAction() { return super.canDoAction(); }
Source:
private void postCreateBrick(VdcReturnValueBase returnValue) { CreateBrickModel model = (CreateBrickModel) getWindow(); model.stopProgress(); if (returnValue != null START && returnValue.getSucceeded()) END setWindow(null); } This code style might give formatting error. Even if one line statement it should be within curly braces.

Target:
private void postCreateBrick(VdcReturnValueBase returnValue) { CreateBrickModel model = (CreateBrickModel) getWindow(); model.stopProgress(); if (returnValue != null && returnValue.getSucceeded()) { setWindow(null); } }
Source:
protected boolean bootProtocolDhcp() { String bootProtocol = (String) START this.entry.get("BOOTPROTO"); END return bootProtocol != null && "dhcp".equalsIgnoreCase(bootProtocol); } this. prefix is redundant

Target:
protected boolean bootProtocolDhcp() { return "dhcp".equalsIgnoreCase((String) entry.get("BOOTPROTO")); }
Source:
private boolean isDiskValidForStorage(Disk disk, StorageDomain storage) { START if (disk.isShareable() && storage.getStorageType().equals(StorageType.GLUSTERFS)) { END return false; } return true; } StorageType is an enum - it should be compared with ==

Target:
private boolean isDiskValidForStorage(Disk disk, StorageDomain storage) { if (disk.isShareable() && storage.getStorageType() == StorageType.GLUSTERFS) { return false; } return true; }
Source:
public Guid getId() { START return this.id; END } this. prefix is not required within getters

Target:
public Guid getId() { return id; }
Source:
public void testGetById(){ StorageDevice storageDevice = dao.getById(EXISTING_STORAGE_DEVICE_ID_1); assertNotNull("Failed to retrive storage device", storageDevice); START assertEquals("Failed to retrive corrective storage device", storageDevice.getId(), EXISTING_STORAGE_DEVICE_ID_1); END storageDevice = dao.getById(NON_EXISTING_STORAGE_DEVICE_ID); assertNull(storageDevice); } expected as the second arg, actual third arg

Target:
public void testGetById(){ StorageDevice storageDevice = dao.getById(EXISTING_STORAGE_DEVICE_ID_1); assertNotNull("Failed to retrive storage device", storageDevice); assertEquals("Failed to retrive corrective storage device", EXISTING_STORAGE_DEVICE_ID_1, storageDevice.getId()); storageDevice = dao.getById(NON_EXISTING_STORAGE_DEVICE_ID); assertNull(storageDevice); }
Source:
public AuditLogType getAuditLogTypeValue() { START if (getSucceeded()) { END return AuditLogType.SYNC_STORAGE_DEVICES_IN_HOST; } else { return AuditLogType.SYNC_STORAGE_DEVICES_IN_HOST_FAILED; } } it's a matter of styling, but this could be written as: return getSucceeded() ? AuditLogType.SYNC_STORAGE_DEVICES_IN_HOST : AuditLogType.SYNC_STORAGE_DEVICES_IN_HOST_FAILED;

Target:
public AuditLogType getAuditLogTypeValue() { return getSucceeded() ? AuditLogType.SYNC_STORAGE_DEVICES_IN_HOST : AuditLogType.SYNC_STORAGE_DEVICES_IN_HOST_FAILED; }
Source:
START protected boolean isFileDomainInEditState(StorageDomain storageDomain) { END return (storageDomain.getStatus() == StorageDomainStatus.Maintenance || storageDomain.getStorageDomainSharedStatus() == StorageDomainSharedStatus.Unattached); } This method can (and should be) private

Target:
private boolean isFileDomainInEditState(StorageDomain storageDomain) { return (storageDomain.getStatus() == StorageDomainStatus.Maintenance || storageDomain.getStorageDomainSharedStatus() == StorageDomainSharedStatus.Unattached); }
Source:
START @Override protected void executeQueryCommand() { END if (getParameters().getStorageType() != null) { getQueryReturnValue().setReturnValue( WipeAfterDeleteUtils.getDefaultWipeAfterDeleteFlag(getParameters().getStorageType())); } } style - move the '@Override' annotation to a separate line above

Target:
protected void executeQueryCommand() { if (getParameters().getStorageType() != null) { getQueryReturnValue().setReturnValue( WipeAfterDeleteUtils.getDefaultWipeAfterDeleteFlag(getParameters().getStorageType())); } }
Source:
RequestBuilder createKeepAliveRequest() { RequestBuilder builder = createRequest(); // This request shouldn't do anything other than refresh the REST API session START builder.setHeader(ENGINE_REFRESH_HEADER, "refresh-only"); //$NON-NLS-1$ END return builder; } so probably good to check the value at server side and perform refresh only if specific value is provided.

Target:
RequestBuilder createKeepAliveRequest() { return createRequest(); }
Source:
public ValidationResult canAddRngDevice(VDSGroup cluster, VmRngDevice rngDevice) { VmRngDevice.Source source = rngDevice.getSource(); boolean supported = cluster != null && isFeatureSupported(cluster.getcompatibility_version()) && cluster.getRequiredRngSources().contains(source); if (supported) { return ValidationResult.VALID; } START return new ValidationResult(VdcBllMessages.ACTION_NOT_SUPPORTED_FOR_CLUSTER_POOL_LEVEL); END } suggestion: return the ValidationResult if !supported and by-default return VALID. I think it's better as this validator might be extended in the future by adding additional validations so it will be easier to modify it that way.

Target:
public ValidationResult canAddRngDevice(VDSGroup cluster, VmRngDevice rngDevice) { VmRngDevice.Source source = rngDevice.getSource(); boolean supported = cluster != null && isFeatureSupported(cluster.getcompatibility_version()) && cluster.getRequiredRngSources().contains(source); if (!supported) { return new ValidationResult(VdcBllMessages.ACTION_NOT_SUPPORTED_FOR_CLUSTER_POOL_LEVEL); } return ValidationResult.VALID; }
Source:
protected GlusterVolumeSnapshotSchedule getSchedule() { START return this.schedule; END } return schedule; - should suffice

Target:
protected GlusterVolumeSnapshotSchedule getSchedule() { return schedule; }
Source:
public void setVmNetwork(Boolean vmNetwork) { if (!ObjectUtils.objectsEqual(this.vmNetwork, vmNetwork)) { this.vmNetwork = vmNetwork; START onPropertyChanged(new PropertyChangedEventArgs("Vm Network")); //$NON-NLS-1$ END } } You don't need this, nobody was listening on the "Role" property changed event. Therefore the whole ObjectUtils.objectsEqual() check isn't necessary either, you may just set the member. (the case could have been different if this item wasn't always available in the form, see the different constructors of FormItem)

Target:
public void setVmNetwork(Boolean vmNetwork) { this.vmNetwork = vmNetwork; }
Source:
public AbstractValidatedWidgetWithLabel(W contentWidget) { this(contentWidget, new VisibilityRenderer.SimpleVisibilityRenderer()); START addStateUpdateHandler(); END } I missed this in my first review - addStateUpdateHandler() is called due to this() (the other constructor above) so calling addStateUpdateHandler() here is not needed, I guess?

Target:
public AbstractValidatedWidgetWithLabel(W contentWidget) { this(contentWidget, new VisibilityRenderer.SimpleVisibilityRenderer()); }
Source:
private void enforceNego(HttpServletResponse response) throws IOException { START for (String scheme: new HashSet<>(schemes)) { END response.setHeader("WWW-Authenticate", scheme); } response.sendError(HttpServletResponse.SC_UNAUTHORIZED); } why can't the schemes be hash from starters?

Target:
private void enforceNego(HttpServletResponse response) throws IOException { for (String scheme: schemes) { response.setHeader("WWW-Authenticate", scheme); } response.sendError(HttpServletResponse.SC_UNAUTHORIZED); }
Source:
public AuditLogType getAuditLogTypeValue() { START if(getSucceeded()) END return AuditLogType.GLUSTER_VOLUME_GEO_REP_PAUSE; else return AuditLogType.GLUSTER_VOLUME_GEO_REP_PAUSE_FAILED; } Did you apply a different formatting style in Eclipse?

Target:
public AuditLogType getAuditLogTypeValue() { if (getSucceeded()) { return AuditLogType.GLUSTER_VOLUME_GEO_REP_PAUSE; } else { return AuditLogType.GLUSTER_VOLUME_GEO_REP_PAUSE_FAILED; } }
Source:
START public void setValue(String value) { END if (value == null) { clearSelections(); } if (value.isEmpty()) { return; } setValue(value, false); } Why not in combination with above do this: setValue(value, false);

Target:
public void setValue(String value) { setValue(value, false); }
Source:
private void addCheckBox(T checkBoxValue) { String checkBoxLabel = renderer.render(checkBoxValue); if (checkBoxLabel == null) { throw new IllegalArgumentException("null value is not permited"); //$NON-NLS-1$ } START if (checkBoxes.containsKey(checkBoxValue)) { END throw new IllegalArgumentException("Duplicate value: " + checkBoxLabel); //$NON-NLS-1$ } final CheckBox newCheckBox = buildCheckbox(checkBoxValue); checkBoxes.put(checkBoxValue, newCheckBox); } Since the only two places that call this method already check if there is a duplicate key, you don't have check here again.

Target:
private void addCheckBox(T checkBoxValue) { String checkBoxLabel = renderer.render(checkBoxValue); if (checkBoxLabel == null) { throw new IllegalArgumentException("null value is not permited"); //$NON-NLS-1$ } final CheckBox newCheckBox = buildCheckbox(checkBoxValue); checkBoxes.put(checkBoxValue, newCheckBox); }
Source:
private int getRowForTheDay(int date) { int row = date / DAYS_IN_WEEK; START return date % 7 == 0 ? row - 1 : row; END } DAYS_IN_WEEK

Target:
private int getRowForTheDay(int date) { int row = date / DAYS_IN_WEEK; return date % DAYS_IN_WEEK == 0 ? row - 1 : row; }
Source:
private void initializeItems() { List<IStorageModel> items = AsyncDataProvider.getIsoStorageModels(); START items.addAll(AsyncDataProvider.getInstance().getExportStorageModels()); END items.addAll(AsyncDataProvider.getFileDataStorageModels()); items.addAll(AsyncDataProvider.getImportBlockDataStorageModels()); getModel().setItems(items); } Are you sure this has been backported? Checkstyle is complaining about it.

Target:
private void initializeItems() { List<IStorageModel> items = AsyncDataProvider.getIsoStorageModels(); items.addAll(AsyncDataProvider.getExportStorageModels()); items.addAll(AsyncDataProvider.getFileDataStorageModels()); items.addAll(AsyncDataProvider.getImportBlockDataStorageModels()); getModel().setItems(items); }
Source:
private boolean isHostNetworkUnreacable(VDS vds) { VdsDynamic vdsDynamic = vds.getDynamicData(); return (vdsDynamic.getStatus() == VDSStatus.Down || vdsDynamic.getStatus() == VDSStatus.Reboot || vdsDynamic.getStatus() == VDSStatus.Kdumping || vdsDynamic.getStatus() == VDSStatus.NonResponsive || (vdsDynamic.getStatus() == VDSStatus.NonOperational START || (vdsDynamic.getStatus() == VDSStatus.PendingApproval END && vdsDynamic.getNonOperationalReason() == NonOperationalReason.NETWORK_UNREACHABLE)); } Please fix bracketing

Target:
private boolean isHostNetworkUnreacable(VDS vds) { VdsDynamic vdsDynamic = vds.getDynamicData(); return (vdsDynamic.getStatus() == VDSStatus.Down || vdsDynamic.getStatus() == VDSStatus.Reboot || vdsDynamic.getStatus() == VDSStatus.Kdumping || vdsDynamic.getStatus() == VDSStatus.NonResponsive || vdsDynamic.getStatus() == VDSStatus.PendingApproval || (vdsDynamic.getStatus() == VDSStatus.NonOperational && vdsDynamic.getNonOperationalReason() == NonOperationalReason.NETWORK_UNREACHABLE)); }
Source:
private double getVdsMemLimit(VDS curVds) { // if single vm on host. Disregard memory over commitment int computedMemoryOverCommit = (curVds.getVmCount() == 0) ? 100 : curVds.getMaxVdsMemoryOverCommit(); START double vdsMemLimit = computedMemoryOverCommit * curVds.getPhysicalMemMb() / 100.0; END return vdsMemLimit; } also here the variable can be left outuua

Target:
private double getVdsMemLimit(VDS curVds) { // if single vm on host. Disregard memory over commitment int computedMemoryOverCommit = (curVds.getVmCount() == 0) ? 100 : curVds.getMaxVdsMemoryOverCommit(); return (computedMemoryOverCommit * curVds.getPhysicalMemMb() / 100.0); }
Source:
public CommandAssociatedEntity(Guid commandId, VdcObjectType entityType, Guid entityId) { START this.commandId = commandId; END setEntityType(entityType); setEntityId(entityId); } this c'tor implies the entity is immutable. Please let have same assumption for SubjectEntity class and introduce a c'tor there which expect both entityType and entityId and use it here instead of the setters.

Target:
public CommandAssociatedEntity(Guid commandId, VdcObjectType entityType, Guid entityId) { super(entityType, entityId); this.commandId = commandId; }
Source:
public void setGlusterNetwork(ClusterNetworkModel model, boolean value) { if (!isMultiCluster()) { if (value) { // Reset the old gluster network if (getGlusterNetwork() != null) { getGlusterNetwork().setGlusterNetwork(false); } glusterNetwork = model; } else { // Set the management network as gluster START getManagementNetwork().setGlusterNetwork(true); END } } model.setGlusterNetwork(value); } Shouldn't you update the glusterNetwork member here as well?

Target:
public void setGlusterNetwork(ClusterNetworkModel model, boolean value) { if (!isMultiCluster()) { if (value) { // Reset the old gluster network if (getGlusterNetwork() != null) { getGlusterNetwork().setGlusterNetwork(false); } glusterNetwork = model; } } model.setGlusterNetwork(value); }
Source:
START public boolean isUsingScsiReservation() { END return usingScsiReservation; } this should be a Boolean, it can be null (when you don't load the disk as "disk for vm")

Target:
public Boolean isUsingScsiReservation() { return usingScsiReservation; }
Source:
public ValidationResult isUsingScsiReservationValid(VM vm, LunDisk lunDisk) { // this operation is valid only when attaching disk to VMs if (vm == null && Boolean.TRUE.equals(lunDisk.isUsingScsiReservation())) { return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_SCSI_RESERVATION_NOT_VALID_FOR_FLOATING_DISK); } // reservation is can be enabled only when sgio is unfiltered if (lunDisk.isUsingScsiReservation() != null && START lunDisk.isUsingScsiReservation() END && lunDisk.getSgio() == ScsiGenericIO.FILTERED) { return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_SGIO_IS_FILTERED); } return ValidationResult.VALID; } you can use here also Boolean.TRUE.equals()

Target:
public ValidationResult isUsingScsiReservationValid(VM vm, LunDisk lunDisk) { // this operation is valid only when attaching disk to VMs if (vm == null && Boolean.TRUE.equals(lunDisk.isUsingScsiReservation())) { return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_SCSI_RESERVATION_NOT_VALID_FOR_FLOATING_DISK); } // scsi reservation can be enabled only when sgio is unfiltered if (Boolean.TRUE.equals(lunDisk.isUsingScsiReservation()) && lunDisk.getSgio() == ScsiGenericIO.FILTERED) { return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_SGIO_IS_FILTERED); } return ValidationResult.VALID; }
Source:
public void testUpdateVmDeviceUsingScsiReservationProperty() { VmDevice vmDevice = dao.get(getExistingEntityId()); boolean usingScsiReservation = !vmDevice.isUsingScsiReservation(); START Assert.assertTrue(StringUtils.isNotBlank(vmDevice.getAddress())); END vmDevice.setUsingScsiReservation(usingScsiReservation); dao.update(vmDevice); dao.get(getExistingEntityId()); assertEquals(vmDevice.isUsingScsiReservation(), usingScsiReservation); } seems like the address assertion isn't related, we are testing here the scsi reservation property.

Target:
public void testUpdateVmDeviceUsingScsiReservationProperty() { VmDevice vmDevice = dao.get(getExistingEntityId()); boolean usingScsiReservation = !vmDevice.isUsingScsiReservation(); vmDevice.setUsingScsiReservation(usingScsiReservation); dao.update(vmDevice); dao.get(getExistingEntityId()); assertEquals(vmDevice.isUsingScsiReservation(), usingScsiReservation); }
Source:
public int hashCode() { final int prime = 31; int result = super.hashCode(); START result = prime * result + (Boolean.TRUE.equals(usingScsiReservation) ? 1231 : 1237); END result = prime * result + ((lun == null) ? 0 : lun.hashCode()); return result; } I'd prefer an implementation similar to line 55 here.

Target:
public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((usingScsiReservation == null) ? 0 : usingScsiReservation.hashCode()); result = prime * result + ((lun == null) ? 0 : lun.hashCode()); return result; }
Source:
public ParametersParser(InputStream resource, String prefix) { this.properties = loadProperties(resource); this.prefix = prefix; parseProperties(); START } END please call the other constructor.

Target:
public ParametersParser(InputStream resource, String prefix) { this(loadProperties(resource), prefix); }