auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code><START> private static void sartIterate(){ <END> reconPre=new Grid2D(recon); for (int theta = 0; theta < sinogram.getSize()[1]; theta++) { if(isOpencl) sinoDiff1D= projector.projectRayDriven1DCL(recon, theta); else sinoDiff1D = projector.projectRayDriven1D(recon, theta); sinoDiff1D=(Grid1D)NumericPointwiseOperators.subtractedBy(sinoDiff1D, sinogram.getSubGrid(theta)); NumericPointwiseOperators.divideBy(sinoDiff1D, normSinogram.getSubGrid(theta)); if(isOpencl) localImageUpdate = backProj.backprojectPixelDriven1DCL(sinoDiff1D, theta); else localImageUpdate = backProj.backprojectPixelDriven1D(sinoDiff1D, theta); double stepSize = -1.0; NumericPointwiseOperators.multiplyBy(localImageUpdate,(float) stepSize); NumericPointwiseOperators.divideBy(localImageUpdate, normGrids); NumericPointwiseOperators.addBy(recon, localImageUpdate); } recon.getGridOperator().removeNegative(recon); }</code><technical_language>is this method static? a static method? This holds for other methods... I methods part of object..,</technical_language>

Target:
public void sartIterate(){ reconPre=new Grid2D(recon); for (int theta = 0; theta < sinogram.getSize()[1]; theta++) { if(isOpencl) sinoDiff1D= projector.projectRayDriven1DCL(recon, theta); else sinoDiff1D = projector.projectRayDriven1D(recon, theta); sinoDiff1D=(Grid1D)NumericPointwiseOperators.subtractedBy(sinoDiff1D, sinogram.getSubGrid(theta)); NumericPointwiseOperators.divideBy(sinoDiff1D, normSinogram.getSubGrid(theta)); if(isOpencl) localImageUpdate = backProj.backprojectPixelDriven1DCL(sinoDiff1D, theta); else localImageUpdate = backProj.backprojectPixelDriven1D(sinoDiff1D, theta); double stepSize = -1.0; NumericPointwiseOperators.multiplyBy(localImageUpdate,(float) stepSize); NumericPointwiseOperators.divideBy(localImageUpdate, normGrids); NumericPointwiseOperators.addBy(recon, localImageUpdate); } recon.getGridOperator().removeNegative(recon); }
Source:
<code><START> private static Set<Scope> getScopesFromExtensions(Swagger swagger) throws APIManagementException { <END> Set<Scope> scopeList = new LinkedHashSet<>(); Map<String, Object> extensions = swagger.getVendorExtensions(); if (extensions != null && extensions.containsKey(APIConstants.SWAGGER_X_WSO2_SECURITY)) { Map<String, Object> securityDefinitions = (Map<String, Object>) extensions.get(APIConstants.SWAGGER_X_WSO2_SECURITY); for (Map.Entry<String, Object> entry : securityDefinitions.entrySet()) { Map<String, Object> securityDefinition = (Map<String, Object>) entry.getValue(); if (securityDefinition.containsKey(APIConstants.SWAGGER_X_WSO2_SCOPES)) { List<Map<String, String>> oauthScope = (List<Map<String, String>>) securityDefinition.get(APIConstants.SWAGGER_X_WSO2_SCOPES); for (Map<String, String> anOauthScope : oauthScope) { Scope scope = new Scope(); scope.setKey(anOauthScope.get(APIConstants.SWAGGER_SCOPE_KEY)); scope.setName(anOauthScope.get(APIConstants.SWAGGER_NAME)); scope.setDescription(anOauthScope.get(APIConstants.SWAGGER_DESCRIPTION)); scope.setRoles(anOauthScope.get(APIConstants.SWAGGER_ROLES)); scopeList.add(scope); } } } } return scopeList; }</code><technical_language>do need static here? This is in instance-level methods only</technical_language>

Target:
private Set<Scope> getScopesFromExtensions(Swagger swagger) throws APIManagementException { Set<Scope> scopeList = new LinkedHashSet<>(); Map<String, Object> extensions = swagger.getVendorExtensions(); if (extensions != null && extensions.containsKey(APIConstants.SWAGGER_X_WSO2_SECURITY)) { Map<String, Object> securityDefinitions = (Map<String, Object>) extensions.get(APIConstants.SWAGGER_X_WSO2_SECURITY); for (Map.Entry<String, Object> entry : securityDefinitions.entrySet()) { Map<String, Object> securityDefinition = (Map<String, Object>) entry.getValue(); if (securityDefinition.containsKey(APIConstants.SWAGGER_X_WSO2_SCOPES)) { List<Map<String, String>> oauthScope = (List<Map<String, String>>) securityDefinition.get(APIConstants.SWAGGER_X_WSO2_SCOPES); for (Map<String, String> anOauthScope : oauthScope) { Scope scope = new Scope(); scope.setKey(anOauthScope.get(APIConstants.SWAGGER_SCOPE_KEY)); scope.setName(anOauthScope.get(APIConstants.SWAGGER_NAME)); scope.setDescription(anOauthScope.get(APIConstants.SWAGGER_DESCRIPTION)); scope.setRoles(anOauthScope.get(APIConstants.SWAGGER_ROLES)); scopeList.add(scope); } } } } return scopeList; }
Source:
<code>public void waitForEpochAck(long id, StateSummary ss) throws IOException, InterruptedException { synchronized(electingFollowers) { if (electionFinished) { return; } if (ss.getCurrentEpoch() != -1) { if (ss.isMoreRecentThan(leaderStateSummary)) { throw new IOException("Follower is ahead of the leader, leader summary: " + leaderStateSummary.getCurrentEpoch() + " (current epoch), " + leaderStateSummary.getLastZxid() + " (last zxid)"); } <START> if (self.getVotingView().containsKey(id)) { <END> electingFollowers.add(id); } } QuorumVerifier verifier = self.getQuorumVerifier(); if (electingFollowers.contains(self.getId()) && verifier.containsQuorum(electingFollowers)) { electionFinished = true; electingFollowers.notifyAll(); } else { long start = Time.currentElapsedTime(); long cur = start; long end = start + self.getInitLimit()*self.getTickTime(); while(!electionFinished && cur < end) { electingFollowers.wait(end - cur); cur = Time.currentElapsedTime(); } if (!electionFinished) { throw new InterruptedException("Timeout while waiting for epoch to be acked by quorum"); } } } }</code><technical_language>I suggest encapsulate self.getVotingView().containsKey(id) a private method below, if else, for sake of readability private boolean isParticipant(long sid) { return self.getVotingView().containsKey(id); }</technical_language>

