auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private void onNewDR() { final StorageDRModel model = (StorageDRModel) getWindow(); if (!model.validate()) { return; } StorageDomain storageDomain = getEntity(); final StorageSyncSchedule syncSchedule = new StorageSyncSchedule(); syncSchedule.setFrequency(model.getFrequency().getSelectedItem()); syncSchedule.setHour(model.getHour().getEntity()); syncSchedule.setMins(model.getMins().getEntity()); StorageSyncScheduleParameters parameter = new StorageSyncScheduleParameters(syncSchedule, storageDomain.getId(), model.getGeoRepSession().getSelectedItem().getId()); model.startProgress(); Frontend.getInstance().runAction(VdcActionType.ScheduleGlusterStorageSync, parameter, new IFrontendActionAsyncCallback() { @Override public void executed(FrontendActionAsyncResult result) { StorageDRListModel localModel = (StorageDRListModel) result.getState(); model.stopProgress(); localModel.postSaveAction(result.getReturnValue()); } }, this); }

Target:
private void onNewDR() { final StorageDRModel model = (StorageDRModel) getWindow(); if (!model.validate()) { return; } StorageDomain storageDomain = getEntity(); final StorageSyncSchedule syncSchedule = new StorageSyncSchedule(); syncSchedule.setFrequency(model.getFrequency().getSelectedItem()); syncSchedule.setHour(model.getHour().getEntity()); syncSchedule.setMins(model.getMins().getEntity()); Guid georepId = model.getGeoRepSession().getSelectedItem() != null ? model.getGeoRepSession().getSelectedItem().getId() : null; StorageSyncScheduleParameters parameter = new StorageSyncScheduleParameters(syncSchedule, storageDomain.getId(), georepId); model.startProgress(); Frontend.getInstance().runAction(VdcActionType.ScheduleGlusterStorageSync, parameter, new IFrontendActionAsyncCallback() { @Override public void executed(FrontendActionAsyncResult result) { StorageDRListModel localModel = (StorageDRListModel) result.getState(); model.stopProgress(); localModel.postSaveAction(result.getReturnValue()); } }, this); }
Source:
public void visitVariableIdentifier(VariableIdentifierTree varIdentifier) { if (inStaticContext && !isWithinNonStaticFunctionExpression(varIdentifier) && "$this".equals(varIdentifier.variableExpression().text())) { context().newIssue(this, varIdentifier.variableExpression(), MESSAGE); } super.visitVariableIdentifier(varIdentifier); }

Target:
public void visitVariableIdentifier(VariableIdentifierTree varIdentifier) { if (inStaticContext && "$this".equals(varIdentifier.variableExpression().text()) && !isWithinNonStaticFunctionExpression(varIdentifier)) { context().newIssue(this, varIdentifier.variableExpression(), MESSAGE); } super.visitVariableIdentifier(varIdentifier); }
Source:
private WebDriver createWebDriver() { System.out.print("Initializing Selenium: "); String browser = TestProperties.BROWSER; if ("firefox".equals(browser)) { System.out.println("Using Firefox."); String firefoxPath = TestProperties.FIREFOX_PATH; if (!firefoxPath.isEmpty()) { System.out.println("Custom path: " + firefoxPath); System.setProperty("webdriver.firefox.bin", firefoxPath); } FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("browser.download.panel.shown", false); profile.setPreference("browser.helperApps.neverAsk.openFile", "text/csv,application/vnd.ms-excel"); profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "text/csv,application/vnd.ms-excel"); profile.setPreference("browser.download.folderList", 2); profile.setPreference("browser.download.dir", System.getProperty("java.io.tmpdir")); if (TestProperties.IS_HEADLESS_FIREFOX) { System.out.println("Running Firefox is headless mode with Xvfb on display port " + TestProperties.XVFB_PORT + " (Xvfb must already be listening on that port)"); FirefoxBinary firefoxBinary = new FirefoxBinary(new File(firefoxPath)); firefoxBinary.setEnvironmentProperty("DISPLAY", TestProperties.XVFB_PORT); return new FirefoxDriver(firefoxBinary, profile); } return new FirefoxDriver(profile); } System.out.println("Using " + browser + " is not supported!"); return null; }

Target:
private WebDriver createWebDriver() { System.out.print("Initializing Selenium: "); String browser = TestProperties.BROWSER; if ("firefox".equals(browser)) { System.out.println("Using Firefox."); String firefoxPath = TestProperties.FIREFOX_PATH; if (!firefoxPath.isEmpty()) { System.out.println("Custom path: " + firefoxPath); System.setProperty("webdriver.firefox.bin", firefoxPath); } FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("browser.download.panel.shown", false); profile.setPreference("browser.helperApps.neverAsk.openFile", "text/csv,application/vnd.ms-excel"); profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "text/csv,application/vnd.ms-excel"); profile.setPreference("browser.download.folderList", 2); profile.setPreference("browser.download.dir", System.getProperty("java.io.tmpdir")); return new FirefoxDriver(profile); } System.out.println("Using " + browser + " is not supported!"); return null; }
Source:
public InterruptibleCharSequence(CharSequence inner) { super(); this.inner = inner; }

Target:
public InterruptibleCharSequence(CharSequence inner) { this.inner = inner; }
Source:
public static String buildJsonArray(List<String> queries) { final OutputStream os = new ByteArrayOutputStream(); final ObjectMapper mapper = new ObjectMapper(); String json = ""; try { mapper.writeValue(os, queries); final byte[] data = ((ByteArrayOutputStream) os).toByteArray(); json = new String(data, "UTF-8"); } catch (IOException e) { throw new RuntimeException(e); } return json; }

Target:
public final static String buildJsonArray(List<String> queries) { final OutputStream os = new ByteArrayOutputStream(); final ObjectMapper mapper = new ObjectMapper(); try { mapper.writeValue(os, queries); final byte[] data = ((ByteArrayOutputStream) os).toByteArray(); final String json = new String(data, "UTF-8"); return json; } catch (IOException e) { throw new RuntimeException(e); } }
Source:
public void writeTo(OutputStream out) throws IOException { ByteBuffer slab; for (int i = 0; i < slabs.size() - 1; i++) { slab = slabs.get(i); if (slab.hasArray()) { out.write(slab.array(), slab.arrayOffset(), slab.position()); } else { byte[] copy = new byte[slab.limit()]; slab.flip(); slab.get(copy); out.write(copy); } } slab = currentSlab; if (slab.hasArray()) { out.write(slab.array(), slab.arrayOffset(), currentSlabIndex); } else { byte[] copy = new byte[currentSlabIndex]; slab.flip(); slab.get(copy); out.write(copy); } }

