auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public ResponsePayload installApplication(ApplicationWrapper applicationWrapper, @PathParam("tenantDomain") String tenantDomain) throws MDMAPIException { ResponsePayload responseMsg = new ResponsePayload(); ApplicationManager appManagerConnector; org.wso2.carbon.device.mgt.common.operation.mgt.Operation operation = null; ArrayList<DeviceIdentifier> deviceIdentifiers; try { appManagerConnector = MDMAPIUtils.getAppManagementService(); MobileApp mobileApp = applicationWrapper.getApplication(); if (applicationWrapper.getDeviceIdentifiers() != null) { for (DeviceIdentifier deviceIdentifier : applicationWrapper.getDeviceIdentifiers()) { deviceIdentifiers = new ArrayList<DeviceIdentifier>(); if (deviceIdentifier.getType().equals(Platform.android.toString())) { operation = MDMAndroidOperationUtil.createInstallAppOperation(mobileApp); } else if (deviceIdentifier.getType().equals(Platform.ios.toString())) { operation = MDMIOSOperationUtil.createInstallAppOperation(mobileApp); } deviceIdentifiers.add(deviceIdentifier); } appManagerConnector.installApplicationForDevices(operation, applicationWrapper.getDeviceIdentifiers()); } Response.status(HttpStatus.SC_CREATED); responseMsg.setMessageFromServer("Application has installed successfully."); return responseMsg; } catch (ApplicationManagementException e) { String msg = "Error occurred while saving the operation"; log.error(msg, e); throw new MDMAPIException(msg, e); } }

Target:
public ResponsePayload installApplication(ApplicationWrapper applicationWrapper, @PathParam("tenantDomain") String tenantDomain) throws MDMAPIException { ResponsePayload responseMsg = new ResponsePayload(); ApplicationManager appManagerConnector; org.wso2.carbon.device.mgt.common.operation.mgt.Operation operation = null; ArrayList<DeviceIdentifier> deviceIdentifiers; try { appManagerConnector = MDMAPIUtils.getAppManagementService(); MobileApp mobileApp = applicationWrapper.getApplication(); if (applicationWrapper.getDeviceIdentifiers() != null) { for (DeviceIdentifier deviceIdentifier : applicationWrapper.getDeviceIdentifiers()) { deviceIdentifiers = new ArrayList<DeviceIdentifier>(); if (deviceIdentifier.getType().equals(Platform.android.toString())) { operation = MDMAndroidOperationUtil.createInstallAppOperation(mobileApp); } else if (deviceIdentifier.getType().equals(Platform.ios.toString())) { operation = MDMIOSOperationUtil.createInstallAppOperation(mobileApp); } deviceIdentifiers.add(deviceIdentifier); } appManagerConnector.installApplicationForDevices(operation, applicationWrapper.getDeviceIdentifiers()); } Response.status(HttpStatus.SC_CREATED); responseMsg.setMessageFromServer("Application installation request has been sent to the device."); return responseMsg; } catch (ApplicationManagementException e) { String msg = "Error occurred while saving the operation"; log.error(msg, e); throw new MDMAPIException(msg, e); } }
Source:
public void start() throws Exception { synchronized (handlers) { if (!started.compareAndSet(false, true)) { log.info("Already started and start was called. Silently skipping"); return; } for (Stage stage : stagesOrdered()) { currStage = stage; for (Handler handler : handlers.get(stage)) { handler.start(); } } } }

Target:
public void start() throws Exception { synchronized (handlers) { if (!started.compareAndSet(false, true)) { throw new ISE("Already started"); } for (Stage stage : stagesOrdered()) { currStage = stage; for (Handler handler : handlers.get(stage)) { handler.start(); } } } }
Source:
protected Object doGetValue() { try { return convertToNumber(); } catch (NumberFormatException e) { e.printStackTrace(); } return null; }

Target:
protected Object doGetValue() { return convertToNumber(); }
Source:
protected void executeQueryCommand() { Guid vdsId = getParameters().getId(); VDS vds = vdsDao.get(vdsId); if (vds != null && FeatureSupported.isLlldpInformationSupported(vds.getClusterCompatibilityVersion())) { String[] names = new String[0]; GetLldpVDSCommandParameters lldpVDSCommandParameters = new GetLldpVDSCommandParameters(vdsId, names); VDSReturnValue command = runVdsCommand(VDSCommandType.GetLldp, lldpVDSCommandParameters); getQueryReturnValue().setReturnValue(command.getReturnValue()); } else { getQueryReturnValue().setReturnValue(createEmptyResponse()); } }

Target:
protected void executeQueryCommand() { Guid vdsId = getParameters().getId(); String[] names = new String[0]; setLldpVDSCommandParameters(new GetLldpVDSCommandParameters(vdsId, names)); super.executeQueryCommand(); }
Source:
protected static Requirement buildRequirement(String importName) { String filter = String.format("(%s=%s)", PackageNamespace.PACKAGE_NAMESPACE, importName.trim()); return new CapReqBuilder(PackageNamespace.PACKAGE_NAMESPACE).addDirective(PackageNamespace.REQUIREMENT_FILTER_DIRECTIVE, filter) .buildSyntheticRequirement(); }

Target:
private static Requirement buildRequirement(String importName) { final CapReqBuilder b = new CapReqBuilder(PackageNamespace.PACKAGE_NAMESPACE); b.addFilter(PackageNamespace.PACKAGE_NAMESPACE, importName, null, new Attrs()); return b.buildSyntheticRequirement(); }
Source:
public Object invoke(Message request, ServiceDefinition definition) throws Exception { Preconditions.checkArgument(definition != null, "Service definition can't be null"); if (definition.returnType().equals(CompletableFuture.class)) { if (definition.parametrizedType().equals(Message.class)) { return futureInvokeMessage(request); } else { return futureInvokeGeneric(request); } } else { CompletableFuture<Object> future = futureInvokeGeneric(request); Object result = future.get(); return result; } }

Target:
public Object invoke(Message request, ServiceDefinition definition) throws Exception { Preconditions.checkArgument(definition != null, "Service definition can't be null"); if (definition.returnType().equals(CompletableFuture.class)) { if (definition.parametrizedType().equals(Message.class)) { return futureInvoke(request, message -> message); } else { return futureInvoke(request, message -> message.data()); } } else { throw new UnsupportedOperationException("Method: " + definition.method() + " must return CompletableFuture"); } }
Source:
public boolean test() { internalBrowser = new InternalBrowser(); if (url != null) { internalBrowser.setURL(url); } if (this.refresh) { internalBrowser.refresh(); } new WaitUntil(new PageIsLoaded(internalBrowser)); if (Platform.getOS().startsWith(Platform.OS_WIN32)) { return internalBrowser.getText().contains(text); } else { String pageHTML = ""; if (!StringUtils.isEmpty(internalBrowser.getURL())) { pageHTML = (String) internalBrowser.evaluate("return document.documentElement.innerHTML;"); } return pageHTML.contains(text); } }