Target:
public void waitForEpochAck(long id, StateSummary ss) throws IOException, InterruptedException { synchronized(electingFollowers) { if (electionFinished) { return; } if (ss.getCurrentEpoch() != -1) { if (ss.isMoreRecentThan(leaderStateSummary)) { throw new IOException("Follower is ahead of the leader, leader summary: " + leaderStateSummary.getCurrentEpoch() + " (current epoch), " + leaderStateSummary.getLastZxid() + " (last zxid)"); } if (isParticipant(id)) { electingFollowers.add(id); } } QuorumVerifier verifier = self.getQuorumVerifier(); if (electingFollowers.contains(self.getId()) && verifier.containsQuorum(electingFollowers)) { electionFinished = true; electingFollowers.notifyAll(); } else { long start = Time.currentElapsedTime(); long cur = start; long end = start + self.getInitLimit()*self.getTickTime(); while(!electionFinished && cur < end) { electingFollowers.wait(end - cur); cur = Time.currentElapsedTime(); } if (!electionFinished) { throw new InterruptedException("Timeout while waiting for epoch to be acked by quorum"); } } } }
Source:
<code>public List<File> getJspClasspath() { List<File> jspClasspath = new ArrayList<>(); jspClasspath.add(findPluginJar()); <START> jspClasspath.addAll(javaClasspath.getElements()); <END> return jspClasspath; }</code><technical_language>this more robust call for getJavaClasspath relying order of callers for javaclasspath initialized</technical_language>

Target:
public List<File> getJspClasspath() { List<File> jspClasspath = new ArrayList<>(); jspClasspath.add(findPluginJar()); jspClasspath.addAll(getJavaClasspath()); return jspClasspath; }
Source:
<code><START> public PortForwarder(final int myPort, final String hostName, final int hostPort) throws IOException { <END> this.myPort = myPort; log.info("Starting port forwarder " + myPort + " -> " + hostPort); openServerSocket(); Runnable myRunnable = new Runnable() { @Override public void run() { log.info("Forwarder running"); while (isAlive.get()) { if (pause.get()) { continue; } try { final Socket clientSocket = serverSocket.accept(); synchronized (threadMonitor) { if (isAlive.get() && !pause.get()) { clientThreadList.add(new ClientThread(clientSocket, hostName, hostPort)); } } } catch (IOException e) { if (pause.get()) { } else { log.log(Level.SEVERE, "Got exception in forwarder", e); } } } } }; portThread = new Thread(myRunnable); portThread.start(); }</code><technical_language>long line</technical_language>

Target:
public PortForwarder(final int myPort, final String hostName, final int hostPort) throws IOException { this.myPort = myPort; this.hostName = hostName; this.hostPort = hostPort; log.info("Starting port forwarder " + myPort + " -> " + hostPort); startServerSocketThread(); }
Source:
<code>public void setUp() { <START> when(this.exampleProject.getRoot()).thenReturn(mock(Path.class)); <END> when(this.pomService.load(any())).thenReturn(this.pom); this.validator = new CheckModulesValidator(this.pomService); }</code><technical_language>Optional nitpick: this-es unnecessary boilerplate distracting (for :P). leave in if preferred style.</technical_language>

Target:
public void setUp() { Path path = mock(Path.class); when(path.toURI()).thenReturn("/"); when(this.exampleProject.getRoot()).thenReturn(path); when(this.pomService.load(any())).thenReturn(this.pom); this.validator = new CheckModulesValidator(this.pomService); }
Source:
<code>protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { <START> response.sendRedirect(request.getContextPath() + SSOUtils.LOGIN_EXTERNAL_URI); <END> }</code><technical_language>this login I think... 1. redirect external 2. apache takes 3. user press escape 4. reach 5. present login redirect 1 loop</technical_language>

Target:
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.getRequestDispatcher("/WEB-INF/login.jsp").forward(request, response); }
Source:
<code>public void testZkBarrierForVersionUpgrade() { ScheduleAfterDebounceTime debounceTimer = new ScheduleAfterDebounceTime(); ZkBarrierForVersionUpgrade barrier = new ZkBarrierForVersionUpgrade(testZkUtils, debounceTimer); String ver = "1"; List<String> processors = new ArrayList<String>(); processors.add("p1"); processors.add("p2"); class Status { boolean p1 = false; boolean p2 = false; } final Status s = new Status(); <START> barrier.leaderStartBarrier(ver, processors); <END> barrier.waitForBarrier(ver, "p1", new Runnable() { @Override public void run() { s.p1 = true; } }); barrier.waitForBarrier(ver, "p2", new Runnable() { @Override public void run() { s.p2 = true; } }); Assert.assertTrue(TestZkUtils.testWithDelayBackOff(() -> s.p1 && s.p2, 2, 100)); }</code><technical_language>this name is changed yet</technical_language>

Target:
public void testZkBarrierForVersionUpgrade() { ScheduleAfterDebounceTime debounceTimer = new ScheduleAfterDebounceTime(); ZkBarrierForVersionUpgrade barrier = new ZkBarrierForVersionUpgrade(testZkUtils, debounceTimer); String ver = "1"; List<String> processors = new ArrayList<String>(); processors.add("p1"); processors.add("p2"); class Status { boolean p1 = false; boolean p2 = false; } final Status s = new Status(); barrier.startBarrier(ver, processors); barrier.waitForBarrier(ver, "p1", new Runnable() { @Override public void run() { s.p1 = true; } }); barrier.waitForBarrier(ver, "p2", new Runnable() { @Override public void run() { s.p2 = true; } }); Assert.assertTrue(TestZkUtils.testWithDelayBackOff(() -> s.p1 && s.p2, 2, 100)); }
Source:
<code>static void validateConnectionSpecificHeaders(Http2Headers headers, int streamId) throws Http2Exception { for (int i = 0; i < connectionSpecificHeaders.size(); i++) { final AsciiString header = connectionSpecificHeaders.get(i); if (headers.contains(header)) { throw streamError(streamId, PROTOCOL_ERROR, <START> "Connection-speficic headers like [%s] must not be used with HTTP/2.", header); <END> } } final CharSequence teHeader = headers.get(TE); if (teHeader != null && !AsciiString.contentEqualsIgnoreCase(teHeader, TRAILERS)) { throw streamError(streamId, PROTOCOL_ERROR, "TE header must not contain any value other than \"%s\"", TRAILERS); } }</code><technical_language>spelling: specific</technical_language>

