auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void onNext(final DataOperation<Long> op) { final LongKeyOperation operation = (LongKeyOperation) op; final String dataType = operation.getDataType(); final List<LongRange> dataKeyRanges = operation.getDataKeyRanges(); final Map<Integer, Pair<Long, Long>> blockToSubKeyRangeMap; final Iterator<LongRange> rangeIterator = dataKeyRanges.iterator(); try { <START> routerLock.readLock().lock(); <END> if (rangeIterator.hasNext()) { final LongRange keyRange = rangeIterator.next(); blockToSubKeyRangeMap = router.resolveBlocks(keyRange.getMinimumLong(), keyRange.getMaximumLong()); } else { LOG.log(Level.SEVERE, "Invalid operation"); resultAggregator.submitLocalResult(operation, Collections.EMPTY_MAP, Collections.EMPTY_LIST); return; } while (rangeIterator.hasNext()) { final LongRange keyRange = rangeIterator.next(); blockToSubKeyRangeMap.putAll(router.resolveBlocks(keyRange.getMinimumLong(), keyRange.getMaximumLong())); } final int numSubOps = blockToSubKeyRangeMap.size(); resultAggregator.registerOp(operation, numSubOps); if (!blockToSubKeyRangeMap.isEmpty()) { if (typeToBlocks.containsKey(dataType)) { enqueueOperation(operation, blockToSubKeyRangeMap); } else { if (operation.getOperationType() == DataOpType.PUT) { initBlocks(dataType); enqueueOperation(operation, blockToSubKeyRangeMap); } } } } finally { routerLock.readLock().unlock(); } }</code><technical_language>do require a lock router here. L380's resolveBlocks is affected router update</technical_language>

Target:
public void onNext(final DataOperation<Long> op) { final LongKeyOperation operation = (LongKeyOperation) op; final String dataType = operation.getDataType(); final List<LongRange> dataKeyRanges = operation.getDataKeyRanges(); final Map<Integer, Pair<Long, Long>> blockToSubKeyRangeMap; final Iterator<LongRange> rangeIterator = dataKeyRanges.iterator(); if (rangeIterator.hasNext()) { final LongRange keyRange = rangeIterator.next(); blockToSubKeyRangeMap = blockResolver.resolveBlocksForOrderedKeys(keyRange.getMinimumLong(), keyRange.getMaximumLong()); } else { LOG.log(Level.SEVERE, "Invalid operation"); resultAggregator.submitLocalResult(operation, Collections.EMPTY_MAP, Collections.EMPTY_LIST); return; } while (rangeIterator.hasNext()) { final LongRange keyRange = rangeIterator.next(); blockToSubKeyRangeMap.putAll( blockResolver.resolveBlocksForOrderedKeys(keyRange.getMinimumLong(), keyRange.getMaximumLong())); } final int numSubOps = blockToSubKeyRangeMap.size(); resultAggregator.registerOp(operation, numSubOps); if (!blockToSubKeyRangeMap.isEmpty()) { if (typeToBlocks.containsKey(dataType)) { enqueueOperation(operation, blockToSubKeyRangeMap); } else { if (operation.getOperationType() == DataOpType.PUT) { initBlocks(dataType); enqueueOperation(operation, blockToSubKeyRangeMap); } } } }
Source:
<code>private void sendColorized(String msg, TextColor formatting) { <START> for (String part : msg.split("\n")) { <END> this.player.sendMessage(Text.of(formatting, part)); } }</code><technical_language>Splitting this necessary, texts new lines</technical_language>

Target:
private void sendColorized(String msg, TextColor formatting) { for (String part : msg.split("\n")) { this.player.sendMessage(Text.of(formatting, TextSerializers.LEGACY_FORMATTING_CODE.deserialize(part))); } }
Source:
<code>private static Object toJdbcCompatObject(Connection connection, Object arg) { if (arg == null) { return null; } if (arg instanceof Map) { try { return toPGObjectJson(toJsonString(((Map) arg))); } catch (SQLException | IOException e) { throw new RuntimeException(e); } } if (arg.getClass().isArray()) { arg = Arrays.asList((Object[]) arg); } if (arg instanceof Collection) { Collection values = (Collection) arg; if (values.isEmpty()) { return null; <START> } else if (values.iterator().next() instanceof Map) { <END> try { return connection.createArrayOf(ObjectType.NAME, values.toArray(new Object[0])); } catch (SQLException e) { throw new RuntimeException(e); } } List<Object> convertedValues = new ArrayList<>(values.size()); PGType pgType = null; for (Object value : values) { convertedValues.add(toJdbcCompatObject(connection, value)); if (pgType == null && value != null) { pgType = PGTypes.get(DataTypes.guessType(value)); } } try { return connection.createArrayOf(pgType.typName(), convertedValues.toArray(new Object[0])); } catch (SQLException e) { throw new RuntimeException(e); } } return arg; }</code><technical_language>Do need this custom case handling ? regular logic converted values accomplish same</technical_language>

Target:
private static Object toJdbcCompatObject(Connection connection, Object arg) { if (arg == null || arg instanceof Map) { return arg; } if (arg.getClass().isArray()) { arg = Arrays.asList((Object[]) arg); } if (arg instanceof Collection) { Collection values = (Collection) arg; if (values.isEmpty()) { return null; } List<Object> convertedValues = new ArrayList<>(values.size()); PGType pgType = null; for (Object value : values) { convertedValues.add(toJdbcCompatObject(connection, value)); if (pgType == null && value != null) { pgType = PGTypes.get(DataTypes.guessType(value)); } } try { return connection.createArrayOf(pgType.typName(), convertedValues.toArray(new Object[0])); } catch (SQLException e) { throw new RuntimeException(e); } } return arg; }
Source:
<code>public void get(@SpringBean PageModel pageModel, @RequestParam(value = "breadcrumbOverride", required = false) String breadcrumbOverride, @SpringBean("patientService") PatientService patientService, @RequestParam("patientId") String patientId) { <START> String conceptId = Context.getAdministrationService().getGlobalProperty("concept.causeOfDeath"); <END> Patient patient = patientService.getPatientByUuid(patientId); pageModel.put("birthDate", patient.getBirthdate()); pageModel.put("patient", patient); pageModel.put("patientId", patientId); pageModel.put("breadcrumbOverride", breadcrumbOverride); if (conceptId != null && !conceptId.contains("[a-zA-Z]+")) { pageModel.put("conceptAnswers", getConceptAnswerByConcept(Integer.parseInt(conceptId))); } }</code><technical_language>concept uuid instead of numeric internal database id, for global property</technical_language>

