auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public String deleteFieldVariable(String fieldVarId) throws DotDataException, DotSecurityException, DotRuntimeException, PortalException, SystemException { WebContext ctx = WebContextFactory.get(); HttpServletRequest req = ctx.getHttpServletRequest(); UserWebAPI userWebAPI = WebAPILocator.getUserWebAPI(); User user = userWebAPI.getLoggedInUser(req); boolean respectFrontendRoles = userWebAPI.isLoggedToFrontend(req); FieldAPI fieldAPI = APILocator.getFieldAPI(); FieldVariable fieldVar = fieldAPI.findFieldVariable(fieldVarId, user, respectFrontendRoles); fieldAPI.deleteFieldVariable(fieldVar, user, respectFrontendRoles); Field field = APILocator.getContentTypeFieldAPI().find(fieldVar.getFieldId()); ContentTypeAPI tapi = APILocator.getContentTypeAPI(user); ContentType type = tapi.find(field.contentTypeId()); tapi.updateModDate(type); return LanguageUtil.get(user, "message.fieldvariables.deleted"); }

Target:
public String deleteFieldVariable(String fieldVarId) throws DotDataException, DotSecurityException, DotRuntimeException, PortalException, SystemException { WebContext ctx = WebContextFactory.get(); HttpServletRequest req = ctx.getHttpServletRequest(); UserWebAPI userWebAPI = WebAPILocator.getUserWebAPI(); User user = userWebAPI.getLoggedInUser(req); boolean respectFrontendRoles = userWebAPI.isLoggedToFrontend(req); FieldAPI fieldAPI = APILocator.getFieldAPI(); FieldVariable fieldVar = fieldAPI.findFieldVariable(fieldVarId, user, respectFrontendRoles); fieldAPI.deleteFieldVariable(fieldVar, user, respectFrontendRoles); Field field = APILocator.getContentTypeFieldAPI().find(fieldVar.getFieldId()); ContentTypeAPI contentTypeAPI = APILocator.getContentTypeAPI(user); ContentType type = contentTypeAPI.find(field.contentTypeId()); contentTypeAPI.updateModDate(type); return LanguageUtil.get(user, "message.fieldvariables.deleted"); }
Source:
public void drawScreen(int par1, int par2, float par3) { drawDefaultBackground(); super.drawScreen(par1, par2, par3); int butHeight = 20; String txt = "Select Connection to Adjust"; int x = width / 2 - (Minecraft.getMinecraft().fontRendererObj.getStringWidth(txt) / 2); int y = height / 2 - butHeight * 3 - 5; drawString(Minecraft.getMinecraft().fontRendererObj, txt, x, y, ColorUtil.getARGB(Color.white)); for (int i = 0; i < 6; i++) { String blockName = adjacentBlockNames[i]; if (blockName == null) { continue; } int textWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(blockName); drawString(Minecraft.getMinecraft().fontRendererObj, blockName, textPositions[i].x + 60 / 2 - textWidth / 2, textPositions[i].y, ColorUtil.getARGB(Color.gray)); } if (Minecraft.getMinecraft().thePlayer.getName().contains("direwolf20") && ((EnderIO.proxy.getTickCount() / 16) & 1) == 1) { txt = "You can also right-click the connector directly"; x = width / 2 - (Minecraft.getMinecraft().fontRendererObj.getStringWidth(txt) / 2); y = height / 2 + butHeight * 3 - 5; drawString(Minecraft.getMinecraft().fontRendererObj, txt, x, y, ColorUtil.getARGB(Color.white)); } }

Target:
public void drawScreen(int par1, int par2, float par3) { drawDefaultBackground(); for (EnumFacing dir : EnumFacing.VALUES) { String blockName = adjacentBlockNames.get(dir); if (blockName == null) { continue; } int textWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(blockName); Point p = textPositions.get(dir); drawString(Minecraft.getMinecraft().fontRendererObj, blockName, p.x + 60 / 2 - textWidth / 2, p.y, ColorUtil.getARGB(Color.gray)); } super.drawScreen(par1, par2, par3); int butHeight = 20; String txt = "Select Connection to Adjust"; int x = width / 2 - (Minecraft.getMinecraft().fontRendererObj.getStringWidth(txt) / 2); int y = height / 2 - butHeight * 3 - 5; drawString(Minecraft.getMinecraft().fontRendererObj, txt, x, y, ColorUtil.getARGB(Color.white)); if (Minecraft.getMinecraft().thePlayer.getName().contains("direwolf20") && ((EnderIO.proxy.getTickCount() / 16) & 1) == 1) { txt = "You can also right-click the connector directly"; x = width / 2 - (Minecraft.getMinecraft().fontRendererObj.getStringWidth(txt) / 2); y = height / 2 + butHeight * 3 - 5; drawString(Minecraft.getMinecraft().fontRendererObj, txt, x, y, ColorUtil.getARGB(Color.white)); } }
Source:
public RingBitSet(int bitSetSize, RingBitSet sourceSet) { this(bitSetSize); int targetLength = Integer.min(bitSetSize, sourceSet.length); int sourceIndex = sourceSet.index; for (int i = 0; i < targetLength; i++) { this.setNextBit(sourceSet.bitSet.get(sourceIndex)); sourceIndex = (sourceIndex + 1) % sourceSet.size; } }

Target:
public RingBitSet(int bitSetSize, RingBitSet sourceSet) { this(bitSetSize); int targetLength = Integer.min(bitSetSize, sourceSet.length); int sourceIndex = sourceSet.index; int forwardIndex = sourceSet.size - sourceIndex; for (int i = 0; i < targetLength; i++) { this.setNextBit(sourceSet.bitSet.get(sourceIndex)); forwardIndex = (forwardIndex + 1) % sourceSet.size; sourceIndex = (sourceSet.size - forwardIndex) % sourceSet.size; } }
Source:
public static void checkBlackPearlForTapeFailure(final Ds3Client client) throws IOException, SignatureException, TapeFailureException { final Iterable<TapeFailure> tapeFailures = client.getTapeFailure(new GetTapeFailureRequest()).getTapeFailures(); if (tapeFailures != null && !Iterables.isEmpty(tapeFailures)) { throw new TapeFailureException(tapeFailures.iterator()); } }