Target:
public boolean test() { new WaitUntil(new PageIsLoaded(browser)); if (Platform.getOS().startsWith(Platform.OS_WIN32)) { return browser.getText().contains(text); } else { String pageHTML = ""; if (!StringUtils.isEmpty(browser.getURL())) { pageHTML = (String) browser.evaluate("return document.documentElement.innerHTML;"); } return pageHTML.contains(text); } }
Source:
protected List<Instance> collectInstancesFromReservations(List<Reservation> reservation) { List<List<Instance>> allInstances = Lists.newArrayList(Lists.transform(reservation, new Function<Reservation, List<Instance>>() { @Override public List<Instance> apply(Reservation reservation) { return reservation.getInstances(); } })); return Lists.newArrayList(Iterables.concat(allInstances)); }

Target:
protected List<Instance> collectInstancesFromReservations(List<Reservation> reservation) { List<List<Instance>> allInstances = Lists.transform(reservation, new Function<Reservation, List<Instance>>() { @Override public List<Instance> apply(Reservation reservation) { return reservation.getInstances(); } }); return Lists.newArrayList(Iterables.concat(allInstances)); }
Source:
public void setState(State dialogState) { if (txtSearchPattern_.getText().isEmpty()) txtSearchPattern_.setText(dialogState.getQuery()); checkboxCaseSensitive_.setValue(dialogState.isCaseSensitive()); checkboxRegex_.setValue(dialogState.isRegex()); dirChooser_.setText(dialogState.getPath()); String includeFilePatterns = StringUtil.join( Arrays.asList(dialogState.getFilePatterns()), ", "); if (includeFilePatterns == listPresetFilePatterns_.getValue(Include.AllFiles.ordinal())) listPresetFilePatterns_.setSelectedIndex(Include.AllFiles.ordinal()); else if (includeFilePatterns == listPresetFilePatterns_.getValue(Include.CommonRSourceFiles.ordinal())) listPresetFilePatterns_.setSelectedIndex(Include.CommonRSourceFiles.ordinal()); else if (includeFilePatterns == listPresetFilePatterns_.getValue(Include.RScripts.ordinal())) listPresetFilePatterns_.setSelectedIndex(Include.RScripts.ordinal()); else if (includeFilePatterns == listPresetFilePatterns_.getValue(Include.Package.ordinal())) { listPresetFilePatterns_.setSelectedIndex(Include.Package.ordinal()); packageStatus_ = true; } else listPresetFilePatterns_.setSelectedIndex(Include.CustomFilter.ordinal()); txtFilePattern_.setText(includeFilePatterns); manageFilePattern(); String excludeFilePatterns = StringUtil.join( Arrays.asList(dialogState.getExcludeFilePatterns()), ","); if (excludeFilePatterns == listPresetExcludeFilePatterns_.getValue(Exclude.None.ordinal())) listPresetExcludeFilePatterns_.setSelectedIndex(Exclude.None.ordinal()); else if (excludeFilePatterns == listPresetExcludeFilePatterns_.getValue(Exclude.StandardGit.ordinal())) { listPresetExcludeFilePatterns_.setSelectedIndex(Exclude.StandardGit.ordinal()); gitStatus_ = true; } else listPresetExcludeFilePatterns_.setSelectedIndex(Exclude.CustomFilter.ordinal()); txtExcludeFilePattern_.setText(excludeFilePatterns); manageExcludeFilePattern(); }

Target:
public void setState(State dialogState) { if (txtSearchPattern_.getText().isEmpty()) txtSearchPattern_.setText(dialogState.getQuery()); checkboxCaseSensitive_.setValue(dialogState.isCaseSensitive()); checkboxRegex_.setValue(dialogState.isRegex()); dirChooser_.setText(dialogState.getPath()); String includeFilePatterns = StringUtil.join( Arrays.asList(dialogState.getFilePatterns()), ", "); int index = listPresetFilePatterns_.getIndexFromValue(includeFilePatterns); if (index >= 0) listPresetFilePatterns_.setSelectedIndex(index); else listPresetFilePatterns_.setSelectedIndex(Include.CustomFilter.ordinal()); if (index == Include.Package.ordinal()) packageStatus_ = true; txtFilePattern_.setText(includeFilePatterns); manageFilePattern(); String excludeFilePatterns = StringUtil.join( Arrays.asList(dialogState.getExcludeFilePatterns()), ","); index = listPresetExcludeFilePatterns_.getIndexFromValue(excludeFilePatterns); if (index >= 0) listPresetExcludeFilePatterns_.setSelectedIndex(index); else listPresetExcludeFilePatterns_.setSelectedIndex(Exclude.CustomFilter.ordinal()); if (index == Exclude.StandardGit.ordinal()) gitStatus_ = true; txtExcludeFilePattern_.setText(excludeFilePatterns); manageExcludeFilePattern(); }
Source:
private void createWorkAllocationBoard() { logger.info("Creating " + WORK_ALLOCATION + " board"); List<TurboUser> userList = ui.logic.getRepo(ui.logic.getDefaultRepo()).getUsers(); if (userList.isEmpty()) { DialogMessage.showInformationDialog("Auto-create Board - " + WORK_ALLOCATION, WORK_ALLOCATION + " board cannot be created as your" + " account has no push access to the default repo."); return; } panelControl.closeAllPanels(); FilterPanel panelAdded; TurboUser currUser; String realName, loginName; for (int i = 0; i < Math.min(MAX_WORK_ALLOCATION_PANELS, userList.size()); i++){ currUser = userList.get(i); realName = currUser.getRealName(); loginName = currUser.getLoginName(); panelAdded = panelControl.addPanelAt(i); panelAdded.setPanelName("Work allocated to " + (!realName.isEmpty() ? realName : loginName)); panelAdded.setFilterByString("assignee:" + loginName + " sort:milestone,status"); } panelControl.selectFirstPanel(); String boardName = Utility.generateName(WORK_ALLOCATION, prefs.getAllBoards().keySet().stream().collect(Collectors.toList())); triggerBoardSaveEventSequence(boardName); DialogMessage.showInformationDialog("Auto-create Board - " + WORK_ALLOCATION, WORK_ALLOCATION + " board has been created and loaded.\n\n" + "It is saved under the name \"" + boardName + "\"."); }