Target:
public void get(@SpringBean PageModel pageModel, @RequestParam(value = "breadcrumbOverride", required = false) String breadcrumbOverride, @SpringBean("patientService") PatientService patientService, @RequestParam("patientId") String patientId) { String conceptId = Context.getAdministrationService().getGlobalProperty("concept.causeOfDeath"); Patient patient = patientService.getPatientByUuid(patientId); pageModel.put("birthDate", patient.getBirthdate()); pageModel.put("patient", patient); pageModel.put("patientId", patientId); pageModel.put("breadcrumbOverride", breadcrumbOverride); if (conceptId != null && !conceptId.contains("[a-zA-Z]+")) { pageModel.put("conceptAnswers", getConceptAnswers(Integer.parseInt(conceptId))); } }
Source:
<code>public void testMappingWithoutToDate() throws Exception { GeodesyMLType mobs = marshaller.unmarshal(TestResources.geodesyMLTestDataSiteLogReader("IRKJ_RadioInterference_NoToDate"), GeodesyMLType.class) .getValue(); SiteLogType logItem = GeodesyMLUtils.getElementFromJAXBElements(mobs.getElements(), SiteLogType.class) .findFirst().get(); RadioInterferencesType radioInterferencesDTO = logItem.getRadioInterferencesSet().get(0).getRadioInterferences(); RadioInterference radioInterferenceEntity = mapper.to(radioInterferencesDTO); assertCommon(radioInterferencesDTO, radioInterferenceEntity, MappingDirection.FROM_DTO_TO_ENTITY); <START> MatcherAssert.assertThat(((TimePeriodType) radioInterferencesDTO.getValidTime().getAbstractTimePrimitive().getValue()).getEndPosition().getValue().size(), Is.is(0)); <END> MatcherAssert.assertThat(radioInterferenceEntity.getEffectiveDates().getTo(), IsNull.nullValue()); RadioInterferencesType radioInterferencesDTO2 = mapper.from(radioInterferenceEntity); assertCommon(radioInterferencesDTO, radioInterferenceEntity, MappingDirection.FROM_ENTITY_TO_DTO); MatcherAssert.assertThat(((TimePeriodType) radioInterferencesDTO2.getValidTime().getAbstractTimePrimitive().getValue()).getEndPosition(), IsNull.nullValue()); }</code><technical_language>check line length rule</technical_language>

Target:
public void testMappingWithoutToDate() throws Exception { GeodesyMLType mobs = marshaller.unmarshal(TestResources.geodesyMLTestDataSiteLogReader("IRKJ_RadioInterference_NoToDate"), GeodesyMLType.class).getValue(); SiteLogType logItem = GeodesyMLUtils.getElementFromJAXBElements(mobs.getElements(), SiteLogType.class).findFirst().get(); RadioInterferencesType radioInterferencesDTO = logItem.getRadioInterferencesSet().get(0).getRadioInterferences(); RadioInterference radioInterferenceEntity = mapper.to(radioInterferencesDTO); assertCommonFields(radioInterferencesDTO, radioInterferenceEntity, MappingDirection.FROM_DTO_TO_ENTITY); assertThat(((TimePeriodType) radioInterferencesDTO.getValidTime().getAbstractTimePrimitive().getValue()).getEndPosition() .getValue().size(), is(0)); assertThat(radioInterferenceEntity.getEffectiveDates().getTo(), nullValue()); RadioInterferencesType radioInterferencesDTO2 = mapper.from(radioInterferenceEntity); assertCommonFields(radioInterferencesDTO, radioInterferenceEntity, MappingDirection.FROM_ENTITY_TO_DTO); assertThat(((TimePeriodType) radioInterferencesDTO2.getValidTime().getAbstractTimePrimitive().getValue()).getEndPosition(), nullValue()); }
Source:
<code>public Optional<MetacardValidationReport> validateMetacard(Metacard metacard) { Attribute attribute = metacard.getAttribute(sourceAttribute); if (attribute != null <START> && attribute.getValues().stream().filter(Objects::nonNull).count() > 0 <END> && (StringUtils.isEmpty(sourceValue) || attribute.getValues().contains(sourceValue))) { MetacardValidationReportImpl report = new MetacardValidationReportImpl(); Optional<ValidationViolation> violation = relationships.get(relationship).apply(metacard.getAttribute(targetAttribute)); violation.ifPresent(report::addAttributeViolation); return Optional.of(report); } else { return Optional.empty(); } }</code><technical_language>stream().anyMatch(Objects::nonNull)</technical_language>

Target:
public Optional<MetacardValidationReport> validateMetacard(Metacard metacard) { Attribute attribute = metacard.getAttribute(sourceAttribute); if (attribute != null && attribute.getValues().stream().anyMatch(Objects::nonNull) && (StringUtils.isEmpty(sourceValue) || attribute.getValues().contains(sourceValue))) { MetacardValidationReportImpl report = new MetacardValidationReportImpl(); Attribute actualAttribute = metacard.getAttribute(targetAttribute); Collection<String> actualValues = actualAttribute == null ? Collections.emptyList() : actualAttribute .getValues() .stream() .map(Objects::toString) .filter(StringUtils::isNotEmpty) .collect(Collectors.toList()); Optional<ValidationViolation> violation = relationships.get(relationship).apply(actualValues); violation.ifPresent(report::addAttributeViolation); if (violation.isPresent()) { return Optional.of(report); } else { return Optional.empty(); } } else { return Optional.empty(); } }
Source:
<code><START> public Mono<NamedEntityResult> recognizePiiEntities(String text) { <END> return recognizePiiEntitiesWithResponse(text, defaultLanguage).flatMap(FluxUtil::toMono); }</code><technical_language>So, PII information provided plain text? If so, a security concern</technical_language>

Target:
public Mono<RecognizePiiEntitiesResult> recognizePiiEntities(String text) { try { return recognizePiiEntitiesWithResponse(text, defaultLanguage).flatMap(FluxUtil::toMono); } catch (RuntimeException ex) { return monoError(logger, ex); } }
Source:
<code>protected void Perform() { if (StringHelper.isNullOrEmpty(mTicket)) { mTicket = Ticketing.GenerateOTP(); } <START> IVdcUser user = SessionDataContainer.getInstance().getUser(getParameters().getSessionId()); <END> setSucceeded(Backend .getInstance() .getResourceManager() .RunVdsCommand(VDSCommandType.SetVmTicket, new SetVmTicketVDSCommandParameters(getVdsId(), getVmId(), mTicket, mValidTime, user.getUserName(), user.getUserId())).getSucceeded()); if (getSucceeded()) { setActionReturnValue(mTicket); VM vm = DbFacade.getInstance().getVmDAO().getById(getVmId()); vm.setguest_cur_user_name(getCurrentUser().getUserName()); DbFacade.getInstance().getVmDynamicDAO().update(vm.getDynamicData()); } }</code><technical_language>getCurrentUser()</technical_language>