Target:
public static void checkBlackPearlForTapeFailure(final Ds3Client client) throws IOException, SignatureException, CommandException { final Iterable<TapeFailure> tapeFailures = client.getTapeFailure(new GetTapeFailureRequest()).getTapeFailures(); if (tapeFailures != null && !Iterables.isEmpty(tapeFailures)) { throw new CommandException(new TapeFailureException(tapeFailures.iterator())); } }
Source:
protected ToggleButton convertToToggleButton(EngineCategoryDTO category) { final ToggleButton categoryButton = createSidebarToggleButton(category.getName()); categoryButton.setId(String.format("%s-button", category.getName().toLowerCase().replace('.', '-'))); categoryButton.setOnAction(event -> getControl().setSelectedElement(category)); return categoryButton; }

Target:
protected ToggleButton convertToToggleButton(EngineCategoryDTO category) { final ToggleButton categoryButton = createSidebarToggleButton(category.getName()); categoryButton .setId(String.format("engines-%s", SidebarToggleGroupBaseSkin.getToggleButtonId(category.getName()))); categoryButton.setOnAction(event -> getControl().setSelectedElement(category)); return categoryButton; }
Source:
public List<Command> receive(final Command command) { LOG.trace("Received command of type {}", command.getClass().getSimpleName()); List<Command> response = new LinkedList(); if (!(command instanceof SignalCommand)) { for (DolphinServerAction it : dolphinServerActions) { it.setDolphinResponse(response); } serverModelStore.setCurrentResponse(response); } List<CommandHandler> actions = registry.getActionsFor(command.getClass()); if (actions.isEmpty()) { LOG.debug("There is no server action registered for received command type {}, known commands types are {}", command.getClass().getSimpleName(), registry.getActions().keySet()); return response; } List<CommandHandler> actionsCopy = new ArrayList<CommandHandler>(); actionsCopy.addAll(actions); try { for (CommandHandler action : actionsCopy) { action.handleCommand(command, response); } } catch (Exception exception) { throw exception; } return response; }

Target:
public List<Command> receive(final Command command) { LOG.trace("Received command of type {}", command.getClass().getSimpleName()); List<Command> response = new LinkedList(); if (!(command instanceof SignalCommand)) { for (DolphinServerAction it : dolphinServerActions) { it.setDolphinResponse(response); } serverModelStore.setCurrentResponse(response); } List<CommandHandler> actions = registry.getActionsFor(command.getClass()); if (actions.isEmpty()) { LOG.warn("There is no server action registered for received command type {}, known commands types are {}", command.getClass().getSimpleName(), registry.getActions().keySet()); return response; } List<CommandHandler> actionsCopy = new ArrayList<CommandHandler>(); actionsCopy.addAll(actions); try { for (CommandHandler action : actionsCopy) { action.handleCommand(command, response); } } catch (Exception exception) { throw exception; } return response; }
Source:
public void testAddingFlag() { assertTrue(containsFlag( new Toggled(Notification.DEFAULT_SOUND, true, new NoSignal()).value(), Notification.DEFAULT_SOUND)); assertFalse(containsFlag( new Toggled(Notification.DEFAULT_SOUND, false, new NoSignal()).value(), Notification.DEFAULT_SOUND)); }

Target:
public void testAddingFlag() { assertThat(new Toggled(Notification.DEFAULT_SOUND, true, new NoSignal()).value(), is(new NoSignal().value() | Notification.DEFAULT_SOUND)); assertThat(new Toggled(Notification.DEFAULT_SOUND, false, new NoSignal()).value(), is(new NoSignal().value())); }
Source:
public void getClassNameWithoutPackage() { FactIdentifier factIdentifier = DESCRIPTION; assertEquals(factIdentifier.getClassNameWithoutPackage(), String.class.getSimpleName()); }

Target:
public void getClassNameWithoutPackage() { FactIdentifier factIdentifier = new FactIdentifier("test", "com.Test"); assertEquals(factIdentifier.getClassNameWithoutPackage(), "Test"); }
Source:
public UploadModule getModule() { if (this.module == null) { this.module = new UploadModule(); } return this.module; }

Target:
public synchronized UploadModule getModule() { if (this.module == null) { return new UploadModule(); } return this.module; }
Source:
public void updateTransactions(Account account, Urllib urlopen) throws LoginException, BankException, IOException { super.updateTransactions(account, urlopen); Matcher matcher; String response = urlopen.open( "<LINK_0>"); matcher = reTransactions.matcher(response); ArrayList<Transaction> transactions = new ArrayList<Transaction>(); while (matcher.find()) { transactions.add(new Transaction(matcher.group(1), Html.fromHtml(matcher.group(2).trim()).toString(), Helpers.parseBalance(matcher.group(3)))); } account.setTransactions(transactions); }

Target:
public void updateTransactions(Account account, Urllib urlopen) throws LoginException, BankException, IOException { super.updateTransactions(account, urlopen); Matcher matcher; String response = urlopen.open(URL_TRANSACTIONS); matcher = reTransactions.matcher(response); ArrayList<Transaction> transactions = new ArrayList<Transaction>(); while (matcher.find()) { transactions.add(new Transaction(matcher.group(1), Html.fromHtml(matcher.group(2).trim()).toString(), Helpers.parseBalance(matcher.group(3)))); } account.setTransactions(transactions); }
Source:
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CASE_CREATED_REQUEST_CODE) { if (resultCode == RESULT_OK && caseCreatedListener != null) { caseCreatedListener.onCaseCreated((Case) data.getSerializableExtra(EXTRA_DESK_CASE)); } } }

Target:
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CASE_CREATED_REQUEST_CODE) { if (resultCode == RESULT_OK && caseCreatedListener != null) { caseCreatedListener.onCaseCreated((Case) data.getSerializableExtra(EXTRA_DESK_CASE)); } } super.onActivityResult(requestCode, resultCode, data); }
Source:
public void notifyEventTriggered(@NonNull final IEvent event) { sharedLogger.d(event.getTrackingKey() + " event triggered"); totalEventCountRulesManager.notifyEventTriggered(event); firstEventTimeRulesManager.notifyEventTriggered(event); lastEventTimeRulesManager.notifyEventTriggered(event); lastEventVersionCodeRulesManager.notifyEventTriggered(event); lastEventVersionNameRulesManager.notifyEventTriggered(event); if (event == USER_GAVE_POSITIVE_FEEDBACK) { final Activity activity = activityReferenceManager.getValidatedActivity(); if (activity != null) { for (final IFeedbackCollector positiveFeedbackCollector : positiveFeedbackCollectors) { final boolean feedbackCollected = positiveFeedbackCollector.collectFeedback(activity); if (feedbackCollected) { return; } } } } else if (event == USER_GAVE_CRITICAL_FEEDBACK) { final Activity activity = activityReferenceManager.getValidatedActivity(); if (activity != null) { for (final IFeedbackCollector criticalFeedbackCollector : criticalFeedbackCollectors) { final boolean feedbackCollected = criticalFeedbackCollector.collectFeedback(activity); if (feedbackCollected) { return; } } } } }