Target:
public void writeTo(OutputStream out) throws IOException { for (int i = 0; i < slabs.size() - 1; i++) { writeToOutput(out, slabs.get(i), slabs.get(i).position()); } writeToOutput(out, currentSlab, currentSlabIndex); }
Source:
long monthsUntil(final AbstractDate end) { InternationalFixedDate date = InternationalFixedDate.from(end); long monthStart = this.getCalculatedProlepticMonth() * 256L + this.getCalculatedDayOfMonth(); long monthEnd = date.getCalculatedProlepticMonth() * 256L + date.getCalculatedDayOfMonth(); return (monthEnd - monthStart) / 256L; }

Target:
long monthsUntil(final AbstractDate end) { InternationalFixedDate date = InternationalFixedDate.from(end); long monthStart = this.getProlepticMonth() * 32L + this.getInternalDayOfMonth(); long monthEnd = date.getProlepticMonth() * 32L + date.getInternalDayOfMonth(); return (monthEnd - monthStart) / 32L; }
Source:
public void testWithEnvironmentEdge() { EnvironmentEdge edgeForHour11 = new EnvironmentEdge() { @Override public long currentTime() { return 1597895561000L; } @Override public TimeZone currentTimeZone() { return TimeZone.getTimeZone("GMT+08:00"); } }; EnvironmentEdgeManager.injectEdge(edgeForHour11); assertEquals(11, CurrentHourProvider.getCurrentHour()); EnvironmentEdge edgeForHour15 = new EnvironmentEdge() { @Override public long currentTime() { return 1597907081000L; } @Override public TimeZone currentTimeZone() { return TimeZone.getTimeZone("GMT+08:00"); } }; EnvironmentEdgeManager.injectEdge(edgeForHour15); assertEquals(15, CurrentHourProvider.getCurrentHour()); }

Target:
public void testWithEnvironmentEdge() { long deltaFor11 = TimeZone.getDefault().getRawOffset() - 28800000; long timeFor11 = 1597895561000L - deltaFor11; EnvironmentEdgeManager.injectEdge(() -> timeFor11); assertEquals(11, CurrentHourProvider.getCurrentHour()); long deltaFor15 = TimeZone.getDefault().getRawOffset() - 28800000; long timeFor15 = 1597907081000L - deltaFor15; EnvironmentEdgeManager.injectEdge(() -> timeFor15); assertEquals(15, CurrentHourProvider.getCurrentHour()); }
Source:
public void execute(Runnable runnable) { System.out.println("executing"); delegate.execute(new InstrumentedRunnable(runnable)); }

Target:
public void execute(Runnable runnable) { submitted.mark(); delegate.execute(new InstrumentedRunnable(runnable)); }
Source:
protected void doFilterInternal(HttpServletRequest req, HttpServletResponse res, FilterChain chain) throws IOException, ServletException { inErrorOnBehalfOf = false; Authentication authentication = getAuthentication(req, res); if (authentication != null) { SecurityContextHolder.getContext().setAuthentication(authentication); restAuthenticationService.invalidateAuthenticationCookie(res); } if (inErrorOnBehalfOf) { return; } chain.doFilter(req, res); }

Target:
protected void doFilterInternal(HttpServletRequest req, HttpServletResponse res, FilterChain chain) throws IOException, ServletException { Authentication authentication = null; try { authentication = getAuthentication(req, res); } catch (AuthorizeException e) { res.sendError(HttpServletResponse.SC_UNAUTHORIZED, e.getMessage()); log.error(e.getMessage(), e); return; } catch (IllegalArgumentException | SQLException e) { res.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage()); log.error(e.getMessage(), e); return; } catch (AccessDeniedException e) { res.sendError(HttpServletResponse.SC_FORBIDDEN, e.getMessage()); log.error(e.getMessage(), e); return; } if (authentication != null) { SecurityContextHolder.getContext().setAuthentication(authentication); restAuthenticationService.invalidateAuthenticationCookie(res); } chain.doFilter(req, res); }
Source:
public void setArchiveStatusOfInstructor(String googleId, String courseId, boolean archiveStatus) throws InvalidParametersException, EntityDoesNotExistException{ InstructorAttributes instructor = instructorsDb.getInstructorForGoogleId(courseId, googleId); instructor.isArchived = Boolean.valueOf(archiveStatus); instructorsDb.updateInstructorByGoogleId(instructor); }

Target:
public void setArchiveStatusOfInstructor(String googleId, String courseId, boolean archiveStatus) throws InvalidParametersException, EntityDoesNotExistException{ InstructorAttributes instructor = instructorsDb.getInstructorForGoogleId(courseId, googleId); instructor.isArchived = archiveStatus; instructorsDb.updateInstructorByGoogleId(instructor); }
Source:
public void send(@CheckForNull final TransportEndpoint endpoint, @CheckForNull final Message message, @Nullable final SettableFuture<Void> promise) { checkArgument(endpoint != null); checkArgument(message != null); Futures.addCallback(getOrConnect(endpoint.socketAddress()), new FutureCallback<TransportChannel>() { @Override public void onSuccess(TransportChannel input) { input.send(message, promise); } @Override public void onFailure(Throwable cause) { LOGGER.error("Failed to get transportChannel by socketAddress: {}, cause: {}", endpoint.socketAddress(), cause); if (promise != null) { promise.setException(cause); } } }); }

Target:
public void send(@CheckForNull final TransportEndpoint endpoint, @CheckForNull final Message message, @Nullable final SettableFuture<Void> promise) { checkArgument(endpoint != null); checkArgument(message != null); ListenableFuture<TransportChannel> future = getOrConnect(endpoint.socketAddress()); if (!future.isDone()) { Futures.addCallback(future, new FutureCallback<TransportChannel>() { @Override public void onSuccess(TransportChannel input) { input.send(message, promise); } @Override public void onFailure(Throwable cause) { setFailedGetOrConnect(promise, cause, endpoint.socketAddress()); } }); } else { TransportChannel transportChannel; try { transportChannel = future.get(); } catch (CancellationException | ExecutionException cause) { Throwable cause1 = cause instanceof ExecutionException ? cause.getCause() : cause; setFailedGetOrConnect(promise, cause1, endpoint.socketAddress()); return; } catch (InterruptedException cause) { throw Throwables.propagate(cause); } transportChannel.send(message, promise); } }
Source:
public void returnsNextValue() { final List<String> VALID_LIST = Arrays.asList( "Accept: text/plain", "Accept-Charset: utf-8", "Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==", "Cache-Control: no-cache", "From: user@example.com"); MatcherAssert.assertThat( new VerboseIterable<String>(VALID_LIST, "Empty Error Message") .iterator().next(), equalTo("Accept: text/plain")); }