Target:
static void validateConnectionSpecificHeaders(Http2Headers headers, int streamId) throws Http2Exception { for (int i = 0; i < connectionSpecificHeaders.size(); i++) { final AsciiString header = connectionSpecificHeaders.get(i); if (headers.contains(header)) { throw streamError(streamId, PROTOCOL_ERROR, "Connection-specific headers like [%s] must not be used with HTTP/2.", header); } } final CharSequence teHeader = headers.get(TE); if (teHeader != null && !AsciiString.contentEqualsIgnoreCase(teHeader, TRAILERS)) { throw streamError(streamId, PROTOCOL_ERROR, "TE header must not contain any value other than \"%s\"", TRAILERS); } }
Source:
<code>public Object[][] keys() { return new Object[][]{ {"*", 0x123456789abcdef0L, true}, {"any", 0x123456789abcdef0L, true}, {"Any", 0x123456789abcdef0L, true}, {"ANY", 0x123456789abcdef0L, true}, {"0x123456789abcdef0", 0x123456789abcdef0L, true}, {"0x123456789abcdef0,0x0fedcba987654321", 0x123456789abcdef0L, true}, {"0x123456789abcdef0, 0x0fedcba987654321", 0x123456789abcdef0L, true}, {"0x123456789abcdef0", 0x231456789abcdef0L, false}, <START> {"0x123456789abcdef0, 0x0fedcba987654321", 0x321456789abcdef0L, false}, <END> }; }</code><technical_language>comma required</technical_language>

Target:
public Object[][] keys() { return new Object[][]{ {"*", 0x123456789abcdef0L, true}, {"any", 0x123456789abcdef0L, true}, {"Any", 0x123456789abcdef0L, true}, {"ANY", 0x123456789abcdef0L, true}, {"0x123456789abcdef0", 0x123456789abcdef0L, true}, {"0x123456789abcdef0,0x0fedcba987654321", 0x123456789abcdef0L, true}, {"0x123456789abcdef0, 0x0fedcba987654321", 0x123456789abcdef0L, true}, {"0x123456789abcdef0", 0x231456789abcdef0L, false}, {"0x123456789abcdef0, 0x0fedcba987654321", 0x321456789abcdef0L, false} }; }
Source:
<code>public void trace(String s, Throwable t) { <START> delegate.trace(tag + s, t); <END> }</code><technical_language>want check if logging is enabled string concatenation for of methods</technical_language>

Target:
public void trace(String s, Throwable t) { if (delegate.isTraceEnabled()) { delegate.trace(tag + s, t); } }
Source:
<code>public Instance createInstance(Machine machine, LineConsumer lineConsumer) throws UnsupportedRecipeException, InvalidRecipeException, NotFoundException, MachineException { requireNonNull(machine, "Non null machine required"); <START> requireNonNull(lineConsumer, "Non null logs consumer required"); <END> if (machine.getConfig().isDev()) { throw new MachineException("Dev machine is not supported for Ssh machine implementation"); } Recipe recipe = recipeDownloader.getRecipe(machine.getConfig()); SshMachineRecipe sshMachineRecipe = GSON.fromJson(recipe.getScript(), SshMachineRecipe.class); SshClient sshClient = sshMachineFactory.createSshClient(sshMachineRecipe, machine.getConfig().getEnvVariables()); sshClient.start(); return sshMachineFactory.createInstance(machine, sshClient, lineConsumer); }</code><technical_language>Consider usage of source.getContent()</technical_language>

Target:
public Instance createInstance(Machine machine, LineConsumer lineConsumer) throws UnsupportedRecipeException, InvalidRecipeException, NotFoundException, MachineException { requireNonNull(machine, "Non null machine required"); requireNonNull(lineConsumer, "Non null logs consumer required"); requireNonNull(machine.getConfig().getSource().getLocation(), "Location in machine source is required"); if (machine.getConfig().isDev()) { throw new MachineException("Dev machine is not supported for Ssh machine implementation"); } Recipe recipe = recipeDownloader.getRecipe(machine.getConfig()); SshMachineRecipe sshMachineRecipe = GSON.fromJson(recipe.getScript(), SshMachineRecipe.class); SshClient sshClient = sshMachineFactory.createSshClient(sshMachineRecipe, machine.getConfig().getEnvVariables()); sshClient.start(); return sshMachineFactory.createInstance(machine, sshClient, lineConsumer); }
Source:
<code>private Set<PVariable> calculatePatternAdornmentForPlanner(Set<PParameter> boundParameters, PBody normalizedBody) { Set<PVariable> boundVariables = Sets.<PVariable> newHashSet(); for (PParameter parameter : boundParameters) { <START> boundVariables.add(normalizedBody.getVariableByNameChecked(parameter.getName())); <END> } return boundVariables; }</code><technical_language>This breaks previous functionality, introducing implicit dependency name of exported PVariable equals name of PParameter. This true for hand-generated queries PQuery API allows bind PVariables PParameters names ExportedParameter constraint. aggreed, improve ExportedParameter implementation provide a type-safe connection PParameters PVariables</technical_language>

Target:
private Set<PVariable> calculatePatternAdornmentForPlanner(Set<PParameter> boundParameters, PBody normalizedBody) { Map<PParameter, PVariable> parameterMapping = Maps.newHashMap(); for (ExportedParameter constraint : normalizedBody.getSymbolicParameters()) { parameterMapping.put(constraint.getPatternParameter(), constraint.getParameterVariable()); } Set<PVariable> boundVariables = Sets.newHashSet(); for (PParameter parameter : boundParameters) { boundVariables.add(parameterMapping.get(parameter)); } return boundVariables; }
Source:
<code>public void ArticleCRUDUser_003_addDropdown() { WikiBasePageObject base = new WikiBasePageObject(driver); String articleContent = PageContent.articleText; String articleTitle = PageContent.articleNamePrefix + base.getTimeStamp(); <START> ArticlePageObject article = base.openRandomArticleOnWiki(wikiURL); <END> VisualEditModePageObject visualEditMode = article.createArticleUsingDropdown(articleTitle); visualEditMode.addContent(articleContent); visualEditMode.submit(); article.compareContent(articleContent); article.compareTitle(articleTitle); }</code><technical_language>remove OnWiki</technical_language>