Target:
public void notifyEventTriggered(@NonNull final IEvent event) { sharedLogger.d(event.getTrackingKey() + " event triggered"); totalEventCountRulesManager.notifyEventTriggered(event); firstEventTimeRulesManager.notifyEventTriggered(event); lastEventTimeRulesManager.notifyEventTriggered(event); lastEventVersionCodeRulesManager.notifyEventTriggered(event); lastEventVersionNameRulesManager.notifyEventTriggered(event); if (event == USER_GAVE_POSITIVE_FEEDBACK) { final Activity activity = activityReferenceManager.getValidatedActivity(); if (activity == null) { return; } for (final IFeedbackCollector positiveFeedbackCollector : positiveFeedbackCollectors) { if (positiveFeedbackCollector.tryCollectingFeedback( activity, new App(applicationContext), new Environment(applicationContext), new Device(applicationContext))) { return; } } } else if (event == USER_GAVE_CRITICAL_FEEDBACK) { final Activity activity = activityReferenceManager.getValidatedActivity(); if (activity == null) { return; } for (final IFeedbackCollector criticalFeedbackCollector : criticalFeedbackCollectors) { if (criticalFeedbackCollector.tryCollectingFeedback( activity, new App(applicationContext), new Environment(applicationContext), new Device(applicationContext))) { return; } } } }
Source:
public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { this.collector = collector; solrMapper.configure(); if (solrConfig.enableKerberos()) HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer()); this.solrClient = new CloudSolrClient(solrConfig.getZkHostString()); this.toCommitTuples = new ArrayList<>(capacity()); }

Target:
public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { this.collector = collector; if (solrConfig.isKerberosEnabled()) HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer()); this.solrClient = new CloudSolrClient(solrConfig.getZkHostString()); this.toCommitTuples = new ArrayList<>(capacity()); }
Source:
public void testWithDifferentAWSCredentialsForDynamoDBAndCloudWatch() { String test = StringUtils.join(new String[] { "streamName = a", "applicationName = b", "AWSCredentialsProvider = " + credentialName1, "AWSCredentialsProviderDynamoDB = " + credentialName1, "AWSCredentialsProviderCloudWatch = " + credentialName1, "failoverTimeMillis = 100", "shardSyncIntervalMillis = 500" }, '\n'); InputStream input = new ByteArrayInputStream(test.getBytes()); try { KinesisClientLibConfiguration config = configurator.getConfiguration(input); config.getKinesisCredentialsProvider().getCredentials(); fail("expect failure with wrong credentials provider"); } catch (Exception e) { } }

Target:
public void testWithDifferentAWSCredentialsForDynamoDBAndCloudWatch() { String test = StringUtils.join(new String[] { "streamName = a", "applicationName = b", "AWSCredentialsProvider = " + credentialNameKinesis, "AWSCredentialsProviderDynamoDB = " + credentialNameDynamoDB, "AWSCredentialsProviderCloudWatch = " + credentialNameCloudWatch, "failoverTimeMillis = 100", "shardSyncIntervalMillis = 500" }, '\n'); InputStream input = new ByteArrayInputStream(test.getBytes()); KinesisClientLibConfiguration config = configurator.getConfiguration(input); try { config.getKinesisCredentialsProvider().getCredentials(); } catch (Exception e) { fail("Kinesis credential providers should not fail."); } try { config.getDynamoDBCredentialsProvider().getCredentials(); } catch (Exception e) { fail("DynamoDB credential providers should not fail."); } try { config.getCloudWatchCredentialsProvider().getCredentials(); } catch (Exception e) { fail("CloudWatch credential providers should not fail."); } }
Source:
public void testSHEmptyRecycleBin() { try { File f = createTempFile(); W32FileUtils.getInstance().moveToTrash(new File[] { f }); int result = Shell32.INSTANCE.SHEmptyRecycleBin(null, null, Shell32.SHERB_NOCONFIRMATION | Shell32.SHERB_NOPROGRESSUI | Shell32.SHERB_NOSOUND); assertTrue(result == 0); } catch (Exception e) { throw new RuntimeException(e); } }

Target:
public void testSHEmptyRecycleBin() { File file = new File(System.getProperty("java.io.tmpdir"), System.nanoTime() + ".txt"); try { try { fillTempFile(file); W32FileUtils.getInstance().moveToTrash(new File[] { file }); } catch (IOException e) { throw new RuntimeException(e); } int result = Shell32.INSTANCE.SHEmptyRecycleBin(null, null, Shell32.SHERB_NOCONFIRMATION | Shell32.SHERB_NOPROGRESSUI | Shell32.SHERB_NOSOUND); assertEquals("Result should have been ERROR_SUCCESS when emptying Recycle Bin - there should have been a file in it.", W32Errors.ERROR_SUCCESS, result); } finally { if (file.exists()) { file.delete(); } } }
Source:
public static StateTransition transitionBetween(State fromState, State toState){ final StateTransition stateTransition = STATE_TRANSITION_MAP.get(new Tuple2<>(fromState, toState)); if(stateTransition == null) { throw new IllegalStateException( String.format("Illegal state transition from %s to %s", fromState.toString(), toState.toString())); } return stateTransition; }

Target:
public static StateTransition transitionBetween(State fromState, State toState){ final StateTransition stateTransition = STATE_TRANSITION_MAP.get(Tuple.of(fromState, toState)); if(stateTransition == null) { throw new IllegalStateException( String.format("Illegal state transition from %s to %s", fromState.toString(), toState.toString())); } return stateTransition; }
Source:
private CSVWriter initCSVWriter(String path) { try { CSVWriter writer = new CSVWriter( new FileWriter(path), ';'); String[] headerLine = new String[] { "Rule Id", "Problem type", "Title", "Description", "Links", "Application", "File Name", "File Path", "Line", "Story points" }; writer.writeNext(headerLine); return writer; } catch (IOException e) { e.printStackTrace(); } return null; }