Target:
public final void returnsNextValue() { final String accept = "Accept: text/plain"; MatcherAssert.assertThat( new VerboseIterable<String>( Arrays.asList( accept, "Accept-Charset: utf-8", "Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==", "Cache-Control: no-cache", "From: user@example.com" ), "Empty Error Message" ).iterator().next(), Matchers.equalTo(accept) ); }
Source:
private void updateSLinks(ITmfEvent event) { String sId = event.getContent().getFieldValue(String.class, ITraceEventConstants.ID); if (sId == null) { Object resolve = fIdAspect.resolve(event); if (resolve == null) { resolve = Integer.valueOf(0); } sId = String.valueOf(resolve); } Long sLink = fLinkStartTime.remove(sId); int tid = (int) getThreadId(event); ITmfStateSystemBuilder ssb = getStateSystemBuilder(); if (ssb == null) { return; } int linkQuark = ssb.getQuarkAbsoluteAndAdd(EDGES, sId); long ts = event.getTimestamp().toNanos(); if (sLink != null) { ssb.modifyAttribute(sLink, sId, linkQuark); int dstTidQuark = ssb.getQuarkRelativeAndAdd(linkQuark, "DST_TID"); ssb.modifyAttribute(sLink, tid, dstTidQuark); int dstQuark = ssb.getQuarkRelativeAndAdd(linkQuark, "DST"); ssb.modifyAttribute(sLink, event.getTrace().getHostId(), dstQuark); ssb.removeAttribute(ts, linkQuark); } else { int srcTidQuark = ssb.getQuarkRelativeAndAdd(linkQuark, "SRC_TID"); ssb.modifyAttribute(ts, tid, srcTidQuark); int srcQuark = ssb.getQuarkRelativeAndAdd(linkQuark, "SRC"); ssb.modifyAttribute(ts, event.getTrace().getHostId(), srcQuark); fLinkStartTime.put(sId, ts); } }

Target:
private void updateSLinks(ITmfEvent event) { String sId = event.getContent().getFieldValue(String.class, ITraceEventConstants.ID); if (sId == null) { Object resolve = fIdAspect.resolve(event); if (resolve == null) { resolve = Integer.valueOf(0); } sId = String.valueOf(resolve); } HostThread src = fSrcHost.remove(sId); int tid = (int) getThreadId(event); ITmfStateSystemBuilder ssb = getStateSystemBuilder(); if (ssb == null) { return; } long ts = event.getTimestamp().toNanos(); long startTime = fScopeEndTimes.getOrDefault(sId, ts); ts ++; HostThread currHostThread = new HostThread(event.getTrace().getHostId(), tid); if (src != null && !src.equals(currHostThread)) { TmfAttributePool pool = getPool(ssb); int linkQuark = pool.getAvailable(); HostThread dst = currHostThread; ssb.modifyAttribute(startTime, (Object) new EdgeStateValue(fIdCache.computeIfAbsent(sId, FUNCTION), src, dst), linkQuark); ssb.modifyAttribute(ts, (Object) null, linkQuark); pool.recycle(linkQuark, ts); } fSrcHost.put(sId, currHostThread); }
Source:
private String getTemplateContent(String templatePath) { Path commitTemplatePath = Paths.get(templatePath); if (Files.exists(commitTemplatePath)) { byte[] fileBytes; try { fileBytes = Files.readAllBytes(commitTemplatePath); String rawTemplate = new String(fileBytes).trim(); return shouldShowCommentsInCommitTemplate() ? rawTemplate : cleanTemplate(rawTemplate); } catch (IOException e) { } } return null; }

Target:
private String getTemplateContent(String templatePath) { File commitTemplatePath = new File(templatePath); if (commitTemplatePath.exists()) { try { return RawParseUtils.decode(IO.readFully(commitTemplatePath)); } catch (IOException e) { return e.getMessage(); } } return null; }
Source:
public void sendSkullChange(Location location, CompoundTag nbt) throws IllegalArgumentException { Validate.notNull(location, "location cannot be null"); Validate.notNull(nbt, "nbt cannot be null"); afterBlockChanges.add(new UpdateBlockEntityMessage((int) location.getX(), (int) location.getY(), (int) location.getZ(), GlowBlockEntity.SKULL.getValue(), nbt)); }

Target:
public void sendSkullChange(Location location, CompoundTag nbt) { sendBlockEntityChange(location, nbt, GlowBlockEntity.SKULL); }
Source:
public FutureResult<WarehouseS3Credentials> addS3Credentials(final Warehouse warehouse, final WarehouseS3Credentials s3Credentials) { notNull(warehouse, "warehouse"); notEmpty(warehouse.getId(), "warehouse.id"); notNull(s3Credentials, "s3Credentials"); final WarehouseS3Credentials s3CredentialsWithLinks = s3Credentials.withLinks(warehouse.getId()); final WarehouseTask task = createWarehouseTask(s3CredentialsWithLinks, HttpMethod.POST); return new PollResult<>(this, createS3PollHandler(s3CredentialsWithLinks, task, "add")); }

Target:
public FutureResult<WarehouseS3Credentials> addS3Credentials(final Warehouse warehouse, final WarehouseS3Credentials s3Credentials) { notNull(warehouse, "warehouse"); notEmpty(warehouse.getId(), "warehouse.id"); notNull(s3Credentials, "s3Credentials"); final WarehouseTask task = createWarehouseTask(WarehouseS3CredentialsList.URI, s3Credentials, HttpMethod.POST, warehouse.getId()); final String newCredentialsUri = WarehouseS3Credentials.TEMPLATE.expand(warehouse.getId(), s3Credentials.getRegion(), s3Credentials.getAccessKey()).toString(); return new PollResult<>(this, createS3PollHandler(newCredentialsUri, task, "add")); }
Source:
protected Resource getAirdResourceWithAnalysisOn(final EObject object) { for (final Resource anResource : session.getAllSessionResources()) { for (final DAnalysis analysis : getAnalyses(anResource)) { Option<EObject> optionalMainModel = new DAnalysisQuery(analysis).getMainModel(); ArrayList<EObject> releventModels = Lists.<EObject> newArrayList(); if (optionalMainModel.some()) { releventModels.add(optionalMainModel.get()); for (EObject model : analysis.getModels()) { if (!AdapterFactoryEditingDomain.isControlled(model) && !(new EObjectQuery(optionalMainModel.get()).isContainedIn(model))) { releventModels.add(model); } } } if (Iterables.contains(releventModels, object)) { return anResource; } } } return null; }

