auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private static Graphic createGraphic(Map<String, Object> attributes) { int wkid = Integer.parseInt((String) attributes.get("_wkid")); SpatialReference sr = SpatialReference.create(wkid); PointCollection points = new PointCollection(sr); String[] coordinates = ((String) attributes.get("_control_points")).split(";"); Stream.of(coordinates) .map(cs -> cs.split(",")) .map(c -> new Point(Double.valueOf(c[0]), Double.valueOf(c[1]), sr)) .collect(Collectors.toCollection(() -> points)); return new Graphic(new Multipoint(points), attributes); }

Target:
private static Graphic createGraphic(Map<String, Object> attributes) { int wkid = Integer.parseInt((String) attributes.get("_wkid")); SpatialReference spatialReference = SpatialReference.create(wkid); PointCollection points = new PointCollection(spatialReference); String[] coordinates = ((String) attributes.get("_control_points")).split(";"); if (coordinates.length > 0) { for (String ordinate : coordinates) { String[] pointCoordinate = ordinate.split(","); if (pointCoordinate.length > 0) { Point point = new Point(Double.valueOf(pointCoordinate[0]), Double.valueOf(pointCoordinate[1]), spatialReference); points.add(point); } } } return new Graphic(new Multipoint(points), attributes); }
Source:
public ListenableFuture<Image> createImage(ImageTemplate template) { checkState(template instanceof CloneImageTemplate, " cloudstack only currently supports creating images through cloning."); CloneImageTemplate cloneTemplate = (CloneImageTemplate) template; DataCenterAndId datacenterAndId = DataCenterAndId.fromSlashEncoded(cloneTemplate.getSourceNodeId()); Server server = client.serverApi().getServer(datacenterAndId.getDataCenter(), datacenterAndId.getId()); List<Volume> volumes = client.volumeApi().getList(server.dataCenterId()); Volume volume = Iterables.getOnlyElement(volumes); Snapshot snapshot = client.volumeApi().createSnapshot(Volume.Request.createSnapshotBuilder() .dataCenterId(datacenterAndId.getDataCenter()) .volumeId(volume.id()) .name(cloneTemplate.getName()) .description(cloneTemplate.getName()) .build()); trackables.waitUntilRequestCompleted(snapshot); logger.info(">> Registered new template %s, waiting for it to become available.", snapshot.id()); final Image image = new ImageBuilder() .location(find(locations.get(), idEquals(snapshot.properties().location().getId()))) .id(snapshot.id()) .providerId(snapshot.id()) .name(cloneTemplate.getName()) .description(cloneTemplate.getName()) .operatingSystem(OperatingSystem.builder().description(cloneTemplate.getName()).build()) .status(Image.Status.PENDING).build(); return userExecutor.submit(new Callable<Image>() { @Override public Image call() throws Exception { if (snapshotAvailablePredicate.apply(image.getId())) { return image; } throw new UncheckedTimeoutException("Image was not created within the time limit: " + image); } }); }

Target:
public ListenableFuture<Image> createImage(ImageTemplate template) { final CloneImageTemplate cloneTemplate = (CloneImageTemplate) template; final DataCenterAndId datacenterAndId = DataCenterAndId.fromSlashEncoded(cloneTemplate.getSourceNodeId()); final Server server = client.serverApi().getServer(datacenterAndId.getDataCenter(), datacenterAndId.getId()); List<Volume> volumes = client.volumeApi().getList(server.dataCenterId()); final Volume volume = Iterables.getOnlyElement(volumes); return userExecutor.submit(new Callable<Image>() { @Override public Image call() throws Exception { Snapshot snapshot = client.volumeApi().createSnapshot(Volume.Request.createSnapshotBuilder() .dataCenterId(datacenterAndId.getDataCenter()) .volumeId(volume.id()) .name(cloneTemplate.getName()) .description(cloneTemplate.getName()) .build()); trackables.waitUntilRequestCompleted(snapshot); logger.info(">> Registered new snapshot %s, waiting for it to become available.", snapshot.id()); final Image image = new ImageBuilder() .location(find(locations.get(), idEquals(snapshot.properties().location().getId()))) .id(snapshot.id()) .providerId(snapshot.id()) .name(cloneTemplate.getName()) .description(cloneTemplate.getName()) .operatingSystem(OperatingSystem.builder().description(cloneTemplate.getName()).build()) .status(Image.Status.PENDING).build(); if (snapshotAvailablePredicate.apply(image.getId())) { return image; } throw new UncheckedTimeoutException("Image was not created within the time limit: " + image); } }); }
Source:
private static <T> T createFromUris(MetricsManager metricsManager, List<String> endpointUris, Class<T> type) { ServerListConfig serverListConfig = ImmutableServerListConfig.builder() .addAllServers(endpointUris) .sslConfiguration(SSL_CONFIGURATION) .build(); AuxiliaryRemotingParameters build = AuxiliaryRemotingParameters.builder() .shouldRetry(false) .shouldLimitPayload(false) .shouldSupportBlockingOperations(false) .userAgent(UserAgent.of(UserAgent.Agent.of("atlasdb-jepsen", "1.2.3"))) .build(); return AtlasDbHttpClients.createProxyWithQuickFailoverForTesting( metricsManager, serverListConfig, type, build); }

Target:
private static <T> T createFromUris(MetricsManager metricsManager, List<String> endpointUris, Class<T> type) { ServerListConfig serverListConfig = ImmutableServerListConfig.builder() .addAllServers(endpointUris) .sslConfiguration(SSL_CONFIGURATION) .build(); AuxiliaryRemotingParameters parameters = AuxiliaryRemotingParameters.builder() .shouldRetry(false) .shouldLimitPayload(false) .shouldSupportBlockingOperations(true) .userAgent(UserAgent.of(UserAgent.Agent.of("atlasdb-jepsen", UserAgent.Agent.DEFAULT_VERSION))) .build(); return AtlasDbHttpClients.createProxyWithQuickFailoverForTesting( metricsManager, serverListConfig, type, parameters); }
Source:
public String getFileServiceUrl() { return client.url(); }