Target:
public void ArticleCRUDUser_003_addDropdown() { WikiBasePageObject base = new WikiBasePageObject(driver); String articleContent = PageContent.articleText; String articleTitle = PageContent.articleNamePrefix + base.getTimeStamp(); ArticlePageObject article = base.openRandomArticle(wikiURL); VisualEditModePageObject visualEditMode = article.createArticleUsingDropdown(articleTitle); visualEditMode.addContent(articleContent); visualEditMode.submit(); article.verifyContent(articleContent); article.verifyArticleTitle(articleTitle); }
Source:
<code><T> CompletableFuture<T> scheduleTimeout(CompletableFuture<T> future) { <START> Scheduled scheduled = context.schedule(Duration.ofMillis(100), () -> { <END> if (!future.isDone()) { future.completeExceptionally(new TimeoutException()); } }); return future.whenComplete((r, e) -> scheduled.cancel()); }</code><technical_language>response 100 ms results in timeout</technical_language>

Target:
<T> CompletableFuture<T> scheduleTimeout(CompletableFuture<T> future) { Scheduled scheduled = context.schedule(Duration.ofSeconds(1), () -> { if (!future.isDone()) { future.completeExceptionally(new TimeoutException()); } }); return future.whenComplete((r, e) -> scheduled.cancel()); }
Source:
<code>public void testToJavaWrongID() throws IOException { <START> mapper.readValue(JSON_ITEM_ID_VALUE_WRONG_ID, ValueImpl.class); <END> }</code><technical_language>I want this test return a UnsupportedEntityIdValue</technical_language>

Target:
public void testToJavaWrongID() throws IOException { Value unsupported = mapper.readValue(JSON_ITEM_ID_VALUE_WRONG_ID, ValueImpl.class); assertTrue(unsupported instanceof UnsupportedEntityIdValue); }
Source:
<code>private void setCurrentUnit(CourseComponent component){ this.selectedUnit = component; if ( this.selectedUnit == null ) return; environment.getDatabase().updateAccess(null, selectedUnit.getId(), true); CourseComponent parentSectionComponent = component.getParent().getParent(); String prefName = PrefManager.getPrefNameForLastAccessedBy(getProfile() .username, selectedUnit.getCourseId()); final PrefManager prefManager = new PrefManager(MainApplication.instance(), prefName); <START> prefManager.putLastAccessedSubsection(parentSectionComponent.getId(), false); <END> Intent resultData = new Intent(); resultData.putExtra(Router.EXTRA_COURSE_UNIT, selectedUnit); setResult(RESULT_OK, resultData); }</code><technical_language>If storing section (not subsection) accessed item, remove this implemented in CourseOutlineActivity. Note subsection is stored in some other areas well, removed and/or modified</technical_language>

Target:
private void setCurrentUnit(CourseComponent component){ this.selectedUnit = component; if ( this.selectedUnit == null ) return; environment.getDatabase().updateAccess(null, selectedUnit.getId(), true); String prefName = PrefManager.getPrefNameForLastAccessedBy(getProfile() .username, selectedUnit.getCourseId()); final PrefManager prefManager = new PrefManager(MainApplication.instance(), prefName); prefManager.putLastAccessedSubsection(this.selectedUnit.getId(), false); Intent resultData = new Intent(); resultData.putExtra(Router.EXTRA_COURSE_UNIT, selectedUnit); setResult(RESULT_OK, resultData); }
Source:
<code>private InMemoryNoteBucket mergeLeafBucket(int treeDepth, LeafBucket bb, LeafBucket ob, LeafBucket tb) throws MissingObjectException, IOException { bb = notNullOrEmpty(bb); ob = notNullOrEmpty(ob); tb = notNullOrEmpty(tb); InMemoryNoteBucket result = new LeafBucket(treeDepth * 2); int bi = 0, oi = 0, ti = 0; while (bi < bb.size() || oi < ob.size() || ti < tb.size()) { Note b = get(bb, bi), o = get(ob, oi), t = get(tb, ti); Note min = min(b, o, t); b = sameNoteOrNull(min, b); o = sameNoteOrNull(min, o); t = sameNoteOrNull(min, t); <START> if (sameNoteAndContent(o, t)) <END> result = addIfNotNull(result, o); else if (sameNoteAndContent(b, o)) result = addIfNotNull(result, t); else if (sameNoteAndContent(b, t)) result = addIfNotNull(result, o); else result = addIfNotNull(result, noteMerger.merge(b, o, t)); if (b != null) bi++; if (o != null) oi++; if (t != null) ti++; } return result; }</code><technical_language>note null checked sameNoteOrNull(). this instead sameContent() avoid comparing IDs</technical_language>

Target:
private InMemoryNoteBucket mergeLeafBucket(int treeDepth, LeafBucket bb, LeafBucket ob, LeafBucket tb) throws MissingObjectException, IOException { bb = notNullOrEmpty(bb); ob = notNullOrEmpty(ob); tb = notNullOrEmpty(tb); InMemoryNoteBucket result = new LeafBucket(treeDepth * 2); int bi = 0, oi = 0, ti = 0; while (bi < bb.size() || oi < ob.size() || ti < tb.size()) { Note b = get(bb, bi), o = get(ob, oi), t = get(tb, ti); Note min = min(b, o, t); b = sameNoteOrNull(min, b); o = sameNoteOrNull(min, o); t = sameNoteOrNull(min, t); if (sameContent(o, t)) result = addIfNotNull(result, o); else if (sameContent(b, o)) result = addIfNotNull(result, t); else if (sameContent(b, t)) result = addIfNotNull(result, o); else result = addIfNotNull(result, noteMerger.merge(b, o, t)); if (b != null) bi++; if (o != null) oi++; if (t != null) ti++; } return result; }
Source:
<code>private void header(@NonNull NewsCard card) { <START> headerView.setTitle(R.string.view_card_news_title) <END> .setLangCode(card.wikiSite().languageCode()) .setCard(card) .setCallback(getCallback()); }</code><technical_language>title respect card's language. Please #1585</technical_language>