Target:
protected void Perform() { if (StringHelper.isNullOrEmpty(mTicket)) { mTicket = Ticketing.GenerateOTP(); } setSucceeded(Backend .getInstance() .getResourceManager() .RunVdsCommand(VDSCommandType.SetVmTicket, new SetVmTicketVDSCommandParameters(getVdsId(), getVmId(), mTicket, mValidTime, getCurrentUser().getUserName(), getCurrentUser().getUserId())).getSucceeded()); if (getSucceeded()) { setActionReturnValue(mTicket); VM vm = DbFacade.getInstance().getVmDAO().get(getVmId()); vm.setguest_cur_user_name(getCurrentUser().getUserName()); DbFacade.getInstance().getVmDynamicDAO().update(vm.getDynamicData()); } }
Source:
<code>protected ParameterizedRowMapper<Snapshot> createEntityRowMapper() { <START> return new ParameterizedRowMapper<Snapshot>() { <END> @Override public Snapshot mapRow(ResultSet rs, int rowNum) throws SQLException { Snapshot snapshot = new Snapshot(); snapshot.setId(Guid.createGuidFromString(rs.getString("snapshot_id"))); snapshot.setVmId(new Guid(rs.getString("vm_id"))); snapshot.setType(SnapshotType.valueOf(rs.getString("snapshot_type"))); snapshot.setStatus(SnapshotStatus.valueOf(rs.getString("status"))); snapshot.setDescription(rs.getString("description")); snapshot.setCreationDate(new Date(rs.getTimestamp("creation_date").getTime())); snapshot.setAppList(rs.getString("app_list")); snapshot.setVmConfiguration(rs.getString("vm_configuration")); return snapshot; } }; }</code><technical_language>email engine-devel - return time single instance of this mapper? (If introduce a new DAO, this save some "new" operations - save beginning?)</technical_language>

Target:
protected ParameterizedRowMapper<Snapshot> createEntityRowMapper() { return ROW_MAPPER; }
Source:
<code>private void handleOnMediaUploadedSuccess(@NonNull OnMediaUploaded event) { if (event.canceled) { AppLog.i(T.MEDIA, "Upload successfully canceled."); trackUploadMediaEvents(AnalyticsTracker.Stat.MEDIA_UPLOAD_CANCELED, getMediaFromQueueById(event.media.getId()), null); completeUploadWithId(event.media.getId()); uploadNextInQueue(); } else if (event.completed) { AppLog.i(T.MEDIA, "Upload completed - localId=" + event.media.getId() + " title=" + event.media.getTitle()); trackUploadMediaEvents(AnalyticsTracker.Stat.MEDIA_UPLOAD_SUCCESS, getMediaFromQueueById(event.media.getId()), null); completeUploadWithId(event.media.getId()); <START> addMediaToPostCompletedMediaListMap(event.media); <END> uploadNextInQueue(); } else { AppLog.d(T.MEDIA, event.media.getId() + " - progressing " + event.progress); } }</code><technical_language>This called for single-media uploads library, result adding media lists completed upload map post ID 0</technical_language>

Target:
private void handleOnMediaUploadedSuccess(@NonNull OnMediaUploaded event) { if (event.canceled) { AppLog.i(T.MEDIA, "Upload successfully canceled."); trackUploadMediaEvents(AnalyticsTracker.Stat.MEDIA_UPLOAD_CANCELED, getMediaFromInProgressQueueById(event.media.getId()), null); completeUploadWithId(event.media.getId()); uploadNextInQueue(); } else if (event.completed) { AppLog.i(T.MEDIA, "Upload completed - localId=" + event.media.getId() + " title=" + event.media.getTitle()); trackUploadMediaEvents(AnalyticsTracker.Stat.MEDIA_UPLOAD_SUCCESS, getMediaFromInProgressQueueById(event.media.getId()), null); completeUploadWithId(event.media.getId()); if (event.media.getLocalPostId() != 0) { addMediaToPostCompletedMediaListMap(event.media); } uploadNextInQueue(); } else { AppLog.d(T.MEDIA, event.media.getId() + " - progressing " + event.progress); } }
Source:
<code>public void testMissingSetContent() throws FileNotFoundException { final List<Diagnostic<? extends JavaFileObject>> diagnostics = compile( getProcessorUnderTest(), "org/uberfire/annotations/processors/WorkbenchClientEditorTest4"); assertFailedCompilation(diagnostics); assertCompilationMessage(diagnostics, Kind.ERROR, Diagnostic.NOPOS, Diagnostic.NOPOS, <START> "org.uberfire.annotations.processors.WorkbenchClientEditorTest4Activity: The WorkbenchClientEditor must provide a @SetContent annotated method that has two java.lang.String as parameters."); <END> assertNull(result.getActualCode()); }</code><technical_language>mention parameters represent - path content & of content string. a nitpick message more helpful</technical_language>

Target:
public void testMissingSetContent() throws FileNotFoundException { final List<Diagnostic<? extends JavaFileObject>> diagnostics = compile( getProcessorUnderTest(), "org/uberfire/annotations/processors/WorkbenchClientEditorTest4"); assertFailedCompilation(diagnostics); assertCompilationMessage(diagnostics, Kind.ERROR, Diagnostic.NOPOS, Diagnostic.NOPOS, "org.uberfire.annotations.processors.WorkbenchClientEditorTest4Activity: The WorkbenchClientEditor must provide a @SetContent annotated method that has two java.lang.String (path and content) as parameters."); assertNull(result.getActualCode()); }
Source:
<code>public <START> EntityModelWidgetWithInfo(EnableableFormLabel <END> label, Widget contentWidget, Align alignment) { this.label = label; if (this.label == null) { this.label = new EnableableFormLabel(); this.label.setVisible(false); } this.contentWidget = contentWidget; this.alignment = alignment; infoIcon = new InfoIcon(SafeHtmlUtils.EMPTY_SAFE_HTML); initWidget(WidgetUiBinder.uiBinder.createAndBindUi(this)); }</code><technical_language>Enable-able huh? :-) a bit weird me</technical_language>