Target:
private void createWorkAllocationBoard() { logger.info("Creating " + WORK_ALLOCATION + " board"); List<TurboUser> userList = ui.logic.getRepo(ui.logic.getDefaultRepo()).getUsers(); if (userList.isEmpty()) { DialogMessage.showInformationDialog("Auto-create Board - " + WORK_ALLOCATION, WORK_ALLOCATION + " board cannot be created as your" + " account has no push access to the default repo."); return; } int noOfPanelsToBeGenerated = Math.min(MAX_WORK_ALLOCATION_PANELS, userList.size()); List<PanelInfo> panelData = generatePanelInfoFromTurboUsers(userList.subList(0, noOfPanelsToBeGenerated), "Work allocated to %s", "assignee:%s sort:milestone,status"); String boardName = Utility.getNameClosestToDesiredName(WORK_ALLOCATION, prefs.getAllBoardNames()); createBoard(panelData, boardName); DialogMessage.showInformationDialog("Auto-create Board - " + WORK_ALLOCATION, WORK_ALLOCATION + " board has been created and loaded.\n\n" + "It is saved under the name \"" + boardName + "\"."); }
Source:
public boolean hasZeroLockAcquisition() { if (modifications == null || modifications.length == 0) { return false; } boolean hasZeroLock = true; for (WriteCommand wc : modifications) { if (!wc.hasAnyFlag(FlagBitSets.ZERO_LOCK_ACQUISITION_TIMEOUT)) { hasZeroLock = false; break; } } return hasZeroLock; }

Target:
public boolean hasZeroLockAcquisition() { if (modifications == null || modifications.length == 0) { return false; } for (WriteCommand wc : modifications) { if (!wc.hasAnyFlag(FlagBitSets.ZERO_LOCK_ACQUISITION_TIMEOUT)) { return false; } } return true; }
Source:
private List<LUNs> getLUNsFromVgInfo(String vgId) { VDSReturnValue returnValue; try { returnValue = getVdsBroker().RunVdsCommand(VDSCommandType.GetVGInfo, new GetVGInfoVDSCommandParameters(getParameters().getVdsId(), vgId)); } catch (RuntimeException e) { log.errorFormat("Could not get info for VG ID: {0}. Error message: {1}", vgId, e.getMessage()); return null; } return (ArrayList<LUNs>) returnValue.getReturnValue(); }

Target:
private List<LUNs> getLUNsFromVgInfo(String vgId) { List<LUNs> luns = new ArrayList<>(); VDSReturnValue returnValue; try { returnValue = runVdsCommand(VDSCommandType.GetVGInfo, new GetVGInfoVDSCommandParameters(getParameters().getVdsId(), vgId)); } catch (RuntimeException e) { log.errorFormat("Could not get info for VG ID: {0}. Error message: {1}", vgId, e.getMessage()); return luns; } luns.addAll((ArrayList<LUNs>) returnValue.getReturnValue()); return luns; }
Source:
public boolean isHookFor(Collection<? extends URI> uris) { for (URI uri : uris) { if (UmlModel.UML_FILE_EXTENSION.equals(uri.fileExtension())) { return true; } } return false; }

Target:
public boolean isHookFor(Collection<? extends URI> uris) { for (URI uri : uris) { if (fileExtensions.contains(uri.fileExtension())) { return true; } } return false; }
Source:
public ChangeBendpointsOfEdgesCommand(IGraphicalEditPart movedPart, PrecisionPoint moveDelta) { super(movedPart.getEditingDomain(), Messages.ChangeBendpointsOfEdgesCommand_adaptEdgeBendpointsCommandLabel, null); this.movedPart = movedPart; this.moveDelta = moveDelta; }

Target:
public ChangeBendpointsOfEdgesCommand(IGraphicalEditPart movedPart, PrecisionPoint moveDelta) { super(movedPart.getEditingDomain(), Messages.ChangeBendpointsOfEdgesCommand_label, null); this.movedPart = movedPart; this.moveDelta = moveDelta; }
Source:
public void load(GlowAreaEffectCloud entity, CompoundTag tag) { super.load(entity, tag); handleIntIfPresent(tag, COLOR, rgb -> entity.setColor(Color.fromRGB(rgb))); handleIntIfPresent(tag, DURATION, entity::setDuration); handleIntIfPresent(tag, REAPPLICATION_DELAY, entity::setReapplicationDelay); handleIntIfPresent(tag, WAIT_TIME, entity::setWaitTime); handleIntIfPresent(tag, DURATION_ON_USE, entity::setDurationOnUse); handleFloatIfPresent(tag, RADIUS, entity::setRadius); handleFloatIfPresent(tag, RADIUS_ON_USE, entity::setRadiusOnUse); handleFloatIfPresent(tag, RADIUS_PER_TICK, entity::setRadiusPerTick); if (tag.isString(PARTICLE)) { final String particle = tag.getString(PARTICLE); try { entity.setParticle(Particle.valueOf(particle)); } catch (IllegalArgumentException e) { Bukkit.getServer().getLogger().warning(String.format( "Ignoring invalid particle type %s in tag %s", particle, tag)); } } if (tag.isCompoundList(EFFECTS)) { tag.getCompoundList(EFFECTS) .stream() .map(GlowMetaPotion::fromNbt) .forEach(effect -> entity.addCustomEffect(effect, false)); } }

Target:
public void load(GlowAreaEffectCloud entity, CompoundTag tag) { super.load(entity, tag); handleIntIfPresent(tag, COLOR, rgb -> entity.setColor(Color.fromRGB(rgb))); handleIntIfPresent(tag, DURATION, entity::setDuration); handleIntIfPresent(tag, REAPPLICATION_DELAY, entity::setReapplicationDelay); handleIntIfPresent(tag, WAIT_TIME, entity::setWaitTime); handleIntIfPresent(tag, DURATION_ON_USE, entity::setDurationOnUse); handleFloatIfPresent(tag, RADIUS, entity::setRadius); handleFloatIfPresent(tag, RADIUS_ON_USE, entity::setRadiusOnUse); handleFloatIfPresent(tag, RADIUS_PER_TICK, entity::setRadiusPerTick); if (tag.isString(PARTICLE)) { final String particle = tag.getString(PARTICLE); try { entity.setParticle(Particle.valueOf(particle)); } catch (IllegalArgumentException e) { GlowServer.logger.warning(() -> String.format( "Ignoring invalid particle type %s in tag %s", particle, tag)); } } if (tag.isCompoundList(EFFECTS)) { tag.getCompoundList(EFFECTS) .stream() .map(GlowMetaPotion::fromNbt) .forEach(effect -> entity.addCustomEffect(effect, false)); } }
Source:
public void testPartialSpecializationResolution_525288() throws Exception { String code = getAboveComment(); IFile file = importFile("testBug525288.cpp", code); int offset = code.indexOf("a0") - 5; IASTNode target = testF3(file, offset); assertInstance(target, IASTName.class); assertEquals("A<0>", ((IASTName) target).toString()); offset = code.indexOf("a1") - 5; target = testF3(file, offset); assertInstance(target, IASTName.class); assertEquals("A", ((IASTName) target).toString()); }