Target:
protected Resource getAirdResourceWithAnalysisOn(final EObject object) { for (final Resource anResource : session.getAllSessionResources()) { for (final DAnalysis analysis : getAnalyses(anResource)) { Set<EObject> releventModels = new DAnalysisQuery(analysis).getMainModels(); if (Iterables.contains(releventModels, object)) { return anResource; } } } return null; }
Source:
private static void readLightingInfo(Cube cube, NBTTagCompound nbt, ICubicWorldServer world) { NBTTagCompound lightingInfo = nbt.getCompoundTag("LightingInfo"); int[] lastHeightMap = lightingInfo.getIntArray("LastHeightMap"); int[] currentHeightMap = cube.getColumn().getHeightMap(); byte edgeNeedSkyLightUpdate = 63; if (lightingInfo.hasKey("EdgeNeedSkyLightUpdate")) edgeNeedSkyLightUpdate = lightingInfo.getByte("EdgeNeedSkyLightUpdate"); for (int i = 0; i < cube.edgeNeedSkyLightUpdate.length; i++) { cube.edgeNeedSkyLightUpdate[i] = (edgeNeedSkyLightUpdate >>> i & 1) == 1; } int minBlockY = Coords.cubeToMinBlock(cube.getY()); int maxBlockY = Coords.cubeToMaxBlock(cube.getY()); LightingManager lightManager = world.getLightingManager(); for (int i = 0; i < currentHeightMap.length; i++) { int currentY = currentHeightMap[i]; int lastY = lastHeightMap[i]; int minUpdateY = Math.min(currentY, lastY); int maxUpdateY = Math.max(currentY, lastY); boolean needLightUpdate = minUpdateY != maxUpdateY && !(maxUpdateY < minBlockY) && !(minUpdateY > maxBlockY); if (needLightUpdate) { if (minUpdateY < minBlockY) { minUpdateY = minBlockY; } if (maxUpdateY > maxBlockY) { maxUpdateY = maxBlockY; } assert minUpdateY <= maxUpdateY : "minUpdateY > maxUpdateY: " + minUpdateY + ">" + maxUpdateY; int localX = i & 0xF; int localZ = i >> 4; lightManager.markCubeBlockColumnForUpdate(cube, localToBlock(cube.getX(), localX), localToBlock(cube.getZ(), localZ)); } } }

Target:
private static void readLightingInfo(Cube cube, NBTTagCompound nbt, ICubicWorldServer world) { NBTTagCompound lightingInfo = nbt.getCompoundTag("LightingInfo"); int[] lastHeightMap = lightingInfo.getIntArray("LastHeightMap"); int[] currentHeightMap = cube.getColumn().getHeightMap(); byte edgeNeedSkyLightUpdate = 0x3F; if (lightingInfo.hasKey("EdgeNeedSkyLightUpdate")) edgeNeedSkyLightUpdate = lightingInfo.getByte("EdgeNeedSkyLightUpdate"); for (int i = 0; i < cube.edgeNeedSkyLightUpdate.length; i++) { cube.edgeNeedSkyLightUpdate[i] = (edgeNeedSkyLightUpdate >>> i & 1) == 1; } int minBlockY = Coords.cubeToMinBlock(cube.getY()); int maxBlockY = Coords.cubeToMaxBlock(cube.getY()); LightingManager lightManager = world.getLightingManager(); for (int i = 0; i < currentHeightMap.length; i++) { int currentY = currentHeightMap[i]; int lastY = lastHeightMap[i]; int minUpdateY = Math.min(currentY, lastY); int maxUpdateY = Math.max(currentY, lastY); boolean needLightUpdate = minUpdateY != maxUpdateY && !(maxUpdateY < minBlockY) && !(minUpdateY > maxBlockY); if (needLightUpdate) { if (minUpdateY < minBlockY) { minUpdateY = minBlockY; } if (maxUpdateY > maxBlockY) { maxUpdateY = maxBlockY; } assert minUpdateY <= maxUpdateY : "minUpdateY > maxUpdateY: " + minUpdateY + ">" + maxUpdateY; int localX = i & 0xF; int localZ = i >> 4; lightManager.markCubeBlockColumnForUpdate(cube, localToBlock(cube.getX(), localX), localToBlock(cube.getZ(), localZ)); } } }
Source:
@Test public void testDecimalNegate() { final CalciteAssert.AssertThat with = CalciteAssert.that().withSchema("s", CATCHALL); with.query("select - \"bigDecimal\" from \"s\".\"everyTypes\"") .returnsUnordered( "EXPR$0=0", "EXPR$0=null"); with.query("select - \"bigDecimal\" from \"s\".\"everyTypes\"").planContains(".decimalNegate("); }

Target:
@Test void testDecimalNegate() { final CalciteAssert.AssertThat with = CalciteAssert.that().withSchema("s", CATCHALL); with.query("select - \"bigDecimal\" from \"s\".\"everyTypes\"") .planContains("negate()") .returnsUnordered( "EXPR$0=0", "EXPR$0=null"); }
Source:
private RepositoryTreeNode getNodeForPath(Repository repository, String repoRelativePath) { RepositoryTreeNode workingDirNode = getRepositoryChildNode(repository, RepositoryTreeNodeType.WORKINGDIR); RepositoryTreeNode currentNode = workingDirNode; ITreeContentProvider cp = (ITreeContentProvider) getCommonViewer() .getContentProvider(); IPath relPath = new Path(repoRelativePath); for (String segment : relPath.segments()) { for (Object child : cp.getChildren(workingDirNode)) { @SuppressWarnings("unchecked") RepositoryTreeNode<File> childNode = (RepositoryTreeNode<File>) child; if (childNode.getObject().getName().equals(segment)) { currentNode = childNode; break; } } } return currentNode; }

Target:
private RepositoryTreeNode getNodeForPath(Repository repository, String repoRelativePath) { RepositoryTreeNode currentNode = getRepositoryChildNode(repository, RepositoryTreeNodeType.WORKINGDIR); ITreeContentProvider cp = (ITreeContentProvider) getCommonViewer() .getContentProvider(); IPath relPath = new Path(repoRelativePath); for (String segment : relPath.segments()) { for (Object child : cp.getChildren(currentNode)) { @SuppressWarnings("unchecked") RepositoryTreeNode<File> childNode = (RepositoryTreeNode<File>) child; if (childNode.getObject().getName().equals(segment)) { currentNode = childNode; break; } } } return currentNode; }
Source:
public void handleModStateEvent(FMLEvent event) { if (!eventHandlers.containsKey(event.getClass())) { return; } try { eventHandlers.get(event.getClass()) .stream() .map(eventHandler -> { try { return eventHandler.handleEvent(event); } catch (Throwable t) { CompletableFuture<Void> future = CompletableFuture.completedFuture(null); future.completeExceptionally(t); return future; } }) .reduce((future1, future2) -> future1.thenComposeAsync(aVoid -> future2)) .orElse(CompletableFuture.completedFuture(null)) .toCompletableFuture() .join(); } catch (Throwable t) { controller.errorOccurred(this, t); } }