Target:
public EntityModelWidgetWithInfo(EnableableFormLabel label, Widget contentWidget, Align alignment) { if (this.label != null) { this.label = label; } else { this.label = new EnableableFormLabel(); this.label.setVisible(false); } this.contentWidget = contentWidget; this.alignment = alignment; infoIcon = new InfoIcon(SafeHtmlUtils.EMPTY_SAFE_HTML); initWidget(WidgetUiBinder.uiBinder.createAndBindUi(this)); }
Source:
<code>public void testEmptyFlatbush() { <START> Rectangle[] items = {}; <END> Flatbush rtree = new Flatbush<Rectangle>(items); assertEquals(rtree.findIntersections(everything).size(), 0); }</code><technical_language>inline variables compare a list empty list. This way, failure, error message include list size of it. assertEquals(findIntersections(new Flatbush<>(new Rectangle[] {}), EVERYTHING), ImmutableList.of()); private static <T extends HasExtent> List<T> findIntersections(Flatbush<T> rtree, Rectangle rectangle) { List<T> results = new ArrayList<>(); rtree.findIntersections(rectangle, results::add); return results; }</technical_language>

Target:
public void testEmptyFlatbush() { Flatbush<Rectangle> rtree = new Flatbush<>(new Rectangle[] {}); assertEquals(findIntersections(rtree, EVERYTHING), ImmutableList.of()); }
Source:
<code>private void initialize() { project = Adapters.adapt(getElement(), IProject.class); if (project == null) { IResource resource = Adapters.adapt(getElement(), IResource.class); Assert.isNotNull(resource, "unable to adapt element to a project"); <START> if (resource instanceof IProject) { <END> project = (IProject) resource; } else if (resource != null) { project = resource.getProject(); } } noDefaultAndApplyButton(); setDescription(NLS.bind(IDEWorkbenchMessages.ProjectReferencesPage_label, project.getName())); }</code><technical_language>IS this check useful? project.getProject() == project, 2nd part enough IMO. (I a blocker)</technical_language>

Target:
private void initialize() { project = Adapters.adapt(getElement(), IProject.class); if (project == null) { IResource resource = Adapters.adapt(getElement(), IResource.class); Assert.isNotNull(resource, "unable to adapt element to a project"); project = resource.getProject(); } noDefaultAndApplyButton(); setDescription(NLS.bind(IDEWorkbenchMessages.ProjectReferencesPage_label, project.getName())); }
Source:
<code>public void setNodesChecked(List<ITreeNode> nodes, boolean b) { List<ITreeNode> changedNodes = new ArrayList<ITreeNode>(); for (ITreeNode node : nodes) { node = resolveNode(node); if (node != null && <START> isCheckable() <END> && node.isEnabled() && isEnabled()) { if (node.isChecked() != b) { if (b) { m_checkedNodes.add(node); } else { m_checkedNodes.remove(node); } changedNodes.add(node); if (b && !isMultiCheck()) { List<ITreeNode> uncheckedNodes = new ArrayList<ITreeNode>(); for (ITreeNode cn : getCheckedNodes()) { if (cn != node) { m_checkedNodes.remove(cn); uncheckedNodes.add(cn); } } break; } } } } if (changedNodes.size() > 0) { fireNodesChecked(changedNodes); } }</code><technical_language>move start, need loop if tree is checkable</technical_language>

Target:
public void setNodesChecked(List<ITreeNode> nodes, boolean b) { if (!isCheckable()) { return; } List<ITreeNode> changedNodes = new ArrayList<ITreeNode>(); for (ITreeNode node : nodes) { node = resolveNode(node); if (node != null) { if (node.isChecked() != b) { if (b) { m_checkedNodes.add(node); } else { m_checkedNodes.remove(node); } changedNodes.add(node); if (b && !isMultiCheck()) { List<ITreeNode> uncheckedNodes = new ArrayList<ITreeNode>(); for (ITreeNode cn : getCheckedNodes()) { if (cn != node) { m_checkedNodes.remove(cn); uncheckedNodes.add(cn); } } break; } } } } if (changedNodes.size() > 0) { fireNodesChecked(changedNodes); } }
Source:
<code>public static Logger getLogger() { Class<?>[] callingClasses = CONTEXT.getCallingClasses(); for (Class<?> callingClass : callingClasses) { String className = callingClass.getName().split("\\$")[0]; <START> if (!className.equals(LoggerFactory.class.getName()) && !className.equals("com.sun.proxy")) { <END> return getLogger(callingClass.getName()); } } Util.report("Failed to detect logger from call stack."); return getLogger(Logger.ROOT_LOGGER_NAME); }</code><technical_language>I this !className.startsWith("com.sun.proxy")</technical_language>

Target:
public static Logger getLogger() { Class<?> autoComputedCallingClass = Util.getCallingClass(); if (autoComputedCallingClass != null) { return getLogger(Util.getCallingClass().getName()); } Util.report("Failed to detect logger name from caller."); return getLogger(Logger.ROOT_LOGGER_NAME); }
Source:
<code><START> File getScreenshotFile() { <END> String pathOfScreenshot; if (projectAndSceneScreenshotData.sceneName != null) { if (projectAndSceneScreenshotData.isBackpackScene) { pathOfScreenshot = Utils.buildPath(Utils.buildBackpackScenePath(projectAndSceneScreenshotData.sceneName), StageListener.SCREENSHOT_MANUAL_FILE_NAME); } else { pathOfScreenshot = Utils.buildPath(Utils.buildScenePath(projectAndSceneScreenshotData .projectName, projectAndSceneScreenshotData.sceneName), StageListener.SCREENSHOT_MANUAL_FILE_NAME); } } else { pathOfScreenshot = Utils.buildPath(Utils.buildProjectPath(projectAndSceneScreenshotData.projectName), StageListener.SCREENSHOT_MANUAL_FILE_NAME); } File projectAndSceneImageFile = new File(pathOfScreenshot); if (!(projectAndSceneImageFile.exists() && projectAndSceneImageFile.length() > 0)) { projectAndSceneImageFile.delete(); if (projectAndSceneScreenshotData.sceneName != null) { if (projectAndSceneScreenshotData.isBackpackScene) { pathOfScreenshot = Utils.buildPath(Utils.buildBackpackScenePath(projectAndSceneScreenshotData.sceneName), StageListener.SCREENSHOT_AUTOMATIC_FILE_NAME); } else { pathOfScreenshot = Utils.buildPath(Utils.buildScenePath(projectAndSceneScreenshotData .projectName, projectAndSceneScreenshotData.sceneName), StageListener.SCREENSHOT_AUTOMATIC_FILE_NAME); } } else { pathOfScreenshot = Utils.buildPath(Utils.buildProjectPath(projectAndSceneScreenshotData.projectName), StageListener.SCREENSHOT_AUTOMATIC_FILE_NAME); } projectAndSceneImageFile = new File(pathOfScreenshot); } return projectAndSceneImageFile; }</code><technical_language>If motivated, please check sanity of this code, a solution (if applicable)</technical_language>