Target:
public URL getFileServiceUrl() { try { return new URL(azureFileStorageClient.url()); } catch (MalformedURLException e) { throw new RuntimeException(String.format("Invalid URL on %s: %s" + getClass().getSimpleName(), azureFileStorageClient.url()), e); } }
Source:
private HttpFuzzer createFuzzer( HttpMessage message, List<PayloadGeneratorMessageLocation<?>> fuzzLocations, HttpFuzzerOptions options, List<HttpFuzzerMessageProcessor> processors) { if (fuzzLocations.isEmpty()) { return null; } MessageLocationReplacer<HttpMessage> replacer = MessageLocationReplacers.getInstance() .getMLR(HttpMessage.class, this.getMessageLocationClass()); replacer.init(message); MultipleMessageLocationsReplacer<HttpMessage> multipleMessageLocationsReplacer; if (MessageLocationsReplacementStrategy.DEPTH_FIRST == options.getPayloadsReplacementStrategy()) { multipleMessageLocationsReplacer = new MultipleMessageLocationsDepthFirstReplacer<>(); } else { multipleMessageLocationsReplacer = new MultipleMessageLocationsBreadthFirstReplacer<>(); } SortedSet<MessageLocationReplacementGenerator<?, ?>> messageLocationReplacementGenerators = new TreeSet<>(); for (PayloadGeneratorMessageLocation<?> fuzzLocation : fuzzLocations) { messageLocationReplacementGenerators.add(fuzzLocation); } multipleMessageLocationsReplacer.init(replacer, messageLocationReplacementGenerators); return new HttpFuzzer( createFuzzerName(message), options, message, (List<MessageLocationReplacementGenerator<?, MessageLocationReplacement<?>>>) (ArrayList) fuzzLocations, multipleMessageLocationsReplacer, processors); }

Target:
private HttpFuzzer createFuzzer( HttpMessage message, List<PayloadGeneratorMessageLocation<?>> fuzzLocations, HttpFuzzerOptions options, List<HttpFuzzerMessageProcessor> processors) { if (fuzzLocations.isEmpty()) { return null; } MessageLocationReplacer<HttpMessage> replacer = MessageLocationReplacers.getInstance() .getMLR( HttpMessage.class, fuzzLocations.get(0).getMessageLocation().getClass()); replacer.init(message); MultipleMessageLocationsReplacer<HttpMessage> multipleMessageLocationsReplacer; if (MessageLocationsReplacementStrategy.DEPTH_FIRST == options.getPayloadsReplacementStrategy()) { multipleMessageLocationsReplacer = new MultipleMessageLocationsDepthFirstReplacer<>(); } else { multipleMessageLocationsReplacer = new MultipleMessageLocationsBreadthFirstReplacer<>(); } SortedSet<MessageLocationReplacementGenerator<?, ?>> messageLocationReplacementGenerators = new TreeSet<>(); for (PayloadGeneratorMessageLocation<?> fuzzLocation : fuzzLocations) { messageLocationReplacementGenerators.add(fuzzLocation); } multipleMessageLocationsReplacer.init(replacer, messageLocationReplacementGenerators); return new HttpFuzzer( createFuzzerName(message), options, message, (List<MessageLocationReplacementGenerator<?, MessageLocationReplacement<?>>>) (ArrayList) fuzzLocations, multipleMessageLocationsReplacer, processors); }
Source:
public Comparable next() { if (!nextFetched) { value = peek(); nextFetched = true; } if (value == null) { throw new NoSuchElementException(); } nextFetched = false; index++; return value; }

Target:
public Comparable next() { if (!hasNext()) { throw new NoSuchElementException(); } nextFetched = false; index++; return value; }
Source:
public void testScopeWithDuplicateKey() throws Exception { swagger_file = new File(resourceLocation + File.separator + "swaggerFiles/APIScopeTest1.json"); String payload = readFromFile(swagger_file.getAbsolutePath()); HttpResponse updateResponse = apiPublisher.updateResourceOfAPI(SUPER_USER, apiName, apiVersion, payload); verifyResponse(updateResponse); HttpResponse httpResponse = apiPublisher.validateScope(ITEM_VIEW, AGENT_ROLE); verifyResponse(httpResponse); assertEquals(new JSONObject(httpResponse.getData()).get(SCOPE_EXISTANCE).toString(), "true", "Error in scope creation with Invalid values. Scope : " + ITEM_VIEW); }

Target:
public void testScopeWithDuplicateKey() throws Exception { swagger_file = new File(resourceLocation + File.separator + "swaggerFiles/APIScopeTest1.json"); String payload = readFromFile(swagger_file.getAbsolutePath()); HttpResponse updateResponse = apiPublisher.updateResourceOfAPI(SUPER_USER, apiName, apiVersion, payload); verifyResponse(updateResponse); HttpResponse httpResponse = apiPublisher.validateScope(ITEM_VIEW, AGENT_ROLE); verifyResponse(httpResponse); assertEquals(new JSONObject(httpResponse.getData()).get(SCOPE_EXISTANCE).toString(), "true", "Error in scope creation with duplicate key : " + ITEM_VIEW); }
Source:
public String toString() { StringBuilder sb = new StringBuilder(getClass().getSimpleName()).append("{"); sb.append("intArraysSize=").append(intArrays.size()).append(","); sb.append("borrowedIntArraysSize=").append(borrowedIntArrays.size()).append(","); sb.append("estimatedSizeInBytes=").append(estimatedSizeInBytes).append("}"); return sb.toString(); }