Target:
public void handleModStateEvent(FMLEvent event) { if (!eventHandlers.containsKey(event.getClass())) { return; } try { CompletableFuture[] futures = eventHandlers.get(event.getClass()) .stream() .map(eventHandler -> eventHandler.apply(this.getMod(), event)) .toArray(CompletableFuture[]::new); CompletableFuture.allOf(futures).join(); } catch (Throwable t) { controller.errorOccurred(this, t); } }
Source:
public KTable<Windowed<K>, V> aggregate(final Initializer<V> initializer, final Named named, final Materialized<K, V, WindowStore<Bytes, byte[]>> materialized) { Objects.requireNonNull(initializer, "initializer can't be null"); Objects.requireNonNull(named, "named can't be null"); Objects.requireNonNull(materialized, "materialized can't be null"); final MaterializedInternal<K, V, WindowStore<Bytes, byte[]>> materializedInternal = new MaterializedInternal<>( materialized, builder, AGGREGATE_NAME); return aggregateBuilder.build( groupPatterns, initializer, new NamedInternal(named), materialize(materializedInternal), materializedInternal.keySerde() != null ? new FullTimeWindowedSerde<>(materializedInternal.keySerde(), windows.size()) : null, materializedInternal.valueSerde(), materializedInternal.queryableStoreName(), windows, null, null); }

Target:
public KTable<Windowed<K>, V> aggregate(final Initializer<V> initializer, final Named named, final Materialized<K, V, WindowStore<Bytes, byte[]>> materialized) { Objects.requireNonNull(initializer, "initializer can't be null"); Objects.requireNonNull(named, "named can't be null"); Objects.requireNonNull(materialized, "materialized can't be null"); final MaterializedInternal<K, V, WindowStore<Bytes, byte[]>> materializedInternal = new MaterializedInternal<>( materialized, builder, CogroupedKStreamImpl.AGGREGATE_NAME); return aggregateBuilder.build( groupPatterns, initializer, new NamedInternal(named), materialize(materializedInternal), materializedInternal.keySerde() != null ? new FullTimeWindowedSerde<>(materializedInternal.keySerde(), windows.size()) : null, materializedInternal.valueSerde(), materializedInternal.queryableStoreName(), windows, null, null); }
Source:
public static void main(String[] args) throws Exception { if (args.length < 2 || args.length > 3) { usage(); } final String namespace = args.length >= 3 ? args[2] : "kb"; final String propFile = args.length >= 4 ? args[3] : null; Journal j1 = journalFromFile(args[0], propFile), j2 = journalFromFile(args[1], propFile); try { final AbstractTripleStore ts1 = (AbstractTripleStore) j1.getResourceLocator().locate( namespace, TimestampUtility.asHistoricalRead(j1.getLastCommitTime())); final AbstractTripleStore ts2 = (AbstractTripleStore) j2.getResourceLocator().locate( namespace, TimestampUtility.asHistoricalRead(j2.getLastCommitTime())); modelsEqual(ts1, ts2); } finally { j1.close(); j2.close(); } }

Target:
public static void main(String[] args) throws Exception { if (args.length < 2 || args.length > 3) { usage(); } final String namespace = args.length >= 3 ? args[2] : "kb"; Journal j1 = null, j2 = null; try { j1 = journalFromFile(args[0]); j2 = journalFromFile(args[1]); final AbstractTripleStore ts1 = (AbstractTripleStore) j1.getResourceLocator().locate( namespace, TimestampUtility.asHistoricalRead(j1.getLastCommitTime())); final AbstractTripleStore ts2 = (AbstractTripleStore) j2.getResourceLocator().locate( namespace, TimestampUtility.asHistoricalRead(j2.getLastCommitTime())); modelsEqual(ts1, ts2); } finally { if (j1 != null) { j1.close(); } if (j2 != null) { j2.close(); } } }
Source:
public void addTransactionAttribute( @Option(required = true, name = "type") final TransactionAttributeType transactionAttributeType, final PipeOut out) throws FileNotFoundException { JavaSource<?> ejb; if (resource instanceof JavaResource) { ejb = JavaUtils.getJavaClassFrom(resource); ejb.addAnnotation(TransactionAttribute.class).setEnumValue( transactionAttributeType); save(ejb); } else if (resource instanceof JavaMethodResource) { Method<? extends JavaSource<?>> m = ((JavaMethodResource) resource) .getUnderlyingResourceObject(); m.addAnnotation(TransactionAttribute.class).setEnumValue( transactionAttributeType); ejb = m.getOrigin(); save(ejb); } else { throw new RuntimeException( "Impossibile to add transactionAttribute to method " + resource.getName()); } }

Target:
public void addTransactionAttribute( @Option(required = true, name = "type") final TransactionAttributeType transactionAttributeType, final PipeOut out) throws FileNotFoundException { JavaSource<?> ejb; if (resource instanceof JavaResource) { ejb = getJavaClassFrom(resource); if (ejb.hasAnnotation(transactionAttributeType.getAnnotation())) { throw new RuntimeException( "Current class have already TransactionAttribute annotation!"); } ejb.addAnnotation(TransactionAttribute.class).setStringValue( transactionAttributeType.getAnnotation()); save(ejb); } else if (resource instanceof JavaMethodResource) { Method<? extends JavaSource<?>> m = ((JavaMethodResource) resource) .getUnderlyingResourceObject(); if (m.hasAnnotation(transactionAttributeType.getAnnotation())) { throw new RuntimeException( "Current method have already TransactionAttribute annotation!"); } m.addAnnotation(TransactionAttribute.class).setStringValue( transactionAttributeType.getAnnotation()); ejb = m.getOrigin(); save(ejb); } else { throw new RuntimeException( "Impossibile to add transactionAttribute to method " + resource.getName()); } }
Source:
public void testSetPredecessor() { final Instruction predecessor = new Instruction( new InsnNode(Opcodes.NOP), 122); instruction.setPredecessor(predecessor, 0); assertEquals(1, predecessor.getBranches()); try { instruction.setPredecessor(predecessor, 0); fail("exception expected"); } catch (IllegalStateException e) { } }