Target:
public void testPartialSpecializationResolution_525288() throws Exception { CPPASTNameBase.sAllowNameComputation = true; String code = getAboveComment(); IFile file = importFile("testBug525288.cpp", code); int offset = code.indexOf("a0") - 5; IASTNode target = testF3(file, offset); assertInstance(target, IASTName.class); assertEquals("A<0>", ((IASTName) target).toString()); offset = code.indexOf("a1") - 5; target = testF3(file, offset); assertInstance(target, IASTName.class); assertEquals("A", ((IASTName) target).toString()); }
Source:
public void transform(StructuredRecord in, Emitter<StructuredRecord> emitter) throws Exception { StructuredRecord.Builder builder = StructuredRecord.builder(outSchema); Schema inSchema = in.getSchema(); List<Field> inFields = inSchema.getFields(); for (Field field : inFields) { String name = field.getName(); if (!outSchemaMap.containsKey(name)) { continue; } Schema.Type outFieldType = outSchemaMap.get(name); if (!encodeMap.containsKey(name) || encodeMap.get(name) == EncodeType.NONE) { builder.set(name, in.get(name)); } else { byte[] obj = new byte[0]; if (field.getSchema().getType() == Schema.Type.STRING) { obj = ((String) in.get(name)).getBytes(); } else if (field.getSchema().getType() == Schema.Type.BYTES) { obj = in.get(name); } byte[] outValue = new byte[0]; EncodeType type = encodeMap.get(name); if (type == EncodeType.STRING_BASE32) { outValue = base32Encoder.encodeAsString(obj).getBytes(); } else if (type == EncodeType.BASE32) { outValue = base32Encoder.encode(obj); } else if (type == EncodeType.STRING_BASE64) { outValue = base64Encoder.encodeAsString(obj).getBytes(); } else if (type == EncodeType.BASE64) { outValue = base64Encoder.encode(obj); } else if (type == EncodeType.HEX) { outValue = hexEncoder.encode(obj); } if (outFieldType == Schema.Type.BYTES) { builder.set(name, outValue); } else if (outFieldType == Schema.Type.STRING) { builder.set(name, new String(outValue)); } } } emitter.emit(builder.build()); }

Target:
public void transform(StructuredRecord in, Emitter<StructuredRecord> emitter) throws Exception { StructuredRecord.Builder builder = StructuredRecord.builder(outSchema); Schema inSchema = in.getSchema(); List<Field> inFields = inSchema.getFields(); for (Field field : inFields) { String name = field.getName(); if (!outSchemaMap.containsKey(name)) { continue; } Schema.Type outFieldType = outSchemaMap.get(name); if (!encodeMap.containsKey(name) || encodeMap.get(name) == EncodeType.NONE) { builder.set(name, in.get(name)); } else { byte[] obj = new byte[0]; if (field.getSchema().getType() == Schema.Type.STRING) { obj = ((String) in.get(name)).getBytes(); } else if (field.getSchema().getType() == Schema.Type.BYTES) { obj = in.get(name); } byte[] outValue = new byte[0]; EncodeType type = encodeMap.get(name); if (type == EncodeType.STRING_BASE32) { outValue = base32Encoder.encodeAsString(obj).getBytes(); } else if (type == EncodeType.BASE32) { outValue = base32Encoder.encode(obj); } else if (type == EncodeType.STRING_BASE64) { outValue = base64Encoder.encodeAsString(obj).getBytes(); } else if (type == EncodeType.BASE64) { outValue = base64Encoder.encode(obj); } else if (type == EncodeType.HEX) { outValue = hexEncoder.encode(obj); } if (outFieldType == Schema.Type.BYTES) { builder.set(name, outValue); } else if (outFieldType == Schema.Type.STRING) { builder.set(name, new String(outValue, "UTF-8")); } } } emitter.emit(builder.build()); }
Source:
public void beforeShutdown(@Observes final BeforeShutdown bs) { ClassLoader loader; if (!WildFlySecurityManager.isChecking()) { loader = Thread.currentThread().getContextClassLoader(); } else { loader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { @Override public ClassLoader run() { return Thread.currentThread().getContextClassLoader(); } }); } TRACERS.remove(loader); }

Target:
public void beforeShutdown(@Observes final BeforeShutdown bs) { TRACERS.remove(WildFlySecurityManager.getCurrentContextClassLoaderPrivileged()); }
Source:
public void release() { for (RepoWalk repoWalk : repoWalksByProject.values()) { repoWalk.revWalk.release(); repoWalk.repository.close(); } }

Target:
public void release() { Iterator<Map.Entry<Project.NameKey, RepoWalk>> iterator = repoWalksByProject.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<Project.NameKey, RepoWalk> entry = iterator.next(); entry.getValue().revWalk.release(); entry.getValue().repository.close(); iterator.remove(); } }
Source:
private boolean checkIfImageDiskCanBeAdded(VM vm) { boolean returnValue; DiskValidator diskValidator = getDiskValidator(getParameters().getDiskInfo()); returnValue = validate(new StorageDomainValidator(getStorageDomain()).isDomainExistAndActive()) && checkImageConfiguration() && hasFreeSpace(getStorageDomain()) && checkExceedingMaxBlockDiskSize() && canAddShareableDisk() && validate(diskValidator.isVirtIoScsiValid(vm)); if (returnValue && vm != null) { StoragePool sp = getStoragePool(); returnValue = validate(new StoragePoolValidator(sp).isUp()) && isStoragePoolMatching(vm) && isVmNotLocked() && isVmNotInPreviewSnapshot(); } if (returnValue && getParameters().getDiskInfo().isShareable() && getStorageDomain().getStorageType() == StorageType.GLUSTERFS) { returnValue = false; addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_SHAREABLE_DISKS_NOT_SUPPORTED_ON_GLUSTER_DOMAIN); } return returnValue; }