Target:
private CSVWriter initCSVWriter(String path) { try { CSVWriter writer = new CSVWriter( new FileWriter(path), ';'); String[] headerLine = new String[] { "Rule Id", "Problem type", "Title", "Description", "Links", "Application", "File Name", "File Path", "Line", "Story points" }; writer.writeNext(headerLine); return writer; } catch (IOException e) { System.err.println("Windup was not able to create a CSV file " + path + ". CSV Export will not be generated."); throw new WindupException("Unable to create file " + path, e); } }
Source:
public DefaultDockerClient(final URI uri) { URI originalUri = checkNotNull(uri, "uri"); ClientConfig config = DEFAULT_CONFIG .connectorProvider(new ApacheConnectorProvider()) .property(ApacheClientProperties.CONNECTION_MANAGER, new PoolingHttpClientConnectionManager(getSchemeRegistry(originalUri))); this.client = ClientBuilder.newClient(config); if (originalUri.getScheme().equals("unix")) { this.uri = UnixConnectionSocketFactory.sanitizeUri(originalUri); } else { this.uri = originalUri; } }

Target:
public DefaultDockerClient(final URI uri) { this(new Builder().uri(uri)); }
Source:
public void attachmentStandalone() throws IOException, URISyntaxException { byte[] bytesToDB = "binary data".getBytes(); ByteArrayInputStream bytesIn = new ByteArrayInputStream(bytesToDB); Response response = db.saveAttachment(bytesIn, "foo.txt", "text/plain"); Document doc = db.find(Document.class, response.getId()); assertTrue(doc.getAttachments().containsKey("foo.txt")); HttpConnection conn = Http.GET(new URI(db.getDBUri() + "/" + response.getId() + "/foo.txt")); InputStream in = clientResource.get().executeRequest(conn).responseAsInputStream(); ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); int n; while ((n = in.read()) != -1) { bytesOut.write(n); } bytesOut.flush(); in.close(); byte[] bytesFromDB = bytesOut.toByteArray(); assertArrayEquals(bytesToDB, bytesFromDB); }

Target:
public void attachmentStandalone() throws IOException, URISyntaxException { byte[] bytesToDB = "binary data".getBytes(); ByteArrayInputStream bytesIn = new ByteArrayInputStream(bytesToDB); Response response = db.saveAttachment(bytesIn, "foo.txt", "text/plain"); Document doc = db.find(Document.class, response.getId()); assertTrue(doc.getAttachments().containsKey("foo.txt")); HttpConnection conn = Http.GET(new DatabaseURIHelper(db.getDBUri()) .attachmentUri(response.getId(), "foo.txt")); InputStream in = clientResource.get().executeRequest(conn).responseAsInputStream(); ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); int n; while ((n = in.read()) != -1) { bytesOut.write(n); } bytesOut.flush(); in.close(); byte[] bytesFromDB = bytesOut.toByteArray(); assertArrayEquals(bytesToDB, bytesFromDB); }
Source:
public void setWS(String ws) { incrementSequenceNumber(); fWS = ws; if (fRoot != null && ws != null && ws.length() > 0) { Element nlNode = TargetDefinitionDocumentTools.getChildElement(fRoot, TargetDefinitionPersistenceHelper.ENVIRONMENT, TargetDefinitionPersistenceHelper.WS); nlNode.setTextContent(ws); } else { removeElement(TargetDefinitionPersistenceHelper.ENVIRONMENT, TargetDefinitionPersistenceHelper.WS); } }

Target:
public void setWS(String ws) { incrementSequenceNumber(); fWS = ws; if (fRoot != null && ws != null && !ws.isEmpty()) { Element nlNode = TargetDefinitionDocumentTools.getChildElement(fRoot, TargetDefinitionPersistenceHelper.ENVIRONMENT, TargetDefinitionPersistenceHelper.WS); nlNode.setTextContent(ws); } else { removeElement(TargetDefinitionPersistenceHelper.ENVIRONMENT, TargetDefinitionPersistenceHelper.WS); } }
Source:
public void lostConnection() { if (scheduledTask != null && !scheduledTask.isDone()) { return; } logger.info("Try to restore connection to '{}' every {}ms", getBrokerConnection().getName(), getReconnectFrequency()); this.scheduledTask = scheduler.scheduleWithFixedDelay(() -> { try { getBrokerConnection().start(); } catch (MqttException | ConfigurationException e) { logger.warn("Broker connection couldn't be started", e); } }, getFirstReconnectAfter(), getReconnectFrequency(), TimeUnit.MILLISECONDS); }

Target:
public synchronized void lostConnection() { if (closed) { return; } if (scheduledTask != null && !scheduledTask.isDone()) { return; } logger.info("Try to restore connection to '{}' every {}ms", getBrokerConnection().getName(), getReconnectFrequency()); scheduledTask = scheduler.scheduleWithFixedDelay(() -> { try { getBrokerConnection().start(); } catch (MqttException | ConfigurationException e) { logger.warn("Broker connection couldn't be started", e); } }, getFirstReconnectAfter(), getReconnectFrequency(), TimeUnit.MILLISECONDS); }
Source:
public boolean isAllowOtherReadResult(String datasource) { return Boolean.parseBoolean(properties.getProperty("allow.other.read.result." + datasource)); }

Target:
public boolean isAllowOtherReadResult(String datasource) { String property = properties.getProperty("allow.other.read.result." + datasource); if (property == null) { return true; } return Boolean.parseBoolean(property); }
Source:
private List<PodData> getAllInjectablePods( ObjectMeta toCreateMeta, List<Container> toCreateContainers, Map<String, Map<String, Pod>> injectables) { Set<String> machinesInPod = getMachineNames(toCreateMeta, toCreateContainers); return machinesInPod .stream() .map(injectables::get) .filter(Objects::nonNull) .flatMap(m -> m.entrySet().stream()) .collect(toMap(Entry::getKey, Entry::getValue, (v1, v2) -> v1)) .values() .stream() .map(PodData::new) .collect(Collectors.toList()); }

Target:
private List<PodData> getAllInjectablePods( ObjectMeta toCreateMeta, List<Container> toCreateContainers, Map<String, Map<String, Pod>> injectables) { return toCreateContainers .stream() .map(c -> Names.machineName(toCreateMeta, c)) .map(injectables::get) .filter(Objects::nonNull) .flatMap(m -> m.entrySet().stream()) .collect(toMap(Entry::getKey, Entry::getValue, (v1, v2) -> v1)) .values() .stream() .map(PodData::new) .collect(Collectors.toList()); }
Source:
public static String prependIfNotEmpty(final String str, final String prefix) { return isEmpty(str) ? EMPTY : defaultString(prefix) + str; }