Target:
public void testSetPredecessor() { final Instruction predecessor = new Instruction( new InsnNode(Opcodes.NOP), 122); instruction.setPredecessor(predecessor, 0); assertEquals(1, predecessor.getBranches()); }
Source:
static Optional<RefundStatus> newRefundStateForRefundNotification(String notificationStatus) { final EpdqNotification.StatusCode statusCode = EpdqNotification.StatusCode.byCode(notificationStatus); switch (statusCode) { case EPDQ_REFUND: case EPDQ_PAYMENT_DELETED: return Optional.of(REFUNDED); case EPDQ_REFUND_REFUSED: case EPDQ_DELETION_REFUSED: case EPDQ_REFUND_DECLINED_BY_ACQUIRER: return Optional.of(REFUND_ERROR); default: return Optional.empty(); } }

Target:
private static Optional<RefundStatus> newRefundStateForRefundNotification(String notificationStatus) { final EpdqNotification.StatusCode statusCode = EpdqNotification.StatusCode.byCode(notificationStatus); switch (statusCode) { case EPDQ_REFUND: case EPDQ_PAYMENT_DELETED: return Optional.of(REFUNDED); case EPDQ_REFUND_REFUSED: case EPDQ_DELETION_REFUSED: case EPDQ_REFUND_DECLINED_BY_ACQUIRER: return Optional.of(REFUND_ERROR); default: return Optional.empty(); } }
Source:
public synchronized V refreshValue() { value = new SoftReference<>(action.get()); expiresAt = System.nanoTime() + expiry; return value.get(); }

Target:
public synchronized V refreshValue() { V freshValue = action.get(); value = new SoftReference<>(freshValue); expiresAt = System.nanoTime() + expiry; return freshValue; }
Source:
private void localize(CommonApplicationConstants constants) { aliasEditor.setLabel(constants.aliasVmDiskPopup()); sizeEditor.setLabel(constants.sizeVmDiskPopup()); sizeExtendEditor.setLabel(constants.extendImageSizeBy()); descriptionEditor.setLabel(constants.descriptionVmDiskPopup()); datacenterEditor.setLabel(constants.dcVmDiskPopup()); storageDomainEditor.setLabel(constants.storageDomainVmDiskPopup()); hostListEditor.setLabel(constants.hostVmDiskPopup()); quotaEditor.setLabel(constants.quotaVmDiskPopup()); interfaceEditor.setLabel(constants.interfaceVmDiskPopup()); volumeTypeEditor.setLabel(constants.allocationDisk()); storageTypeEditor.setLabel(constants.storageTypeVmDiskPopup()); plugDiskToVmEditor.setLabel(constants.plugDiskVmDiskPopup()); wipeAfterDeleteEditor.setLabel(constants.wipeAfterDeleteVmDiskPopup()); isBootableEditor.setLabel(constants.isBootableVmDiskPopup()); isShareableEditor.setLabel(constants.isShareableVmDiskPopup()); isReadOnlyEditor.setLabel(constants.isReadOnlyVmDiskPopup()); isSgIoUnfilteredEditor.setLabel(constants.isSgIoUnfilteredEditor()); attachEditor.setLabel(constants.attachDiskVmDiskPopup()); isPluggedEditor.setLabel(constants.activateVmDiskPopup()); }

Target:
private void localize(CommonApplicationConstants constants) { aliasEditor.setLabel(constants.aliasVmDiskPopup()); sizeEditor.setLabel(constants.sizeVmDiskPopup()); sizeExtendEditor.setLabel(constants.extendImageSizeBy()); descriptionEditor.setLabel(constants.descriptionVmDiskPopup()); datacenterEditor.setLabel(constants.dcVmDiskPopup()); storageDomainEditor.setLabel(constants.storageDomainVmDiskPopup()); hostListEditor.setLabel(constants.hostVmDiskPopup()); quotaEditor.setLabel(constants.quotaVmDiskPopup()); interfaceEditor.setLabel(constants.interfaceVmDiskPopup()); volumeTypeEditor.setLabel(constants.allocationDisk()); storageTypeEditor.setLabel(constants.storageTypeVmDiskPopup()); plugDiskToVmEditor.setLabel(constants.activateVmDiskPopup()); wipeAfterDeleteEditor.setLabel(constants.wipeAfterDeleteVmDiskPopup()); isBootableEditor.setLabel(constants.isBootableVmDiskPopup()); isShareableEditor.setLabel(constants.isShareableVmDiskPopup()); isReadOnlyEditor.setLabel(constants.isReadOnlyVmDiskPopup()); isSgIoUnfilteredEditor.setLabel(constants.isSgIoUnfilteredEditor()); attachEditor.setLabel(constants.attachDiskVmDiskPopup()); isPluggedEditor.setLabel(constants.activateVmDiskPopup()); }
Source:
private void writeTimelineDocuments(Collection<Report> reports) { for (Report report : reports) { String configName = report.getConfiguration().name; TimelineDocument timelineDocument = new TimelineDocument(timelineConfig, targetDir, configName + "_" + report.getCluster().getClusterIndex(), configName + " on " + report.getCluster(), report.getTimelines(), report.getCluster()); freemarker.template.Configuration cfg = initConfig(); try { timelineDocument.createReportDirectory(); timelineDocument.generateTimelineCharts(); Template reportTemplate = cfg.getTemplate("timelineReport.ftl"); PrintWriter printWriter = new PrintWriter(targetDir + File.separator + timelineDocument.getFileName()); Map root = new HashMap(); root.put("timelineDocument", timelineDocument); reportTemplate.process(root, printWriter); printWriter.close(); } catch (Exception e) { log.error("Templating exception", e); } } }

Target:
private void writeTimelineDocuments(Collection<Report> reports) { for (Report report : reports) { String configName = report.getConfiguration().name; TimelineDocument timelineDocument = new TimelineDocument(timelineConfig, targetDir, configName + "_" + report.getCluster().getClusterIndex(), configName + " on " + report.getCluster(), report.getTimelines(), report.getCluster()); timelineDocument.createReportDirectory(); timelineDocument.createTestCharts(); Map root = new HashMap(); root.put("timelineDocument", timelineDocument); exposeStaticMethods(root, "java.lang.String", "String"); processTemplate(root, targetDir, timelineDocument.getFileName(), "timelineReport.ftl"); } }
Source:
public void newSequence() { moveSequences.add(new ArrayList<Move>()); }

