auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void testAddTwice() throws CoreException { TaskReviewsMappingsStore taskReviewsMappingStore = getEmptyTaskReviewStore(); addReviewData(review1, descriptionWithTaskUrl1); TaskContainerDelta delta = new TaskContainerDelta(review1, Kind.ADDED); taskReviewsMappingStore.containersChanged(ImmutableSet.of(delta)); taskReviewsMappingStore.containersChanged(ImmutableSet.of(delta)); assertTrue(taskReviewsMappingStore.getReviewUrls(taskUrl1).contains(reviewUrl1)); assertTrue(taskReviewsMappingStore.getTaskUrl(reviewUrl1).equals(taskUrl1)); }

Target:
public void testAddTwice() throws CoreException { TaskReviewsMappingsStore taskReviewsMappingStore = getEmptyTaskReviewStore(); addReviewData(review1, descriptionWithTaskUrl1); TaskContainerDelta delta = new TaskContainerDelta(review1, Kind.ADDED); taskReviewsMappingStore.containersChanged(ImmutableSet.of(delta)); taskReviewsMappingStore.containersChanged(ImmutableSet.of(delta)); Collection<String> reviewUrls = taskReviewsMappingStore.getReviewUrls(taskUrl1); assertTrue(reviewUrls.contains(reviewUrl1)); assertTrue(reviewUrls.size() == 1); assertTrue(taskReviewsMappingStore.getTaskUrl(reviewUrl1).equals(taskUrl1)); }
Source:
private void addNewElement(int hashPosition, Block block, int position) { elementType.appendTo(block, position, elementBlock); if (elementBlock.getSizeInBytes() - initialElementBlockSizeInBytes > FOUR_MEGABYTES) { throw new PrestoException( EXCEEDED_FUNCTION_MEMORY_LIMIT, format("The input to %s is too large. More than %s of memory is needed to hold the intermediate hash set.\n", functionName, MAX_FUNCTION_MEMORY)); } blockPositionByHash.set(hashPosition, elementBlock.getPositionCount() - 1); if (++size >= maxFill) { rehash(); } }

Target:
private void addNewElement(int hashPosition, Block block, int position) { elementType.appendTo(block, position, elementBlock); if (elementBlock.getSizeInBytes() - initialElementBlockSizeInBytes > FOUR_MEGABYTES) { throw new PrestoException( EXCEEDED_FUNCTION_MEMORY_LIMIT, format("The input to %s is too large. More than %s of memory is needed to hold the intermediate hash set.\n", functionName, MAX_FUNCTION_MEMORY)); } blockPositionByHash.set(hashPosition, elementBlock.getPositionCount() - 1); size++; if (size >= maxFill) { rehash(); } }
Source:
public CommandHandlingExecutor(JobServerContext jobServerContext, TaskExecutorManager taskExecutorManager, JobMasterClient masterClient, WorkerNetAddress workerNetAddress) { mServerContext = Preconditions.checkNotNull(jobServerContext); mTaskExecutorManager = Preconditions.checkNotNull(taskExecutorManager, "taskExecutorManager"); mMasterClient = Preconditions.checkNotNull(masterClient, "masterClient"); mWorkerNetAddress = Preconditions.checkNotNull(workerNetAddress, "workerNetAddress"); if (ServerConfiguration.getBoolean(PropertyKey.TEST_MODE)) { mHealthReporter = new AlwaysHealthyJobWorkerHealthReporter(); } else { mHealthReporter = new JobWorkerHealthReporter(); } }