Target:
File getScreenshotFile() { String pathOfManualScreenshot; String pathOfAutomaticScreenshot; if (projectAndSceneScreenshotData.sceneName != null) { if (projectAndSceneScreenshotData.isBackpackScene) { String backpackScenePath = Utils.buildBackpackScenePath(projectAndSceneScreenshotData.sceneName); pathOfManualScreenshot = Utils.buildPath(backpackScenePath, StageListener.SCREENSHOT_MANUAL_FILE_NAME); pathOfAutomaticScreenshot = Utils.buildPath(backpackScenePath, StageListener.SCREENSHOT_AUTOMATIC_FILE_NAME); } else { String scenePath = Utils.buildScenePath(projectAndSceneScreenshotData.projectName, projectAndSceneScreenshotData.sceneName); pathOfManualScreenshot = Utils.buildPath(scenePath, StageListener.SCREENSHOT_MANUAL_FILE_NAME); pathOfAutomaticScreenshot = Utils.buildPath(scenePath, StageListener.SCREENSHOT_AUTOMATIC_FILE_NAME); } } else { String projectPath = Utils.buildProjectPath(projectAndSceneScreenshotData.projectName); pathOfManualScreenshot = Utils.buildPath(projectPath, StageListener.SCREENSHOT_MANUAL_FILE_NAME); pathOfAutomaticScreenshot = Utils.buildPath(projectPath, StageListener.SCREENSHOT_AUTOMATIC_FILE_NAME); } File projectAndSceneImageFile = new File(pathOfManualScreenshot); if (!(projectAndSceneImageFile.exists() && projectAndSceneImageFile.length() > 0)) { projectAndSceneImageFile.delete(); projectAndSceneImageFile = new File(pathOfAutomaticScreenshot); } return projectAndSceneImageFile; }
Source:
<code>protected void write(Schema schema, Object datum, Encoder out) throws IOException { if (datum instanceof Byte) datum = ((Byte)datum).intValue(); else if (datum instanceof Short) datum = ((Short)datum).intValue(); else if (datum instanceof Character) datum = (int)(char)(Character)datum; else if (datum instanceof Map) <START> if (ReflectData.isMapWithNonStringKeysSchema(schema)) { <END> datum = ((Map)datum).entrySet(); } try { super.write(schema, datum, out); } catch (NullPointerException e) { NullPointerException result = new NullPointerException("in "+schema.getFullName()+" "+e.getMessage()); result.initCause(e.getCause() == null ? e : e.getCause()); throw result; } }</code><technical_language>this (datum instanceof Map) && isMapWithNonStringKeysSchema(schema)</technical_language>

Target:
protected void write(Schema schema, Object datum, Encoder out) throws IOException { if (datum instanceof Byte) datum = ((Byte)datum).intValue(); else if (datum instanceof Short) datum = ((Short)datum).intValue(); else if (datum instanceof Character) datum = (int)(char)(Character)datum; else if (datum instanceof Map && ReflectData.isNonStringMapSchema(schema)) { datum = ((Map)datum).entrySet(); } try { super.write(schema, datum, out); } catch (NullPointerException e) { NullPointerException result = new NullPointerException("in "+schema.getFullName()+" "+e.getMessage()); result.initCause(e.getCause() == null ? e : e.getCause()); throw result; } }
Source:
<code>public void visitFileInput(PyFileInputTree pyFileInputTree) { scopesByRootTree = new HashMap<>(); pyFileInputTree.accept(new FirstPhaseVisitor()); pyFileInputTree.accept(new SecondPhaseVisitor()); scopesByRootTree.values().stream() .filter(scope -> scope.rootTree instanceof PyFunctionLikeTree) .forEach(scope -> { PyFunctionLikeTree funcDef = (PyFunctionLikeTree) scope.rootTree; for (TreeSymbol symbol : scope.symbols()) { if (funcDef.is(Kind.LAMBDA)) { ((PyLambdaExpressionTreeImpl) funcDef).addLocalVariableSymbol(symbol); } else { ((PyFunctionDefTreeImpl) funcDef).addLocalVariableSymbol(symbol); } } }); scopesByRootTree.values().stream() <START> .filter(scope -> scope.rootTree instanceof PyClassDefTree) <END> .forEach(scope -> { PyClassDefTreeImpl classDef = (PyClassDefTreeImpl) scope.rootTree; scope.symbols.forEach(classDef::addClassField); scope.instanceAttributesByName.values().forEach(classDef::addInstanceField); }); }</code><technical_language>of .is(Tree.Kind.CLASSDEF)</technical_language>

Target:
public void visitFileInput(PyFileInputTree pyFileInputTree) { scopesByRootTree = new HashMap<>(); pyFileInputTree.accept(new FirstPhaseVisitor()); pyFileInputTree.accept(new SecondPhaseVisitor()); scopesByRootTree.values().stream() .filter(scope -> scope.rootTree instanceof PyFunctionLikeTree) .forEach(scope -> { PyFunctionLikeTree funcDef = (PyFunctionLikeTree) scope.rootTree; for (TreeSymbol symbol : scope.symbols()) { if (funcDef.is(Kind.LAMBDA)) { ((PyLambdaExpressionTreeImpl) funcDef).addLocalVariableSymbol(symbol); } else { ((PyFunctionDefTreeImpl) funcDef).addLocalVariableSymbol(symbol); } } }); scopesByRootTree.values().stream() .filter(scope -> scope.rootTree.is(Kind.CLASSDEF)) .forEach(scope -> { PyClassDefTreeImpl classDef = (PyClassDefTreeImpl) scope.rootTree; scope.symbols.forEach(classDef::addClassField); scope.instanceAttributesByName.values().forEach(classDef::addInstanceField); }); }
Source:
<code>private boolean satisfiesFlowThreadsAvailableCriteria() { <START> final int flowThreadsAvailableConfig = this.azkabanProps. <END> getInt(ConfigurationKeys.AZKABAN_POLLING_CRITERIA_FLOW_THREADS_AVAILABLE, 0); if (flowThreadsAvailableConfig <= 0) { return true; } final int remainingFlowThreads = FlowRunnerManager.this.getMaxNumRunningFlows() - FlowRunnerManager.this.getNumRunningFlows(); return remainingFlowThreads > 0; }</code><technical_language>Do boolean type is more for flowThreadsAvailableConfig care actual value? Consider this.azkabanProps.getBoolean(ConfigurationKeys.AZKABAN_POLLING_CRITERIA_FLOW_THREADS_AVAILABLE, false);</technical_language>