Target:
public static String prependIfNotEmpty(final String str, final String prefix) { if (isEmpty(prefix) || isEmpty(str)) { return str; } return prefix + str; }
Source:
protected void okPressed() { Collection<String> selectedItems = asString(items.getSelection()); List<String> names = (List<String>) ConfigInfo.names(available); boolean anyMatch = selectedItems.stream().anyMatch(names::contains); if (anyMatch) { selected = asString(items.getSelection()); super.okPressed(); } }

Target:
protected void okPressed() { Collection<String> selectedItems = asString(items.getSelection()); List<String> names = ConfigInfo.names(available); boolean anyMatch = selectedItems.stream().anyMatch(names::contains); if (anyMatch) { selected = asString(items.getSelection()); super.okPressed(); } }
Source:
public ErrorParserManager(IProject project, URI baseDirectoryURI, IMarkerGenerator markerGenerator, String[] parsersIDs) { fProject = project; fMarkerGenerator = markerGenerator; fDirectoryStack = new Vector<URI>(); fErrors = new ArrayList<ProblemMarkerInfo>(); enableErrorParsers(parsersIDs); if (baseDirectoryURI != null) fBaseDirectoryURI = baseDirectoryURI; else if (project != null) fBaseDirectoryURI = project.getLocationURI(); else fBaseDirectoryURI = org.eclipse.core.filesystem.URIUtil.toURI(System.getProperty("user.dir")); }

Target:
public ErrorParserManager(IProject project, URI baseDirectoryURI, IMarkerGenerator markerGenerator, String[] parsersIDs) { fProject = project; fMarkerGenerator = markerGenerator; fDirectoryStack = new Vector<URI>(); fErrors = new ArrayList<ProblemMarkerInfo>(); enableErrorParsers(parsersIDs); if (baseDirectoryURI != null) { fBaseDirectoryURI = baseDirectoryURI; } else if (project != null) { fBaseDirectoryURI = project.getLocationURI(); } else { fBaseDirectoryURI = org.eclipse.core.filesystem.URIUtil.toURI(System.getProperty("user.dir")); } }
Source:
private void getData(String sessionId) { if (sessionId.equals(this.sessionId)) { return; } this.sessionId = sessionId; SessionMatchingSetup sessionMatchingSetup = new SessionMatchingSetup( databaseService.getWebClientProperties().isShowOnlyMatchedTests(), EnumSet.of(SessionMatchingSetup.MatchBy.ALL)); RootNode controlTree = databaseService.getControlTreeForSessions( new HashSet<String>(Arrays.asList(sessionId)), sessionMatchingSetup); fetchSessionScopeData(controlTree); fetchPerTestData(controlTree); }

Target:
private void getData(String sessionId) { if (sessionId.equals(this.sessionId)) { return; } this.sessionId = sessionId; SessionMatchingSetup sessionMatchingSetup = new SessionMatchingSetup( true, EnumSet.of(SessionMatchingSetup.MatchBy.ALL)); RootNode controlTree = databaseService.getControlTreeForSessions( new HashSet<String>(Arrays.asList(sessionId)), sessionMatchingSetup); fetchSessionScopeData(controlTree); fetchPerTestData(controlTree); }
Source:
public void onPostUploaded(OnPostUploaded event) { final PostModel post = event.post; if (post != null && post.getId() == mPost.getId()) { if (!(mPostLoadingState == PostLoadingState.UPLOADING_FOR_PREVIEW) && !(mPostLoadingState == PostLoadingState.REMOTE_AUTO_SAVING_FOR_PREVIEW) && !(mPostLoadingState == PostLoadingState.PREVIEWING) && !(mPostLoadingState == PostLoadingState.REMOTE_AUTO_SAVE_PREVIEW_ERROR) ) { View snackbarAttachView = findViewById(R.id.editor_activity); UploadUtils.onPostUploadedSnackbarHandler(this, snackbarAttachView, event.isError(), post, event.isError() ? event.error.message : null, getSite(), mDispatcher); if (!event.isError()) { mPost = post; mIsNewPost = false; invalidateOptionsMenu(); } } else { if (!event.isError() && !(mPostLoadingState == PostLoadingState.PREVIEWING) && !(mPostLoadingState == PostLoadingState.REMOTE_AUTO_SAVE_PREVIEW_ERROR) ) { mPost = post; mIsNewPost = false; invalidateOptionsMenu(); ActivityLauncher.previewPostOrPageForResult( EditPostActivity.this, mSite, mPost, mPostLoadingState == PostLoadingState.UPLOADING_FOR_PREVIEW ? RemotePreviewLogicHelper.RemotePreviewType.REMOTE_PREVIEW : RemotePreviewLogicHelper.RemotePreviewType.REMOTE_PREVIEW_WITH_REMOTE_AUTO_SAVE ); updatePostLoadingAndDialogState(PostLoadingState.PREVIEWING, mPost); } else if (event.isError() || (mPostLoadingState == PostLoadingState.REMOTE_AUTO_SAVE_PREVIEW_ERROR)) { updatePostLoadingAndDialogState(PostLoadingState.NONE); UploadUtils.showSnackbarError(findViewById(R.id.editor_activity), getString(R.string.remote_preview_operation_error)); } } } }

Target:
public void onPostUploaded(OnPostUploaded event) { final PostModel post = event.post; if (post != null && post.getId() == mPost.getId()) { if (!isRemotePreviewingFromEditor()) { View snackbarAttachView = findViewById(R.id.editor_activity); UploadUtils.onPostUploadedSnackbarHandler(this, snackbarAttachView, event.isError(), post, event.isError() ? event.error.message : null, getSite(), mDispatcher); updatePostOnSuccessfulUpload(event, post); } else { if (!event.isError() && isUploadingPostForPreview()) { updatePostOnSuccessfulUpload(event, post); ActivityLauncher.previewPostOrPageForResult( EditPostActivity.this, mSite, post, mPostLoadingState == PostLoadingState.UPLOADING_FOR_PREVIEW ? RemotePreviewLogicHelper.RemotePreviewType.REMOTE_PREVIEW : RemotePreviewLogicHelper.RemotePreviewType.REMOTE_PREVIEW_WITH_REMOTE_AUTO_SAVE ); updatePostLoadingAndDialogState(PostLoadingState.PREVIEWING, mPost); } else if (event.isError() || isRemoteAutoSaveError()) { updatePostLoadingAndDialogState(PostLoadingState.NONE); UploadUtils.showSnackbarError(findViewById(R.id.editor_activity), getString(R.string.remote_preview_operation_error)); } } } }
Source:
public void removeChildrenFromLRU() { if (children != null) { for (ExpressionInfo child : children) { removeChildFromLRU(child); } children = null; numChildrenHint = 0; } if (fakeChildren != null) { for (ExpressionInfo fakeChild : fakeChildren) { if (fakeChild == null) { break; } removeChildFromLRU(fakeChild); } clearFakeChildren(); } }