Target:
private void header(@NonNull NewsCard card) { headerView.setTitle(card.title()) .setLangCode(card.wikiSite().languageCode()) .setCard(card); }
Source:
<code>private void putUpWebUI() throws IOException { if (zookeeperMode) { <START> LOG.info("WebUI is not supported in Zookeeper mode"); <END> } else if (regionServerMode) { LOG.info("WebUI is not supported in RegionServer mode"); } else { Configuration conf = new Configuration(); int port = conf.getInt(HBASE_CANARY_INFO_PORT, DEFAULT_CANARY_INFOPORT); if (port < 0) return; String addr = conf.get(HBASE_CANARY_INFO_BINDADDRESS, "0.0.0.0"); try { InfoServer infoServer = new InfoServer("canary", addr, port, false, conf); infoServer.addUnprivilegedServlet("canary", "/canary-status", CanaryStatusServlet.class); infoServer.setAttribute("sink", this.sink); infoServer.start(); LOG.info("Bind Canary http info server to port: " + port); } catch (BindException e) { LOG.warn("Failed binding Canary http info server to port: " + port, e); } } }</code><technical_language>nit: skip warnings (and function body) HBASE_CANARY_INFO_PORT == -1</technical_language>

Target:
private void putUpWebUI() throws IOException { int port = conf.getInt(HBASE_CANARY_INFO_PORT, DEFAULT_CANARY_INFOPORT); if (port < 0) { return; } if (zookeeperMode) { LOG.info("WebUI is not supported in Zookeeper mode"); } else if (regionServerMode) { LOG.info("WebUI is not supported in RegionServer mode"); } else { String addr = conf.get(HBASE_CANARY_INFO_BINDADDRESS, "0.0.0.0"); try { infoServer = new InfoServer("canary", addr, port, false, conf); infoServer.addUnprivilegedServlet("canary", "/canary-status", CanaryStatusServlet.class); infoServer.setAttribute("sink", this.sink); infoServer.start(); LOG.info("Bind Canary http info server to {}:{} ", addr, port); } catch (BindException e) { LOG.warn("Failed binding Canary http info server to {}:{}", addr, port, e); } } }
Source:
<code>public Object getAttribute(String s) throws IOException { <START> throw new UnsupportedOperationException("No FileStoreAttributeViews are currently supported."); <END> }</code><technical_language>suggestion throw new UnsupportedOperationException("FileStoreAttributeViews supported."); Indicating currently needed, more blunt exception message</technical_language>

Target:
public Object getAttribute(String s) throws IOException { throw new UnsupportedOperationException("FileStoreAttributeViews aren't supported."); }
Source:
<code>public static final byte[] toBytes(final InputRow row, AggregatorFactory[] aggs, boolean reportParseExceptions) { try { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeLong(row.getTimestampFromEpoch()); List<String> dimList = row.getDimensions(); WritableUtils.writeVInt(out, dimList.size()); if (dimList != null) { for (String dim : dimList) { List<String> dimValues = row.getDimension(dim); writeString(dim, out); writeStringArray(dimValues, out); } } Supplier<InputRow> supplier = new Supplier<InputRow>() { @Override public InputRow get() { return row; } }; WritableUtils.writeVInt(out, aggs.length); for (AggregatorFactory aggFactory : aggs) { String k = aggFactory.getName(); writeString(k, out); Aggregator agg = aggFactory.factorize( IncrementalIndex.makeColumnSelectorFactory( aggFactory, supplier, true ) ); try { agg.aggregate(); } catch (ParseException e) { if (reportParseExceptions) { throw new ParseException(e, "Encountered parse error for aggregator[%s]", agg.getName()); <START> } else { <END> log.debug(e, "Encountered parse error, skipping aggregator[%s].", agg.getName()); } } String t = aggFactory.getTypeName(); if (t.equals("float")) { out.writeFloat(agg.getFloat()); } else if (t.equals("long")) { WritableUtils.writeVLong(out, agg.getLong()); } else { Object val = agg.get(); ComplexMetricSerde serde = getComplexMetricSerde(t); writeBytes(serde.toBytes(val), out); } } return out.toByteArray(); } catch(IOException ex) { throw Throwables.propagate(ex); } }</code><technical_language>able get rid of nesting of else</technical_language>

Target:
public static final byte[] toBytes(final InputRow row, AggregatorFactory[] aggs, boolean reportParseExceptions) { try { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeLong(row.getTimestampFromEpoch()); List<String> dimList = row.getDimensions(); WritableUtils.writeVInt(out, dimList.size()); if (dimList != null) { for (String dim : dimList) { List<String> dimValues = row.getDimension(dim); writeString(dim, out); writeStringArray(dimValues, out); } } Supplier<InputRow> supplier = new Supplier<InputRow>() { @Override public InputRow get() { return row; } }; WritableUtils.writeVInt(out, aggs.length); for (AggregatorFactory aggFactory : aggs) { String k = aggFactory.getName(); writeString(k, out); Aggregator agg = aggFactory.factorize( IncrementalIndex.makeColumnSelectorFactory( aggFactory, supplier, true ) ); try { agg.aggregate(); } catch (ParseException e) { if (reportParseExceptions) { throw new ParseException(e, "Encountered parse error for aggregator[%s]", agg.getName()); } log.debug(e, "Encountered parse error, skipping aggregator[%s].", agg.getName()); } String t = aggFactory.getTypeName(); if (t.equals("float")) { out.writeFloat(agg.getFloat()); } else if (t.equals("long")) { WritableUtils.writeVLong(out, agg.getLong()); } else { Object val = agg.get(); ComplexMetricSerde serde = getComplexMetricSerde(t); writeBytes(serde.toBytes(val), out); } } return out.toByteArray(); } catch(IOException ex) { throw Throwables.propagate(ex); } }
Source:
<code>public boolean hasNext() { if ( next == RelationshipSelections.UNINITIALIZED ) { <START> this.next(); <END> next = relationshipCursor.relationshipReference(); } if ( next == RelationshipSelections.NO_ID ) { close(); return false; } return true; }</code><technical_language>This infinite loop me</technical_language>