Target:
private boolean satisfiesFlowThreadsAvailableCriteria() { final boolean flowThreadsAvailableConfig = this.azkabanProps. getBoolean(ConfigurationKeys.AZKABAN_POLLING_CRITERIA_FLOW_THREADS_AVAILABLE, false); if (!flowThreadsAvailableConfig) { return true; } final int remainingFlowThreads = FlowRunnerManager.this.getMaxNumRunningFlows() - FlowRunnerManager.this.getNumRunningFlows(); final boolean flowThreadsAvailable = remainingFlowThreads > 0; if (this.areFlowThreadsAvailable != flowThreadsAvailable) { this.areFlowThreadsAvailable = flowThreadsAvailable; if (flowThreadsAvailable) { FlowRunnerManager.logger.info("Polling criteria satisfied: available flow threads (" + remainingFlowThreads + ")."); } else { FlowRunnerManager.logger.info("Polling criteria NOT satisfied: available flow threads (" + remainingFlowThreads + ")."); } } return flowThreadsAvailable; }
Source:
<code>public void changeInstanceState( ManagedApplication ma, Instance instance, InstanceStatus newStatus ) throws IOException, TargetException { String instancePath = InstanceHelpers.computeInstancePath( instance ); this.logger.fine( "Trying to change the state of " + instancePath + " to " + newStatus + " in " + ma.getName() + "..." ); checkConfiguration(); <START> if( instance.getParent() == null || "target".equals(instance.getComponent().getInstallerName())) { <END> if( newStatus == InstanceStatus.NOT_DEPLOYED && ( instance.getStatus() == InstanceStatus.DEPLOYED_STARTED || instance.getStatus() == InstanceStatus.DEPLOYING || instance.getStatus() == InstanceStatus.STARTING )) undeployRoot( ma, instance ); else if( instance.getStatus() == InstanceStatus.NOT_DEPLOYED && (newStatus == InstanceStatus.DEPLOYED_STARTED || newStatus == InstanceStatus.DEPLOYED_STOPPED)) deployRoot( ma, instance ); else this.logger.warning( "Ignoring a request to update a root instance's state." ); } else { Map<String,byte[]> instanceResources = null; if( newStatus == InstanceStatus.DEPLOYED_STARTED || newStatus == InstanceStatus.DEPLOYED_STOPPED ) instanceResources = ResourceUtils.storeInstanceResources( ma.getApplicationFilesDirectory(), instance ); MsgCmdChangeInstanceState message = new MsgCmdChangeInstanceState( instance, newStatus, instanceResources ); send( ma, message, instance ); this.logger.fine( "A message was (or will be) sent to the agent to change the state of " + instancePath + " in " + ma.getName() + "." ); } }</code><technical_language>Revert previous check, please. this in next iteration</technical_language>

Target:
public void changeInstanceState( ManagedApplication ma, Instance instance, InstanceStatus newStatus ) throws IOException, TargetException { String instancePath = InstanceHelpers.computeInstancePath( instance ); this.logger.fine( "Trying to change the state of " + instancePath + " to " + newStatus + " in " + ma.getName() + "..." ); checkConfiguration(); if( instance.getParent() == null ) { if( newStatus == InstanceStatus.NOT_DEPLOYED && ( instance.getStatus() == InstanceStatus.DEPLOYED_STARTED || instance.getStatus() == InstanceStatus.DEPLOYING || instance.getStatus() == InstanceStatus.STARTING )) undeployRoot( ma, instance ); else if( instance.getStatus() == InstanceStatus.NOT_DEPLOYED && newStatus == InstanceStatus.DEPLOYED_STARTED ) deployRoot( ma, instance ); else this.logger.warning( "Ignoring a request to update a root instance's state." ); } else { Map<String,byte[]> instanceResources = null; if( newStatus == InstanceStatus.DEPLOYED_STARTED || newStatus == InstanceStatus.DEPLOYED_STOPPED ) instanceResources = ResourceUtils.storeInstanceResources( ma.getApplicationFilesDirectory(), instance ); MsgCmdChangeInstanceState message = new MsgCmdChangeInstanceState( instance, newStatus, instanceResources ); send( ma, message, instance ); this.logger.fine( "A message was (or will be) sent to the agent to change the state of " + instancePath + " in " + ma.getName() + "." ); } }
Source:
<code>public Comparator<String> nameComparator() { final Map<String, Integer> positions = positions(); return new Comparator<String>() { @Override <START> public int compare(String left, String right) { <END> Integer lp = positions.get(left); Integer rp = positions.get(right); if (lp == null) { return rp != null ? 1 : left.compareTo(right); } else if (rp == null) { return lp != null ? -1 : left.compareTo(right); } else if (lp == rp) { return left.compareTo(right); } else { return lp - rp; } } }; }</code><technical_language>This easier read: int lp = position(left); int rp = position(right); int cmp = lp - rp; if (cmp == 0) { cmp = left.compareTo(right); } return cmp; private int position(String name) { Integer p = positions.get(name); return p != null ? p : positions.size(); }</technical_language>

Target:
public Comparator<String> nameComparator() { final Map<String, Integer> positions = positions(); return new Comparator<String>() { @Override public int compare(String left, String right) { int lp = position(left); int rp = position(right); int cmp = lp - rp; if (cmp == 0) { cmp = left.compareTo(right); } return cmp; } private int position(String name) { Integer p = positions.get(name); return p != null ? p : positions.size(); } }; }
Source:
<code>public AttributeDefinition getAttributeDefinition() { AttributeDefinition attr = new AttributeDefinition(); attr.setNamespace(AttributesManager.NS_USER_ATTR_DEF); attr.setFriendlyName("login-namespace:surf-ram-persistent-shadow"); <START> attr.setDisplayName("FENIX login"); <END> attr.setType(String.class.getName()); attr.setDescription("Login for FENIX. Do not use it directly! " + "Use \"user:virt:login-namespace:surf-ram-persistent\" attribute instead."); return attr; }</code><technical_language>SURF RAM login, for description</technical_language>

Target:
public AttributeDefinition getAttributeDefinition() { AttributeDefinition attr = new AttributeDefinition(); attr.setNamespace(AttributesManager.NS_USER_ATTR_DEF); attr.setFriendlyName("login-namespace:surf-ram-persistent-shadow"); attr.setDisplayName("SURF RAM login"); attr.setType(String.class.getName()); attr.setDescription("Login for SURF RAM. Do not use it directly! " + "Use \"user:virt:login-namespace:surf-ram-persistent\" attribute instead."); return attr; }
Source:
<code>public String getClassName(String tableName) { <START> String className = tableName.substring(0, 1).toUpperCase() + <END> toCamelCase(tableName.substring(1)); return normalizeJavaName(className); }</code><technical_language>upercase tableName system locale is a good idea, java ENGLISH locale. in example making className named "something" "SOMETHNG" in turkish work java. query parameters loweCased upperCased system locale field names, class names Locale.ENGLISH</technical_language>