Target:
public void removeChildrenFromLRU() { if (children != null) { for (ExpressionInfo child : children) { removeChildFromLRU(child); } children = null; numChildrenHint = 0; } for (ExpressionInfo fakeChild : fakeChildren) { removeChildFromLRU(fakeChild); } fakeChildren.clear(); }
Source:
public static boolean isAlreadyPresent(ArrayList<Order> ordersPlaced, Order newOrder) { for (Order orderPlaced : ordersPlaced) { if ((orderPlaced instanceof BuyOrder) && (newOrder instanceof BuyOrder)){ if ((orderPlaced instanceof SellOrder) && (newOrder instanceof SellOrder)){ if (orderPlaced.getStockSymbol().equals( newOrder.getStockSymbol())) { return true; } } } } return false; }

Target:
public static boolean isAlreadyPresent(ArrayList<Order> ordersPlaced, Order newOrder) { for (Order orderPlaced : ordersPlaced) { boolean isBuyOrder = (orderPlaced instanceof BuyOrder) && (newOrder instanceof BuyOrder); boolean isSellOrder = (orderPlaced instanceof SellOrder) && (newOrder instanceof SellOrder); if (isBuyOrder && isSellOrder){ if (orderPlaced.getStockSymbol().equals(newOrder.getStockSymbol())) { return true; } } } return false; }
Source:
public void save() { Settings settings = load(); try (OutputStream outputStream = new FileOutputStream(new File(settingsFileName))) { DefaultPropertiesPersister persister = new DefaultPropertiesPersister(); persister.store(settings.getProperties(), outputStream, "Phoenicis User Settings"); } catch (Exception e) { e.printStackTrace(); } }

Target:
public void save() { Settings settings = load(); try (OutputStream outputStream = new FileOutputStream(new File(settingsFileName))) { DefaultPropertiesPersister persister = new DefaultPropertiesPersister(); persister.store(settings.getProperties(), outputStream, "Phoenicis User Settings"); } catch (IOException e) { e.printStackTrace(); } }
Source:
public void run() { dataLakeFileClient.upload(createRandomInputStream(options.getSize()), options.getSize(), true); }

Target:
public void run() { inputStream.reset(); dataLakeFileClient.upload(inputStream, options.getSize(), true); }
Source:
private void xorHeaders(RawPacket source, RawPacket dest) { dest.getBuffer()[0] ^= source.getBuffer()[0]; dest.getBuffer()[1] ^= source.getBuffer()[1]; int length = (source.getLength() & 0xffff) - RawPacket.FIXED_HEADER_SIZE; dest.getBuffer()[2] ^= (length >> 8); dest.getBuffer()[3] ^= (length & 0x00ff); dest.getBuffer()[4] ^= source.getBuffer()[4]; dest.getBuffer()[5] ^= source.getBuffer()[5]; dest.getBuffer()[6] ^= source.getBuffer()[6]; dest.getBuffer()[7] ^= source.getBuffer()[7]; }

Target:
private void xorHeaders(RawPacket source, RawPacket dest) { dest.getBuffer()[0] ^= source.getBuffer()[source.getOffset() + 0]; dest.getBuffer()[1] ^= source.getBuffer()[source.getOffset() + 1]; int length = (source.getLength() & 0xffff) - RawPacket.FIXED_HEADER_SIZE; dest.getBuffer()[2] ^= (length >> 8); dest.getBuffer()[3] ^= (length & 0x00ff); dest.getBuffer()[4] ^= source.getBuffer()[source.getOffset() + 4]; dest.getBuffer()[5] ^= source.getBuffer()[source.getOffset() + 5]; dest.getBuffer()[6] ^= source.getBuffer()[source.getOffset() + 6]; dest.getBuffer()[7] ^= source.getBuffer()[source.getOffset() + 7]; }
Source:
public Connection getDBConnection(DataSource dataSource, boolean autoCommit) throws SQLException { UnitOfWorkTransactionContext unitOfWorkTransactionContext = transactionContextThreadLocal.get(); if (unitOfWorkTransactionContext == null) { throw new UnitOfWorkException("There is no transaction getting started"); } Connection connection = unitOfWorkTransactionContext.getDBConnection(dataSource); if (!autoCommit) { connection.setAutoCommit(autoCommit); } return connection; }

Target:
public Connection getDBConnection(DataSource dataSource, boolean autoCommit) throws SQLException { UnitOfWorkTransactionContext unitOfWorkTransactionContext = transactionContextThreadLocal.get(); if (unitOfWorkTransactionContext == null) { throw new UnitOfWorkException( "Can not get a connection as Transaction context is not started for dataSource : " + dataSource); } Connection connection = unitOfWorkTransactionContext.getDBConnection(dataSource); if (!autoCommit && connection.getAutoCommit()) { connection.setAutoCommit(autoCommit); } return connection; }
Source:
public List<String> getSuggestions(CommandSource source, String arguments) throws CommandException { final List<String> retList = new ArrayList<String>(); this.command.addTabCompletionOptions((ICommandSender) source, arguments.split(" "), null); return retList; }

Target:
public List<String> getSuggestions(CommandSource source, String arguments) throws CommandException { return this.command.addTabCompletionOptions((ICommandSender) source, arguments.split(" "), null); }
Source:
private void configureNavigationButtons() { next.setOnClickListener(v -> { if (DeviceInfoUtil.getConnectionType(this) == ConnectionType.NO_INTERNET) { ViewUtil.showShortSnackbar(cardLayout, R.string.no_internet); return; } setTitleAndDescriptions(); presenter.handleNext(descriptionsAdapter.getTitle(), descriptionsAdapter.getDescriptions()); }); previous.setOnClickListener(v -> presenter.handlePrevious()); categoryNext.setOnClickListener(v -> presenter.handleCategoryNext(categoriesModel, false)); categoryPrevious.setOnClickListener(v -> presenter.handlePrevious()); licensePrevious.setOnClickListener(v -> presenter.handlePrevious()); submit.setOnClickListener(v -> { Toast.makeText(this, R.string.uploading_started, Toast.LENGTH_LONG).show(); presenter.handleSubmit(categoriesModel); finish(); }); }