Target:
public void newSequence() { moveSequences.add(new ArrayList<>()); }
Source:
public void setUp() throws Throwable { String json = TestFileUtil.readRawFile("announce_2016_11_21.json"); AnnouncementList content = GsonUnmarshaller.unmarshal(AnnouncementList.class, json); announcementIOS = content.items().get(0); announcementAndroid = content.items().get(1); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.ROOT); dateBefore = format.parse("2016-08-01"); dateDuring = format.parse("2016-11-20"); dateAfter = format.parse("2017-01-05"); }

Target:
public void setUp() throws Throwable { super.setUp(); String json = TestFileUtil.readRawFile("announce_2016_11_21.json"); announcementList = GsonUnmarshaller.unmarshal(AnnouncementList.class, json); }
Source:
private static <V> void randomize(List<V> list) { ThreadLocalRandom random = ThreadLocalRandom.current(); switch (random.nextInt(3)) { case 0: Collections.shuffle(list, random); break; case 1: Collections.reverse(list); break; case 2: } }

Target:
private static <V> void randomize(List<V> list) { long seed = ThreadLocalRandom.current().nextLong(); logger.info("Seed used for randomize: " + seed); Random random = new Random(seed); switch (random.nextInt(3)) { case 0: Collections.shuffle(list, random); break; case 1: Collections.reverse(list); break; case 2: } }
Source:
public void onSave(final ICalloutRecord calloutRecord) { I_AD_User user = calloutRecord.getModel(I_AD_User.class); if (!isMarketingChannelsUseEnforced()) { return; } if (userDAO.isSystemUser(UserId.ofRepoId(user.getAD_User_ID()))) { return; } boolean canBeSaved = true; if (mktgChannelDao.retrieveMarketingChannelsCountForUser(UserId.ofRepoId(user.getAD_User_ID())) <= 0) { canBeSaved = false; } if (!canBeSaved) { throw new AdempiereException(MSG_CAN_NOT_REMOVE_CHANNEL).markAsUserValidationError(); } }

Target:
public void onSave(final ICalloutRecord calloutRecord) { final I_AD_User user = calloutRecord.getModel(I_AD_User.class); if (!isMarketingChannelsUseEnforced(user.getAD_Client_ID(), user.getAD_Org_ID())) { return; } if (userDAO.isSystemUser(UserId.ofRepoId(user.getAD_User_ID()))) { return; } boolean canBeSaved = true; if (mktgChannelDao.retrieveMarketingChannelsCountForUser(UserId.ofRepoId(user.getAD_User_ID())) <= 0) { canBeSaved = false; } if (!canBeSaved) { throw new AdempiereException(MSG_CAN_NOT_REMOVE_CHANNEL).markAsUserValidationError(); } }
Source:
protected boolean mergeImpl() throws IOException { if (implicitDirCache) { dircache = nonNullRepo().lockDirCache(); } if (!inCore) { checkoutMetadata = new HashMap<>(); } try { return mergeTrees(mergeBase(), sourceTrees[0], sourceTrees[1], false); } finally { if (implicitDirCache) { dircache.unlock(); } checkoutMetadata = null; } }

Target:
protected boolean mergeImpl() throws IOException { if (implicitDirCache) { dircache = nonNullRepo().lockDirCache(); } if (!inCore) { checkoutMetadata = new HashMap<>(); } try { return mergeTrees(mergeBase(), sourceTrees[0], sourceTrees[1], false); } finally { checkoutMetadata = null; if (implicitDirCache) { dircache.unlock(); } } }
Source:
public <T> T invoke(Method method, Object instance, Object... args) { MethodHandle methodHandle = cache.get(method); if (methodHandle == null) { cache.put(method, methodHandleFactory.create(instance.getClass(), method)); } try { return (T) cache.get(method) .invokeExact(instance, args); } catch (Throwable e) { throw new MethodExecutorException(e); } }

Target:
public <T> T invoke(Method method, Object instance, Object... args) { MethodHandle methodHandle = cache.get(method); if (methodHandle == null) { methodHandle = methodHandleFactory.create(instance.getClass(), method); cache.put(method, methodHandle); } try { return (T) methodHandle.invokeExact(instance, args); } catch (Throwable e) { Throwables.propagateIfPossible(e); throw new MethodExecutorException(e); } }
Source:
private static Stream<RelationalSymbolicValue> knownRelations(ProgramState programState) { return programState.getValuesWithConstraints(BooleanConstraint.TRUE) .stream() .filter(sv -> sv instanceof RelationalSymbolicValue) .map(sv -> (RelationalSymbolicValue) sv); }

Target:
private static Stream<RelationalSymbolicValue> knownRelations(ProgramState programState) { return programState.getValuesWithConstraints(BooleanConstraint.TRUE) .stream() .filter(RelationalSymbolicValue.class::isInstance) .map(RelationalSymbolicValue.class::cast); }
Source:
protected CreateVDSCommandParameters buildCreateVmParameters() { CreateVDSCommandParameters parameters = new CreateVDSCommandParameters(getVdsId(), getVm()); parameters.setPassthroughVnicToVfMap(initParametersForPassthroughVnics()); parameters.setRunInUnknownStatus(getParameters().isRunInUnknownStatus()); parameters.setVmPayload(vmPayload); if (initializationType == InitializationType.Sysprep && osRepository.isWindows(getVm().getVmOsId()) && (getVm().getFloppyPath() == null || "".equals(getVm().getFloppyPath()))) { parameters.setInitializationType(InitializationType.Sysprep); } if (initializationType == InitializationType.CloudInit && !osRepository.isWindows(getVm().getVmOsId())) { parameters.setInitializationType(InitializationType.CloudInit); } return parameters; }

Target:
protected CreateVDSCommandParameters buildCreateVmParameters() { CreateVDSCommandParameters parameters = new CreateVDSCommandParameters(getVdsId(), getVm()); parameters.setRunInUnknownStatus(getParameters().isRunInUnknownStatus()); parameters.setVmPayload(vmPayload); parameters.setHibernationVolHandle(getMemoryFromActiveSnapshot()); parameters.setPassthroughVnicToVfMap(getPassthroughVnicToVfMap()); if (initializationType == InitializationType.Sysprep && osRepository.isWindows(getVm().getVmOsId()) && (getVm().getFloppyPath() == null || "".equals(getVm().getFloppyPath()))) { parameters.setInitializationType(InitializationType.Sysprep); } if (initializationType == InitializationType.CloudInit && !osRepository.isWindows(getVm().getVmOsId())) { parameters.setInitializationType(InitializationType.CloudInit); } return parameters; }
Source:
private void assertAccountUpdateConsumers(Set<Account> expectedAccounts, int expectedNumberOfConsumers, List<Collection<Account>> accountsInConsumers) throws Exception { assertEquals("Wrong number of consumers", expectedNumberOfConsumers, accountsInConsumers.size()); for (Collection<Account> accounts : accountsInConsumers) { assertEquals("Wrong number of updated accounts received by consumers", expectedAccounts.size(), accounts.size()); for (Account account : accounts) { assertTrue("Account should be received by the consumers but not.", expectedAccounts.contains(adjustSnapshotVersion(account, -1))); } TestUtils.assertException(UnsupportedOperationException.class, () -> accounts.add(Account.UNKNOWN_ACCOUNT), null); } }