Target:
private boolean checkIfImageDiskCanBeAdded(VM vm) { boolean returnValue; DiskValidator diskValidator = getDiskValidator(getParameters().getDiskInfo()); returnValue = validate(new StorageDomainValidator(getStorageDomain()).isDomainExistAndActive()) && checkImageConfiguration() && hasFreeSpace(getStorageDomain()) && checkExceedingMaxBlockDiskSize() && canAddShareableDisk() && validate(diskValidator.isVirtIoScsiValid(vm)); if (returnValue && getParameters().getDiskInfo().isShareable() && getStorageDomain().getStorageType() == StorageType.GLUSTERFS) { returnValue = false; addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_SHAREABLE_DISKS_NOT_SUPPORTED_ON_GLUSTER_DOMAIN); } if (returnValue && vm != null) { StoragePool sp = getStoragePool(); returnValue = validate(new StoragePoolValidator(sp).isUp()) && isStoragePoolMatching(vm) && isVmNotLocked() && isVmNotInPreviewSnapshot(); } return returnValue; }
Source:
public void beginContact(Contact contact) { Object dataA = contact.getFixtureA().getBody().getUserData(); Object dataB = contact.getFixtureB().getBody().getUserData(); if (dataA instanceof EntityRef && dataB instanceof EntityRef) { EntityRef entityA = (EntityRef) dataA; EntityRef entityB = (EntityRef) dataB; entitySystemManager.sendEvent(new ContactEvent(entityB, contact), entityA); entitySystemManager.sendEvent(new ContactEvent(entityA, contact), entityB); } if (dataA instanceof EntityRef) { dataA = new SolObjectEntityWrapper((EntityRef) dataA); } if (dataB instanceof EntityRef) { dataB = new SolObjectEntityWrapper((EntityRef) dataB); } SolObject oA = (SolObject) dataA; SolObject oB = (SolObject) dataB; boolean aIsProj = oA instanceof Projectile; if (!aIsProj && !(oB instanceof Projectile)) { return; } Projectile proj = (Projectile) (aIsProj ? oA : oB); SolObject o = aIsProj ? oB : oA; proj.setObstacle(o, myGame); }

Target:
public void beginContact(Contact contact) { Object dataA = contact.getFixtureA().getBody().getUserData(); Object dataB = contact.getFixtureB().getBody().getUserData(); if (dataA instanceof EntityRef && dataB instanceof EntityRef) { EntityRef entityA = (EntityRef) dataA; EntityRef entityB = (EntityRef) dataB; entitySystemManager.sendEvent(new ContactEvent(entityB, contact), entityA); entitySystemManager.sendEvent(new ContactEvent(entityA, contact), entityB); } if (dataA instanceof EntityRef) { dataA = new SolObjectEntityWrapper((EntityRef) dataA); } if (dataB instanceof EntityRef) { dataB = new SolObjectEntityWrapper((EntityRef) dataB); } SolObject firstSolObject = (SolObject) dataA; SolObject secondSolObject = (SolObject) dataB; boolean firstSolObjectIsProjectile = firstSolObject instanceof Projectile; if (!firstSolObjectIsProjectile && !(secondSolObject instanceof Projectile)) { return; } Projectile projectile = (Projectile) (firstSolObjectIsProjectile ? firstSolObject : secondSolObject); SolObject solObject = firstSolObjectIsProjectile ? secondSolObject : firstSolObject; projectile.setObstacle(solObject, myGame); }
Source:
private void ensureOpen(final AsyncCompletionHandler<Void> handler) { if (!channelFuture.isDone()) { channelFuture.syncUninterruptibly(); } if (!channelFuture.isSuccess()) { handler.failed(new MongoSocketOpenException("Exception opening socket", address, channelFuture.cause())); } else if (pendingException != null) { handler.failed(pendingException); } else { handler.completed(null); } }

Target:
private synchronized void ensureOpen(final AsyncCompletionHandler<Void> handler) { if (pendingException != null) { handler.failed(pendingException); } else if (!channelFuture.isDone()) { channelFuture.addListener(new GenericFutureListener<Future<? super Void>>() { @Override public void operationComplete(final Future<? super Void> future) throws Exception { handleChannelFutureCompletion(handler); } }); } else { handleChannelFutureCompletion(handler); } }
Source:
private int detectCompletionType(IDocument doc, String text, int offset) { if (offset == 0) return COMPLETION_TYPE_HEADER; IRegion lineInfo = null; try { lineInfo = doc.getLineInformationOfOffset(offset); } catch (BadLocationException e) { e.printStackTrace(); return COMPLETION_TYPE_UNKNOWN; } String lineText = text.substring(lineInfo.getOffset(), lineInfo.getOffset() + lineInfo.getLength()); int deltaOffset = offset - lineInfo.getOffset(); String partialLineText = lineText.substring(0, deltaOffset); if (partialLineText.matches(TAG_MATCH_REGEXP)) { Pattern regex = Pattern.compile(TAG_PREFIX_MATCH); Matcher matcher = regex.matcher(partialLineText); matcher.matches(); prefix = matcher.group(1); return COMPLETION_TYPE_TAG; } if (partialLineText.matches(ATTRIBUTE_NAME_MATCH_REGEXP)) { Pattern regex = Pattern.compile(ATTRIBUTE_NAME_PREFIX_MATCH); Matcher matcher = regex.matcher(partialLineText); matcher.matches(); prefix = matcher.group("prefix"); regex = Pattern.compile(ATTRIBUTE_NAME_ACKEY_MATCH); matcher = regex.matcher(partialLineText); matcher.matches(); acKey = matcher.group("ackey"); return COMPLETION_TYPE_ATTRIBUTE_NAME; } if (partialLineText.matches(ATTRIBUTE_VALUE_MATCH_REGEXP)) { Pattern regex = Pattern.compile(ATTRIBUTE_VALUE_PREFIX_MATCH); Matcher matcher = regex.matcher(partialLineText); matcher.matches(); prefix = matcher.group("prefix"); regex = Pattern.compile(ATTRIBUTE_VALUE_ACKEY_MATCH); matcher = regex.matcher(partialLineText); matcher.matches(); acKey = matcher.group("ackey"); return COMPLETION_TYPE_ATTRIBUTE_VALUE; } return COMPLETION_TYPE_UNKNOWN; }