Target:
private void configureNavigationButtons() { next.setOnClickListener(v -> { if (!NetworkUtils.isInternetConnectionEstablished(this)) { ViewUtil.showShortSnackbar(cardLayout, R.string.no_internet); return; } setTitleAndDescriptions(); presenter.handleNext(descriptionsAdapter.getTitle(), descriptionsAdapter.getDescriptions()); }); previous.setOnClickListener(v -> presenter.handlePrevious()); categoryNext.setOnClickListener(v -> presenter.handleCategoryNext(categoriesModel, false)); categoryPrevious.setOnClickListener(v -> presenter.handlePrevious()); licensePrevious.setOnClickListener(v -> presenter.handlePrevious()); submit.setOnClickListener(v -> { Toast.makeText(this, R.string.uploading_started, Toast.LENGTH_LONG).show(); presenter.handleSubmit(categoriesModel); finish(); }); }
Source:
public void getDuplicatePatientsByAttributes_shouldReturnPatients() { Patient patient = Context.getPatientService().getPatient(2); List<String> attributes = new ArrayList<>(); attributes.add(patient.getGender()); attributes.add(patient.getGivenName()); attributes.add(patient.getMiddleName()); attributes.add(patient.getFamilyName()); List<Patient> receivedPatientList = patientService.getDuplicatePatientsByAttributes(attributes); assertNotNull(receivedPatientList); }

Target:
public void getDuplicatePatientsByAttributes_shouldReturnPatients() { List<PersonAttribute> activePersonAttributes = Context.getPatientService().getPatient(2).getActiveAttributes(); List<String> activeAttributes = new ArrayList<>(); for (PersonAttribute personAttribute : activePersonAttributes) { activeAttributes.add(personAttribute.getValue()); } List<Patient> receivedPatientList = patientService.getDuplicatePatientsByAttributes(activeAttributes); assertNotNull(receivedPatientList); assertEquals(receivedPatientList.size(), 0); }
Source:
public void validate(Object obj, Errors errors) { ConceptNameTag cnt = (ConceptNameTag) obj; if (cnt == null) { errors.rejectValue("conceptNameTag", "error.general"); } else { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "tag", "error.name"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "description", "error.description"); if (cnt.getTag() != null) { for (ConceptNameTag currentTag : Context.getConceptService().getAllConceptNameTags()) { if (currentTag.getTag().trim() == (cnt.getTag().trim())) { errors.rejectValue("tag", "conceptsearch.error.duplicate"); } } } } }

Target:
public void validate(Object obj, Errors errors) { ConceptNameTag cnt = (ConceptNameTag) obj; if (cnt == null) { errors.rejectValue("conceptNameTag", "error.general"); } else { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "tag", "error.name"); if (cnt.getTag() != null) { for (ConceptNameTag currentTag : Context.getConceptService().getAllConceptNameTags()) { if (currentTag != null) { if (currentTag.getTag().trim().equals((cnt.getTag().trim()))) { errors.rejectValue("tag", "Concept.name.tag.duplicate"); } } } } } }
Source:
private IJavaProject getSingleProject() { IJavaProject first= null; for (IJavaElement fElement : fElements) { final IJavaProject project = fElement.getJavaProject(); if (project != null) { if (first == null) first= project; else if (!project.equals(first)) return null; } } return first; }

Target:
private IJavaProject getSingleProject() { IJavaProject first= null; for (IJavaElement element : fElements) { final IJavaProject project= element.getJavaProject(); if (project != null) { if (first == null) first= project; else if (!project.equals(first)) return null; } } return first; }
Source:
private static void assertOnMapIterator(Iterator<Map.Entry<String, JsonNode>> expectedNode, ObjectNode actualNode, boolean ignoredDefaults, String[] ignoredFields) { while (expectedNode.hasNext()) { assertTrue(actualNode.fields().hasNext()); Map.Entry<String, JsonNode> expectedField = expectedNode.next(); String fieldName = expectedField.getKey(); Set<String> ignoredFieldSet = new HashSet<>(Arrays.asList(ignoredFields)); if (shouldSkipField(fieldName, expectedField.getValue(), ignoredDefaults, ignoredFieldSet)) { continue; } if (expectedField.getValue().isValueNode()) { assertEquals(expectedField.getValue(), actualNode.get(expectedField.getKey())); } else if (expectedField.getValue().isArray()) { Iterator<JsonNode> expectedArray = expectedField.getValue().elements(); Iterator<JsonNode> actualArray = actualNode.get(expectedField.getKey()).elements(); while (expectedArray.hasNext()) { assertTrue(actualArray.hasNext()); Iterator<JsonNode> expectedElements = expectedArray.next().elements(); Iterator<JsonNode> actualElements = actualArray.next().elements(); while (expectedElements.hasNext()) { assertTrue(actualElements.hasNext()); JsonNode a = expectedElements.next(); JsonNode b = actualElements.next(); if (ignoredFieldSet.contains(fieldName)) { continue; } if (shouldSkipField(null, a, true, null)) { continue; } assertEquals(a.asText(), b.asText()); } } } else { assertObjectEquals(expectedField.getValue(), actualNode.get(expectedField.getKey()), ignoredDefaults, ignoredFields); } } }

Target:
private static void assertOnMapIterator(Iterator<Map.Entry<String, JsonNode>> expectedNode, ObjectNode actualNode, boolean ignoredDefaults, String[] ignoredFields) { Set<String> ignoredFieldSet = new HashSet<>(Arrays.asList(ignoredFields)); while (expectedNode.hasNext()) { assertTrue(actualNode.fields().hasNext()); Map.Entry<String, JsonNode> expectedField = expectedNode.next(); String fieldName = expectedField.getKey(); if (shouldSkipField(fieldName, expectedField.getValue(), ignoredDefaults, ignoredFieldSet)) { continue; } if (expectedField.getValue().isValueNode()) { assertEquals(expectedField.getValue(), actualNode.get(expectedField.getKey())); } else if (expectedField.getValue().isArray()) { Iterator<JsonNode> expectedArray = expectedField.getValue().elements(); Iterator<JsonNode> actualArray = actualNode.get(expectedField.getKey()).elements(); while (expectedArray.hasNext()) { assertTrue(actualArray.hasNext()); Iterator<JsonNode> expectedElements = expectedArray.next().elements(); Iterator<JsonNode> actualElements = actualArray.next().elements(); while (expectedElements.hasNext()) { assertTrue(actualElements.hasNext()); JsonNode a = expectedElements.next(); JsonNode b = actualElements.next(); if (ignoredFieldSet.contains(fieldName)) { continue; } if (shouldSkipField(null, a, true, null)) { continue; } assertEquals(a.asText(), b.asText()); } } } else { assertObjectEquals(expectedField.getValue(), actualNode.get(expectedField.getKey()), ignoredDefaults, ignoredFields); } } }
Source:
private synchronized Set<String> getSharedWith(Map<ByteArrayWrapper, Set<String>> cache, AbsoluteCapability cap) { return new HashSet<>(cache.computeIfAbsent(generateKey(cap), k -> new HashSet<>())); }