Target:
private void assertAccountUpdateConsumers(Set<Account> expectedAccounts, int expectedNumberOfConsumers, List<Collection<Account>> accountsInConsumers) throws Exception { assertEquals("Wrong number of consumers", expectedNumberOfConsumers, accountsInConsumers.size()); for (Collection<Account> accounts : accountsInConsumers) { assertEquals("Wrong number of updated accounts received by consumers", expectedAccounts.size(), accounts.size()); for (Account account : accounts) { assertTrue("Account update not received by consumers", expectedAccounts.contains(account)); } TestUtils.assertException(UnsupportedOperationException.class, () -> accounts.add(Account.UNKNOWN_ACCOUNT), null); } }
Source:
private boolean shouldRepartitionForIndexJoin(List<VariableReferenceExpression> joinColumns, PreferredProperties parentPreferredProperties, ActualProperties probeProperties) { if (!distributedIndexJoins) { return false; } if (probeProperties.isSingleNode()) { return false; } Optional<PartitioningProperties> parentPartitioningPreferences = parentPreferredProperties.getGlobalProperties() .flatMap(PreferredProperties.Global::getPartitioningProperties); boolean parentAlreadyPartitionedOnChild = parentPartitioningPreferences .map(partitioning -> probeProperties.isStreamPartitionedOn(partitioning.getPartitioningColumns(), isExactPartitioningPreferred(session))) .orElse(false); if (preferStreamingOperators && parentAlreadyPartitionedOnChild) { return false; } if (!probeProperties.isStreamPartitionedOn(joinColumns, isExactPartitioningPreferred(session))) { return true; } return probeProperties.isEffectivelySingleStream() && probeProperties.isStreamRepartitionEffective(joinColumns); }

Target:
private boolean shouldRepartitionForIndexJoin(List<VariableReferenceExpression> joinColumns, PreferredProperties parentPreferredProperties, ActualProperties probeProperties) { if (!distributedIndexJoins) { return false; } if (probeProperties.isSingleNode()) { return false; } Optional<PartitioningProperties> parentPartitioningPreferences = parentPreferredProperties.getGlobalProperties() .flatMap(PreferredProperties.Global::getPartitioningProperties); boolean parentAlreadyPartitionedOnChild = parentPartitioningPreferences .map(partitioning -> probeProperties.isStreamPartitionedOn(partitioning.getPartitioningColumns(), false)) .orElse(false); if (preferStreamingOperators && parentAlreadyPartitionedOnChild) { return false; } if (!probeProperties.isStreamPartitionedOn(joinColumns, false)) { return true; } return probeProperties.isEffectivelySingleStream() && probeProperties.isStreamRepartitionEffective(joinColumns); }
Source:
public List<ListenableFuture<R>> applyBatch(List<T> arguments) { Preconditions.checkState(!closed, "Autobatcher is already shut down"); List<ListenableFuture<R>> results = new ArrayList<>(); buffer.publishEvents((EventTranslator<DefaultBatchElement<T, R>>[]) arguments.stream().map(argument -> { SettableFuture<R> result = SettableFuture.create(); EventTranslator<DefaultBatchElement<T, R>> translator = (refresh, sequence) -> { refresh.result = result; refresh.argument = argument; }; results.add(result); return translator; }).collect(Collectors.toList()).toArray()); return results; }

Target:
public List<ListenableFuture<R>> applyBatch(List<T> arguments) { Preconditions.checkState(!closed, "Autobatcher is already shut down"); List<ListenableFuture<R>> results = new ArrayList<>(); buffer.publishEvents((EventTranslator<DefaultBatchElement<T, R>>[]) arguments.stream().map(argument -> { DisruptorFuture<R> result = new DisruptorFuture<>(safeLoggablePurpose); EventTranslator<DefaultBatchElement<T, R>> translator = (refresh, sequence) -> { refresh.result = result; refresh.argument = argument; }; results.add(result); return translator; }).toArray(EventTranslator[]::new)); return results; }
Source:
public void testChildAccessors() { WContainer container = new WContainer(); Assert.assertEquals("Should have no child count", 0, container.getChildCount()); WComponent child = new DefaultWComponent(); container.add(child); Assert.assertEquals("Incorrect child count", 1, container.getChildCount()); Assert.assertEquals("Incorrect child index", 0, container.getIndexOfChild(child)); Assert.assertEquals("Incorrect child returned", child, container.getChildAt(0)); container.remove(child); Assert.assertEquals("Should have no child count after removing", 0, container.getChildCount()); container.add(child); Assert.assertEquals("Incorrect child count", 1, container.getChildren().size()); Assert.assertEquals("Incorrect child index", 0, container.getChildren().indexOf(child)); Assert.assertEquals("Incorrect child returned", child, container.getChildren().get(0)); try { container.getChildren().add(new DefaultWComponent()); Assert.fail("Expected getChildren() to return unmodifiable List."); } catch (UnsupportedOperationException e) { Assert.assertEquals("Incorrect child count", 1, container.getChildren().size()); } }

Target:
public void testChildAccessors() { WBeanContainer container = new WBeanContainer(); Assert.assertEquals("Should have no child count", 0, container.getChildCount()); WComponent child = new DefaultWComponent(); container.add(child); Assert.assertEquals("Incorrect child count", 1, container.getChildCount()); Assert.assertEquals("Incorrect child index", 0, container.getIndexOfChild(child)); Assert.assertEquals("Incorrect child returned", child, container.getChildAt(0)); container.remove(child); Assert.assertEquals("Should have no child count after removing", 0, container.getChildCount()); container.add(child); Assert.assertEquals("Incorrect child count", 1, container.getChildren().size()); Assert.assertEquals("Incorrect child index", 0, container.getChildren().indexOf(child)); Assert.assertEquals("Incorrect child returned", child, container.getChildren().get(0)); try { container.getChildren().add(new DefaultWComponent()); Assert.fail("Expected getChildren() to return unmodifiable List."); } catch (UnsupportedOperationException e) { Assert.assertEquals("Incorrect child count", 1, container.getChildren().size()); } }