Target:
private int detectCompletionType(IDocument doc, String text, int offset) { if (offset == 0){ return COMPLETION_TYPE_HEADER; } IRegion lineInfo = null; try { lineInfo = doc.getLineInformationOfOffset(offset); } catch (BadLocationException e) { e.printStackTrace(); return COMPLETION_TYPE_UNKNOWN; } String lineText = text.substring(lineInfo.getOffset(), lineInfo.getOffset() + lineInfo.getLength()); int deltaOffset = offset - lineInfo.getOffset(); String partialLineText = lineText.substring(0, deltaOffset); if (partialLineText.matches(TAG_MATCH_REGEXP)) { Matcher matcher = TAG_PREFIX_PATTERN.matcher(partialLineText); matcher.matches(); prefix = matcher.group(1); return COMPLETION_TYPE_TAG; } if (partialLineText.matches(ATTRIBUTE_NAME_MATCH_REGEXP)) { Matcher matcher = ATT_NAME_PREFIX_PATTERN.matcher(partialLineText); matcher.matches(); prefix = matcher.group("prefix"); matcher = ATTR_NAME_ACKEY_MATCH.matcher(partialLineText); matcher.matches(); acKey = matcher.group("ackey"); return COMPLETION_TYPE_ATTRIBUTE_NAME; } if (partialLineText.matches(ATTRIBUTE_VALUE_MATCH_REGEXP)) { Matcher matcher = ATTR_VALUE_PREFIX_PATTERN.matcher(partialLineText); matcher.matches(); prefix = matcher.group("prefix"); matcher = ATTR_VALUE_ACKEY_PATTERN.matcher(partialLineText); matcher.matches(); acKey = matcher.group("ackey"); return COMPLETION_TYPE_ATTRIBUTE_VALUE; } return COMPLETION_TYPE_UNKNOWN; }
Source:
void enableSSL(SslSimpleBuilder builder) { sslBuilder = builder; }

Target:
public void enableSSL(SslSimpleBuilder builder) { sslBuilder = builder; }
Source:
public void shortenUrl() throws IOException { Manifests.DEFAULT.put("Nerodesk-BitlyId", "nerodesk"); Manifests.DEFAULT.put( "Nerodesk-BitlyKey", "R_95c4f6c85c67498bba37a73872577410" ); final String label = "shorten"; final CdShortUrl doc = new CdShortUrl(this.createDoc(label, label)); MatcherAssert.assertThat( doc.shortUrl(), Matchers.equalTo("<LINK_0>") ); }

Target:
public void shortenUrl() throws IOException { final Doc doc = Mockito.mock(Doc.class); final String first = "<LINK_1>"; Mockito.when(doc.shortUrl()).thenReturn(first) .thenReturn("<LINK_2>"); final Doc cdd = new CdShortUrl(doc); MatcherAssert.assertThat( cdd.shortUrl(), Matchers.equalTo(first) ); MatcherAssert.assertThat( cdd.shortUrl(), Matchers.equalTo(first) ); }
Source:
public Observable<List<SearchedEntity>> searchResources(final String query, String resources, final Boolean exactMatch) { switch (PrefManager.getUserStatus()) { case 0: return baseApiManager.getSearchApi().searchResources(query, resources, exactMatch); case 1: if (resources.equals(Constants.ENTITY_TYPE_CLIENTS)) { return mDatabaseHelperClient.readAllClientsByQuery(query, exactMatch); } else if (resources.equals(Constants.ENTITY_TYPE_GROUPS)) { return mDatabaseHelperGroup.readAllGroupsByQuery(query, exactMatch) .mergeWith(mDatabaseHelperCenter.readAllCentersByQuery(query, exactMatch)); } else if (resources.equals(Constants.ENTITY_TYPE_LOANS)) { return mDatabaseHelperLoan.readAllLoansByQuery(query, exactMatch); } else if (resources.equals(Constants.ENTITY_TYPE_SAVINGS)) { return mDatabaseHelperSaving.readAllSavingsByQuery(query, exactMatch); } else { return mDatabaseHelperClient.readAllClientsByQuery(query, exactMatch) .mergeWith(mDatabaseHelperGroup.readAllGroupsByQuery(query, exactMatch)) .mergeWith(mDatabaseHelperLoan.readAllLoansByQuery(query, exactMatch)) .mergeWith(mDatabaseHelperSaving.readAllSavingsByQuery(query, exactMatch)); } default: return Observable.just((List<SearchedEntity>) new ArrayList<SearchedEntity>()); } }

Target:
public Observable<List<SearchedEntity>> searchResources(final String query, String resources, final Boolean exactMatch) { switch (PrefManager.getUserStatus()) { case 0: return baseApiManager.getSearchApi().searchResources(query, resources, exactMatch); case 1: if (resources.equals(Constants.ENTITY_TYPE_CLIENTS)) { return mDatabaseHelperClient.readAllClientsByQuery(query, exactMatch); } else if (resources.equals(Constants.ENTITY_TYPE_GROUPS)) { return Observable.merge(mDatabaseHelperGroup.readAllGroupsByQuery(query, exactMatch), mDatabaseHelperCenter.readAllCentersByQuery(query, exactMatch)); } else if (resources.equals(Constants.ENTITY_TYPE_LOANS)) { return mDatabaseHelperLoan.readAllLoansByQuery(query, exactMatch); } else if (resources.equals(Constants.ENTITY_TYPE_SAVINGS)) { return mDatabaseHelperSaving.readAllSavingsByQuery(query, exactMatch); } else { return Observable.merge(mDatabaseHelperClient.readAllClientsByQuery(query, exactMatch), (mDatabaseHelperGroup.readAllGroupsByQuery(query, exactMatch)), (mDatabaseHelperLoan.readAllLoansByQuery(query, exactMatch)), (mDatabaseHelperSaving.readAllSavingsByQuery(query, exactMatch))); } default: return Observable.just((List<SearchedEntity>) new ArrayList<SearchedEntity>()); } }
Source:
public void testAdditionalProtocols() { Validator validator = getValidator(); assertNumberOfViolations( validator.validate( new Bar( "<img src='data:image/png;base64,100101' />" ) ), 0 ); assertNumberOfViolations( validator.validate( new Bar( "<img/>" ) ), 0 ); assertNumberOfViolations( validator.validate( new Bar( "<img src='not_data:image/png;base64,100101' />" ) ), 1 ); assertNumberOfViolations( validator.validate( new Bar( "<img not_src='data:image/png;base64,100101' />" ) ), 1 ); assertNumberOfViolations( validator.validate( new Bar( "<div src='data:image/png;base64,100101' />" ) ), 1 ); assertNumberOfViolations( validator.validate( new Bar( "<div src='data:image/png;base64,100101' />" ) ), 1 ); assertNumberOfViolations( validator.validate( new Bar( "<custom>" + " <img src='data:image/png;base64,100101' />" + " <custom attr1='strange_protocol:some_text' />" + " <custom attr3='some_protocol:some_text' />" + " <custom><img /></custom>" + " <section id='sec1' attr='val'></section>" + " <custom attr1='dataprotocol:some_text' attr2='strange_protocol:some_text' />" + "</custom>" ) ), 0 ); }