Target:
public String getClassName(String tableName) { String className = tableName.substring(0, 1).toUpperCase(Locale.ENGLISH) + toCamelCase(tableName.substring(1)); return normalizeJavaName(className); }
Source:
<code>private static Option<IndexedGuideGroup> appendNewGroup(final TargetObsComp obsComp, final TelescopePosTableWidget positionTable) { final TargetEnvironment env = obsComp.getTargetEnvironment(); final GuideEnvironment ge = env.getGuideEnvironment(); final GuideGroup primaryGroup = ge.getPrimary(); final ImList<GuideGroup> oldGroups = ge.getOptions(); final int newGroupIdx = oldGroups.size(); final GuideGroup newGroup = GuideGroup.create("Manual Group"); final IndexedGuideGroup igg = new IndexedGuideGroup(newGroupIdx, newGroup); final ImList<GuideGroup> newGroups = oldGroups.append(newGroup); <START> if (!positionTable.confirmGroupChange(primaryGroup, newGroup)) { <END> return None.instance(); } obsComp.setTargetEnvironment(env.setGuideEnvironment(ge.setOptions(newGroups) .setPrimaryIndex(newGroupIdx))); positionTable.selectGroup(igg); return new Some<>(igg); }</code><technical_language>This is nitpicking, if is set if (condTrue) x else y</technical_language>

Target:
private static Option<Tuple2<TargetEnvironment,IndexedGuideGroup>> appendNewGroup(final TargetObsComp obsComp, final TelescopePosTableWidget positionTable) { final TargetEnvironment env = obsComp.getTargetEnvironment(); final GuideEnvironment ge = env.getGuideEnvironment(); final GuideGroup primaryGroup = ge.getPrimary(); final ImList<GuideGroup> oldGroups = ge.getOptions(); final int newGroupIdx = oldGroups.size(); final GuideGroup newGroup = GuideGroup.create("Manual Group"); final IndexedGuideGroup igg = new IndexedGuideGroup(newGroupIdx, newGroup); final ImList<GuideGroup> newGroups = oldGroups.append(newGroup); final TargetEnvironment newEnv; if (positionTable.confirmGroupChange(primaryGroup, newGroup)) { newEnv = env.setGuideEnvironment(ge.setOptions(newGroups).setPrimaryIndex(newGroupIdx)); return new Some<>(new Pair<>(newEnv, igg)); } else { return None.instance(); } }
Source:
<code>protected void removeAllAnnotations() { for (int i = 0; i < timarkers.size(); i++) { TiMarker timarker = timarkers.get(i); if (timarker.getMarker() != null) { timarker.getMarker().remove(); <START> timarker.release(); <END> } } timarkers.clear(); if (mClusterManager != null) { mClusterManager.clearItems(); mClusterManager.cluster(); } }</code><technical_language>Java if (timarker.getMarker() != null) { timarker.getMarker().remove(); } timarker.release();</technical_language>

Target:
protected void removeAllAnnotations() { for (int i = 0; i < timarkers.size(); i++) { TiMarker timarker = timarkers.get(i); if (timarker.getMarker() != null) { timarker.getMarker().remove(); } timarker.release(); } timarkers.clear(); if (mClusterManager != null) { mClusterManager.clearItems(); mClusterManager.cluster(); } }
Source:
<code>public List<FeedbackSessionAttributes> getFeedbackSessionsForUserInCourse( String courseId, String userEmail) throws EntityDoesNotExistException { if (coursesLogic.isCoursePresent(courseId) == false) { throw new EntityDoesNotExistException( "Trying to get feedback sessions for a course that does not exist."); } <START> List<FeedbackSessionAttributes> sessions = <END> getFeedbackSessionsForCourse(courseId); List<FeedbackSessionAttributes> viewableSessions = new ArrayList<FeedbackSessionAttributes>(); if (!sessions.isEmpty()) { InstructorAttributes instructor = instructorsLogic.getInstructorForEmail(courseId, userEmail); for (FeedbackSessionAttributes session : sessions) { if (isFeedbackSessionViewableTo(session, userEmail, instructor)) { viewableSessions.add(session); } } } return viewableSessions; }</code><technical_language>existence check avoided if this method receives a CourseAttributes object instead. Check this method is called if callers pass CourseAttributes object instead. If can, do a separate issue</technical_language>

Target:
public List<FeedbackSessionAttributes> getFeedbackSessionsForUserInCourse( String courseId, String userEmail) throws EntityDoesNotExistException { if (coursesLogic.isCoursePresent(courseId) == false) { throw new EntityDoesNotExistException( "Trying to get feedback sessions for a course that does not exist."); } return getFeedbackSessionsForUserInCourseSkipCheck(courseId, userEmail); }
Source:
<code>public void interrupt_on_parsing() throws Exception { final StringReader in = new StringReader("class A {\n"); final ByteArrayOutputStream out = new ByteArrayOutputStream(); final ByteArrayOutputStream err = new ByteArrayOutputStream(); <START> <END> Interpreter bsh = new Interpreter(in, new PrintStream(out), new PrintStream(err), false); bsh.setShutdownOnExit(false); bsh.interrupt(); Thread t = new Thread(bsh); t.start(); Thread.sleep(250); String stdout = out.toString(); String stderr = err.toString(); System.out.println(">>" + stdout + "<<\n>>" + stderr + "<<"); assertTrue(stdout.contains("... interrupted ...")); assertTrue(!stderr.contains("Parser Error:")); }</code><technical_language>I open suggestions needs motivated. I tests currently this method a major issue</technical_language>

Target:
public void interrupt_on_parsing() throws Exception { final StringReader in = new StringReader("class A {\n"); final ByteArrayOutputStream out = new ByteArrayOutputStream(); final ByteArrayOutputStream err = new ByteArrayOutputStream(); Interpreter bsh = new Interpreter(in, new PrintStream(out), new PrintStream(err), false); bsh.interrupt(); Thread t = new Thread(bsh); t.start(); Thread.sleep(250); String stdout = out.toString(); String stderr = err.toString(); System.out.println(">>" + stdout + "<<\n>>" + stderr + "<<"); assertTrue(stdout.contains("... interrupted ...")); assertTrue(!stderr.contains("Parser Error:")); }
Source:
<code>public Observable<DynamicRealmObject> from(DynamicRealm realm, final DynamicRealmObject object) { final RealmConfiguration realmConfig = realm.getConfiguration(); return Observable.create(new Observable.OnSubscribe<DynamicRealmObject>() { @Override public void call(final Subscriber<? super DynamicRealmObject> subscriber) { final DynamicRealm observableRealm = DynamicRealm.getInstance(realmConfig); objectRefs.get().acquireReference(object); final RealmChangeListener listener = new RealmChangeListener() { @Override public void onChange() { if (!subscriber.isUnsubscribed()) { subscriber.onNext(object); } } }; object.addChangeListener(listener); subscriber.add(Subscriptions.create(new Action0() { @Override public void call() { object.removeChangeListener(listener); observableRealm.close(); <START> objectRefs.get().acquireReference(object); <END> } })); subscriber.onNext(object); } }); }</code><technical_language>objectRefs.get().acquireReference(object) -> objectRefs.get().releaseReference(object) I want decrease reference count here</technical_language>