Target:
public String toString() { return toStringHelper(this) .add("intArraysSize", intArrays.size()) .add("borrowedIntArraysSize", borrowedIntArrays.size()) .add("estimatedSizeInBytes", estimatedSizeInBytes) .toString(); }
Source:
public boolean checkCancelEditQuestionButtonVisibility(int qnIndex) { WebElement cancelEditButton = browser.driver.findElement(By.xpath(" if (cancelEditButton.isDisplayed()) { return true; } else { return false; } }

Target:
public boolean checkCancelEditQuestionButtonVisibility(int qnIndex) { WebElement cancelEditButton = browser.driver.findElement(By.xpath(" return cancelEditButton.isDisplayed(); }
Source:
public void equals_shouldReturnFalse_whenFieldsRefundReferenceIsDifferent() { TransactionEvent event1 = new TransactionEvent(Type.REFUND, "charge", "success", extractState(EXTERNAL_SUBMITTED), 100L, ZonedDateTime.now(),null); TransactionEvent event2 = new TransactionEvent(Type.REFUND, "charge", "submitted", extractState(EXTERNAL_SUBMITTED), 100L, ZonedDateTime.now(),null); assertThat(event1.equals(event2), is(false)); }

Target:
public void equals_shouldReturnFalse_whenFieldsRefundReferenceIsDifferent() { TransactionEvent event1 = new TransactionEvent(Type.REFUND, "charge", "success", extractState(EXTERNAL_SUBMITTED), 100L, ZonedDateTime.now(), USER_EXTERNAL_ID); TransactionEvent event2 = new TransactionEvent(Type.REFUND, "charge", "submitted", extractState(EXTERNAL_SUBMITTED), 100L, ZonedDateTime.now(),USER_EXTERNAL_ID); assertThat(event1.equals(event2), is(false)); }
Source:
public List<T2<ClusterNode, Object>> recordedMessages(boolean stopRecord) { synchronized (this) { List<T2<ClusterNode, Object>> msgs = recordedMsgs; recordedMsgs = new ArrayList<>(); if (stopRecord) recordClasses = null; return msgs; } }

Target:
public List<Object> recordedMessages(boolean stopRecord) { synchronized (this) { List<Object> msgs = recordedMsgs; recordedMsgs = new ArrayList<>(); if (stopRecord) recordClasses = null; return msgs; } }
Source:
public Map<String, Map<String, Integer>> dumpHashTableStats() { Map<String, Map<String, Integer>> ret = new HashMap<String, Map<String, Integer>>(); if (leftHashTable != null) { ret.put(leftHashTable.name, leftHashTable.dumpStats()); } if (rightHashTable != null) { ret.put(rightHashTable.name, rightHashTable.dumpStats()); } return ret; }

Target:
public Map<String, Map<String, Integer>> dumpHashTableStats() { Map<String, Map<String, Integer>> ret = new HashMap<>(); if (leftHashTable != null) { ret.put(leftHashTable.name, leftHashTable.dumpStats()); } if (rightHashTable != null) { ret.put(rightHashTable.name, rightHashTable.dumpStats()); } return ret; }
Source:
public void run() { countDown--; if (countDown == 0) { System.out.println("## interrupt"); Thread.currentThread().interrupt(); } }

Target:
public void run() { countDown--; if (countDown == 0) { Thread.currentThread().interrupt(); } }
Source:
private static void applyFrameBoundsHeuristics(FrameDesc a, FrameDesc b) { int aEnd = a.getEnd(), bStart = b.getStart(); if (aEnd != -1 && bStart != -1) { return; } long tsDiff = (b.getTimestamp() - a.getTimestamp()) & 0xFFFFFFFFL; if (tsDiff > (1L << 30) && tsDiff < (-(1L << 30) & 0xFFFFFFFFL)) { return; } else if (tsDiff >= (-(1L << 30) & 0xFFFFFFFFL)) { logger.warn("Frames that are out of order detected."); } else { int bMin = b.getMinSeen(), aMax = a.getMaxSeen(); int snDiff = (bMin - aMax) & 0xFFFF; if (bStart != -1 || aEnd != -1) { if (snDiff == 2) { if (aEnd == -1) { aEnd = (aMax + 1) & 0xFFFF; if (logger.isDebugEnabled()) { logger.debug("Guessed frame end=" + aEnd); } a.setEnd(aEnd); } else { bStart = (bMin - 1) & 0xFFFF; if (logger.isDebugEnabled()) { logger.debug("Guessed frame start=" + bStart); } b.setStart(bStart); } } else if (snDiff < 2 || snDiff > (-3 & 0xFFFF)) { logger.warn("Frame corruption or packets that are out of " + "order detected."); } } else { if (snDiff == 3) { bStart = (bMin - 1) & 0xFFFF; aEnd = (aMax + 1) & 0xFFFF; if (logger.isDebugEnabled()) { logger.debug( "Guessed frame start=" + bStart + ",end=" + aEnd); } a.setEnd(aEnd); b.setStart(bStart); } else if (snDiff < 3 || snDiff > (-4 & 0xFFFF)) { logger.warn("Frame corruption or packets that are out of" + " order detected."); } } } }

Target:
private static void applyFrameBoundsHeuristics(FrameDesc a, FrameDesc b) { int aLastSeqNum = a.getEnd(), bFirstSeqNum = b.getStart(); if (aLastSeqNum != -1 && bFirstSeqNum != -1) { return; } long tsDiff = (b.getTimestamp() - a.getTimestamp()) & 0xFFFFFFFFL; if (tsDiff > (1L << 30) && tsDiff < (-(1L << 30) & 0xFFFFFFFFL)) { return; } else if (tsDiff >= (-(1L << 30) & 0xFFFFFFFFL)) { logger.warn("Frames that are out of order detected."); } else { int bMinSeqNum = b.getMinSeen(), aMaxSeqNum = a.getMaxSeen(); int snDiff = (bMinSeqNum - aMaxSeqNum) & 0xFFFF; if (bFirstSeqNum != -1 || aLastSeqNum != -1) { if (snDiff == 2) { if (aLastSeqNum == -1) { aLastSeqNum = (aMaxSeqNum + 1) & 0xFFFF; if (logger.isDebugEnabled()) { logger.debug("Guessed frame end=" + aLastSeqNum); } a.setEnd(aLastSeqNum); } else { bFirstSeqNum = (bMinSeqNum - 1) & 0xFFFF; if (logger.isDebugEnabled()) { logger.debug("Guessed frame start=" + bFirstSeqNum); } b.setStart(bFirstSeqNum); } } else if (snDiff < 2 || snDiff > (-3 & 0xFFFF)) { logger.warn("Frame corruption or packets that are out of " + "order detected."); } } else { if (snDiff == 3) { bFirstSeqNum = (bMinSeqNum - 1) & 0xFFFF; aLastSeqNum = (aMaxSeqNum + 1) & 0xFFFF; if (logger.isDebugEnabled()) { logger.debug( "Guessed frame start=" + bFirstSeqNum + ",end=" + aLastSeqNum); } a.setEnd(aLastSeqNum); b.setStart(bFirstSeqNum); } else if (snDiff < 3 || snDiff > (-4 & 0xFFFF)) { logger.warn("Frame corruption or packets that are out of" + " order detected."); } } } }
Source:
void resetLogic() { for (int i = 0; i < fieldSize; i++) for (int j = 0; j < fieldSize; j++) fieldArray[i][j] = 0; playerMark = CROSS_MARK; aIMark = ZERO_MARK; turn = 0; autoGameEnabled = false; }

Target:
void resetLogic() { for (int i = 0; i < fieldSize; i++) for (int j = 0; j < fieldSize; j++) { fieldArray[i][j] = 0; } playerMark = CROSS_MARK; aIMark = ZERO_MARK; turn = 0; autoGameEnabled = false; }
Source:
public void applyTo(Appendable appendable) throws IOException { String date = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss").format(Calendar.getInstance().getTime()); appendable.append("<o:Title>"); appendable.append(title); appendable.append("</o:Title>"); appendable.append("<o:Author>"); appendable.append(author); appendable.append("</o:Author>"); appendable.append("<o:LastAuthor>"); appendable.append(author); appendable.append("</o:LastAuthor>"); appendable.append("<o:Revision>1</o:Revision><o:TotalTime>1332</o:TotalTime>"); appendable.append("<o:LastPrinted>"); appendable.append(date); appendable.append("</o:LastPrinted>"); appendable.append("<o:Created>"); appendable.append(date); appendable.append("</o:Created>"); appendable.append("<o:LastSaved>"); appendable.append(date); appendable.append("</o:LastSaved>"); appendable.append("<o:Pages>1</o:Pages><o:Words>0</o:Words><o:Characters>0</o:Characters>"); appendable.append("<o:Company>"); appendable.append("company"); appendable.append("</o:Company>"); appendable.append("<o:Lines>1</o:Lines><o:Paragraphs>1</o:Paragraphs><o:CharactersWithSpaces>0</o:CharactersWithSpaces><o:Version>1</o:Version>"); }

Target:
public void applyTo(Appendable appendable) throws IOException { String date = new SimpleDateFormat(DATE).format(Calendar.getInstance().getTime()); appendable.append(O_TITLE); appendable.append(title); appendable.append(C_TITLE); appendable.append(O_AUTHOR); appendable.append(author); appendable.append(C_AUTHOR); appendable.append(O_LAST_AUTHOR); appendable.append(author); appendable.append(C_LAST_AUTHOR); appendable.append(REVISION_TIME); appendable.append(O_LAST_PRINTED); appendable.append(date); appendable.append(C_LAST_PRINTED); appendable.append(O_CREATED); appendable.append(date); appendable.append(C_CREATED); appendable.append(O_LAST_SAVED); appendable.append(date); appendable.append(C_LAST_SAVED); appendable.append(PAGES_WORDS_CHARACTERS); appendable.append(O_COMPANY); appendable.append("company"); appendable.append(C_COMPANY); appendable.append(LINES_PARAGRAPHS_CHARACTERS_WITH_SPACES__VERSION); }
Source:
public static Map<String, List<QualifiedOafJsonRecord>> mapByColumnFamily(Iterable<InfoSpaceRecord> records) { Preconditions.checkNotNull(records); Map<String, List<QualifiedOafJsonRecord>> oafRecordsByFamilyMap = Maps.newHashMap(); for (InfoSpaceRecord record : records) { String columnFamily = record.getColumnFamily().toString(); List<QualifiedOafJsonRecord> storedRecords = oafRecordsByFamilyMap.get(columnFamily); if (storedRecords==null) { oafRecordsByFamilyMap.put(columnFamily, storedRecords = Lists.newArrayList()); } storedRecords.add(new QualifiedOafJsonRecord(record.getQualifier().toString(), record.getOafJson().toString())); } return oafRecordsByFamilyMap; }

Target:
public static Map<String, List<QualifiedOafJsonRecord>> mapByColumnFamily(Iterable<InfoSpaceRecord> records) { Preconditions.checkNotNull(records); Map<String, List<QualifiedOafJsonRecord>> oafRecordsByFamilyMap = Maps.newHashMap(); for (InfoSpaceRecord record : records) { List<QualifiedOafJsonRecord> storedRecords = oafRecordsByFamilyMap.computeIfAbsent(record.getColumnFamily().toString(), k -> Lists.newArrayList()); storedRecords.add(new QualifiedOafJsonRecord(record.getQualifier().toString(), record.getOafJson().toString())); } return oafRecordsByFamilyMap; }
Source:
protected void doExecute() { if (callback == null || session == null) { return; } try { int nbViewpointsInChange = (newSelectedViewpoints != null ? newSelectedViewpoints.size() + 1 : 0) + (newDeselectedViewpoints != null ? newDeselectedViewpoints.size() : 0); monitor.beginTask("Apply new viewpoints selection...", nbViewpointsInChange); if (newSelectedViewpoints != null) { List<Viewpoint> sorted = sortByDependencies(newSelectedViewpoints); boolean securityExceptionOccured = false; monitor.worked(1); for (final Viewpoint viewpoint : sorted) { monitor.subTask("Select viewpoint : " + new IdentifiedElementQuery(viewpoint).getLabel()); try { callback.selectViewpoint(viewpoint, session, createNewRepresentations, new SubProgressMonitor(monitor, 1)); } catch (SecurityException e) { securityExceptionOccured = true; } } if (securityExceptionOccured) { String viewpointsInErrorMessage = "Viewpoint"; if (newSelectedViewpoints.size() > 1) { viewpointsInErrorMessage += "s"; } for (Viewpoint nonSelectableViewpoint : newSelectedViewpoints) { viewpointsInErrorMessage += " '" + nonSelectableViewpoint.getName() + "', "; } viewpointsInErrorMessage = viewpointsInErrorMessage.substring(0, viewpointsInErrorMessage.lastIndexOf(", ")); String errorMessage = "Unable to activate " + viewpointsInErrorMessage + " because of insufficient rights. Please contact your administrator to modify your rights."; throw new SecurityException(errorMessage); } } if (newDeselectedViewpoints != null) { for (final Viewpoint viewpoint : newDeselectedViewpoints) { monitor.subTask("Deselect viewpoint : " + new IdentifiedElementQuery(viewpoint).getLabel()); callback.deselectViewpoint(viewpoint, session, new SubProgressMonitor(monitor, 1)); } } } finally { monitor.done(); } }

Target:
protected void doExecute() { if (callback == null || session == null) { return; } try { int nbViewpointsInChange = (newSelectedViewpoints != null ? newSelectedViewpoints.size() + 1 : 0) + (newDeselectedViewpoints != null ? newDeselectedViewpoints.size() : 0); monitor.beginTask("Apply new viewpoints selection...", nbViewpointsInChange); if (newSelectedViewpoints != null) { List<Viewpoint> sorted = sortByDependencies(newSelectedViewpoints); monitor.worked(1); for (final Viewpoint viewpoint : sorted) { monitor.subTask("Select viewpoint : " + new IdentifiedElementQuery(viewpoint).getLabel()); try { callback.selectViewpoint(viewpoint, session, createNewRepresentations, new SubProgressMonitor(monitor, 1)); } catch (SecurityException e) { String errorMessage = "Unable to activate viewpoint '" + viewpoint.getName() + "' because of insufficient rights."; throw new SecurityException(errorMessage, e); } } } if (newDeselectedViewpoints != null) { for (final Viewpoint viewpoint : newDeselectedViewpoints) { monitor.subTask("Deselect viewpoint : " + new IdentifiedElementQuery(viewpoint).getLabel()); callback.deselectViewpoint(viewpoint, session, new SubProgressMonitor(monitor, 1)); } } } finally { monitor.done(); } }
Source:
public void toggleStars(final ToggleStarRequest req, final AsyncCallback<VoidResult> callback) { run(callback, new Action<VoidResult>() { public VoidResult run(final ReviewDb db) throws OrmException { final Account.Id me = getAccountId(); final Set<Change.Id> existing = currentUser.get().getStarredChanges(); List<StarredChange> add = new ArrayList<StarredChange>(); List<StarredChange.Key> remove = new ArrayList<StarredChange.Key>(); if (req.getAddSet() != null) { for (final Change.Id id : req.getAddSet()) { if (!existing.contains(id)) { StarredChange.Key key = new StarredChange.Key(me, id); add.add(new StarredChange(key)); } } } if (req.getRemoveSet() != null) { for (final Change.Id id : req.getRemoveSet()) { StarredChange.Key key = new StarredChange.Key(me, id); remove.add(key); } } db.starredChanges().insert(add); db.starredChanges().deleteKeys(remove); for (StarredChange sc : add) { starredChangesCache.evict(new StarredChange.Key(sc.getAccountId(), sc .getChangeId())); } for (StarredChange.Key key : remove) { starredChangesCache.evict(key); } return VoidResult.INSTANCE; } }); }

Target:
public void toggleStars(final ToggleStarRequest req, final AsyncCallback<VoidResult> callback) { run(callback, new Action<VoidResult>() { public VoidResult run(final ReviewDb db) throws OrmException { final Account.Id me = getAccountId(); final Set<Change.Id> existing = currentUser.get().getStarredChanges(); List<StarredChange> add = new ArrayList<StarredChange>(); List<StarredChange.Key> remove = new ArrayList<StarredChange.Key>(); if (req.getAddSet() != null) { for (final Change.Id id : req.getAddSet()) { if (!existing.contains(id)) { add.add(new StarredChange(new StarredChange.Key(me, id))); } } } if (req.getRemoveSet() != null) { for (final Change.Id id : req.getRemoveSet()) { remove.add(new StarredChange.Key(me, id)); } } db.starredChanges().insert(add); db.starredChanges().deleteKeys(remove); for (StarredChange sc : add) { starredChangesCache.evict(sc.getKey()); } for (StarredChange.Key key : remove) { starredChangesCache.evict(key); } return VoidResult.INSTANCE; } }); }
Source:
public void testListStudentAddresses() throws NoSuchFieldException { Response response = given().headers(getAuthHeaders()) .get("/students/students/{ID}/addresses", TEST_STUDENT_ID); if (roleIsAllowed(getRole(), studentPermissions, StudentPermissions.FEATURE_OWNED_GROUP_STUDENTS_RESTRICTION_TEST)) { assertOk(response, studentPermissions, StudentPermissions.LIST_STUDENTADDRESSS, 403); } else { assertOk(response, studentPermissions, StudentPermissions.LIST_STUDENTADDRESSS); } }

Target:
public void testListStudentAddresses() throws NoSuchFieldException { Response response = given().headers(getAuthHeaders()) .get("/students/students/{ID}/addresses", TEST_STUDENT_ID); if (roleIsAllowed(getRole(), studentPermissions, StudentPermissions.FEATURE_OWNED_GROUP_STUDENTS_RESTRICTION)) { assertOk(response, studentPermissions, StudentPermissions.LIST_STUDENTADDRESSS, 403); } else { assertOk(response, studentPermissions, StudentPermissions.LIST_STUDENTADDRESSS); } }
Source:
public static Config loadConfig(Config original) { JobConfig jobConfig = new JobConfig(original); Config fullConfig = original; if (jobConfig.getConfigLoaderFactory().isPresent()) { ConfigLoaderFactory factory = ReflectionUtil.getObj(jobConfig.getConfigLoaderFactory().get(), ConfigLoaderFactory.class); ConfigLoader loader = factory.getLoader(original.subset(ConfigLoaderFactory.CONFIG_LOADER_PROPERTIES_PREFIX)); fullConfig = override(ConfigUtil.rewriteConfig(loader.getConfig()), original); } return fullConfig; }

Target:
public static Config loadConfig(Config original) { JobConfig jobConfig = new JobConfig(original); if (!jobConfig.getConfigLoaderFactory().isPresent()) { throw new ConfigException("Missing key " + JobConfig.CONFIG_LOADER_FACTORY + "."); } ConfigLoaderFactory factory = ReflectionUtil.getObj(jobConfig.getConfigLoaderFactory().get(), ConfigLoaderFactory.class); ConfigLoader loader = factory.getLoader(original.subset(ConfigLoaderFactory.CONFIG_LOADER_PROPERTIES_PREFIX)); return rewriteConfig(override(loader.getConfig(), original)); }
Source:
public void testBlockwisePUTWithBegining413AndSmallerSZX() throws Exception { System.out.println("Blockwise PUT fails for excessive body size"); reqtPayload = generateRandomPayload(128 + 10); respPayload = generateRandomPayload(30); String path = "test"; Request request = createRequest(PUT, path, server); request.setPayload(reqtPayload); client.sendRequest(request); server.expectRequest(CON, PUT, path).storeBoth("A").block1(0, true, 128).size1(reqtPayload.length()).payload(reqtPayload, 0, 128).go(); server.sendResponse(ACK, REQUEST_ENTITY_TOO_LARGE).loadBoth("A").block1(0, false, 64).go(); server.expectRequest(CON, PUT, path).storeBoth("B").block1(0, true, 64).size1(reqtPayload.length()).payload(reqtPayload, 0, 64).go(); server.sendResponse(ACK, CONTINUE).loadBoth("B").block1(0, true, 64).go(); server.expectRequest(CON, PUT, path).storeBoth("C").block1(1, true, 64).payload(reqtPayload, 64, 128).go(); server.sendResponse(ACK, CONTINUE).loadBoth("C").block1(1, true, 64).go(); server.expectRequest(CON, PUT, path).storeBoth("D").block1(2, false, 64).payload(reqtPayload, 128, 138).go(); server.sendResponse(ACK, CHANGED).loadBoth("D").block1(2, false, 64).payload(respPayload).go(); Response response = request.waitForResponse(RESPONSE_TIMEOUT_IN_MS); assertResponseContainsExpectedPayload(response, CHANGED, respPayload); }

Target:
public void testBlockwisePUTWithBegining413AndSmallerSZX() throws Exception { System.out.println("Block1 with REQUEST_ENTITY_TOO_LARGE negotiation"); reqtPayload = generateRandomPayload(128 + 10); String path = "test"; Request request = createRequest(PUT, path, server); request.setPayload(reqtPayload); client.sendRequest(request); server.expectRequest(CON, PUT, path).storeBoth("A").block1(0, true, 128).size1(reqtPayload.length()).payload(reqtPayload, 0, 128).go(); server.sendResponse(ACK, REQUEST_ENTITY_TOO_LARGE).loadBoth("A").block1(0, false, 64).go(); server.expectRequest(CON, PUT, path).storeBoth("B").block1(0, true, 64).size1(reqtPayload.length()).payload(reqtPayload, 0, 64).go(); server.sendResponse(ACK, CONTINUE).loadBoth("B").block1(0, true, 64).go(); server.expectRequest(CON, PUT, path).storeBoth("C").block1(1, true, 64).payload(reqtPayload, 64, 128).go(); server.sendResponse(ACK, CONTINUE).loadBoth("C").block1(1, true, 64).go(); server.expectRequest(CON, PUT, path).storeBoth("D").block1(2, false, 64).payload(reqtPayload, 128, 138).go(); server.sendResponse(ACK, CHANGED).loadBoth("D").block1(2, false, 64).go(); Response response = request.waitForResponse(RESPONSE_TIMEOUT_IN_MS); assertThat(response, is(notNullValue())); assertThat(response.getPayloadSize(), is(0)); assertThat(response.getCode(), is(CHANGED)); assertThat(response.getToken(), is(request.getToken())); }
Source:
public CommCareSession(CommCarePlatform platform) { this.platform = platform; collectedDatums = new OrderedHashtable(); this.frame = new SessionFrame(); this.frameStack = new Stack<>(); }

Target:
public CommCareSession(CommCarePlatform platform) { this.platform = platform; collectedDatums = new OrderedHashtable(); this.frame = new SessionFrame(); this.frameStack = new Stack<SessionFrame>(); }
Source:
public SetPropertyTextResult setPropertyText(JsonRpcPeer peer, JSONObject params) { final SetPropertyTextRequest request = mObjectMapper.convertValue( params, SetPropertyTextRequest.class); final String[] parts = request.styleSheetId.split("\\.", 2); final int nodeId = Integer.parseInt(parts[0]); final String ruleName = parts[1]; final String[] keyValue = request.text.split(":", 2); final String key = keyValue[0].trim(); final String value = keyValue[1].replace(";", "").trim(); final SetPropertyTextResult result = new SetPropertyTextResult(); result.style = new CSSStyle(); result.style.styleSheetId = request.styleSheetId; result.style.cssProperties = new ArrayList<>(); result.style.shorthandEntries = Collections.emptyList(); mDocument.postAndWait(new Runnable() { @Override public void run() { final Object elementForNodeId = mDocument.getElementForNodeId(nodeId); if (elementForNodeId == null) { LogUtil.w("Failed to get style of an element that does not exist, nodeid=" + nodeId); return; } mDocument.setElementStyle(elementForNodeId, ruleName, key, value); mDocument.getElementStyles(elementForNodeId, ruleName, new StyleAccumulator() { @Override public void store(String name, String value, boolean isDefault) { final CSSProperty property = new CSSProperty(); property.name = name; property.value = value; result.style.cssProperties.add(property); } }); } }); return result; }

Target:
public SetPropertyTextResult setPropertyText(JsonRpcPeer peer, JSONObject params) { final SetPropertyTextRequest request = mObjectMapper.convertValue( params, SetPropertyTextRequest.class); final String[] parts = request.styleSheetId.split("\\.", 2); final int nodeId = Integer.parseInt(parts[0]); final String ruleName = parts[1]; final String value; final String key; if (" ".equals(request.text)) { key = null; value = null; } else { final String[] keyValue = request.text.split(":", 2); key = keyValue[0].trim(); value = StringUtil.removeAll(keyValue[1], ';').trim(); } final SetPropertyTextResult result = new SetPropertyTextResult(); result.style = new CSSStyle(); result.style.styleSheetId = request.styleSheetId; result.style.cssProperties = new ArrayList<>(); result.style.shorthandEntries = Collections.emptyList(); mDocument.postAndWait(new Runnable() { @Override public void run() { final Object elementForNodeId = mDocument.getElementForNodeId(nodeId); if (elementForNodeId == null) { LogUtil.w("Failed to get style of an element that does not exist, nodeid=" + nodeId); return; } if (key == null) { mDocument.setElementStyle(elementForNodeId, ruleName, key, value); } mDocument.getElementStyles(elementForNodeId, ruleName, new StyleAccumulator() { @Override public void store(String name, String value, boolean isDefault) { final CSSProperty property = new CSSProperty(); property.name = name; property.value = value; result.style.cssProperties.add(property); } }); } }); return result; }
Source:
public static DirectConnectionConfig getDefaultConfig() { return DirectConnectionConfig.defaultConfig; }

Target:
public static DirectConnectionConfig getDefaultConfig() { return new DirectConnectionConfig(); }
Source:
public void testPurgeExpired() throws Exception { long lifespan = 10000; cs.store(TestInternalCacheEntryFactory.create("k1", "v1", lifespan)); cs.store(TestInternalCacheEntryFactory.create("k2", "v2", lifespan)); cs.store(TestInternalCacheEntryFactory.create("k3", "v3", lifespan)); assert cs.containsKey("k1"); assert cs.containsKey("k2"); assert cs.containsKey("k3"); createUnrelatedFile(); Thread.sleep(lifespan + 100); cs.purgeExpired(); FileCacheStore fcs = (FileCacheStore) cs; assert fcs.load("k1") == null; assert fcs.load("k2") == null; assert fcs.load("k3") == null; }

Target:
public void testPurgeExpired() throws Exception { long start = now(); long lifespan = 1000; cs.store(TestInternalCacheEntryFactory.create("k1", "v1", lifespan)); cs.store(TestInternalCacheEntryFactory.create("k2", "v2", lifespan)); cs.store(TestInternalCacheEntryFactory.create("k3", "v3", lifespan)); assert cs.containsKey("k1") || moreThanLifespanElapsed(start, lifespan); assert cs.containsKey("k2") || moreThanLifespanElapsed(start, lifespan); assert cs.containsKey("k3") || moreThanLifespanElapsed(start, lifespan); createUnrelatedFile(); Thread.sleep(lifespan + 100); cs.purgeExpired(); FileCacheStore fcs = (FileCacheStore) cs; assert fcs.load("k1") == null; assert fcs.load("k2") == null; assert fcs.load("k3") == null; }
Source:
public RESULT onRecordBeforeCreate(ORecord iRecord) { RESULT result = RESULT.RECORD_NOT_CHANGED; if (!(iRecord instanceof ODocument)) { return result; } ODocument doc = (ODocument) iRecord; if ("ArtifactEntry".equals(doc.getClassName())) { doc.field("created", new Date()); result = RESULT.RECORD_CHANGED; } for (OClass oClass : doc.getSchemaClass().getAllSuperClasses()) { if ("GenericEntity".equals(oClass.getName())) { String uuid = doc.field("uuid"); if (uuid == null || uuid.trim().isEmpty()) { throw new OValidationException( String.format("Failed to persist document [%s]. UUID can't be empty or null.", doc.getSchemaClass())); } } else if ("ArtifactEntry".equals(oClass.getName())) { ODocument artifactCoordinates = doc.field("artifactCoordinates"); String artifactCoordinatesPath = artifactCoordinates == null ? "" : artifactCoordinates.field("path"); doc.field("created", new Date()); result = RESULT.RECORD_CHANGED; String artifactEntryPath = doc.field("artifactPath"); artifactEntryPath = artifactEntryPath == null ? "" : artifactEntryPath.trim(); if (artifactCoordinatesPath.trim().isEmpty() && artifactEntryPath.trim().isEmpty()) { throw new OValidationException( String.format("Failed to persist document [%s]. 'artifactPath' can't be empty or null.", doc.getSchemaClass())); } else if (artifactCoordinates != null && !artifactEntryPath.equals(artifactCoordinatesPath)) { throw new OValidationException( String.format("Failed to persist document [%s]. Paths [%s] and [%s] dont match.", doc.getSchemaClass(), artifactEntryPath, artifactCoordinatesPath)); } } } return result; }

Target:
public RESULT onRecordBeforeCreate(ORecord iRecord) { RESULT result = RESULT.RECORD_NOT_CHANGED; if (!(iRecord instanceof ODocument)) { return result; } ODocument doc = (ODocument) iRecord; if ("ArtifactEntry".equals(doc.getClassName())) { validateArtifactEntryCreatedProperty(doc); } for (OClass oClass : doc.getSchemaClass().getAllSuperClasses()) { if ("GenericEntity".equals(oClass.getName())) { String uuid = doc.field("uuid"); if (uuid == null || uuid.trim().isEmpty()) { throw new OValidationException( String.format("Failed to persist document [%s]. UUID can't be empty or null.", doc.getSchemaClass())); } } else if ("ArtifactEntry".equals(oClass.getName())) { ODocument artifactCoordinates = doc.field("artifactCoordinates"); String artifactCoordinatesPath = artifactCoordinates == null ? "" : artifactCoordinates.field("path"); String artifactEntryPath = doc.field("artifactPath"); artifactEntryPath = artifactEntryPath == null ? "" : artifactEntryPath.trim(); if (artifactCoordinatesPath.trim().isEmpty() && artifactEntryPath.trim().isEmpty()) { throw new OValidationException( String.format("Failed to persist document [%s]. 'artifactPath' can't be empty or null.", doc.getSchemaClass())); } else if (artifactCoordinates != null && !artifactEntryPath.equals(artifactCoordinatesPath)) { throw new OValidationException( String.format("Failed to persist document [%s]. Paths [%s] and [%s] dont match.", doc.getSchemaClass(), artifactEntryPath, artifactCoordinatesPath)); } validateArtifactEntryCreatedProperty(doc); } } return result; }
Source:
@Override public void onResponse(Call<AggregatedFeedContent> call, Response<AggregatedFeedContent> response) { if (response.isSuccessful()) { UtcDate date = DateUtil.getUtcRequestDateFor(age); List<Card> cards = new ArrayList<>(); AggregatedFeedContent content = response.body(); if (age == 0 && content.news() != null) { cards.add(new NewsListCard(content.news(), age, wiki)); } if (content.tfa() != null) { cards.add(new FeaturedArticleCard(content.tfa(), age, wiki)); } if (content.mostRead() != null) { cards.add(new MostReadListCard(content.mostRead(), wiki)); } if (content.potd() != null) { cards.add(new FeaturedImageCard(content.potd(), age, wiki)); } cb.success(cards); } else { L.v(response.message()); cb.error(new IOException(response.message())); } }

Target:
@Override public void onResponse(Call<AggregatedFeedContent> call, Response<AggregatedFeedContent> response) { if (response.isSuccessful()) { List<Card> cards = new ArrayList<>(); AggregatedFeedContent content = response.body(); if (age == 0 && content.news() != null) { cards.add(new NewsListCard(content.news(), age, wiki)); } if (content.tfa() != null) { cards.add(new FeaturedArticleCard(content.tfa(), age, wiki)); } if (content.mostRead() != null) { cards.add(new MostReadListCard(content.mostRead(), wiki)); } if (content.potd() != null) { cards.add(new FeaturedImageCard(content.potd(), age, wiki)); } cb.success(cards); } else { L.v(response.message()); cb.error(new IOException(response.message())); } }
Source:
public void testSetOwnerRole() throws Exception { String id = "0"; ShareableMetacardImpl before = ShareableMetacardImpl.from(ImmutableMap.of(Metacard.ID, id, Core.METACARD_OWNER, "user1")); ShareableMetacardImpl after = ShareableMetacardImpl.from(ImmutableMap.of(Metacard.ID, id, Core.METACARD_OWNER, "user2")); UpdateRequest update = mockUpdateRequest(ImmutableMap.of(id, after)); doReturn(true).when(subject).isPermitted(any(Permission.class)); accessPlugin.processPreUpdate(update, ImmutableMap.of(id, before)); }

Target:
public void testSetOwnerRole() throws Exception { String id = "0"; ShareableMetacardImpl before = ShareableMetacardImpl.create(ImmutableMap.of(Core.ID, id, Core.METACARD_OWNER, "user1")); ShareableMetacardImpl after = ShareableMetacardImpl.create(ImmutableMap.of(Core.ID, id, Core.METACARD_OWNER, "user2")); before.setTags(Collections.singleton(WorkspaceAttributes.WORKSPACE_TAG)); after.setTags(Collections.singleton(WorkspaceAttributes.WORKSPACE_TAG)); UpdateRequest update = mockUpdateRequest(ImmutableMap.of(id, after)); doReturn(true).when(subject).isPermitted(any(Permission.class)); accessPlugin.processPreUpdate(update, ImmutableMap.of(id, before)); }
Source:
public RassXmlAwardEntry toRassXmlAwardEntry() { RassXmlAwardEntry award = new RassXmlAwardEntry(); award.setProposalNumber(proposalNumber); award.setStatus(status); award.setAgencyNumber(agencyNumber); award.setProjectTitle(projectTitle); award.setStartDate(buildDateFromDateTime(startDate)); award.setStopDate(buildDateFromDateTime(stopDate)); award.setDirectCostAmount(directCostAmount); award.setIndirectCostAmount(indirectCostAmount); award.setTotalAmount(totalAmount); award.setPurpose(purpose); award.setGrantNumber(grantNumber); award.setGrantDescription(grantDescription); award.setFederalPassThrough(federalPassThrough); award.setFederalPassThroughAgencyNumber(federalPassThroughAgencyNumber); award.setOrganizationCode(organizationCode); award.setCostShareRequired(costShareRequired); award.setFinalReportDueDate(buildDateFromDateTime(finalReportDueDate)); award.setEverify(everify); award.setFinalFinancialReportRequired(finalFinancialReportRequired); award.setBudgetStartDate(buildDateFromDateTime(budgetStartDate)); award.setBudgetStopDate(buildDateFromDateTime(budgetStopDate)); award.setPricingType(pricingType); award.setPrimeAgreementNumber(primeAgreementNumber); for (RassXMLAwardPiCoPiEntryFixture fixture : piFixtures) { if (fixture.active) { award.getPrincipalAndCoPrincipalInvestigators().add(fixture.toRassXMLAwardPiCoPiEntry()); } } return award; }

Target:
public RassXmlAwardEntry toRassXmlAwardEntry() { RassXmlAwardEntry award = new RassXmlAwardEntry(); award.setProposalNumber(proposalNumber); award.setStatus(status); award.setAgencyNumber(agencyNumber); award.setProjectTitle(projectTitle); award.setStartDate(buildDateFromDateTime(startDate)); award.setStopDate(buildDateFromDateTime(stopDate)); award.setDirectCostAmount(directCostAmount); award.setIndirectCostAmount(indirectCostAmount); award.setTotalAmount(totalAmount); award.setPurpose(purpose); award.setGrantNumber(grantNumber); award.setGrantDescription(grantDescription); award.setFederalPassThrough(federalPassThrough); award.setFederalPassThroughAgencyNumber(federalPassThroughAgencyNumber); award.setOrganizationCode(organizationCode); award.setCostShareRequired(costShareRequired); award.setFinalReportDueDate(buildDateFromDateTime(finalReportDueDate)); award.setEverify(everify); award.setFinalFinancialReportRequired(finalFinancialReportRequired); award.setBudgetStartDate(buildDateFromDateTime(budgetStartDate)); award.setBudgetStopDate(buildDateFromDateTime(budgetStopDate)); award.setBudgetTotalAmount(budgetTotalAmount); award.setPricingType(pricingType); award.setPrimeAgreementNumber(primeAgreementNumber); for (RassXMLAwardPiCoPiEntryFixture fixture : piFixtures) { if (fixture.active) { award.getPrincipalAndCoPrincipalInvestigators().add(fixture.toRassXMLAwardPiCoPiEntry()); } } return award; }
Source:
public Map<String, String> getAttributes() { return attributes; }

Target:
public Map<String, String> getAttributes() { return this.attributes != null ? new MapView<String, String>(attributes) : null; }
Source:
protected abstract Collection<ThirdPartyDetails> createThirdPartyDetails() throws IOException, ThirdPartyToolException, ProjectBuildingException, MojoFailureException, InvalidDependencyVersionException, ArtifactNotFoundException, ArtifactResolutionException, DependenciesToolException, MojoExecutionException; protected void init() throws Exception { if ( licenseMergesUrl != null ) { if ( HttpRequester.isStringUrl( licenseMergesUrl ) ) { InputStream input = new URL( licenseMergesUrl ).openStream(); String httpRequestResult = IOUtil.toString( input ); licenseMerges = Arrays.asList( httpRequestResult.split( "\n" ) ); input.close(); } } }

Target:
protected abstract Collection<ThirdPartyDetails> createThirdPartyDetails() throws IOException, ThirdPartyToolException, ProjectBuildingException, MojoFailureException, InvalidDependencyVersionException, ArtifactNotFoundException, ArtifactResolutionException, DependenciesToolException, MojoExecutionException; protected void init() throws IOException { if ( licenseMergesUrl != null ) { getLog().warn( "" ); getLog().warn( "licenseMerges will be overridden by licenseMergesUrl." ); getLog().warn( "" ); if ( UrlRequester.isStringUrl( licenseMergesUrl ) ) { licenseMerges = Arrays.asList( UrlRequester.getFromUrl( licenseMergesUrl ) ); } } }
Source:
public void shouldReturnMusicList() { when(dao.searchSimilarTitle(music.getTitle())).thenReturn(Arrays.asList(music)); controller.search(music); assertEquals(Arrays.asList(music), result.included().get("musics")); }

Target:
public void shouldReturnMusicList() { when(dao.searchSimilarTitle(music.getTitle())).thenReturn(Arrays.asList(music)); controller.search(music); assertThat((List<Music>) result.included().get("musics"), contains(music)); }
Source:
private boolean canPerformInverseNavigation(EStructuralFeature feature){ return allowInverseNavigation && ( hasEOpposite(feature) || ( useIndex && modelComprehension.representable(feature) && (feature instanceof EReference) )); }

Target:
private boolean canPerformInverseNavigation(EStructuralFeature feature){ return ( hasEOpposite(feature) || ( useIndex && modelComprehension.representable(feature) && (feature instanceof EReference) )); }
Source:
public Response deleteItem(@Context HttpServletRequest request, @PathParam("id") String id, @QueryParam("deleteChildren") boolean deleteChildren) { Response response = null; try (ItemManager itemManager = new ItemManager()) { if(itemManager.isOrphan(id)){ if (itemManager.delete(id, deleteChildren)) { response = Response.ok().build(); } else { throw new Error(); } try (StatusManager statusMan = new StatusManager(); ThumbnailManager thumbMan = new ThumbnailManager()) { Status status = new Status(); status.setStatusName(Status.StatusName.ITEM_UPDATE); statusMan.save(status); thumbMan.updateDirtyBits(id); } } else { response = Response.status(400).build(); } } return response; }

Target:
public Response deleteItem(@Context HttpServletRequest request, @PathParam("id") String id, @QueryParam("deleteChildren") boolean deleteChildren) { Response response = null; try (ItemManager itemManager = new ItemManager()) { if(itemManager.isOrphan(id)){ if (itemManager.delete(id, deleteChildren, true)) { response = Response.ok().build(); } else { throw new Error(); } try (StatusManager statusMan = new StatusManager(); ThumbnailManager thumbMan = new ThumbnailManager()) { Status status = new Status(); status.setStatusName(Status.StatusName.ITEM_UPDATE); statusMan.save(status); thumbMan.updateDirtyBits(id); } } else { response = Response.status(400).build(); } } return response; }
Source:
public int getStateTableIndex(ITimeEvent event) { if (event instanceof TimeEvent && ((TimeEvent) event).hasValue()) { TimeEvent tcEvent = (TimeEvent) event; XmlEntry entry = (XmlEntry) event.getEntry(); int value = tcEvent.getValue(); if (entry.getType() == EntryDisplayType.DISPLAY) { int index = value % stateValues.size(); return index; } } if (event instanceof TimeEvent) { TimeEvent tcEvent = (TimeEvent) event; if (tcEvent.hasValue()) { return INVISIBLE; } } return TRANSPARENT; }

Target:
public int getStateTableIndex(ITimeEvent event) { if (event instanceof TimeEvent && ((TimeEvent) event).hasValue()) { TimeEvent tcEvent = (TimeEvent) event; XmlEntry entry = (XmlEntry) event.getEntry(); int value = tcEvent.getValue(); if (entry.getType() == EntryDisplayType.DISPLAY) { int index = value % stateValues.size(); return index; } } return INVISIBLE; }
Source:
public Optional<Long> ownerLevel() { return Optional.ofNullable(priority); }

Target:
public Long ownerLevel() { return ownerLevel; }