Target:
public void testAdditionalProtocols() { Validator validator = getValidator(); assertNumberOfViolations( validator.validate( new Bar( "<img src='data:image/png;base64,100101' />" ) ), 0 ); assertNumberOfViolations( validator.validate( new Bar( "<img/>" ) ), 0 ); assertNumberOfViolations( validator.validate( new Bar( "<img src='not_data:image/png;base64,100101' />" ) ), 1 ); assertNumberOfViolations( validator.validate( new Bar( "<img not_src='data:image/png;base64,100101' />" ) ), 1 ); assertNumberOfViolations( validator.validate( new Bar( "<div src='data:image/png;base64,100101' />" ) ), 1 ); assertNumberOfViolations( validator.validate( new Bar( "<div src='data:image/png;base64,100101' />" ) ), 1 ); assertNumberOfViolations( validator.validate( new Bar( "<custom>" + " <img src='data:image/png;base64,100101' />" + " <custom attr1='strange_protocol:some_text' />" + " <custom attr3='some_protocol:some_text' />" + " <custom><img /></custom>" + " <section id='sec1' attr='val'></section>" + " <custom attr1='dataprotocol:some_text' attr2='strange_protocol:some_text' />" + "</custom>" ) ), 0 ); assertNumberOfViolations( validator.validate( new Bar( "<div>" + "<img src='not_data:image/png;base64,100101' />" + "<custom attr1='strange_protocol:some_text' />" + "/<div>" ) ), 1 ); }
Source:
public void hashFirstNRowComponents(int numberOfComponents) { Preconditions.checkState(state == State.DEFINING_ROW_NAME, "Can only indicate hashFirstNRowComponents() inside the rowName scope."); Preconditions.checkState(rowNameComponents.isEmpty(), "hashFirstNRowComponents must be the first row component"); numberOfComponentsHashed = numberOfComponents; ignoreHotspottingChecks = true; }

Target:
public void hashFirstNRowComponents(int numberOfComponents) { Preconditions.checkState(numberOfComponents >= 0, "Need to specify a non-negative number of components to hash."); checkHashRowComponentsPreconditions("hashFirstNRowComponents"); numberOfComponentsHashed = numberOfComponents; ignoreHotspottingChecks = true; }
Source:
public void write() { Document doc = createDocument(); Element rootElement = doc.createElement("options"); doc.appendChild(rootElement); Element sound = doc.createElement("sound"); sound.appendChild(doc.createTextNode(Integer.toString(this.sound))); rootElement.appendChild(sound); Element controls = doc.createElement("controls"); rootElement.appendChild(controls); Element left = doc.createElement("left"); left.appendChild(doc.createTextNode(this.left.getName())); controls.appendChild(left); Element right = doc.createElement("right"); right.appendChild(doc.createTextNode(this.right.getName())); controls.appendChild(right); Element shoot = doc.createElement("shoot"); shoot.appendChild(doc.createTextNode(this.shoot.getName())); controls.appendChild(shoot); try { TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(new File(file)); transformer.transform(source, result); } catch (TransformerConfigurationException e) { e.printStackTrace(); } catch (TransformerException e) { e.printStackTrace(); } }

Target:
public void write() { Document doc = appendElements(); try { TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(new File(file)); transformer.transform(source, result); } catch (TransformerConfigurationException e) { e.printStackTrace(); } catch (TransformerException e) { e.printStackTrace(); } }
Source:
public NonBlockingRouterFactory(VerifiableProperties verifiableProperties, ClusterMap clusterMap, NotificationSystem notificationSystem) { if (verifiableProperties != null && clusterMap != null && notificationSystem != null) { routerConfig = new RouterConfig(verifiableProperties); registry = clusterMap.getMetricRegistry(); routerMetrics = new NonBlockingRouterMetrics(registry); this.clusterMap = clusterMap; this.notificationSystem = notificationSystem; } else { StringBuilder errorMessage = new StringBuilder("Null arg(s) received during instantiation of CoordinatorBackedRouterFactory -"); if (verifiableProperties == null) { errorMessage.append(" [VerifiableProperties] "); } if (clusterMap == null) { errorMessage.append(" [ClusterMap] "); } if (notificationSystem == null) { errorMessage.append(" [NotificationSystem] "); } throw new IllegalArgumentException(errorMessage.toString()); } logger.trace("Instantiated NonBlockingRouterFactory"); }

Target:
public NonBlockingRouterFactory(VerifiableProperties verifiableProperties, ClusterMap clusterMap, NotificationSystem notificationSystem) throws Exception { if (verifiableProperties != null && clusterMap != null && notificationSystem != null) { routerConfig = new RouterConfig(verifiableProperties); MetricRegistry registry = clusterMap.getMetricRegistry(); routerMetrics = new NonBlockingRouterMetrics(registry); this.clusterMap = clusterMap; this.notificationSystem = notificationSystem; networkConfig = new NetworkConfig(verifiableProperties); networkMetrics = new NetworkMetrics(registry); SSLConfig sslConfig = new SSLConfig(verifiableProperties); sslFactory = sslConfig.sslEnabledDatacenters.length() > 0 ? new SSLFactory(sslConfig) : null; this.time = SystemTime.getInstance(); } else { throw new IllegalArgumentException("Null argument passed in"); } logger.trace("Instantiated NonBlockingRouterFactory"); }
Source:
protected int getMaxResults() { if (getUriInfo()!=null && QueryHelper.hasMatrixParam(getUriInfo(), MAX)) { HashMap<String,String> matrixConstraints = QueryHelper.getMatrixConstraints(getUriInfo(), MAX); String maxString = matrixConstraints.get(MAX); try { return Integer.valueOf(maxString); } catch (NumberFormatException e) { LOG.error("Max number of results is not a valid number: '" + maxString + "'. Resorting to default behavior - no limit on number of query results."); return Integer.MAX_VALUE; } } else { return Integer.MAX_VALUE; } }

Target:
protected int getMaxResults() { if (getUriInfo()!=null && QueryHelper.hasMatrixParam(getUriInfo(), MAX)) { HashMap<String,String> matrixConstraints = QueryHelper.getMatrixConstraints(getUriInfo(), MAX); String maxString = matrixConstraints.get(MAX); try { return Integer.valueOf(maxString); } catch (NumberFormatException e) { LOG.error("Max number of results is not a valid number: '" + maxString + "'. Resorting to default behavior - no limit on number of query results."); return NO_LIMIT; } } else { return NO_LIMIT; } }
Source:
protected String getSoqlForRemoteIds() { String fullQuery = getQuery(0); StringBuffer soql = new StringBuffer(); soql.append("SELECT ").append(getIdFieldName()).append(" FROM"); StringTokenizer tokenizer = new StringTokenizer(fullQuery, " ", false); int depth = 0; boolean afterFrom = false; while (tokenizer.hasMoreElements()) { String token = tokenizer.nextToken(); if (afterFrom) { soql.append(" ").append(token); } if (token.startsWith("(")) { depth++; } else if (token.endsWith(")")) { depth--; } else if (depth == 0 && afterFrom == false && token.toLowerCase().equals("from")) { afterFrom = true; } } return soql.toString(); }