Target:
public boolean hasNext() { if ( next == RelationshipSelections.UNINITIALIZED ) { fetchNext(); next = relationshipCursor.relationshipReference(); } if ( next == RelationshipSelections.NO_ID ) { close(); return false; } return true; }
Source:
<code>public Object unmarshal(Exchange exchange, InputStream stream) throws Exception { if (usingIterator) { if (clazzName != null || clazz != null) { if (clazz != null && clazz.getName() != null) { clazzName = clazz.getName(); } clazz = exchange.getContext().getClassResolver().resolveMandatoryClass(clazzName); ASN1GenericIterator asn1GenericIterator = new ASN1GenericIterator(clazz, stream); return asn1GenericIterator; } ASN1MessageIterator asn1MessageIterator = new ASN1MessageIterator(exchange, stream); return asn1MessageIterator; } else { <START> ASN1InputStream ais = new ASN1InputStream(stream); <END> ASN1Primitive asn1Record = null; ByteArrayOutputStream asn1Out = null; try { asn1Out = new ByteArrayOutputStream(); while (ais.available() > 0) { asn1Record = ais.readObject(); asn1Out.write(asn1Record.getEncoded()); } } finally { if (asn1Out != null) { asn1Out.close(); } if (ais != null) { ais.close(); } } return asn1Out.toByteArray(); } }</code><technical_language>a quick read. I able save lines a try-with-resource statement for ASN1InputStream ByteArrayOutputStream</technical_language>

Target:
public Object unmarshal(Exchange exchange, InputStream stream) throws Exception { if (usingIterator) { if (clazzName != null) { Class<?> clazz = exchange.getContext().getClassResolver().resolveMandatoryClass(clazzName); ASN1GenericIterator asn1GenericIterator = new ASN1GenericIterator(clazz, stream); return asn1GenericIterator; } ASN1MessageIterator asn1MessageIterator = new ASN1MessageIterator(exchange, stream); return asn1MessageIterator; } else { ASN1Primitive asn1Record = null; byte[] asn1Bytes; try (ASN1InputStream ais = new ASN1InputStream(stream); ByteArrayOutputStream asn1Out = new ByteArrayOutputStream();) { while (ais.available() > 0) { asn1Record = ais.readObject(); asn1Out.write(asn1Record.getEncoded()); } asn1Bytes = asn1Out.toByteArray(); } return asn1Bytes; } }
Source:
<code>public ApplicationContext connect(Map<String, String> parameters) throws ConnectionException { AoSession aoSession = null; try (ServiceLocator serviceLocator = new ServiceLocator(orb, getParameter(parameters, PARAM_NAMESERVICE))) { String nameOfService = getParameter(parameters, PARAM_SERVICENAME).replace(".ASAM-ODS", ""); AoFactory aoFactory = serviceLocator.resolveFactory(nameOfService); LOGGER.info("Connecting to ODS Server ..."); LOGGER.info("AoFactory name: {}", aoFactory.getName()); LOGGER.info("AoFactory description: {}", aoFactory.getDescription()); LOGGER.info("AoFactory interface version: {}", aoFactory.getInterfaceVersion()); LOGGER.info("AoFactory type: {}", aoFactory.getType()); aoSession = aoFactory.newSession(String.format(AUTH_TEMPLATE, getParameter(parameters, PARAM_USER), getParameter(parameters, PARAM_PASSWORD))); LOGGER.info("Connection to ODS server established."); CORBAFileServerIF fileServer = serviceLocator.resolveFileServer(nameOfService); return new ODSContext(orb, aoSession, fileServer, parameters); } catch (AoException e) { closeSession(aoSession); throw new <START> ConnectionException("Unablte to <END> connect to ODS server due to: " + e.reason, e); } }</code><technical_language>Typo: Unable</technical_language>

Target:
public ApplicationContext connect(Map<String, String> parameters) throws ConnectionException { AoSession aoSession = null; try (ServiceLocator serviceLocator = new ServiceLocator(orb, getParameter(parameters, PARAM_NAMESERVICE))) { String nameOfService = getParameter(parameters, PARAM_SERVICENAME).replace(".ASAM-ODS", ""); AoFactory aoFactory = serviceLocator.resolveFactory(nameOfService); LOGGER.info("Connecting to ODS Server ..."); LOGGER.info("AoFactory name: {}", aoFactory.getName()); LOGGER.info("AoFactory description: {}", aoFactory.getDescription()); LOGGER.info("AoFactory interface version: {}", aoFactory.getInterfaceVersion()); LOGGER.info("AoFactory type: {}", aoFactory.getType()); aoSession = aoFactory.newSession(String.format(AUTH_TEMPLATE, getParameter(parameters, PARAM_USER), getParameter(parameters, PARAM_PASSWORD))); LOGGER.info("Connection to ODS server established."); CORBAFileServerIF fileServer = serviceLocator.resolveFileServer(nameOfService); return new ODSContext(orb, aoSession, fileServer, parameters); } catch (AoException e) { closeSession(aoSession); throw new ConnectionException("Unable to connect to ODS server due to: " + e.reason, e); } }
Source:
<code>public String translatePath(String path) { String translated; if (path.startsWith("~" + File.separator)) { translated = System.getProperty("user.home") + path.substring(1); <START> } else if (path.startsWith("~") && !Util.isWindows()) { END> String userName = path.substring(1); translated = new File(new File(System.getProperty("user.home")).getParent(), userName).getAbsolutePath(); translated = userName.isEmpty() || path.endsWith(File.separator) ? translated + File.separator : translated; } else if (!new File(path).isAbsolute()) { translated = ctx.getCurrentDir().getAbsolutePath() + File.separator + path; } else { translated = path; } return translated; }</code><technical_language>this valid shells Windows seek provide *nix-like behavior? years I windows cygwin, I know. OTOH, code dropped ~ takes work Windows. question: if path.startsWith("~") Windows, else cases want</technical_language>

Target:
public String translatePath(String path) { String translated; if (path.startsWith("~" + File.separator)) { translated = System.getProperty("user.home") + path.substring(1); } else if (path.startsWith("~")) { String userName = path.substring(1); translated = new File(new File(System.getProperty("user.home")).getParent(), userName).getAbsolutePath(); translated = userName.isEmpty() || path.endsWith(File.separator) ? translated + File.separator : translated; } else if (!new File(path).isAbsolute()) { translated = ctx.getCurrentDir().getAbsolutePath() + File.separator + path; } else { translated = path; } return translated; }
Source:
<code>public Extension getExtensionInstance(Class<? extends Extension> extensionClass) { if(extensionClass.equals(LockingSupport.class)) return new MongoLockingSupport(this); else <START> return null; <END> }</code><technical_language>throw exception, log a warning</technical_language>