Target:
public CommandHandlingExecutor(JobServerContext jobServerContext, TaskExecutorManager taskExecutorManager, JobMasterClient masterClient, WorkerNetAddress workerNetAddress) { mServerContext = Preconditions.checkNotNull(jobServerContext); mTaskExecutorManager = Preconditions.checkNotNull(taskExecutorManager, "taskExecutorManager"); mMasterClient = Preconditions.checkNotNull(masterClient, "masterClient"); mWorkerNetAddress = Preconditions.checkNotNull(workerNetAddress, "workerNetAddress"); if (ServerConfiguration.getBoolean(PropertyKey.JOB_WORKER_THROTTLING)) { mHealthReporter = new JobWorkerHealthReporter(); } else { mHealthReporter = new AlwaysHealthyJobWorkerHealthReporter(); } }
Source:
public void testRemoveButton() throws Exception { if (!endToEndTestEnabled()) { return; } try { createNewNote(); waitForParagraph(1, "READY"); driver.findElement(By.xpath(getParagraphXPath(1) + " driver.findElement(By.xpath(getParagraphXPath(1) + " waitForParagraph(2, "READY"); Integer oldNosOfParas = driver.findElements(By.xpath(" collector.checkThat("Before Remove : Number of paragraphs are ", oldNosOfParas, CoreMatchers.equalTo(2)); driver.findElement(By.xpath(getParagraphXPath(1) + " driver.findElement(By.xpath(getParagraphXPath(1) + " sleep(1000, true); driver.findElement(By.xpath(" " sleep(1000, true); Integer newNosOfParas = driver.findElements(By.xpath(" collector.checkThat("After Remove : Number of paragraphs are", newNosOfParas, CoreMatchers.equalTo(oldNosOfParas - 1)); ZeppelinITUtils.sleep(1000, false); deleteTestNotebook(driver); } catch (Exception e) { handleException("Exception in ParagraphActionsIT while testRemoveButton ", e); } }

Target:
public void testRemoveButton() throws Exception { if (!endToEndTestEnabled()) { return; } try { createNewNote(); waitForParagraph(1, "READY"); driver.findElement(By.xpath(getParagraphXPath(1) + " driver.findElement(By.xpath(getParagraphXPath(1) + " .click(); waitForParagraph(2, "READY"); Integer oldNosOfParas = driver.findElements(By.xpath (" collector.checkThat("Before Remove : Number of paragraphs are ", oldNosOfParas, CoreMatchers.equalTo(2)); driver.findElement(By.xpath(getParagraphXPath(1) + " clickAndWait(By.xpath(getParagraphXPath(1) + " clickAndWait(By.xpath(" "] Integer newNosOfParas = driver.findElements(By.xpath (" collector.checkThat("After Remove : Number of paragraphs are", newNosOfParas, CoreMatchers.equalTo(oldNosOfParas - 1)); ZeppelinITUtils.sleep(1000, false); deleteTestNotebook(driver); } catch (Exception e) { handleException("Exception in ParagraphActionsIT while testRemoveButton ", e); } }
Source:
public double calculateFitness(TaskRequest taskRequest, VirtualMachineCurrentState targetVM, TaskTrackerState taskTrackerState) { double totalWeightedScores = 0.0; double totalWeights = 0.0; for (WeightedFitnessCalculator calculator : calculators) { double score = calculator.getFitnessCalculator().calculateFitness(taskRequest, targetVM, taskTrackerState); totalWeightedScores += (score * calculator.getWeight()); totalWeights += calculator.getWeight(); } return totalWeightedScores / totalWeights; }

Target:
public double calculateFitness(TaskRequest taskRequest, VirtualMachineCurrentState targetVM, TaskTrackerState taskTrackerState) { double totalWeightedScores = 0.0; double totalWeights = 0.0; for (WeightedFitnessCalculator calculator : calculators) { double score = calculator.getFitnessCalculator().calculateFitness(taskRequest, targetVM, taskTrackerState); if (score == 0.0) { return score; } totalWeightedScores += (score * calculator.getWeight()); totalWeights += calculator.getWeight(); } return totalWeightedScores / totalWeights; }
Source:
private void initialiseMetrics(MetricRegistry metricRegistry) { metricRegistry.<Gauge<Integer>>register("connectordb.numbackends", () -> numBackends); metricRegistry.<Gauge<Integer>>register("connectordb.xact_commit", () -> xactCommit); metricRegistry.<Gauge<Integer>>register("connectordb.xact_rollback", () -> xactRollback); metricRegistry.<Gauge<Integer>>register("connectordb.blks_read", () -> blksRead); metricRegistry.<Gauge<Integer>>register("connectordb.blks_hit", () -> blksHit); metricRegistry.<Gauge<Integer>>register("connectordb.tup_returned", () -> tupReturned); metricRegistry.<Gauge<Integer>>register("connectordb.tup_fetched", () -> tupFetched); metricRegistry.<Gauge<Integer>>register("connectordb.tup_inserted", () -> tupInserted); metricRegistry.<Gauge<Integer>>register("connectordb.tup_updated", () -> tupUpdated); metricRegistry.<Gauge<Integer>>register("connectordb.tup_deleted", () -> tupDeleted); metricRegistry.<Gauge<Integer>>register("connectordb.conflicts", () -> conflicts); metricRegistry.<Gauge<Integer>>register("connectordb.temp_files", () -> tempFiles); metricRegistry.<Gauge<Integer>>register("connectordb.deadlocks", () -> deadlocks); metricRegistry.<Gauge<Double>>register("connectordb.blk_read_time", () -> blkReadTime); metricRegistry.<Gauge<Double>>register("connectordb.blk_write_time", () -> blkWriteTime); }

Target:
private void initialiseMetrics(MetricRegistry metricRegistry) { for (String key : longDatabaseStatsMap.keySet()) { metricRegistry.<Gauge<Long>>register("connectordb." + key, () -> longDatabaseStatsMap.get(key)); } for (String key : doubleDatabaseStatsMap.keySet()) { metricRegistry.<Gauge<Double>>register("connectordb." + key, () -> doubleDatabaseStatsMap.get(key)); } metricRegistry.<Gauge<Integer>>register("connectordb.stats_healthy", () -> statsHealthy); }
Source:
private Film getBasicFilm(ProgData progData) { Film film = new Film(PaHelper.getFilmUri(identifierFor(progData)), PaHelper.getEpisodeCurie(identifierFor(progData)), Publisher.PA); film.addAliasUrl(PaHelper.getFilmRtAlias(progData.getRtFilmnumber())); film.addAlias(PaHelper.getProgIdAlias(progData.getProgId())); setBasicDetails(progData, film); return film; }

Target:
private Film getBasicFilm(ProgData progData) { Film film = new Film(PaHelper.getFilmUri(identifierFor(progData)), PaHelper.getEpisodeCurie(identifierFor(progData)), Publisher.PA); setBasicDetails(progData, film); return film; }
Source:
public void doSearchType(ITypeBinding typeBinding, IProgressMonitor monitor) throws CoreException { IMethodBinding[] methods = typeBinding.getDeclaredMethods(); IVariableBinding[] fields = typeBinding.getDeclaredFields(); SubMonitor subMonitor = SubMonitor.convert(monitor, "Searching for references.", methods.length + fields.length); for (IMethodBinding methodBinding : methods) { if (monitor.isCanceled()) throw new OperationCanceledException(); if (methodOverrides(methodBinding)) continue; IMethod method = (IMethod) methodBinding.getJavaElement(); if (method == null) continue; if (hasReferences(method, subMonitor.newChild(1))) continue; result.unusedElementFound(method); unusedMemberCount++; } for (IVariableBinding fieldBinding : fields) { if (monitor.isCanceled()) throw new OperationCanceledException(); IField field = (IField) fieldBinding.getJavaElement(); if (field == null) continue; if (hasReferences(field, subMonitor.newChild(1))) continue; result.unusedElementFound(field); unusedMemberCount++; } if (monitor.isCanceled()) throw new OperationCanceledException(); }

Target:
public void doSearchType(ITypeBinding typeBinding, IProgressMonitor monitor) throws CoreException { IMethodBinding[] methods = typeBinding.getDeclaredMethods(); IVariableBinding[] fields = typeBinding.getDeclaredFields(); SubMonitor subMonitor = SubMonitor.convert(monitor, "Searching for references.", methods.length + fields.length); for (IMethodBinding methodBinding : methods) { if (monitor.isCanceled()) throw new OperationCanceledException(); if (methodOverrides(methodBinding)) continue; IMethod method = (IMethod) methodBinding.getJavaElement(); if (method == null) continue; if (hasReferences(method, subMonitor.newChild(1))) continue; result.unusedElementFound(method); unusedMemberCount++; } for (IVariableBinding fieldBinding : fields) { IField field = (IField) fieldBinding.getJavaElement(); if (field == null) continue; if (hasReferences(field, subMonitor.split(1))) continue; result.unusedElementFound(field); unusedMemberCount++; } if (monitor.isCanceled()) throw new OperationCanceledException(); }
Source:
public long writeTo(WritableByteChannel channel) throws IOException { if (materializedBlobBuffer == null) { throw new IllegalStateException("Attempt to write out a PutRequest that cannot be written out."); } long written = 0; if (sentBytes < sizeInBytes()) { if (bufferToSend == null) { bufferToSend = ByteBuffer.allocate(sizeExcludingBlobSize()); writeHeader(); bufferToSend.put(blobId.toBytes()); BlobPropertiesSerDe.putBlobPropertiesToBuffer(bufferToSend, properties); bufferToSend.putInt(usermetadata.capacity()); bufferToSend.put(usermetadata); bufferToSend.putShort((short) blobType.ordinal()); bufferToSend.putLong(blobSize); bufferToSend.flip(); } if (bufferToSend.hasRemaining()) { written = channel.write(bufferToSend); } if (!bufferToSend.hasRemaining()) { written += channel.write(materializedBlobBuffer); } sentBytes += written; } return written; }

Target:
public long writeTo(WritableByteChannel channel) throws IOException { long written = 0; if (sentBytes < sizeInBytes()) { if (bufferToSend == null) { bufferToSend = ByteBuffer.allocate(sizeExcludingBlobSize()); writeHeader(); bufferToSend.put(blobId.toBytes()); BlobPropertiesSerDe.putBlobPropertiesToBuffer(bufferToSend, properties); bufferToSend.putInt(usermetadata.capacity()); bufferToSend.put(usermetadata); bufferToSend.putShort((short) blobType.ordinal()); bufferToSend.putLong(blobSize); bufferToSend.flip(); } if (bufferToSend.hasRemaining()) { written = channel.write(bufferToSend); } if (!bufferToSend.hasRemaining()) { written += channel.write(blob); } sentBytes += written; } return written; }
Source:
private void makeTree(InternalJob job) { final Set<String> taskNames = job.getITasks() .stream() .filter(internalTask -> internalTask.getFlowScript() != null) .filter(internalTask -> FlowActionType.parse(internalTask.getFlowScript() .getActionType()) .equals(FlowActionType.IF)) .flatMap(internalTask -> Stream.of(internalTask.getFlowScript() .getActionTarget(), internalTask.getFlowScript() .getActionTargetElse(), internalTask.getFlowScript() .getActionContinuation()) .filter(Objects::nonNull) .filter(action -> !action.equals(internalTask.getName()))) .collect(Collectors.toSet()); for (InternalTask td : job.getITasks()) { EligibleTaskDescriptor lt = new EligibleTaskDescriptorImpl(td); if (isEntryPoint(td, taskNames)) { eligibleTasks.put(td.getId(), lt); } if (td.getJoinedBranches() != null || td.getIfBranch() != null) { branchTasks.put(td.getId(), lt); } allTasksWithTheirChildren.put(td, lt); } for (InternalTask td : job.getITasks()) { if (td.getDependences() != null) { TaskDescriptor taskDescriptor = allTasksWithTheirChildren.get(td); for (InternalTask depends : td.getIDependences()) { ((EligibleTaskDescriptorImpl) taskDescriptor).addParent(allTasksWithTheirChildren.get(depends)); } for (TaskDescriptor lt : taskDescriptor.getParents()) { ((EligibleTaskDescriptorImpl) lt).addChild(taskDescriptor); hasChildren.add(lt.getTaskId()); } } } }

Target:
private void makeTree(InternalJob job) { final Set<String> nonEligibleTaskNames = job.getITasks() .stream() .filter(internalTask -> internalTask.getFlowScript() != null) .filter(internalTask -> FlowActionType.parse(internalTask.getFlowScript() .getActionType()) .equals(FlowActionType.IF)) .flatMap(internalTask -> Stream.of(internalTask.getFlowScript() .getActionTarget(), internalTask.getFlowScript() .getActionTargetElse(), internalTask.getFlowScript() .getActionContinuation()) .filter(Objects::nonNull) .filter(action -> !action.equals(internalTask.getName()))) .collect(Collectors.toSet()); for (InternalTask td : job.getITasks()) { EligibleTaskDescriptor lt = new EligibleTaskDescriptorImpl(td); if (isEntryPoint(td, nonEligibleTaskNames)) { eligibleTasks.put(td.getId(), lt); } if (td.getJoinedBranches() != null || td.getIfBranch() != null) { branchTasks.put(td.getId(), lt); } allTasksWithTheirChildren.put(td, lt); } for (InternalTask td : job.getITasks()) { if (td.getDependences() != null) { TaskDescriptor taskDescriptor = allTasksWithTheirChildren.get(td); for (InternalTask depends : td.getIDependences()) { ((EligibleTaskDescriptorImpl) taskDescriptor).addParent(allTasksWithTheirChildren.get(depends)); } for (TaskDescriptor lt : taskDescriptor.getParents()) { ((EligibleTaskDescriptorImpl) lt).addChild(taskDescriptor); hasChildren.add(lt.getTaskId()); } } } }
Source:
public Boolean run() { Application application = cloudHubClient.getApplication(applicationName); applicationStatus = application.getStatus(); if (application != null && expectedStatus.equals(application.getStatus())) { return false; } return true; }

Target:
public Boolean run() { Application application = cloudHubClient.getApplications(applicationName); if (application != null) { applicationStatus = application.getStatus(); if (application != null && expectedStatus.equals(application.getStatus())) { return false; } } return true; }
Source:
private byte[] encodeTlvValue(Object value, Type type) { LOG.trace("Encoding value in TLV", value); switch (type) { case STRING: return TlvEncoder.encodeString((String) value); case INTEGER: return TlvEncoder.encodeInteger((Number) value); case FLOAT: return TlvEncoder.encodeFloat((Number) value); case BOOLEAN: return TlvEncoder.encodeBoolean((Boolean) value); case TIME: return TlvEncoder.encodeDate((Date) value); case OPAQUE: return (byte[]) value; case OBJLNK: return TlvEncoder.encodeObjlnk((ObjectLink) value); default: throw new CodecException(String.format("Invalid value %s for type %s", value, type)); } }

Target:
private byte[] encodeTlvValue(Object value, Type type) { LOG.trace("Encoding value in TLV", value); try { switch (type) { case STRING: return TlvEncoder.encodeString((String) value); case INTEGER: return TlvEncoder.encodeInteger((Number) value); case FLOAT: return TlvEncoder.encodeFloat((Number) value); case BOOLEAN: return TlvEncoder.encodeBoolean((Boolean) value); case TIME: return TlvEncoder.encodeDate((Date) value); case OPAQUE: return (byte[]) value; case OBJLNK: return TlvEncoder.encodeObjlnk((ObjectLink) value); default: throw new CodecException(String.format("Invalid value %s for type %s", value, type)); } } catch (IllegalArgumentException e) { throw new CodecException(String.format("Invalid value %s for type %s", value, type), e); } }
Source:
public AuthRegistryConfig(String repository, String username, String password, String auth, String email, String serverAddress) { this.repository = repository; this.username = username; this.password = password; this.auth = auth; this.email = email; this.serverAddress = serverAddress; }

Target:
public AuthRegistryConfig(String repository, String username, String password, String auth, String email, String serverAddress) { this.repository = repository; this.username = username; this.password = password; this.auth = auth; this.email = email; this.serverAddress = serverAddress; properties.put("username", username); properties.put("password", password); properties.put("auth", auth); properties.put("email", email); properties.put("serveraddress", serverAddress); configs.put(repository, properties); }
Source:
public void getMetricsFromFeed(@NonNull Callback<List<Metric>> callback, Resource resource) { URI uri = Uris.getUri(String.format(BackendPipes.Paths.FEED_METRICS, resource.getFeed(), resource.getId().replace("/","%2F"))); readPipe(BackendPipes.Names.FEED_METRICS, uri, callback); }

Target:
public void getMetricsFromFeed(@NonNull Callback<List<Metric>> callback, Resource resource) { URI uri = Uris.getUri(String.format(BackendPipes.Paths.FEED_METRICS, resource.getFeed(), Uris.getEncodedParameter(resource.getId()))); readPipe(BackendPipes.Names.FEED_METRICS, uri, callback); }
Source:
public StructuredEventContainer getStructuredEventsForStack(String name, Long workspaceId) { return getEventsForUserWithResourceId(CloudbreakEventService.DATAHUB_RESOURCE_TYPE, getStackIfAvailable(workspaceId, name).getId()); }

Target:
public StructuredEventContainer getStructuredEventsForStack(String name, Long workspaceId) { StackView stackView = stackService.getViewByNameInWorkspace(name, workspaceId); return getEventsForUserWithResourceId(stackView.getType().getResourceType(), getStackIfAvailable(workspaceId, name, stackView.getType()).getId()); }
Source:
public synchronized Long persist(final String name, final EntityEntry entry, final boolean useAutoInc) throws DatabaseEngineException { ResultSet generatedKeys = null; try { getConnection(); final MappedEntity me = entities.get(name); if (me == null) { throw new DatabaseEngineException(String.format("Unknown entity '%s'", name)); } final PreparedStatement ps; if (useAutoInc) { ps = me.getInsertReturning(); } else { ps = me.getInsertWithAutoInc(); } entityToPreparedStatement(me.getEntity(), ps, entry, useAutoInc); generatedKeys = ps.executeQuery(); long ret = 0; if (useAutoInc) { if (generatedKeys.next()) { ret = generatedKeys.getLong(1); } } else if (hasIdentityColumn(me.getEntity())) { final List<Map<String, ResultColumn>> q = query( "SELECT max(" + quotize(me.getAutoIncColumn()) + ") FROM" + quotize(name) ); if (!q.isEmpty()) { ret = q.get(0).values().iterator().next().toLong(); } executeUpdateSilently(format("SELECT setval('%s', %d, false)", getQuotizedSequenceName(me.getEntity(), me.getAutoIncColumn()), ret + 1 )); ret = 0; } return ret == 0 ? null : ret; } catch (final Exception ex) { throw new DatabaseEngineException("Something went wrong persisting the entity", ex); } finally { try { if (generatedKeys != null) { generatedKeys.close(); } } catch (final Exception e) { logger.trace("Error closing result set.", e); } } }

Target:
public synchronized Long persist(final String name, final EntityEntry entry, final boolean useAutoInc) throws DatabaseEngineException { ResultSet generatedKeys = null; try { getConnection(); final MappedEntity me = entities.get(name); if (me == null) { throw new DatabaseEngineException(String.format("Unknown entity '%s'", name)); } final PreparedStatement ps; if (useAutoInc) { ps = me.getInsertReturning(); } else { ps = me.getInsertWithAutoInc(); } entityToPreparedStatement(me.getEntity(), ps, entry, useAutoInc); generatedKeys = ps.executeQuery(); long ret = 0; if (useAutoInc) { if (generatedKeys.next()) { ret = generatedKeys.getLong(1); } } else if (hasIdentityColumn(me.getEntity())) { final List<Map<String, ResultColumn>> q = query( format("SELECT max(%s) FROM %s", quotize(me.getAutoIncColumn()), quotize(name)) ); if (!q.isEmpty()) { ret = q.get(0).values().iterator().next().toLong(); } executeUpdateSilently(format("SELECT setval('%s', %d, false)", getQuotizedSequenceName(me.getEntity(), me.getAutoIncColumn()), ret + 1 )); ret = 0; } return ret == 0 ? null : ret; } catch (final Exception ex) { throw new DatabaseEngineException("Something went wrong persisting the entity", ex); } finally { try { if (generatedKeys != null) { generatedKeys.close(); } } catch (final Exception e) { logger.trace("Error closing result set.", e); } } }
Source:
public void convert_missing_doi() throws IOException { ImmutableMap<String, String> extIds = ImmutableMap.of("other", "2"); Result sourceDataset = documentEntity(extIds); DataSetReference metadata = converter.convert(sourceDataset); assertNotNull(metadata); assertEquals(ID, metadata.getId()); assertEquals("other", metadata.getReferenceType()); assertEquals("2", metadata.getIdForGivenType()); assertEquals(1, metadata.getCreatorNames().size()); assertEquals(FULL_NAME, metadata.getCreatorNames().get(0)); assertEquals(2, metadata.getTitles().size()); assertEquals(TITLE, metadata.getTitles().get(0)); assertEquals(OTHER_TITLE, metadata.getTitles().get(1)); assertEquals(ABSTRACT, metadata.getDescription()); assertEquals(PUBLISHER, metadata.getPublisher()); assertEquals(YEAR, metadata.getPublicationYear()); assertEquals(1, metadata.getFormats().size()); assertEquals(FORMAT, metadata.getFormats().iterator().next()); assertEquals(RESOURCE_TYPE_CLASSID, metadata.getResourceTypeValue()); assertEquals(1, metadata.getAlternateIdentifiers().size()); assertEquals(extIds, metadata.getAlternateIdentifiers()); }

Target:
public void convert_missing_doi() { ImmutableMap<String, String> extIds = ImmutableMap.of("other", "2"); Result sourceDataset = documentEntity(extIds); DataSetReference metadata = converter.convert(sourceDataset); assertNotNull(metadata); assertEquals(ID, metadata.getId()); assertEquals("other", metadata.getReferenceType()); assertEquals("2", metadata.getIdForGivenType()); assertEquals(1, metadata.getCreatorNames().size()); assertEquals(FULL_NAME, metadata.getCreatorNames().get(0)); assertEquals(2, metadata.getTitles().size()); assertEquals(TITLE, metadata.getTitles().get(0)); assertEquals(OTHER_TITLE, metadata.getTitles().get(1)); assertEquals(ABSTRACT, metadata.getDescription()); assertEquals(PUBLISHER, metadata.getPublisher()); assertEquals(YEAR, metadata.getPublicationYear()); assertEquals(1, metadata.getFormats().size()); assertEquals(FORMAT, metadata.getFormats().iterator().next()); assertEquals(RESOURCE_TYPE_CLASSID, metadata.getResourceTypeValue()); assertEquals(1, metadata.getAlternateIdentifiers().size()); assertEquals(extIds, metadata.getAlternateIdentifiers()); }
Source:
public ManagedObjectReference getDecendentMoRef(ManagedObjectReference root, String type, String name) throws Exception { if (name == null || name.length() == 0) { return null; } try { PropertySpec pSpec = new PropertySpec(); pSpec.setType(type); pSpec.setAll(false); pSpec.getPathSet().add("name"); ObjectSpec oSpec = new ObjectSpec(); oSpec.setObj(root); oSpec.setSkip(false); oSpec.getSelectSet().addAll(constructCompleteTraversalSpec()); PropertyFilterSpec spec = new PropertyFilterSpec(); spec.getPropSet().add(pSpec); spec.getObjectSet().add(oSpec); List<PropertyFilterSpec> specArr = new ArrayList<PropertyFilterSpec>(); specArr.add(spec); ManagedObjectReference propCollector = getPropCol(); List<ObjectContent> ocary = vimPort.retrieveProperties(propCollector, specArr); if (ocary == null || ocary.size() == 0) { return null; } for (ObjectContent oc : ocary) { ManagedObjectReference mor = oc.getObj(); List<DynamicProperty> propary = oc.getPropSet(); if (type == null || type.equals(mor.getType())) { if (propary.size() > 0) { String propval = (String)propary.get(0).getVal(); if (propval != null && name.equalsIgnoreCase(propval)) return mor; } } } } catch (Exception e) { s_logger.debug("Failed to get mor for name: " + name + " and type: " + type, e); throw e; } return null; }

Target:
public ManagedObjectReference getDecendentMoRef(ManagedObjectReference root, String type, String name) throws Exception { if (name == null || name.length() == 0) { return null; } try { PropertySpec pSpec = new PropertySpec(); pSpec.setType(type); pSpec.setAll(false); pSpec.getPathSet().add("name"); ObjectSpec oSpec = new ObjectSpec(); oSpec.setObj(root); oSpec.setSkip(false); oSpec.getSelectSet().addAll(constructCompleteTraversalSpec()); PropertyFilterSpec spec = new PropertyFilterSpec(); spec.getPropSet().add(pSpec); spec.getObjectSet().add(oSpec); List<PropertyFilterSpec> specArr = new ArrayList<PropertyFilterSpec>(); specArr.add(spec); ManagedObjectReference propCollector = getPropCol(); List<ObjectContent> ocary = vimPort.retrieveProperties(propCollector, specArr); if (ocary == null || ocary.size() == 0) { return null; } for (ObjectContent oc : ocary) { ManagedObjectReference mor = oc.getObj(); List<DynamicProperty> propary = oc.getPropSet(); if (type == null || type.equals(mor.getType())) { if (propary.size() > 0) { String propval = (String)propary.get(0).getVal(); if (propval != null && name.equalsIgnoreCase(propval)) return mor; } } } } catch (InvalidPropertyFaultMsg invalidPropertyException) { s_logger.debug("Failed to get Vmware ManagedObjectReference for name: " + name + " and type: " + type + " due to " + invalidPropertyException.getMessage()); throw invalidPropertyException; } catch (RuntimeFaultFaultMsg runtimeFaultException) { s_logger.debug("Failed to get Vmware ManagedObjectReference for name: " + name + " and type: " + type + " due to " + runtimeFaultException.getMessage()); throw runtimeFaultException; } return null; }
Source:
public void preInit(FMLPreInitializationEvent event) { Log.setModLog(event.getModLog()); configDir = new File(event.getModConfigurationDirectory(), "antiqueatlas"); configDir.mkdir(); extTileIdMap = ExtTileIdMap.instance(); extTileConfig = new ExtTileConfig(new File(configDir, "tileids.json")); extTileConfig.load(extTileIdMap); registerVanillaCustomTiles(); checkSaveConfig(); }

Target:
public void preInit(FMLPreInitializationEvent event) { configDir = new File(event.getModConfigurationDirectory(), "antiqueatlas"); configDir.mkdir(); extTileIdMap = ExtTileIdMap.instance(); extTileConfig = new ExtTileConfig(new File(configDir, "tileids.json")); extTileConfig.load(extTileIdMap); registerVanillaCustomTiles(); checkSaveConfig(); }
Source:
public String buildConditionSql(String objName, String fieldName, String customizedValue, String customizedRelation, String tableName, boolean caseSensitive) { Pair<String, String> pair = new Pair<>(); pair.setFirst(customizedRelation); pair.setSecond(customizedValue); formatValue(fieldName, pair, caseSensitive); if (("''".equals(pair.getSecond()) || "'null'".equalsIgnoreCase(pair.getSecond())) && ("=".equals(pair.getFirst()) || "!=".equals(pair.getFirst()))) { String nullRelation = "=".equals(pair.getFirst()) ? "IS" : "IS NOT"; return StringFormat.format("(%1$s.%2$s %3$s NULL)", tableName, getDbFieldName(fieldName), nullRelation); } else { SearchObjectAutoCompleter.EntitySearchInfo info = SearchObjectAutoCompleter.getEntitySearchInfo(objName); if (info.commaDelimitedListColumns != null && info.commaDelimitedListColumns.contains(fieldName.toLowerCase())) { return StringFormat.format("%1$s %2$s ANY(string_to_array(%3$s.%4$s, ','))", pair.getSecond(), pair.getFirst(), tableName, getDbFieldName(fieldName)); } String formatString = " %1$s.%2$s %3$s %4$s "; if (pair.getFirst().equalsIgnoreCase("LIKE") || pair.getFirst().equalsIgnoreCase("ILIKE")) { formatString = " (%1$s.%2$s IS NULL OR %1$s.%2$s %3$s %4$s) "; } return StringFormat.format(formatString, tableName, getDbFieldName(fieldName), pair.getFirst(), SyntaxChecker.escapeUnderScore(pair.getSecond(), customizedRelation)); } }

Target:
public String buildConditionSql(String objName, String fieldName, String customizedValue, String customizedRelation, String tableName, boolean caseSensitive) { Pair<String, String> pair = new Pair<>(); pair.setFirst(customizedRelation); pair.setSecond(customizedValue); formatValue(fieldName, pair, caseSensitive); if (("''".equals(pair.getSecond()) || "'null'".equalsIgnoreCase(pair.getSecond())) && ("=".equals(pair.getFirst()) || "!=".equals(pair.getFirst()))) { String nullRelation = "=".equals(pair.getFirst()) ? "IS" : "IS NOT"; return StringFormat.format("(%1$s.%2$s %3$s NULL)", tableName, getDbFieldName(fieldName), nullRelation); } else { SearchObjectAutoCompleter.EntitySearchInfo info = SearchObjectAutoCompleter.getEntitySearchInfo(objName); if (info.commaDelimitedListColumns != null && info.commaDelimitedListColumns.contains(fieldName.toLowerCase())) { return StringFormat.format("%1$s %2$s ANY(string_to_array(%3$s.%4$s, ','))", pair.getSecond(), pair.getFirst(), tableName, getDbFieldName(fieldName)); } String formatString; if (pair.getFirst().equalsIgnoreCase("LIKE") || pair.getFirst().equalsIgnoreCase("ILIKE")) { formatString = " (%1$s.%2$s IS NULL OR %1$s.%2$s %3$s %4$s) "; } else { formatString = " %1$s.%2$s %3$s %4$s "; } return StringFormat.format(formatString, tableName, getDbFieldName(fieldName), pair.getFirst(), SyntaxChecker.escapeUnderScore(pair.getSecond(), customizedRelation)); } }
Source:
public Map<String, String> getMetadataLanguages() { Map<String, String> metadataLanguages = new HashMap<>(); metadataLanguages.put("English", "en"); metadataLanguages.put("Deutsch", "de"); return metadataLanguages; }

Target:
public Map<String, String> getMetadataLanguages() { Map<String, String> metadataLanguages = new HashMap<>(); String[] availableMetadataLanguages = ConfigCore.getStringArrayParameter(ParameterCore.METADATA_LANGUAGE_LIST); for (String availableLanguage : availableMetadataLanguages) { String[] language = availableLanguage.split("-"); metadataLanguages.put(language[0], language[1]); } return metadataLanguages; }
Source:
public Map<GroupKey, List<Result>> load(SearchKey key) throws DiscoveryException, SQLException, TskCoreException { List<Result> domainResults = getResultDomainsFromDatabase(key); DiscoveryAttributes.FrequencyAttribute freqAttr = new DiscoveryAttributes.FrequencyAttribute(); freqAttr.addAttributeToResults(domainResults, key.getSleuthkitCase(), key.getCentralRepository()); for (AbstractFilter filter : key.getFilters()) { if (filter.useAlternateFilter()) { domainResults = filter.applyAlternateFilter(domainResults, key.getSleuthkitCase(), key.getCentralRepository()); } } List<AttributeType> searchAttributes = new ArrayList<>(); searchAttributes.add(key.getGroupAttributeType()); searchAttributes.addAll(key.getFileSortingMethod().getRequiredAttributes()); for (AttributeType attr : searchAttributes) { attr.addAttributeToResults(domainResults, key.getSleuthkitCase(), key.getCentralRepository()); } final SearchResults searchResults = new SearchResults( key.getGroupSortingType(), key.getGroupAttributeType(), key.getFileSortingMethod()); searchResults.add(domainResults); return searchResults.toLinkedHashMap(); }

Target:
public Map<GroupKey, List<Result>> load(SearchKey key) throws DiscoveryException, SQLException, TskCoreException, InterruptedException { List<Result> domainResults = getResultDomainsFromDatabase(key); List<AttributeType> searchAttributes = new ArrayList<>(); searchAttributes.add(key.getGroupAttributeType()); searchAttributes.addAll(key.getFileSortingMethod().getRequiredAttributes()); for (AttributeType attr : searchAttributes) { if (Thread.currentThread().isInterrupted()) { throw new InterruptedException(); } attr.addAttributeToResults(domainResults, key.getSleuthkitCase(), key.getCentralRepository()); } for (AbstractFilter filter : key.getFilters()) { if (Thread.currentThread().isInterrupted()) { throw new InterruptedException(); } if (filter.useAlternateFilter()) { domainResults = filter.applyAlternateFilter(domainResults, key.getSleuthkitCase(), key.getCentralRepository()); } } final SearchResults searchResults = new SearchResults( key.getGroupSortingType(), key.getGroupAttributeType(), key.getFileSortingMethod()); searchResults.add(domainResults); return searchResults.toLinkedHashMap(); }
Source:
private static SparseArray<String> getStringsForLocale(Locale targetLocale, @StringRes int[] strings) { Resources currentResources = WikipediaApp.getInstance().getResources(); Configuration config = new Configuration(currentResources.getConfiguration()); Locale systemLocale = config.locale; config.locale = targetLocale; SparseArray<String> localizedStrings = new SparseArray<>(); Resources targetResources = new Resources(currentResources.getAssets(), currentResources.getDisplayMetrics(), config); for (int stringRes : strings) { localizedStrings.put(stringRes, targetResources.getString(stringRes)); } config.locale = systemLocale; new Resources(currentResources.getAssets(), currentResources.getDisplayMetrics(), config); return localizedStrings; }

Target:
private static SparseArray<String> getStringsForLocale(Locale targetLocale, @StringRes int[] strings) { Configuration config = getCurrentConfiguration(); Locale systemLocale = config.locale; config.locale = targetLocale; SparseArray<String> localizedStrings = getTargetStrings(strings, config); config.locale = systemLocale; resetConfiguration(config); return localizedStrings; }
Source:
private void setFalseChecked() { if (OPTION_CHECKED != null) { OPTION_CHECKED.clear(); setFalse(); } }

Target:
private void setFalseChecked() { if (OPTION_CHECKED != null) { setFalse(); } }
Source:
public void shouldSaveConditionInRulesPage() throws DotSecurityException, DotDataException { final Role role = new RoleDataGen().nextPersisted(); final User user = new UserDataGen().roles(role).nextPersisted(); final Host host = new SiteDataGen().nextPersisted(); final Template template = new TemplateDataGen().nextPersisted(); final HTMLPageAsset htmlPageAsset = new HTMLPageDataGen(host, template) .nextPersisted(); addPermission(role, htmlPageAsset, PermissionAPI.PERMISSION_PUBLISH); addRulesPermission(role, host, true); final Rule rule = new RuleDataGen().page(htmlPageAsset).nextPersisted(); final ConditionGroup conditionGroup = new ConditionGroupDataGen().rule(rule).next(); this.addRulesPermission(role, host, true); rulesAPI.saveConditionGroup(conditionGroup, user, false); List<Rule> allRules = rulesAPI.getAllRules(user, false); checkCondition(user, conditionGroup, allRules); }

Target:
public void shouldSaveConditionInRulesPage() throws DotSecurityException, DotDataException { final Role role = new RoleDataGen().nextPersisted(); final User user = new UserDataGen().roles(role).nextPersisted(); final Host host = new SiteDataGen().nextPersisted(); final Template template = new TemplateDataGen().nextPersisted(); final HTMLPageAsset htmlPageAsset = new HTMLPageDataGen(host, template) .nextPersisted(); addPermission(role, htmlPageAsset, PermissionAPI.PERMISSION_PUBLISH); addRulesPublishPermissions(role, host); final Rule rule = new RuleDataGen().page(htmlPageAsset).nextPersisted(); final ConditionGroup conditionGroup = new ConditionGroupDataGen().rule(rule).next(); rulesAPI.saveConditionGroup(conditionGroup, user, false); List<Rule> allRules = rulesAPI.getAllRules(user, false); createConditionAndCheck(user, conditionGroup, allRules); }
Source:
public void is_ListView_created() { String descriptionText = "This is the description of testView"; String jobDslScript = "listView('"+ LIST_VIEW_NAME +"') {\n" + " description('"+descriptionText+"')\n" + "}"; openNewlyCreatedListView(jobDslScript, LIST_VIEW_NAME); WebElement description = find(By.xpath(" Assert.assertThat(description.getText(), containsString(descriptionText)); }

Target:
public void is_ListView_created() { String descriptionText = "This is the description of testView"; String jobDslScript = "listView('"+ LIST_VIEW_NAME +"') {\n" + " description('"+descriptionText+"')\n" + "}"; View view = openNewlyCreatedListView(jobDslScript, LIST_VIEW_NAME); checkDescription(view, descriptionText); }
Source:
public synchronized void handleAfterUndeploy(@Observes AfterUnDeploy afterDeploy, final Container container) throws Exception { if(deployed == null) { return; } Integer count = deployed.get(container.getName()); if (count == null) { return; } deployed.put(container.getName(), --count); if (count == 0 && afterClassRun) { for (int i = setupTasksInForce.size() - 1; i >= 0; i--) { try { setupTasksInForce.get(i).tearDown(managementClient.get(), container.getName()); } catch (Exception e) { log.error("Setup task failed during tear down. Offending class '" + setupTasksAll.get(i) + "'", e); } } active.remove(container.getName()); deployed.remove(container.getName()); } if (deployed.isEmpty()) { deployed = null; setupTasksAll.clear(); setupTasksInForce.clear(); afterClassRun = false; } }

Target:
public synchronized void handleAfterUndeploy(@Observes AfterUnDeploy afterDeploy, final Container container) throws Exception { if(deployed == null) { return; } Integer count = deployed.get(container.getName()); if (count == null) { log.debugf("No deployments found for container %s.", container.getName()); return; } deployed.put(container.getName(), --count); if (count == 0 && afterClassRun) { for (int i = setupTasksInForce.size() - 1; i >= 0; i--) { try { setupTasksInForce.get(i).tearDown(managementClient.get(), container.getName()); } catch (Exception e) { log.error("Setup task failed during tear down. Offending class '" + setupTasksAll.get(i) + "'", e); } } active.remove(container.getName()); deployed.remove(container.getName()); } if (deployed.isEmpty()) { deployed = null; setupTasksAll.clear(); setupTasksInForce.clear(); afterClassRun = false; } }
Source:
private List<String> getPorts(InstanceGroupType type) { List<String> ret = new ArrayList<>(); ret.add("22"); if (InstanceGroupType.GATEWAY.equals(type)) { ret.add("443"); } return ret; }

Target:
private List<String> getPorts(InstanceGroupType type) { List<String> ret = new ArrayList<>(); ret.add("22"); if (InstanceGroupType.GATEWAY == type) { ret.add("443"); } return ret; }
Source:
public void onPropertyUpdateRemovesTheOldVertexFromTheIndexBeforeAddingTheNewOne() { IndexHandler indexHandler = mock(IndexHandler.class); GraphWrapper graphWrapper = newGraph() .withVertex("newVertex", v -> v .withProperty("vrecoll_name", "new") ) .withVertex(v -> v .withProperty("vrecoll_name", "old") .withOutgoingRelation("VERSION_OF", "newVertex") ) .wrap(); FulltextIndexChangeListener instance = new FulltextIndexChangeListener(indexHandler, graphWrapper); Collection collection = new VresBuilder() .withVre("thevre", "vre", vre -> vre .withCollection("vrecolls", coll -> coll .withDisplayName(localProperty("vrecoll_name")) ) ) .build().getCollection("vrecolls").get(); Vertex oldVertex = graphWrapper.getGraph().traversal().V().has("vrecoll_name", "old").next(); Vertex newVertex = graphWrapper.getGraph().traversal().V().has("vrecoll_name", "new").next(); instance.onPropertyUpdate(collection, Optional.of(oldVertex), newVertex); InOrder inOrder = inOrder(indexHandler); inOrder.verify(indexHandler).removeFromQuickSearchIndex(collection, oldVertex); inOrder.verify(indexHandler).addToQuickSearchIndex(collection, "new", newVertex); }

Target:
public void onPropertyUpdateRemovesTheOldVertexFromTheIndexBeforeAddingTheNewOne() { IndexHandler indexHandler = mock(IndexHandler.class); GraphWrapper graphWrapper = newGraph() .withVertex("newVertex", v -> v .withProperty("vrecoll_name", "new") ) .withVertex(v -> v .withProperty("vrecoll_name", "old") .withOutgoingRelation("VERSION_OF", "newVertex") ) .wrap(); FulltextIndexChangeListener instance = new FulltextIndexChangeListener(indexHandler, graphWrapper); Collection collection = new VresBuilder() .withVre("thevre", "vre", vre -> vre .withCollection("vrecolls", coll -> coll .withDisplayName(localProperty("vrecoll_name")) ) ) .build().getCollection("vrecolls").get(); Vertex oldVertex = graphWrapper.getGraph().traversal().V().has("vrecoll_name", "old").next(); Vertex newVertex = graphWrapper.getGraph().traversal().V().has("vrecoll_name", "new").next(); instance.onPropertyUpdate(collection, Optional.of(oldVertex), newVertex); InOrder inOrder = inOrder(indexHandler); inOrder.verify(indexHandler).removeFromQuickSearchIndex(collection, oldVertex); inOrder.verify(indexHandler).insertIntoQuickSearchIndex(collection, "new", newVertex); }
Source:
public void testIndexing() throws Exception { List<Page> pages = readPages(new File("src/test/resources/wat-18.warc")); JavaRDD<Page> pagesRDD = sc.parallelize(pages); IndexStats stats = new IndexStats(sc); JavaPairRDD<RowColumn, Bytes> linkIndex = IndexUtil.createLinkIndex(stats, pagesRDD); List<Tuple2<RowColumn, Bytes>> linkIndexList = linkIndex.collect(); JavaPairRDD<RowColumn, Bytes> linkIndexNoRank = IndexUtil.filterRank(linkIndex); Assert.assertEquals(4, pagesRDD.count()); Assert.assertEquals(126, linkIndex.count()); try (FluoClient client = FluoFactory.newClient(miniFluo.getClientConfiguration())) { try (LoaderExecutor le = client.newLoaderExecutor()) { for (Page page : pages) { log.debug("Loading page with links", page.getUrl(), page.getOutboundLinks().size()); le.execute(PageUpdate.updatePage(page)); } } miniFluo.waitForObservers(); boolean foundDiff = false; foundDiff |= diffExportTable(linkIndexList); foundDiff |= diffFluoTable(client, linkIndexNoRank.collect()); if (foundDiff) { dump(client); dumpExportTable(); print(linkIndexList); } Assert.assertFalse(foundDiff); String url = "<LINK_3>"; log.info("Deleting page {}", url); try (LoaderExecutor le = client.newLoaderExecutor()) { le.execute(PageUpdate.deletePage(url)); } miniFluo.waitForObservers(); } }

Target:
public void testIndexing() throws Exception { Map<String, Page> pages = readPages(new File("src/test/resources/wat-18.warc")); try (FluoClient client = FluoFactory.newClient(miniFluo.getClientConfiguration())) { try (LoaderExecutor le = client.newLoaderExecutor()) { for (Page page : pages.values()) { log.debug("Loading page with links", page.getUrl(), page.getOutboundLinks().size()); le.execute(PageUpdate.updatePage(page)); } } miniFluo.waitForObservers(); assertOutput(pages.values(), client); String deleteUrl = "<LINK_3>"; log.info("Deleting page {}", deleteUrl); try (LoaderExecutor le = client.newLoaderExecutor()) { le.execute(PageUpdate.deletePage(deleteUrl)); } miniFluo.waitForObservers(); int numPages = pages.size(); Assert.assertNotNull(pages.remove(deleteUrl)); Assert.assertEquals(numPages-1, pages.size()); assertOutput(pages.values(), client); String updateUrl = "<LINK_2>"; Page updatePage = pages.get(updateUrl); long numLinks = updatePage.getNumOutbound(); Assert.assertTrue(updatePage.addOutboundLink("<LINK_0>", "Example")); Assert.assertEquals(numLinks+1, (long)updatePage.getNumOutbound()); Assert.assertTrue(updatePage.removeOutboundLink("<LINK_1>")); Assert.assertEquals(numLinks, (long)updatePage.getNumOutbound()); try (LoaderExecutor le = client.newLoaderExecutor()) { le.execute(PageUpdate.updatePage(updatePage)); } miniFluo.waitForObservers(); Assert.assertNotNull(pages.put(updateUrl, updatePage)); assertOutput(pages.values(), client); } }
Source:
default KeyStore createCertForHost(String hostname) throws NoSuchAlgorithmException, InvalidKeyException, CertificateException, NoSuchProviderException, SignatureException, KeyStoreException, IOException, UnrecoverableKeyException{ return createCertForHost(new CertData(hostname)); }

Target:
KeyStore createCertForHost(String hostname) throws NoSuchAlgorithmException, InvalidKeyException, CertificateException, NoSuchProviderException, SignatureException, KeyStoreException, IOException, UnrecoverableKeyException; default KeyStore createCertForHost(CertData certData) throws NoSuchAlgorithmException, InvalidKeyException, CertificateException, NoSuchProviderException, SignatureException, KeyStoreException, IOException, UnrecoverableKeyException{ return createCertForHost(certData.getCommonName()); }
Source:
public Condition(String key, String[] values) { super(); if ("VRIF".equals(key)) { key = "verified"; } if ("CRVW".equals(key)) { key = "code-review"; } this.key = key; this.val = values; }

Target:
public Condition(String key, String[] values) { super(); this.key = GerritHookFilterChangeState.this.translateConditionKey(key); this.val = values; }
Source:
public void testSendGelfMessage() throws Exception { final ImmutableList<String> typenames = ImmutableList.of(); final Map<String,Object> settings = new HashMap<String,Object>(); final Map<String, Object> additionalFields = new HashMap<>(); additionalFields.put("test", "test"); final GelfWriter gelfWriter; try { gelfWriter = new GelfWriter( typenames, true, true, settings, "gelf.example.com", null, additionalFields, "TEST", null, null, null, null, null, null, null, null, null, null ); } catch (final NullPointerException e) { throw new RuntimeException("Unexpected failure to create gelfwriter for test", e); } gelfWriter.start(); gelfWriter.doWrite(dummyServer(), dummyQuery(), ImmutableList.<Result>of(result)); Assert.assertTrue( "Transport hasn't been called", MockGelfTransport.calls.size() > 0 ); Assert.assertEquals( "Additional fields not set", "test", MockGelfTransport.calls.get(0).getAdditionalFields().get("test") ); }

Target:
public void testSendGelfMessage() throws Exception { final ImmutableList<String> typenames = ImmutableList.of(); final Map<String, Object> settings = new HashMap<>(); doNothing().when(gelfTransport).send( messageArgumentCaptor.capture() ); final GelfWriter gelfWriter; gelfWriter = new GelfWriter( typenames, ImmutableMap.of("type", (Object) "jmx"), gelfTransport ); gelfWriter.start(); gelfWriter.doWrite(dummyServer(), dummyQuery(), ResultFixtures.singleNumericResult()); final GelfMessage gelfMessage = messageArgumentCaptor.getValue(); assertThat(gelfMessage.getAdditionalFields()) .containsEntry("type", "jmx") .as("Additional fields were not checked"); assertThat(gelfMessage.getFullMessage()) .isNotEmpty() .as("Invalid full message"); assertThat(gelfMessage.getMessage()) .isNotEmpty() .as("Invalid message"); verify( gelfTransport, times(1) ).send(isA(GelfMessage.class)); }
Source:
public DefaultEventContext(FlowConstruct flow, ComponentLocation location, String correlationId, Optional<CompletableFuture<Void>> externalCompletion) { this(flow, NullExceptionHandler.getInstance(), location, correlationId, externalCompletion); }

Target:
public DefaultEventContext(FlowConstruct flow, ComponentLocation location, String correlationId, Optional<CompletableFuture<Void>> externalCompletion) { super(NullExceptionHandler.getInstance(), 0, externalCompletion); this.id = flow.getUniqueIdString(); this.serverId = flow.getServerId(); this.location = location; this.processingTime = ProcessingTime.newInstance(flow); this.correlationId = correlationId; if (flow != null && flow.getMuleContext() != null) { eventContextMaintain(flow.getMuleContext().getEventContextService()); } this.flowCallStack = new DefaultFlowCallStack(); createStreamingState(); }
Source:
public boolean shouldRetry() { return retriesOnFailure.decrementAndGet() > 0; }

Target:
public boolean shouldRetry() { return retriesOnFailure.decrementAndGet() >= 0; }
Source:
public String getBranchName() { return spaceName; }

Target:
public String getBranchName() { return branchName; }