Target:
private synchronized Set<String> getSharedWith(Map<ByteArrayWrapper, Set<String>> cache, AbsoluteCapability cap) { return new HashSet<>(cache.getOrDefault(generateKey(cap), new HashSet<>())); }
Source:
public void write(byte[] b, int off, int len) throws IOException { if(sink == null) { throw new IOException("Unconnected pipe"); } while (len>0) { FastPipedInputStream s = sink(); if(s.closed!=null) { throw (IOException) new IOException("Pipe is already closed", s.closed); } synchronized(s.buffer) { if(s.writePosition == s.readPosition && s.writeLaps > s.readLaps) { byte[] buf = s.buffer; s = null; Thread t = Thread.currentThread(); String oldName = t.getName(); t.setName("Blocking to write "+HexDump.toHex(b,off,Math.min(len,256))+": "+oldName); try { buf.wait(TIMEOUT); } catch (InterruptedException e) { throw (InterruptedIOException)new InterruptedIOException(e.getMessage()).initCause(e); } finally { t.setName(oldName); } continue; } int amount = Math.min(len, (s.writePosition < s.readPosition ? s.readPosition : s.buffer.length) - s.writePosition); System.arraycopy(b, off, s.buffer, s.writePosition, amount); s.writePosition += amount; if(s.writePosition == s.buffer.length) { s.writePosition = 0; ++s.writeLaps; } off += amount; len -= amount; written += amount; s.buffer.notifyAll(); } } }

Target:
public void write(byte[] b, int off, int len) throws IOException { if(sink == null) { throw new IOException("Unconnected pipe"); } while (len>0) { FastPipedInputStream s = sink(); if(s.closed!=null) { throw new IOException("Pipe is already closed", s.closed); } synchronized(s.buffer) { if(s.writePosition == s.readPosition && s.writeLaps > s.readLaps) { byte[] buf = s.buffer; s = null; Thread t = Thread.currentThread(); String oldName = t.getName(); t.setName("Blocking to write "+HexDump.toHex(b,off,Math.min(len,256))+": "+oldName); try { buf.wait(TIMEOUT); } catch (InterruptedException e) { throw (InterruptedIOException)new InterruptedIOException(e.getMessage()).initCause(e); } finally { t.setName(oldName); } continue; } int amount = Math.min(len, (s.writePosition < s.readPosition ? s.readPosition : s.buffer.length) - s.writePosition); System.arraycopy(b, off, s.buffer, s.writePosition, amount); s.writePosition += amount; if(s.writePosition == s.buffer.length) { s.writePosition = 0; ++s.writeLaps; } off += amount; len -= amount; written += amount; s.buffer.notifyAll(); } } }
Source:
public void success() { SingleSubject<Integer> ms = SingleSubject.create(); assertFalse(ms.hasValue()); assertNull(ms.getValue()); assertFalse(ms.hasThrowable()); assertNull(ms.getThrowable()); assertFalse(ms.hasObservers()); assertEquals(0, ms.observerCount()); TestObserver<Integer> to = ms.test(); to.assertEmpty(); assertTrue(ms.hasObservers()); assertEquals(1, ms.observerCount()); ms.onSuccess(1); assertTrue(ms.hasValue()); assertEquals(1, ms.getValue().intValue()); assertFalse(ms.hasThrowable()); assertNull(ms.getThrowable()); assertFalse(ms.hasObservers()); assertEquals(0, ms.observerCount()); to.assertResult(1); ms.test().assertResult(1); assertTrue(ms.hasValue()); assertEquals(1, ms.getValue().intValue()); assertFalse(ms.hasThrowable()); assertNull(ms.getThrowable()); assertFalse(ms.hasObservers()); assertEquals(0, ms.observerCount()); }

Target:
public void success() { SingleSubject<Integer> ss = SingleSubject.create(); assertFalse(ss.hasValue()); assertNull(ss.getValue()); assertFalse(ss.hasThrowable()); assertNull(ss.getThrowable()); assertFalse(ss.hasObservers()); assertEquals(0, ss.observerCount()); TestObserver<Integer> to = ss.test(); to.assertEmpty(); assertTrue(ss.hasObservers()); assertEquals(1, ss.observerCount()); ss.onSuccess(1); assertTrue(ss.hasValue()); assertEquals(1, ss.getValue().intValue()); assertFalse(ss.hasThrowable()); assertNull(ss.getThrowable()); assertFalse(ss.hasObservers()); assertEquals(0, ss.observerCount()); to.assertResult(1); ss.test().assertResult(1); assertTrue(ss.hasValue()); assertEquals(1, ss.getValue().intValue()); assertFalse(ss.hasThrowable()); assertNull(ss.getThrowable()); assertFalse(ss.hasObservers()); assertEquals(0, ss.observerCount()); }
Source:
public void setEnabled(boolean enabled) { if (enabled != enabled_) { enabled_ = enabled; handlers_.fireEvent(new EnabledChangedEvent(this)); } if (Desktop.isDesktop()) DesktopMenuCallback.setCommandEnabled(id_, enabled_); }

Target:
public void setEnabled(boolean enabled) { if (enabled != enabled_) { enabled_ = enabled; handlers_.fireEvent(new EnabledChangedEvent(this)); } }
Source:
public String getClassName(Class clazz, String name) { if (this.classToProperty.containsKey(clazz)) { String classNameProperty = this.classToProperty.get(clazz); String className = environment .getProperty(name + "." + NAMESPACE + "." + classNameProperty); if(className==null) className=environment .getProperty(NAMESPACE + "." + classNameProperty); return className; } return null; }

Target:
public String getClassName(Class clazz, String name) { if (this.classToProperty.containsKey(clazz)) { String classNameProperty = this.classToProperty.get(clazz); String className = environment .getProperty(name + "." + NAMESPACE + "." + classNameProperty); if(className==null) { className=environment .getProperty(NAMESPACE + "." + classNameProperty); } return className; } return null; }