Target:
public <E extends Extension> E getExtensionInstance(Class<? extends Extension> extensionClass) { if(extensionClass.equals(LockingSupport.class)) return (E)new MongoLockingSupport(this); else return null; }
Source:
<code>public boolean configure(StaplerRequest req, JSONObject json) throws FormException { Jenkins j = Jenkins.getInstance(); if (json.has("primaryView")) { final String viewName = json.getString("primaryView"); final View newPrimaryView = j.getView(viewName); if (newPrimaryView == null) { <START> throw new FormException("The specified primary view does not exist: " + viewName, "primaryView"); <END> } j.setPrimaryView(newPrimaryView); } else { j.setPrimaryView(j.getViews().iterator().next()); } return true; }</code><technical_language>Shown UI i18n aware</technical_language>

Target:
public boolean configure(StaplerRequest req, JSONObject json) throws FormException { Jenkins j = Jenkins.getInstance(); if (json.has("primaryView")) { final String viewName = json.getString("primaryView"); final View newPrimaryView = j.getView(viewName); if (newPrimaryView == null) { throw new FormException(Messages.GlobalDefaultViewConfiguration_ViewDoesNotExist(viewName), "primaryView"); } j.setPrimaryView(newPrimaryView); } else { j.setPrimaryView(j.getViews().iterator().next()); } return true; }
Source:
<code>public boolean validateTopologySettingInInstanceConfig(ClusterConfig clusterConfig, <START> String instanceName) throws IllegalArgumentException{ <END> Topology.computeInstanceTopologyMap(clusterConfig, instanceName, this, false ); return true; }</code><technical_language>runtime exception is recommended put in method signature. in java doc is good enough</technical_language>

Target:
public boolean validateTopologySettingInInstanceConfig(ClusterConfig clusterConfig, String instanceName) { Topology.computeInstanceTopologyMap(clusterConfig, instanceName, this, false ); return true; }
Source:
<code>protected File getReportsDirectory(MavenProject pom, MojoInfo mojo) throws ComponentConfigurationException { String reportsDirectoryOverride = getReportsDirectoryOverride(mojo); <START> if (reportsDirectoryOverride != null) <END> return mojo.expressionEvaluator.alignToBaseDirectory(new File(reportsDirectoryOverride)); if (this.reportDirectoryConfigKey != null) { File reportsDir = mojo.getConfigurationValue(this.reportDirectoryConfigKey, File.class); if (reportsDir != null) return reportsDir; } return new File(pom.getBuild().getDirectory(), "surefire-reports"); }</code><technical_language>Tabs instead of spaces</technical_language>

Target:
@Nonnull protected File getReportsDirectory(MavenProject pom, MojoInfo mojo) throws ComponentConfigurationException { String reportsDirectoryOverride = getReportsDirectoryOverride(mojo); if (reportsDirectoryOverride != null) return mojo.expressionEvaluator.alignToBaseDirectory(new File(reportsDirectoryOverride)); if (this.reportDirectoryConfigKey != null) { File reportsDir = mojo.getConfigurationValue(this.reportDirectoryConfigKey, File.class); if (reportsDir != null) return reportsDir; } return new File(pom.getBuild().getDirectory(), "surefire-reports"); }
Source:
<code><START> private static String createDescription(Object args) { <END> if (args instanceof Collection) { return Arrays.toString(((Collection) args).toArray()); } return ObjectUtils.toString(args); }</code><technical_language>is args nullable</technical_language>

Target:
private static String createDescription(Object args) { if (args instanceof Collection) { return Arrays.toString(((Collection) args).toArray()); } if (args instanceof SerializableVoid) { return ""; } return ObjectUtils.toString(args); }
Source:
<code>public Object get(String column) { if ( column.contains( "." ) ) { <START> String[] fields = column.split( "\\." ); <END> return this.getObject( this.dbObject.toMap(), fields ); } else { return this.dbObject.get( column ); } }</code><technical_language>_split_ is compile a regular expression. extract regular expression in a constant, reuse</technical_language>

Target:
public Object get(String column) { if ( column.contains( "." ) ) { String[] fields = column.split( EMBEDDED_FIELDNAME_SEPARATOR ); return this.getObject( this.dbObject.toMap(), fields, 0 ); } else { return this.dbObject.get( column ); } }
Source:
<code>public static <INPUT, OUTPUT> List<Callable<Collection<OUTPUT>>> partitionWork(Collection<INPUT> work, PartitionFactory<INPUT, OUTPUT> factory) throws Exception { List<Callable<Collection<OUTPUT>>> callables = new LinkedList<Callable<Collection<OUTPUT>>>(); if (!work.isEmpty()) { int partitionSize = Math.max(1, work.size() / partitions); List<INPUT> workList = new LinkedList<INPUT>(work); <START> List<List<INPUT>> partitioned = Lists.partition(workList, partitionSize); <END> for (List<INPUT> partition : partitioned) { Callable<Collection<OUTPUT>> worker = factory.createWorker(partition); callables.add(worker); } } return callables; }</code><technical_language>Change Iterables.partition return Iterable</technical_language>