Target:
protected String getSoqlForRemoteIds() { String fullQuery = getQuery(0); StringBuffer soql = new StringBuffer(); soql.append("SELECT ").append(getIdFieldName()).append(" FROM"); StringTokenizer tokenizer = new StringTokenizer(fullQuery, " ", false); int depth = 0; boolean afterFrom = false; while (tokenizer.hasMoreElements()) { String token = tokenizer.nextToken(); if (afterFrom) { soql.append(" ").append(token); } if (token.startsWith("(")) { depth++; } else if (token.endsWith(")")) { depth--; } else if (depth == 0 && !afterFrom && token.toLowerCase(Locale.US).equals("from")) { afterFrom = true; } } return soql.toString(); }
Source:
private void processPenaltyCodes(Settings s) { updates.add(new WSUpdate("ScoreBoard.PenaltyCode", null)); String file = s.get(PenaltyCodesManager.PenaltiesFileSetting); if(file != null && !file.isEmpty()) { try { PenaltyCodesDefinition penalties = pm.loadFromJSON(file); for(PenaltyCode p : penalties.getPenalties()) { updates.add(new WSUpdate("ScoreBoard.PenaltyCode."+p.getCode(), p.CuesForWS(p))); } updates.add(new WSUpdate("ScoreBoard.PenaltyCode.?","Unknown")); } catch (Exception e) { throw new RuntimeException(e); } } }

Target:
private void processPenaltyCodes(Settings s) { updates.add(new WSUpdate("ScoreBoard.PenaltyCode", null)); String file = s.get(PenaltyCodesManager.PenaltiesFileSetting); if(file != null && !file.isEmpty()) { PenaltyCodesDefinition penalties = pm.loadFromJSON(file); for(PenaltyCode p : penalties.getPenalties()) { updates.add(new WSUpdate("ScoreBoard.PenaltyCode."+p.getCode(), p.CuesForWS(p))); } updates.add(new WSUpdate("ScoreBoard.PenaltyCode.?","Unknown")); } }
Source:
public DictionaryInterface setString(String key, String value) { return setObject(key, value); }

Target:
public Dictionary setString(String key, String value) { return setObject(key, value); }
Source:
public void testLookSensorValues() throws InterpretationException { Formula lookXPositionFormula = getFormulaBySensor(Sensors.OBJECT_X); assertEquals(LOOK_X_POSITION, lookXPositionFormula.interpretDouble(testSprite), DELTA); Formula lookYPositionFormula = getFormulaBySensor(Sensors.OBJECT_Y); assertEquals(LOOK_Y_POSITION, lookYPositionFormula.interpretDouble(testSprite), DELTA); Formula lookAlphaValueFormula = getFormulaBySensor(Sensors.OBJECT_TRANSPARENCY); assertEquals(LOOK_ALPHA, lookAlphaValueFormula.interpretDouble(testSprite), DELTA); Formula lookBrightnessFormula = getFormulaBySensor(Sensors.OBJECT_BRIGHTNESS); assertEquals(LOOK_BRIGHTNESS, lookBrightnessFormula.interpretDouble(testSprite), DELTA); Formula lookScaleFormula = getFormulaBySensor(Sensors.OBJECT_SIZE); assertEquals(LOOK_SCALE, lookScaleFormula.interpretDouble(testSprite), DELTA); Formula lookRotateFormula = getFormulaBySensor(Sensors.OBJECT_ROTATION); assertEquals(LOOK_ROTATION, lookRotateFormula.interpretDouble(testSprite), DELTA); Formula lookZPositionFormula = getFormulaBySensor(Sensors.OBJECT_LAYER); assertEquals(1, lookZPositionFormula.interpretInteger(testSprite).intValue()); }

Target:
public void testLookSensorValues() throws InterpretationException { Formula lookXPositionFormula = getFormulaBySensor(Sensors.OBJECT_X); assertEquals(LOOK_X_POSITION, lookXPositionFormula.interpretDouble(testSprite), DELTA); Formula lookYPositionFormula = getFormulaBySensor(Sensors.OBJECT_Y); assertEquals(LOOK_Y_POSITION, lookYPositionFormula.interpretDouble(testSprite), DELTA); Formula lookAlphaValueFormula = getFormulaBySensor(Sensors.OBJECT_TRANSPARENCY); assertEquals(LOOK_ALPHA, lookAlphaValueFormula.interpretDouble(testSprite), DELTA); Formula lookBrightnessFormula = getFormulaBySensor(Sensors.OBJECT_BRIGHTNESS); assertEquals(LOOK_BRIGHTNESS, lookBrightnessFormula.interpretDouble(testSprite), DELTA); Formula lookScaleFormula = getFormulaBySensor(Sensors.OBJECT_SIZE); assertEquals(LOOK_SCALE, lookScaleFormula.interpretDouble(testSprite), DELTA); Formula lookRotateFormula = getFormulaBySensor(Sensors.OBJECT_ROTATION); assertEquals(LOOK_ROTATION, lookRotateFormula.interpretDouble(testSprite), DELTA); Formula lookZPositionFormula = getFormulaBySensor(Sensors.OBJECT_LAYER); assertEquals(1.0, lookZPositionFormula.interpretDouble(testSprite)); }
Source:
private RemoteServerDialog(RemoteServerDialogForm form, Http http) { this.form = form; this.form.onConnect(server -> { Response<Boolean> response = server.testPull(http); if (response.isSuccess()) { triggerConnect(server); form.hideDialog(); } else { String error = response.isRedirection() ? "Redirection detected.\n\nPlease, review the connection parameters and try again." : response.isUnauthorized() ? "Wrong credentials.\n\nPlease, review the connection parameters and try again." : response.isNotFound() ? "Aggregate not found.\n\nPlease, review the connection parameters and try again." : "Please, review the connection parameters and try again."; showErrorDialog(form, error, "Wrong connection parameters"); } }); }

Target:
private RemoteServerDialog(RemoteServerDialogForm form, Http http) { this.form = form; this.form.onConnect(server -> { form.setTestingConnection(); new Thread(() -> { try { Response<Boolean> response = server.testPull(http); if (response.isSuccess()) { triggerConnect(server); form.hideDialog(); } else showError( response.isRedirection() ? "Redirection detected" : response.isUnauthorized() ? "Wrong credentials" : response.isNotFound() ? "Aggregate not found" : "", response.isRedirection() ? "Unexpected error" : "Configuration error" ); } catch (HttpException e) { showError(e.getMessage(), "Unexpected error"); } finally { form.unsetTestingConnection(); } }).start(); }); }