Target:
public Observable<DynamicRealmObject> from(DynamicRealm realm, final DynamicRealmObject object) { final RealmConfiguration realmConfig = realm.getConfiguration(); return Observable.create(new Observable.OnSubscribe<DynamicRealmObject>() { @Override public void call(final Subscriber<? super DynamicRealmObject> subscriber) { final DynamicRealm observableRealm = DynamicRealm.getInstance(realmConfig); objectRefs.get().acquireReference(object); final RealmChangeListener listener = new RealmChangeListener() { @Override public void onChange() { if (!subscriber.isUnsubscribed()) { subscriber.onNext(object); } } }; object.addChangeListener(listener); subscriber.add(Subscriptions.create(new Action0() { @Override public void call() { object.removeChangeListener(listener); observableRealm.close(); objectRefs.get().releaseReference(object); } })); subscriber.onNext(object); } }); }
Source:
<code>private void removePublishCache(String tenantId, String triggerId, Set<String> dataIds) { if (!isEmpty(dataIds)) { dataIds.stream().forEach(dataId -> { CacheKey cacheKey = new CacheKey(tenantId, dataId); <START> Set<String> triggers = publishCache.get(cacheKey); <END> if (!isEmpty(triggers)) { triggers.remove(triggerId); if (triggers.isEmpty()) { publishCache.remove(cacheKey); } else { publishCache.put(cacheKey, triggers); } } }); } }</code><technical_language>suggestion: triggers ->triggerIds</technical_language>

Target:
private void removePublishCache(String tenantId, String triggerId, Set<String> dataIds) { if (!isEmpty(dataIds)) { dataIds.stream().forEach(dataId -> { CacheKey cacheKey = new CacheKey(tenantId, dataId); Set<String> triggerIds = publishCache.get(cacheKey); if (!isEmpty(triggerIds)) { triggerIds.remove(triggerId); if (triggerIds.isEmpty()) { publishCache.remove(cacheKey); } else { publishCache.put(cacheKey, triggerIds); } } }); } }
Source:
<code>public void setUp() throws Exception { this.props = new Props(); <START> this.props.put(ConfigurationKeys.AZKABAN_EXECUTOR_MAX_FAILURE_COUNT, 1); <END> this.props.put(ConfigurationKeys.AZKABAN_ADMIN_ALERT_EMAIL, AZ_ADMIN_ALERT_EMAIL); this.loader = mock(ExecutorLoader.class); this.mailAlerter = mock(Alerter.class); this.alerterHolder = mock(AlerterHolder.class); this.apiGateway = mock(ExecutorApiGateway.class); this.executorHealthChecker = new ExecutorHealthChecker(this.props, this.loader, this .apiGateway, this.alerterHolder); this.flow1 = TestUtils.createTestExecutableFlow("exectest1", "exec1"); this.flow1.setExecutionId(EXECUTION_ID_11); this.flow1.setStatus(Status.RUNNING); this.executor1 = new Executor(1, "localhost", 12345, true); when(this.loader.fetchActiveFlows()).thenReturn(this.activeFlows); when(this.alerterHolder.get("email")).thenReturn(this.mailAlerter); }</code><technical_language>set 2, test counting</technical_language>

Target:
public void setUp() throws Exception { this.props = new Props(); this.props.put(ConfigurationKeys.AZKABAN_EXECUTOR_MAX_FAILURE_COUNT, 2); this.props.put(ConfigurationKeys.AZKABAN_ADMIN_ALERT_EMAIL, AZ_ADMIN_ALERT_EMAIL); this.loader = mock(ExecutorLoader.class); this.mailAlerter = mock(Alerter.class); this.alerterHolder = mock(AlerterHolder.class); this.apiGateway = mock(ExecutorApiGateway.class); this.executorHealthChecker = new ExecutorHealthChecker(this.props, this.loader, this .apiGateway, this.alerterHolder); this.flow1 = TestUtils.createTestExecutableFlow("exectest1", "exec1"); this.flow1.setExecutionId(EXECUTION_ID_11); this.flow1.setStatus(Status.RUNNING); this.executor1 = new Executor(1, "localhost", 12345, true); when(this.loader.fetchActiveFlows()).thenReturn(this.activeFlows); when(this.alerterHolder.get("email")).thenReturn(this.mailAlerter); }
Source:
<code>public void queryOneExistedObjectTableUpdate() { User expectedUser = new User(null, "such@email.com"); putUsersBlocking(3); final Observable<User> userObservable = storIOSQLite .get() .object(User.class) .withQuery(Query.builder() .table(UserTableMeta.TABLE) .where(UserTableMeta.COLUMN_EMAIL + "=?") .whereArgs(expectedUser.email()) .build()) .prepare() .createObservable(); TestSubscriber<User> testSubscriber = new TestSubscriber<User>(); userObservable.subscribe(testSubscriber); <START> testSubscriber.awaitTerminalEvent(500, MILLISECONDS); <END> testSubscriber.assertValueCount(1); testSubscriber.assertValue(null); testSubscriber.assertNoErrors(); putUserBlocking(expectedUser); testSubscriber.awaitTerminalEvent(500, MILLISECONDS); testSubscriber.assertValueCount(2); testSubscriber.assertValues(null, expectedUser); testSubscriber.assertNoErrors(); }</code><technical_language>needed</technical_language>

Target:
public void queryOneExistedObjectTableUpdate() { User expectedUser = new User(null, "such@email.com"); putUsersBlocking(3); final Observable<User> userObservable = storIOSQLite .get() .object(User.class) .withQuery(Query.builder() .table(UserTableMeta.TABLE) .where(UserTableMeta.COLUMN_EMAIL + "=?") .whereArgs(expectedUser.email()) .build()) .prepare() .createObservable() .take(2); TestSubscriber<User> testSubscriber = new TestSubscriber<User>(); userObservable.subscribe(testSubscriber); testSubscriber.awaitTerminalEvent(5, SECONDS); testSubscriber.assertValue(null); testSubscriber.assertNoErrors(); putUserBlocking(expectedUser); testSubscriber.awaitTerminalEvent(5, SECONDS); testSubscriber.assertValues(null, expectedUser); testSubscriber.assertNoErrors(); testSubscriber.unsubscribe(); }