Target:
public static <INPUT, OUTPUT> List<Callable<Collection<OUTPUT>>> partitionWork(Collection<INPUT> work, PartitionFactory<INPUT, OUTPUT> factory) throws Exception { List<Callable<Collection<OUTPUT>>> callables = new LinkedList<Callable<Collection<OUTPUT>>>(); if (!work.isEmpty()) { int partitionSize = Math.max(1, work.size() / partitions); List<INPUT> subList = new LinkedList<INPUT>(); int index = 0; Iterator<INPUT> iterator = work.iterator(); while (iterator.hasNext()) { subList.add(iterator.next()); if (index != 0 && partitionSize != 0 && (index % partitionSize == 0)) { Callable<Collection<OUTPUT>> worker = factory.createWorker(subList); callables.add(worker); subList = new LinkedList<INPUT>(); } index++; } if (!subList.isEmpty()) { Callable<Collection<OUTPUT>> worker = factory.createWorker(subList); callables.add(worker); } } return callables; }
Source:
<code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); imageViewContact = (ImageView) findViewById(R.id.image_contact); imageViewLookup = (ImageView) findViewById(R.id.image_lookup); imageViewPhoto = (ImageView) findViewById(R.id.image_photo); imageViewDisplayPhoto = (ImageView) findViewById(R.id.image_display_photo); numberEntry = (EditText) findViewById(R.id.number_entry); if (ContextCompat.checkSelfPermission(this.getApplication(), Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_CONTACTS}, READ_CONTACTS); } findViewById(R.id.button_pick_contact).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI); startActivityForResult(intent, REQUEST_CONTACT); } }); findViewById(R.id.button_find).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(numberEntry.getText().toString())); GlideRequests glideRequests = GlideApp.with(MainActivity.this); RequestOptions originalSize = new RequestOptions().override(Target.SIZE_ORIGINAL); <START> glideRequests.load(uri).apply(originalSize).into(imageViewLookup); <END> } }); }</code><technical_language>inline this: GlideApp.with(MainActivity.this) .load(uri) .override(Target.SIZE_ORIGINAL) .into(imageView);</technical_language>

Target:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); imageViewContact = (ImageView) findViewById(R.id.image_contact); imageViewLookup = (ImageView) findViewById(R.id.image_lookup); imageViewPhoto = (ImageView) findViewById(R.id.image_photo); imageViewDisplayPhoto = (ImageView) findViewById(R.id.image_display_photo); numberEntry = (EditText) findViewById(R.id.number_entry); if (ContextCompat.checkSelfPermission( getApplication(), Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_CONTACTS}, READ_CONTACTS); } findViewById(R.id.button_pick_contact).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI); startActivityForResult(intent, REQUEST_CONTACT); } }); findViewById(R.id.button_find).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(numberEntry.getText().toString())); GlideApp.with(MainActivity.this) .load(uri) .override(Target.SIZE_ORIGINAL) .into(imageViewLookup); } }); }
Source:
<code>private boolean validatePage() { if <START> (dcc.getDirectory() == null || dcc.getDirectory().equals("")) { <END> setErrorMessage("Destination not selected!"); return false; } if(0 == systemTree.getCheckedElements().length){ setErrorMessage("Nothing selected for FMU generation!"); return false; } if (!isSomeLibrarySelected()){ setErrorMessage("No libraries selected to include"); return false; } setErrorMessage(null); return true; }</code><technical_language>switching "".eqauls(dcc.getDirectory()) need null check</technical_language>

Target:
private boolean validatePage() { if ("".equals(dcc.getDirectory())){ setErrorMessage("Destination not selected!"); return false; } if(0 == systemTree.getCheckedElements().length){ setErrorMessage("Nothing selected for FMU generation!"); return false; } if (!isSomeLibrarySelected()){ setErrorMessage("No libraries selected to include"); return false; } setErrorMessage(null); return true; }
Source:
<code>public void applyEnrichmentTag_NotHandledTagType() { when(enrichmentTag.getTagType()).thenReturn("ABC"); defaultEnrichmentTagApplier.applyEnrichmentTag(judgment, enrichmentTag); <START> verifyZeroInteractions(enrichmentTagValueConverter, jsonStringParser, judgmentUpdater); <END> }</code><technical_language>I understand verify in cases in this class expect a exception. Execution of this test reach this line</technical_language>

Target:
public void applyEnrichmentTag_NotHandledTagType() { when(enrichmentTag.getTagType()).thenReturn("ABC"); catchException(defaultEnrichmentTagApplier).applyEnrichmentTag(judgment, enrichmentTag); assertTrue(caughtException() instanceof IllegalArgumentException); verifyZeroInteractions(enrichmentTagValueConverter, jsonStringParser, judgmentUpdater); }
Source:
<code>public void testPrepareSolution() throws IOException { System.out.println("prepareSolution"); File originProject = new File("src/test/resources/arith_funcs/"); File targetFolder = createTemporaryCopyOf(originProject); ExerciseBuilder instance = new ExerciseBuilder(); instance.prepareSolution(targetFolder.toPath()); File expectedFolder = new File("src/test/resources/arith_funcs_solution/src"); File outputFolder = new File(targetFolder.getAbsolutePath() + "/src"); Map<String, File> expectedFiles = getFileMap(expectedFolder); Map<String, File> actualFiles = getFileMap(outputFolder); for(String fileName : expectedFiles.keySet()) { File expected = expectedFiles.get(fileName); File actual = actualFiles.get(fileName); List<String> expectedLines = FileUtils.readLines(expected); List<String> actualLines = FileUtils.readLines(actual); for (int i = 0 ; i < expectedLines.size() ; ++i) { String expectedLine = expectedLines.get(i); String actualLine = actualLines.get(i); assertEquals("Line in file " + fileName + " did not match ", expectedLine, actualLine); } <START> } <END> }</code><technical_language>This directory comparison logic is repeated. Factor out a helper method</technical_language>

Target:
public void testPrepareSolution() throws IOException { File originProject = new File("src/test/resources/arith_funcs/"); File targetFolder = createTemporaryCopyOf(originProject); ExerciseBuilder instance = new ExerciseBuilder(); instance.prepareSolution(targetFolder.toPath()); File expectedFolder = new File("src/test/resources/arith_funcs_solution/src"); File outputFolder = new File(targetFolder.getAbsolutePath() + "/src"); assertFileLines(expectedFolder, outputFolder); }
Source:
<code>public void testNoUriUnsubscribeOutput() throws Exception { <START> StoredConfig dbconfig = db.getConfig(); <END> RemoteConfig remoteConfig = new RemoteConfig(dbconfig, "origin"); remoteConfig.setTimeout(0); remoteConfig.update(dbconfig); dbconfig.save(); String[] output = execute("git unsubscribe origin"); assertArrayEquals("expected unsuccessful unsubscribe", new String[] { MessageFormat.format( CLIText.get().noRemoteUriUnsubscribe, "origin"), "" }, output); }</code><technical_language>this section is copied in tests, sense factor out a helper method</technical_language>

Target:
public void testNoUriUnsubscribeOutput() throws Exception { setupEmptyConfig(); try { execute("git unsubscribe origin"); } catch (Exception e) { assertEquals(MessageFormat.format( CLIText.get().noRemoteUriUnsubscribe, "origin"), e.getMessage()); return; } fail("Should have died"); }