auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
private List<Properties> createInternalConfigurations() { List<Properties> results = new ArrayList<>(); Properties authConfig = new Properties(); authConfig.put(ExtensionManager.CLASS, "org.ovirt.extensions.builtin.ldapkerberos.LdapKerberosAuthenticator"); authConfig.put(ExtensionManager.PROVIDES, "org.ovirt.engine.core.authentication"); authConfig.put(ExtensionManager.ENABLED, true); authConfig.put(ExtensionManager.MODULE, "org.ovirt.engine.extensions.builtin"); authConfig.put(ExtensionManager.NAME, "builtin-authn-internal"); authConfig.put("org.ovirt.engine.aaa.authn.profile.name", "internal"); authConfig.put("ovirt.engine.aaa.authn.authz.plugin", "builitin-authz-internal"); results.add(authConfig); Properties dirConfig = new Properties(); dirConfig.put(ExtensionManager.CLASS, "org.ovirt.extensions.builtin.ldapkerberos.LdapKerberosDirectory"); dirConfig.put(ExtensionManager.PROVIDES, "org.ovirt.engine.core.authorization"); dirConfig.put(ExtensionManager.ENABLED, true); dirConfig.put(ExtensionManager.MODULE, "org.ovirt.engine.extensions.builtin"); dirConfig.put(ExtensionManager.NAME, "builtin-authz-internal"); dirConfig.put("org.ovirt.engine.aaa.authz.profile.name", "internal"); results.add(authConfig); return results; }

Target:
private List<Properties> createInternalConfigurations() { List<Properties> results = new ArrayList<>(); Properties authConfig = new Properties(); authConfig.put(ExtensionManager.CLASS, "org.ovirt.engine.extensions.aaa.builtin.internal.InternalAuthenticator"); authConfig.put(ExtensionManager.PROVIDES, "org.ovirt.engine.core.authentication"); authConfig.put(ExtensionManager.ENABLED, "true"); authConfig.put(ExtensionManager.MODULE, "org.ovirt.engine.extensions.builtin"); authConfig.put(ExtensionManager.NAME, "builtin-authn-internal"); authConfig.put("ovirt.engine.aaa.authn.profile.name", "internal"); authConfig.put("ovirt.engine.aaa.authn.authz.plugin", "builtin-authz-internal"); authConfig.put("ovirt.engine.aaa.authn.user", Config.<String> getValue(ConfigValues.AdminUser)); authConfig.put("ovirt.engine.aaa.authn.password", Config.<String> getValue(ConfigValues.AdminPassword)); results.add(authConfig); Properties dirConfig = new Properties(); dirConfig.put(ExtensionManager.CLASS, "org.ovirt.engine.extensions.aaa.builtin.internal.InternalDirectory"); dirConfig.put(ExtensionManager.PROVIDES, "org.ovirt.engine.core.authorization"); dirConfig.put(ExtensionManager.ENABLED, "true"); dirConfig.put(ExtensionManager.MODULE, "org.ovirt.engine.extensions.builtin"); dirConfig.put("ovirt.engine.aaa.authz.user", Config.<String> getValue(ConfigValues.AdminUser)); dirConfig.put(ExtensionManager.NAME, "builtin-authz-internal"); dirConfig.put("ovirt.engine.aaa.authz.profile.name", "internal"); results.add(dirConfig); return results; }
Source:
private String getIdForEvent(MuleEvent event) throws Exception { if (useSecureHash) { byte[] bytes; MuleMessage message = event.getMessage(); Object payload = message.getPayload(); if(Boolean.parseBoolean(System.getProperty("RollBackExceptionStrategy","false"))) { byte[] payloadBytes = (byte[]) objectToByteArray.transform(payload); bytes = concat(payloadBytes, message.getUniqueId().getBytes()); } else { bytes = (byte[]) objectToByteArray.transform(payload); } if (payload instanceof InputStream) { event.getMessage().setPayload(bytes); } MessageDigest md = MessageDigest.getInstance(messageDigestAlgorithm); byte[] digestedBytes = md.digest(bytes); return (String)byteArrayToHexString.transform(digestedBytes); } else { return event.getMuleContext().getExpressionManager().parse(idExpression, event, true); } }

Target:
private String getIdForEvent(MuleEvent event) throws Exception { if (useSecureHash) { byte[] bytes; MuleMessage message = event.getMessage(); Object payload = message.getPayload(); if(Boolean.parseBoolean(System.getProperty(MULE_FORCE_REDELIVERY,"false"))) { byte[] payloadBytes = (byte[]) objectToByteArray.transform(payload); bytes = concat(payloadBytes, message.getUniqueId().getBytes()); } else { bytes = (byte[]) objectToByteArray.transform(payload); } if (payload instanceof InputStream) { event.getMessage().setPayload(bytes); } MessageDigest md = MessageDigest.getInstance(messageDigestAlgorithm); byte[] digestedBytes = md.digest(bytes); return (String)byteArrayToHexString.transform(digestedBytes); } else { return event.getMuleContext().getExpressionManager().parse(idExpression, event, true); } }
Source:
public Response exit(final Response res, final Identity idt) throws IOException { final String text; if (idt.equals(Identity.ANONYMOUS)) { text = ""; } else { text = new String(this.codec.encode(idt)); } return new RsWithCookie( res, this.cookie, text, "Path=/", String.format( Locale.ENGLISH, "Expires=%1$ta, %1$td %1$tb %1$tY %1$tT GMT", new Date( System.currentTimeMillis() + TimeUnit.DAYS.toMillis(this.age) ) ), "HttpOnly" ); }

Target:
public Response exit(final Response res, final Identity idt) throws IOException { final String text; if (idt.equals(Identity.ANONYMOUS)) { text = ""; } else { text = new String(this.codec.encode(idt)); } return new RsWithCookie( res, this.cookie, text, "Path=/", "HttpOnly", String.format( Locale.ENGLISH, "Expires=%1$ta, %1$td %1$tb %1$tY %1$tT GMT", new Date( System.currentTimeMillis() + TimeUnit.DAYS.toMillis(this.age) ) ) ); }
Source:
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException { String failureUrlParam = StringUtil.cleanseUrlString(request.getParameter("failureUrl")); String successUrlParam = StringUtil.cleanseUrlString(request.getParameter("successUrl")); String failureUrl = failureUrlParam==null?null:failureUrlParam.trim(); boolean sessionTimeout = (Boolean) request.getAttribute("sessionTimeout"); if (StringUtils.isEmpty(failureUrl) && !sessionTimeout) { failureUrl = defaultFailureUrl; } if (sessionTimeout) { failureUrl = "?sessionTimeout=true"; } if (failureUrl != null) { if (!StringUtils.isEmpty(successUrlParam)) { if (!failureUrl.contains("?")) { failureUrl += "?successUrl=" + successUrlParam; } else { failureUrl += "&successUrl=" + successUrlParam; } } saveException(request, exception); getRedirectStrategy().sendRedirect(request, response, failureUrl); } else { super.onAuthenticationFailure(request, response, exception); } }

Target:
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException { String failureUrlParam = StringUtil.cleanseUrlString(request.getParameter("failureUrl")); String successUrlParam = StringUtil.cleanseUrlString(request.getParameter("successUrl")); String failureUrl = failureUrlParam==null?null:failureUrlParam.trim(); Boolean sessionTimeout = (Boolean) request.getAttribute("sessionTimeout"); if (StringUtils.isEmpty(failureUrl) && BooleanUtils.isNotTrue(sessionTimeout)) { failureUrl = defaultFailureUrl; } if (BooleanUtils.isTrue(sessionTimeout)) { failureUrl = "?sessionTimeout=true"; } successUrlParam = request.getHeader("referer"); if (failureUrl != null) { if (!StringUtils.isEmpty(successUrlParam)) { if (!failureUrl.contains("?")) { failureUrl += "?successUrl=" + successUrlParam; } else { failureUrl += "&successUrl=" + successUrlParam; } } saveException(request, exception); getRedirectStrategy().sendRedirect(request, response, failureUrl); } else { super.onAuthenticationFailure(request, response, exception); } }
Source:
private Map<String, Object> runCWLCommand(String cwlFile, String jsonSettings, String outputDir, String workingDir) { String[] s = {"cwltool","--enable-dev","--non-strict","--enable-net","--outdir", outputDir, "--tmpdir-prefix", workingDir, cwlFile, jsonSettings}; final ArrayList<String> extraFlags = (ArrayList)config.getList("cwltool-extra-parameters"); if (extraFlags.size() > 0) { System.out.println("########### WARNING ###########"); System.out.println("You are using extra flags for CWLtool which may not be supported. Use at your own risk."); } for (int i = 0; i < extraFlags.size(); i++) { extraFlags.set(i, extraFlags.get(i).trim()); System.out.println(extraFlags.get(i)); } ArrayList<String> newCommand = new ArrayList<>(Arrays.asList(s)); newCommand.addAll(1, extraFlags); final String joined = Joiner.on(" ").join(newCommand); System.out.println("Executing: " + joined); final ImmutablePair<String, String> execute = Utilities.executeCommand(joined); String stdout = execute.getLeft().replaceAll("(?m)^", "\t"); String stderr = execute.getRight().replaceAll("(?m)^", "\t"); final String cwltool = "cwltool"; outputIntegrationOutput(outputDir, execute, stdout, stderr, cwltool); Map<String, Object> obj = (Map<String, Object>)yaml.load(execute.getLeft()); return obj; }

Target:
private Map<String, Object> runCWLCommand(String cwlFile, String jsonSettings, String outputDir, String workingDir) { ArrayList<String> extraFlags = (ArrayList)config.getList("cwltool-extra-parameters"); if (extraFlags.size() > 0) { System.out.println("########### WARNING ###########"); System.out.println("You are using extra flags for CWLtool which may not be supported. Use at your own risk."); } extraFlags = (ArrayList)extraFlags.stream() .map(flag -> trimAndPrintInput(flag)) .collect(Collectors.toList()); ArrayList<String> command = new ArrayList<>(Arrays.asList("cwltool","--enable-dev","--non-strict","--enable-net","--outdir", outputDir, "--tmpdir-prefix", workingDir, cwlFile, jsonSettings)); command.addAll(1, extraFlags); final String joined = Joiner.on(" ").join(command); System.out.println("Executing: " + joined); final ImmutablePair<String, String> execute = Utilities.executeCommand(joined); String stdout = execute.getLeft().replaceAll("(?m)^", "\t"); String stderr = execute.getRight().replaceAll("(?m)^", "\t"); final String cwltool = "cwltool"; outputIntegrationOutput(outputDir, execute, stdout, stderr, cwltool); Map<String, Object> obj = (Map<String, Object>)yaml.load(execute.getLeft()); return obj; }
Source:
private void splitChunk(Scope chunk, int linePos) { Position chunkStart = chunk.getBodyStart(); Position chunkEnd = chunk.getEnd(); Position preamble = chunk.getPreamble(); String preambleLine = docDisplay_.getTextForRange(Range.create(preamble.getRow(), preamble.getColumn(), preamble.getRow() + 1, 0)); if (linePos < chunkStart.getRow()) linePos = chunkStart.getRow(); Range firstChunkRange = Range.create(chunkStart.getRow(), chunkStart.getColumn(), linePos, 0); String firstChunkContents = docDisplay_.getTextForRange(firstChunkRange); firstChunkContents = firstChunkContents.trim(); firstChunkContents = preambleLine + firstChunkContents; if (!firstChunkContents.endsWith("\n")) firstChunkContents += "\n"; firstChunkContents += "```\n\n"; Range secondChunkRange = Range.create(linePos, 0, chunkEnd.getRow(), chunkEnd.getColumn()); String secondChunkContents = docDisplay_.getTextForRange(secondChunkRange); secondChunkContents = secondChunkContents.trim(); secondChunkContents = preambleLine + secondChunkContents; Range chunkRange = Range.create(chunkStart.getRow() - 1, chunkStart.getColumn(), chunkEnd.getRow(), chunkEnd.getColumn()); docDisplay_.replaceRange(chunkRange, secondChunkContents); docDisplay_.setCursorPosition(Position.create(chunkStart.getRow() - 1, chunkStart.getColumn())); docDisplay_.insertCode(firstChunkContents, false); }

Target:
private void splitChunk(Scope chunk, int linePos) { Position chunkStart = chunk.getBodyStart(); Position chunkEnd = chunk.getEnd(); if (chunkEnd == null) chunkEnd = docDisplay_.getDocumentEnd(); Position preamble = chunk.getPreamble(); String preambleLine = docDisplay_.getLine(preamble.getRow()) + "\n"; if (linePos < chunkStart.getRow()) linePos = chunkStart.getRow(); Range firstChunkRange = Range.create(chunkStart.getRow(), chunkStart.getColumn(), linePos, 0); String firstChunkContents = docDisplay_.getTextForRange(firstChunkRange); firstChunkContents = firstChunkContents.trim(); firstChunkContents = preambleLine + firstChunkContents; if (!firstChunkContents.endsWith("\n")) firstChunkContents += "\n"; firstChunkContents += getChunkEnd() + "\n\n"; Range secondChunkRange = Range.create(linePos, 0, chunkEnd.getRow(), chunkEnd.getColumn()); String secondChunkContents = docDisplay_.getTextForRange(secondChunkRange); secondChunkContents = secondChunkContents.trim(); secondChunkContents = preambleLine + secondChunkContents; Range chunkRange = Range.create(chunkStart.getRow() - 1, chunkStart.getColumn(), chunkEnd.getRow(), chunkEnd.getColumn()); docDisplay_.replaceRange(chunkRange, secondChunkContents); docDisplay_.setCursorPosition(Position.create(chunkStart.getRow() - 1, chunkStart.getColumn())); docDisplay_.insertCode(firstChunkContents, false); }
Source:
public void start(StartContext context) throws StartException { try { httpAuthenticationFactory = checkNotNullParam("httpAuthenticationFactorySupplier", httpAuthenticationFactorySupplier).call(); } catch (Exception e) { throw new IllegalStateException(e); } }

Target:
public void start(StartContext context) throws StartException { httpAuthenticationFactory = httpAuthenticationFactorySupplier.get(); }
Source:
private void init() { setMasterVolume(new EntityModel<String>()); setSlaveVolume(new EntityModel<String>()); setSlaveHost(new EntityModel<String>()); setForce(new EntityModel<Boolean>()); setMessage(""); getForce().setEntity(false); }

Target:
private void init() { setMasterVolume(new EntityModel<String>()); setSlaveVolume(new EntityModel<String>()); setSlaveHost(new EntityModel<String>()); setForce(new EntityModel<Boolean>()); getForce().setEntity(false); }
Source:
public void metadataForNewTableIsLowerCased() { TableReference userTable = TableReference.createFromFullyQualifiedName("test.xXcOoLtAbLeNaMeXx"); byte[] originalMetadata = new TableMetadata( new NameMetadataDescription(), new ColumnMetadataDescription(), ConflictHandler.RETRY_ON_VALUE_CHANGED, TableMetadataPersistence.LogSafety.SAFE) .persistToBytes(); keyValueService.createTable(userTable, originalMetadata); assertThat(keyValueService.getMetadataForTables().keySet().stream() .anyMatch(tableRef -> tableRef.getQualifiedName().equals(userTable.getQualifiedName().toLowerCase())), is(true)); }

Target:
public void metadataForNewTableIsLowerCased() { TableReference userTable = TableReference.createFromFullyQualifiedName("test.xXcOoLtAbLeNaMeXx"); keyValueService.createTable(userTable, originalMetadata); assertThat(keyValueService.getMetadataForTables().keySet().stream() .anyMatch(tableRef -> tableRef.getQualifiedName().equals(userTable.getQualifiedName().toLowerCase())), is(true)); }
Source:
private Column<CallbackModel> createRefererColumn() { return new Column<CallbackModel>(String.class, Constant.messages.getString("callback.panel.table.column.referer")){ public Object getValue(CallbackModel model){ return model.getHttpMessage().getRequestHeader().getHeader("Referer"); } }; }

Target:
private static CustomColumn<CallbackRequest> createRefererColumn() { return new CustomColumn<CallbackRequest>(String.class, Constant.messages.getString("callback.panel.table.column.referer")){ @Override public Object getValue(CallbackRequest model){ return model.getReferer(); } }; }
Source:
public JsonResponse<T> handle(Request request, Response response) { byte[] bytes = readResponseBytes(response); String contentType = response.getHeader(CONTENT_TYPE); if ((contentType == null) || !SUPPORTED_MEDIA_TYPES.contains(MediaType.parse(contentType))) { return new JsonResponse<>(response.getStatusCode(), response.getStatusMessage(), response.getHeaders(), bytes); } return new JsonResponse<>(response.getStatusCode(), response.getStatusMessage(), response.getHeaders(), jsonCodec, bytes); }

Target:
public JsonResponse<T> handle(Request request, Response response) { byte[] bytes = readResponseBytes(response); String contentType = response.getHeader(CONTENT_TYPE); if ((contentType == null) || !MediaType.parse(contentType).is(MEDIA_TYPE_JSON)) { return new JsonResponse<T>(response.getStatusCode(), response.getStatusMessage(), response.getHeaders(), bytes); } return new JsonResponse(response.getStatusCode(), response.getStatusMessage(), response.getHeaders(), codec.get(), bytes); }
Source:
public void readConfigFromRestApi() { Log.v(TAG, "Reading config from REST ..."); asyncQueryVersionComplete = false; asyncQueryConfigComplete = false; asyncQuerySystemInfoComplete = false; new GetRequest(mContext, mUrl, GetRequest.URI_VERSION, mApiKey, null, result -> { JsonObject json = new JsonParser().parse(result).getAsJsonObject(); mVersion = json.get("version").getAsString(); Log.i(TAG, "Syncthing version is " + mVersion); updateDebugFacilitiesCache(); asyncQueryVersionComplete = true; checkReadConfigFromRestApiCompleted(); }); new GetRequest(mContext, mUrl, GetRequest.URI_CONFIG, mApiKey, null, result -> { onReloadConfigComplete(result); asyncQueryConfigComplete = true; checkReadConfigFromRestApiCompleted(); }); getSystemInfo(info -> { mLocalDeviceId = info.myID; asyncQuerySystemInfoComplete = true; checkReadConfigFromRestApiCompleted(); }); }

Target:
public void readConfigFromRestApi() { Log.v(TAG, "Reading config from REST ..."); synchronized (mAsyncQueryCompleteLock) { asyncQueryVersionComplete = false; asyncQueryConfigComplete = false; asyncQuerySystemInfoComplete = false; } new GetRequest(mContext, mUrl, GetRequest.URI_VERSION, mApiKey, null, result -> { JsonObject json = new JsonParser().parse(result).getAsJsonObject(); mVersion = json.get("version").getAsString(); Log.i(TAG, "Syncthing version is " + mVersion); updateDebugFacilitiesCache(); synchronized (mAsyncQueryCompleteLock) { asyncQueryVersionComplete = true; checkReadConfigFromRestApiCompleted(); } }); new GetRequest(mContext, mUrl, GetRequest.URI_CONFIG, mApiKey, null, result -> { onReloadConfigComplete(result); synchronized (mAsyncQueryCompleteLock) { asyncQueryConfigComplete = true; checkReadConfigFromRestApiCompleted(); } }); getSystemInfo(info -> { mLocalDeviceId = info.myID; synchronized (mAsyncQueryCompleteLock) { asyncQuerySystemInfoComplete = true; checkReadConfigFromRestApiCompleted(); } }); }
Source:
public void testCardinalityThreeColumns() { int blockSize = 3; long uniqueElts = 10000 * blockSize; String projection = getCardinalityProjection(getUniqueElements(blockSize, uniqueElts)); double error = uniqueElts * 0.05; functionAssertions.assertFunctionWithError(projection, BIGINT, uniqueElts, error); }

Target:
public void testCardinalityThreeColumns() { int blockSize = 3; long uniqueElements = 10000 * blockSize; double error = uniqueElements * 0.05; String projection = getCardinalityProjection(getUniqueElements(blockSize, uniqueElements)); functionAssertions.assertFunctionWithError(projection, BIGINT, uniqueElements, error); }
Source:
public void transactionCreation() { ByteBuffer transactionId = ByteBuffer.wrap(TRANSACTION_ID); AmqpTransaction actual = new AmqpTransaction(transactionId); assertNotNull(actual); actual.toString(); assertArrayEquals(TRANSACTION_ID, actual.getTransactionId().array()); }

Target:
public void transactionCreation() { ByteBuffer transactionId = ByteBuffer.wrap(TRANSACTION_ID); AmqpTransaction actual = new AmqpTransaction(transactionId); assertNotNull(actual); assertArrayEquals(TRANSACTION_ID, actual.getTransactionId().array()); }
Source:
private void findBNodesSyntax1() { Set<Node> rejects = new HashSet<>() ; Set<Node> blankNodesInTripleTerms = new HashSet<>(); ExtendedIterator<Triple> iter = find(ANY, ANY, ANY) ; try { for ( ; iter.hasNext() ; ) { Triple t = iter.next() ; Node subj = t.getSubject() ; Node obj = t.getObject() ; if ( subj.isBlank() ) { int sConn = inLinks(subj) ; if ( sConn == 0 && containedInOneGraph(subj) ) freeBnodes.add(subj) ; } else if ( subj.isNodeTriple() ) { extractBlankNodes(blankNodesInTripleTerms, subj); } if ( obj.isNodeTriple() ) { extractBlankNodes(blankNodesInTripleTerms, obj); continue; } if ( ! obj.isBlank() ) continue ; if ( rejects.contains(obj) ) continue ; int connectivity = inLinks(obj) ; if ( connectivity == 1 && containedInOneGraph(obj) ) { nestedObjects.add(obj) ; } else rejects.add(obj) ; } freeBnodes.removeAll(blankNodesInTripleTerms); nestedObjects.removeAll(blankNodesInTripleTerms); } finally { iter.close() ; } }

Target:
private void findBNodesSyntax1() { Set<Node> blankNodesInTripleTerms = new HashSet<>(); Set<Node> rejects = new HashSet<>() ; ExtendedIterator<Triple> iter = find(ANY, ANY, ANY) ; try { for ( ; iter.hasNext() ; ) { Triple t = iter.next() ; Node subj = t.getSubject() ; Node obj = t.getObject() ; if ( subj.isBlank() ) { int sConn = inLinks(subj) ; if ( sConn == 0 && containedInOneGraph(subj) ) freeBnodes.add(subj) ; } else if ( subj.isNodeTriple() ) { extractBlankNodesInTripleTerms(blankNodesInTripleTerms, subj); } if ( obj.isNodeTriple() ) { extractBlankNodesInTripleTerms(blankNodesInTripleTerms, obj); continue; } if ( ! obj.isBlank() ) continue ; if ( rejects.contains(obj) ) continue ; int connectivity = inLinks(obj) ; if ( connectivity == 1 && containedInOneGraph(obj) ) { nestedObjects.add(obj) ; } else rejects.add(obj) ; } freeBnodes.removeAll(blankNodesInTripleTerms); nestedObjects.removeAll(blankNodesInTripleTerms); } finally { iter.close() ; } }
Source:
private void writeObject(ObjectOutputStream out) throws IOException { writeNotNull(out, commit); writeNotNull(out, into); writeVarInt32(out, submitType.ordinal()); }

Target:
private void writeObject(ObjectOutputStream out) throws IOException { writeNotNull(out, commit); writeNotNull(out, into); writeEnum(out, submitType); }
Source:
private void startBackgroundTemperatureRefresh() { Runnable runnable = new Runnable() { @Override public void run() { try { getTemprature(); } catch (Exception e) { logger.debug("Exception occurred during execution: {}", e.getMessage(), e); } } }; refreshTemperatureJob = scheduler.scheduleAtFixedRate(runnable, 0, refresh.intValue(), TimeUnit.SECONDS); }

Target:
private void startBackgroundTemperatureRefresh() { Runnable runnable = new Runnable() { @Override public void run() { try { getTemperature(); } catch (Exception e) { logger.debug("Exception occurred during execution: {}", e.getMessage(), e); } } }; refreshTemperatureJob = scheduler.scheduleAtFixedRate(runnable, 0, refresh.intValue(), TimeUnit.SECONDS); }
Source:
public ModuleDeploymentProperties setCount(int count) { put(COUNT, "" + count); return this; }

Target:
public ModuleDeploymentProperties setCount(int count) { put(COUNT_KEY, String.valueOf(count)); return this; }
Source:
public void cache_instance_of_StorageFactory_in_testing() { Supplier<StorageFactory> testingSupplier = spy(inMemorySupplier); storageFactorySwitch.init(inMemorySupplier, testingSupplier); Environment.getInstance().setToTests(); storageFactorySwitch.get(); storageFactorySwitch.get(); verify(testingSupplier, times(1)).get(); }

Target:
public void cache_instance_of_StorageFactory_in_testing() { final Supplier<StorageFactory> testingSupplier = spy(inMemorySupplier); storageFactorySwitch.init(inMemorySupplier, testingSupplier); Environment.getInstance().setToTests(); storageFactorySwitch.get(); storageFactorySwitch.get(); verify(testingSupplier, times(1)).get(); }
Source:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_web_gui); mLoadingView = findViewById(R.id.loading); mConfig = new ConfigXml(this); loadCaCert(); mWebView = findViewById(R.id.webview); setWebViewProxy(mWebView.getContext().getApplicationContext(), "", 0, "localhost|0.0.0.0|127.*|[::1]"); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.setWebViewClient(mWebViewClient); mWebView.clearCache(true); }

Target:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_web_gui); mLoadingView = findViewById(R.id.loading); mConfig = new ConfigXml(this); loadCaCert(); mWebView = findViewById(R.id.webview); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setDomStorageEnabled(true); mWebView.setWebViewClient(mWebViewClient); mWebView.clearCache(true); }
Source:
private JobIdData submit(String sessionId, InputStream job, MediaType mediaType, Map<String, String> variables, Map<String, String> genericInfos) throws Exception { String uriTmpl = restEndpointURL + addSlashIfMissing(restEndpointURL) + "scheduler/submit"; ResteasyClient client = new ResteasyClientBuilder().httpEngine(httpEngine) .providerFactory(providerFactory) .build(); ResteasyWebTarget target = client.target(uriTmpl); if (variables != null) { for (String key : variables.keySet()) { target = target.matrixParam(key, variables.get(key)); } } if (genericInfos != null) { for (String key : genericInfos.keySet()) { target = target.queryParam(key, genericInfos.get(key)); } } MultipartFormDataOutput formData = new MultipartFormDataOutput(); formData.addFormData("file", job, mediaType); GenericEntity<MultipartFormDataOutput> entity = new GenericEntity<MultipartFormDataOutput>(formData) { }; Response response = target.request() .header("sessionid", sessionId) .post(Entity.entity(entity, MediaType.MULTIPART_FORM_DATA_TYPE)); if (response.getStatus() != HttpURLConnection.HTTP_OK) { if (response.getStatus() == HttpURLConnection.HTTP_UNAUTHORIZED) { throw new NotConnectedRestException("User not authenticated or session timeout."); } else { throwException(String.format("Job submission failed status code: %d", response.getStatus()), response); } } return response.readEntity(JobIdData.class); }

Target:
private JobIdData submit(String sessionId, InputStream job, MediaType mediaType, Map<String, String> variables, Map<String, String> genericInfos) throws NotConnectedRestException { String uriTmpl = restEndpointURL + addSlashIfMissing(restEndpointURL) + "scheduler/submit"; ResteasyClient client = new ResteasyClientBuilder().httpEngine(httpEngine) .providerFactory(providerFactory) .build(); ResteasyWebTarget target = client.target(uriTmpl); if (variables != null) { for (String key : variables.keySet()) { target = target.matrixParam(key, variables.get(key)); } } if (genericInfos != null) { for (String key : genericInfos.keySet()) { target = target.queryParam(key, genericInfos.get(key)); } } MultipartFormDataOutput formData = new MultipartFormDataOutput(); formData.addFormData("file", job, mediaType); GenericEntity<MultipartFormDataOutput> entity = new GenericEntity<MultipartFormDataOutput>(formData) { }; Response response = target.request() .header("sessionid", sessionId) .post(Entity.entity(entity, MediaType.MULTIPART_FORM_DATA_TYPE)); if (response.getStatus() != HttpURLConnection.HTTP_OK) { if (response.getStatus() == HttpURLConnection.HTTP_UNAUTHORIZED) { throw new NotConnectedRestException("User not authenticated or session timeout."); } else { throwException(String.format("Job submission failed status code: %d", response.getStatus()), response); } } return response.readEntity(JobIdData.class); }
Source:
public void saveVault(Player player, Inventory inventory) { if (plugin.getInVault().containsKey(player.getUniqueId().toString())) { Inventory inv = Bukkit.createInventory(null, 6 * 9); inv.setContents(inventory.getContents().clone()); if (inventory.getViewers().size() >= 1) { VaultViewInfo info = plugin.getInVault().get(player.getUniqueId().toString()); vaultManager.saveVault(inv, info.getHolderUUID(), info.getNumber()); plugin.getOpenInventories().remove(info.toString()); } plugin.getInVault().remove(player.getUniqueId().toString()); } }

Target:
public void saveVault(Player player, Inventory inventory) { if (plugin.getInVault().containsKey(player.getUniqueId().toString())) { Inventory inv = Bukkit.createInventory(null, 6 * 9); inv.setContents(inventory.getContents().clone()); if (inventory.getViewers().size() == 1) { VaultViewInfo info = plugin.getInVault().get(player.getUniqueId().toString()); vaultManager.saveVault(inv, info.getHolderUUID(), info.getNumber()); plugin.getOpenInventories().remove(info.toString()); } plugin.getInVault().remove(player.getUniqueId().toString()); } }
Source:
private void ensureExist(String path, String prop) throws IOException { Path folder = Paths.get(path); if (Files.notExists(folder)) { Files.createDirectory(folder); } if (!Files.isDirectory(folder)) { throw new IOException(String.format("Projects folder %s is invalid. Check %s configuration property.", path, prop)); } }

Target:
private void ensureExist(String path, String prop) throws IOException { Path folder = Paths.get(path); if (Files.notExists(folder)) { Files.createDirectory(folder); } if (!Files.isDirectory(folder)) { throw new IOException(String.format("Projects %s is not directory. Check %s configuration property.", path, prop)); } }
Source:
@Test public void listFilesTest() throws IOException { List<Object> expected = new ArrayList<>(); expectedPaths().forEach(expected::add); List<Object> actual = new ArrayList<>(); BundleGeneratorUtils.listFiles(DIRECTORY).forEach(actual::add); assert TestUtils.isMatching(expected, actual); }

Target:
public void listFilesTest() throws IOException { List<Object> expected = new ArrayList<>(); expectedPaths().forEach(expected::add); List<Object> actual = new ArrayList<>(); BundleGeneratorUtils.listFiles(DIRECTORY).forEach(actual::add); assert TestUtils.isMatching(expected, actual); }
Source:
public static long makeUUID(byte mateId, byte libraryId, long readId, int offset) { if (mateId != (mateId & ~(-1 << bitsForMate))) throw new IllegalArgumentException("byte specified for mateId will lose some of its bits when saved! (was: " + mateId + " but only allowed " + bitsForMate + " bits!"); if (libraryId != (libraryId & ~(-1 << bitsForLibrary))) throw new IllegalArgumentException("byte specified for libraryId will lose some of its bits when saved! (was: " + libraryId + " but only allowed " + bitsForLibrary + " bits!"); if (readId != (readId & ~(-1 << bitsForReadId))) throw new IllegalArgumentException("byte specified for readId will lose some of its bits when saved! (was: " + readId + " but only allowed " + bitsForReadId + " bits!"); if (offset != (offset & ~(-1 << bitsForLibrary))) throw new IllegalArgumentException("byte specified for offset will lose some of its bits when saved! (was: " + offset + " but only allowed " + offset + " bits!"); return ((mateId << mateIdShift) + (libraryId << libraryIdShift) + (readId << readIdShift) + (offset << offsetShift)); }

Target:
public static long makeUUID(byte mateId, byte libraryId, long readId, int offset) { if (mateId != (mateId & ~(-1 << bitsForMate))) throw new IllegalArgumentException("byte specified for mateId will lose some of its bits when saved! (was: " + mateId + " but only allowed " + bitsForMate + " bits!"); if (libraryId != (libraryId & ~(-1 << bitsForLibrary))) throw new IllegalArgumentException("byte specified for libraryId will lose some of its bits when saved! (was: " + libraryId + " but only allowed " + bitsForLibrary + " bits!"); if (readId != (readId & ~(-1 << bitsForReadId))) throw new IllegalArgumentException("byte specified for readId will lose some of its bits when saved! (was: " + readId + " but only allowed " + bitsForReadId + " bits!"); if (offset != (offset & ~(-1 << bitsForOffset))) throw new IllegalArgumentException("byte specified for offset will lose some of its bits when saved! (was: " + offset + " but only allowed " + offset + " bits!"); return ((offset << offsetShift) + (libraryId << libraryIdShift) + (mateId << mateIdShift) + (readId << readIdShift)); }
Source:
private Set<SignatureAlgorithm> parseAlgorithms(JWKSet jwkSet) { if (jwkSet == null) { return Collections.emptySet(); } List<JWK> jwks = new ArrayList<>(); for (JWK jwk : jwkSet.getKeys()) { KeyUse keyUse = jwk.getKeyUse(); if (keyUse != null && keyUse.equals(KeyUse.SIGNATURE)) { jwks.add(jwk); } } Set<SignatureAlgorithm> algorithms = new HashSet<>(); for (JWK jwk : jwks) { Algorithm algorithm = jwk.getAlgorithm(); if (algorithm != null) { SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.from(algorithm.getName()); if (signatureAlgorithm != null) { algorithms.add(signatureAlgorithm); } } } return algorithms; }

Target:
private Set<SignatureAlgorithm> parseAlgorithms(JWKSet jwkSet) { if (jwkSet == null) { throw new IllegalArgumentException(String.format("No JWKs received from %s", jwkSetUri)); } List<JWK> jwks = new ArrayList<>(); for (JWK jwk : jwkSet.getKeys()) { KeyUse keyUse = jwk.getKeyUse(); if (keyUse != null && keyUse.equals(KeyUse.SIGNATURE)) { jwks.add(jwk); } } Set<SignatureAlgorithm> algorithms = new HashSet<>(); for (JWK jwk : jwks) { Algorithm algorithm = jwk.getAlgorithm(); if (algorithm != null) { SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.from(algorithm.getName()); if (signatureAlgorithm != null) { algorithms.add(signatureAlgorithm); } } } return algorithms; }
Source:
public PsAll(final List<? extends Pass> passes, final int identity) { this.all = passes; this.index = identity; if (this.index < 0) { throw new IllegalArgumentException("Index must be >= 0"); } if (this.index >= this.all.size()) { throw new IllegalArgumentException( String.format( "Trying to return index %s from a list of %s passes", this.index, this.all.size() ) ); } }

Target:
public PsAll(final List<? extends Pass> passes, final int identity) { this.all = new ArrayList<Pass>(passes); this.index = identity; if (this.index < 0) { throw new IllegalArgumentException("Index must be >= 0"); } if (this.index >= this.all.size()) { throw new IllegalArgumentException( String.format( "Trying to return index %s from a list of %s passes", this.index, this.all.size() ) ); } }
Source:
public synchronized void incGeneration() { currentGeneration++; }

Target:
public void incGeneration() { currentGeneration.incrementAndGet(); }
Source:
public void testJmxRegistrationAtStartupAndStop(Method m) throws Exception { final String otherJmxDomain = getMethodSpecificJmxDomain(m, JMX_DOMAIN); CacheContainer otherContainer = TestCacheManagerFactory.createCacheManagerEnforceJmxDomain(otherJmxDomain, true, false); ObjectName otherName = getCacheManagerObjectName(otherJmxDomain); try { assertEquals("0", server.getAttribute(otherName, "CreatedCacheCount")); } finally { otherContainer.stop(); } try { server.getAttribute(otherName, "CreatedCacheCount").equals("0"); fail("Failure expected, " + otherName + " shouldn't be registered in mbean server"); } catch (InstanceNotFoundException e) { } }

Target:
public void testJmxRegistrationAtStartupAndStop(Method m) throws Exception { final String otherJmxDomain = getMethodSpecificJmxDomain(m, JMX_DOMAIN); CacheContainer otherContainer = TestCacheManagerFactory.createCacheManagerEnforceJmxDomain(otherJmxDomain, true, false); ObjectName otherName = getCacheManagerObjectName(otherJmxDomain); try { assertEquals("0", server.getAttribute(otherName, "CreatedCacheCount")); } finally { otherContainer.stop(); } Exceptions.expectException(InstanceNotFoundException.class, () -> server.getAttribute(otherName, "CreatedCacheCount")); }
Source:
public Path createDirectory(Path parent, String name, String... files) { Path directory = parent.resolve(name); try { java.nio.file.Files.createDirectory(directory); Arrays.stream(files) .forEach(f -> { try { java.nio.file.Files.createFile(directory.resolve(f)); } catch (IOException e) { assertThat(e).describedAs("Should not happen").isNull(); } }); } catch (IOException e) { assertThat(e).describedAs("Should not happen").isNull(); } return directory; }

Target:
public Path createDirectory(Path parent, String name, String... files) { Path directory = parent.resolve(name); try { java.nio.file.Files.createDirectory(directory); Arrays.stream(files) .forEach(f -> createFile(directory, f)); } catch (IOException e) { throw new UncheckedIOException("error during fixture directory creation", e); } return directory; }
Source:
public Page getOutput() { if ((state != State.FINISHING) || !finishFuture.isDone()) { return null; } state = State.FINISHED; Collection<Slice> fragments = getFutureValue(finishFuture); PageBuilder page = new PageBuilder(fragments.size() + 2, TYPES); BlockBuilder rowsBuilder = page.getBlockBuilder(0); BlockBuilder fragmentBuilder = page.getBlockBuilder(1); BlockBuilder operatorExecutionInfoBuilder = page.getBlockBuilder(2); page.declarePosition(); BIGINT.writeLong(rowsBuilder, rowCount); fragmentBuilder.appendNull(); operatorExecutionInfoBuilder.appendNull(); for (Slice fragment : fragments) { page.declarePosition(); rowsBuilder.appendNull(); VARBINARY.writeSlice(fragmentBuilder, fragment); operatorExecutionInfoBuilder.appendNull(); } page.declarePosition(); rowsBuilder.appendNull(); fragmentBuilder.appendNull(); TaskId taskId = operatorContext.getDriverContext().getPipelineContext().getTaskId(); OperatorExecutionContext operatorExecutionContext = new OperatorExecutionContext(operatorContext.getDriverContext().getLifespan(), taskId.getStageId().getId(), taskId.getId()); Slice operatorExecutionContextSlice = wrappedBuffer(OPERATOR_EXECUTION_CONTEXT_JSON_CODEC.toJsonBytes(operatorExecutionContext)); VARBINARY.writeSlice(operatorExecutionInfoBuilder, operatorExecutionContextSlice); return page.build(); }

Target:
public Page getOutput() { if ((state != State.FINISHING) || !finishFuture.isDone()) { return null; } state = State.FINISHED; Collection<Slice> fragments = getFutureValue(finishFuture); int positionCount = fragments.size() + 1; BlockBuilder rowsBuilder = BIGINT.createBlockBuilder(null, positionCount); BlockBuilder fragmentBuilder = VARBINARY.createBlockBuilder(null, positionCount); rowsBuilder.writeLong(rowCount); fragmentBuilder.appendNull(); for (Slice fragment : fragments) { rowsBuilder.appendNull(); VARBINARY.writeSlice(fragmentBuilder, fragment); } TaskId taskId = operatorContext.getDriverContext().getPipelineContext().getTaskId(); Slice tableCommitContext = wrappedBuffer(tableCommitContextCodec.toJsonBytes( new TableCommitContext( operatorContext.getDriverContext().getLifespan(), taskId.getStageId().getId(), taskId.getId(), false, true))); return new Page(positionCount, rowsBuilder.build(), fragmentBuilder.build(), RunLengthEncodedBlock.create(VARBINARY, tableCommitContext, positionCount)); }
Source:
static void printAndReset() { for (int size : memoryUsages.keySet()) { System.out.println(String.format("\nfor %d elements", size)); for (String usages : memoryUsages.get(size).get()) { System.out.println("\t" + usages); } } memoryUsages = memoryUsages.dropWhile(v -> true); }

Target:
static void printAndReset() { for (int size : memoryUsages.keySet()) { System.out.println(String.format("\nfor %d elements", size)); for (String usages : memoryUsages.get(size).get()) { System.out.println("\t" + usages); } } memoryUsages = memoryUsages.take(0); }
Source:
public <T> T[] toArray(@Nullable T[] a) { if (a == null) { throw new IllegalArgumentException(); } fLock.readLock().lock(); try { int size = size(); @SuppressWarnings("unchecked") final @NonNull T[] ret = checkNotNull((T[]) Array.newInstance(a.getClass().getComponentType(), size)); int i = 0; for (E elem : this) { @SuppressWarnings("unchecked") T arrayElem = (T) elem; ret[i++] = arrayElem; } return ret; } finally { fLock.readLock().unlock(); } }

Target:
public <T> T[] toArray(@Nullable T[] a) { fLock.readLock().lock(); try { return checkNotNull(fStartTimesIndex.values().toArray(a)); } finally { fLock.readLock().unlock(); } }
Source:
private void updateController() { this.controller = modelProvider.getModel(); final GridTimer modelTimer = getModelTimer(); final boolean wasTimerActive = modelTimer.isActive(); if (statusUpdateHandlerRegistration != null) { statusUpdateHandlerRegistration.removeHandler(); } statusUpdateHandlerRegistration = modelTimer.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { onRefresh(modelTimer.getValue()); } }); if (wasTimerActive) { modelTimer.start(); } }

Target:
private void updateController() { this.controller = modelProvider.getModel(); updateTimer(); }
Source:
public void testSplitColumnInvalidType() throws DbException { final Schema schema = new Schema(ImmutableList.of(Type.LONG_TYPE), ImmutableList.of("long")); final TupleBatchBuffer input = new TupleBatchBuffer(schema); input.putLong(0, 1L); Split splitOp = new Split(new TupleSource(input), 0, ":"); splitOp.open(TestEnvVars.get()); splitOp.close(); }

Target:
public void testSplitColumnInvalidType() throws DbException { final Schema schema = Schema.ofFields("long", Type.LONG_TYPE); final TupleBatchBuffer input = new TupleBatchBuffer(schema); input.putLong(0, 1L); Split splitOp = new Split(new TupleSource(input), 0, ":"); splitOp.open(TestEnvVars.get()); }
Source:
public static String getVolumeName(String userName) { Objects.nonNull(userName); return DigestUtils.md5Hex(userName); }

Target:
public static String getVolumeName(String userName) { Objects.requireNonNull(userName); return DigestUtils.md5Hex(userName); }
Source:
public List<ITmfStateInterval> queryHistoryRange(int attributeQuark, long t1, long t2, long resolution, IProgressMonitor monitor) throws TimeRangeException, AttributeNotFoundException, StateSystemDisposedException { if (isDisposed) { throw new StateSystemDisposedException(); } List<ITmfStateInterval> intervals; ITmfStateInterval currentInterval; long ts, tEnd; IProgressMonitor mon = monitor; if (mon == null) { mon = new NullProgressMonitor(); } if (t2 < t1 || resolution <= 0) { throw new TimeRangeException(); } if (t2 > this.getCurrentEndTime()) { tEnd = this.getCurrentEndTime(); } else { tEnd = t2; } intervals = new ArrayList<>(); currentInterval = querySingleState(t1, attributeQuark); intervals.add(currentInterval); for (ts = t1; ts < tEnd; ts += ((currentInterval.getEndTime() - ts) / resolution + 1) * resolution) { if (mon.isCanceled()) { return intervals; } currentInterval = querySingleState(ts, attributeQuark); intervals.add(currentInterval); } if (currentInterval.getEndTime() < tEnd) { currentInterval = querySingleState(tEnd, attributeQuark); intervals.add(currentInterval); } return intervals; }

Target:
public List<ITmfStateInterval> queryHistoryRange(int attributeQuark, long t1, long t2, long resolution, IProgressMonitor monitor) throws TimeRangeException, AttributeNotFoundException, StateSystemDisposedException { if (isDisposed) { throw new StateSystemDisposedException(); } List<ITmfStateInterval> intervals = new LinkedList<>(); ITmfStateInterval currentInterval; long ts, tEnd; IProgressMonitor mon = monitor; if (mon == null) { mon = new NullProgressMonitor(); } if (t2 < t1 || resolution <= 0) { throw new TimeRangeException(); } if (t2 > this.getCurrentEndTime()) { tEnd = this.getCurrentEndTime(); } else { tEnd = t2; } for (ts = t1; ts <= tEnd; ts += ((currentInterval.getEndTime() - ts) / resolution + 1) * resolution) { if (mon.isCanceled()) { return intervals; } currentInterval = querySingleState(ts, attributeQuark); intervals.add(currentInterval); } return intervals; }
Source:
public IPropertyDescriptor[] getPropertyDescriptors() { Map<String, String> envVariables = getTraceProperties(); if (!envVariables.isEmpty()) { IPropertyDescriptor[] propertyDescriptorArray = new IPropertyDescriptor[envVariables.size()+sfDescriptors.length]; int index =0; for (Map.Entry<String, String> varName : envVariables.entrySet()) { ReadOnlyTextPropertyDescriptor descriptor = new ReadOnlyTextPropertyDescriptor(varName.getKey(), varName.getKey()); descriptor.setCategory(sfTracePropertiesCategory); propertyDescriptorArray[index] = descriptor; index++; } for(int i=0; i<sfDescriptors.length; i++) { propertyDescriptorArray[index] = sfDescriptors[i]; index++; } return propertyDescriptorArray; } return Arrays.copyOf(sfDescriptors, sfDescriptors.length); }

Target:
public IPropertyDescriptor[] getPropertyDescriptors() { Map<String, String> traceProperties = getTraceProperties(); if (!traceProperties.isEmpty()) { IPropertyDescriptor[] propertyDescriptorArray = new IPropertyDescriptor[traceProperties.size() + sfDescriptors.length]; int index = 0; for (Map.Entry<String, String> varName : traceProperties.entrySet()) { ReadOnlyTextPropertyDescriptor descriptor = new ReadOnlyTextPropertyDescriptor(this.getName() + "_" + varName.getKey(), varName.getKey()); descriptor.setCategory(sfTracePropertiesCategory); propertyDescriptorArray[index] = descriptor; index++; } for (int i = 0; i < sfDescriptors.length; i++) { propertyDescriptorArray[index] = sfDescriptors[i]; index++; } return propertyDescriptorArray; } return Arrays.copyOf(sfDescriptors, sfDescriptors.length); }
Source:
public static void hl7v2MessageList(String hl7v2StoreName) throws IOException { CloudHealthcare client = createClient(); String pageToken = null; try { Messages.List request = client .projects() .locations() .datasets() .hl7V2Stores() .messages() .list(hl7v2StoreName) .setPageSize(100) .setPageToken(pageToken); ListMessagesResponse response; do { response = request.execute(); if (response.getHl7V2Messages() == null) { continue; } System.out.printf("Retrieved %s HL7v2 messages: \n", response.getHl7V2Messages().size()); for (Message message : response.getHl7V2Messages()) { System.out.println("\t" + message); } request.setPageToken(response.getNextPageToken()); } while (response.getNextPageToken() != null); } catch (IOException e) { System.out.println("Unable to list HL7v2 messages: \n" + e.toString()); } }

Target:
public static void hl7v2MessageList(String hl7v2StoreName) throws IOException { CloudHealthcare client = createClient(); String pageToken = null; try { Messages.List request = client .projects() .locations() .datasets() .hl7V2Stores() .messages() .list(hl7v2StoreName) .setPageSize(100) .setPageToken(pageToken); ListMessagesResponse response; do { response = request.execute(); if (response.getHl7V2Messages() == null) { continue; } System.out.printf("Retrieved %s HL7v2 messages: \n", response.getHl7V2Messages().size()); for (Message message : response.getHl7V2Messages()) { System.out.println("\t" + message); } request.setPageToken(response.getNextPageToken()); } while (response.getNextPageToken() != null); } catch (IOException e) { System.out.println("Unable to list HL7v2 messages:" + e.toString()); } }
Source:
public void ValidationStereotypesListClass3Test() { EList<Stereotype> appliedStereotypes = class3.getAppliedStereotypes(); List<Stereotype> expectedStereotypes = new ArrayList<Stereotype>(); expectedStereotypes.add(stereotype1); expectedStereotypes.add(stereotype3); assertEquals(appliedStereotypes, expectedStereotypes); }

Target:
public void ValidationStereotypesListClass3Test() { EList<Stereotype> appliedStereotypes = class3.getAppliedStereotypes(); List<Stereotype> expectedStereotypes = new ArrayList<Stereotype>(); expectedStereotypes.add(stereotype1); expectedStereotypes.add(stereotype3); assertEquals("The stereotypes applied on the class must be the same as the expected stereotypes.", appliedStereotypes, expectedStereotypes); }
Source:
protected void compute(CoreSession session, List<String> ids, Map<String, Serializable> properties) { Map<String, Serializable> actualProperties = new HashMap<>(properties); String eventId = (String) actualProperties.remove(NOTIFY); Collection<DocumentRef> refs = ids.stream().map(IdRef::new).collect(Collectors.toList()); ids.forEach(id -> actualProperties.forEach((k, v) -> session.setDocumentSystemProp(new IdRef(id), k, v))); session.save(); if (eventId != null) { EventService eventService = Framework.getService(EventService.class); DocumentModelList docs = session.getDocuments(refs.toArray(new DocumentRef[refs.size()])); docs.forEach(d -> { DocumentEventContext ctx = new DocumentEventContext(session, session.getPrincipal(), d); ctx.setProperties(new HashMap<>(d.getContextData())); ctx.setCategory(DocumentEventCategories.EVENT_DOCUMENT_CATEGORY); ctx.setProperty(CoreEventConstants.REPOSITORY_NAME, session.getRepositoryName()); ctx.setProperty(CoreEventConstants.SESSION_ID, session.getSessionId()); Event event = ctx.newEvent(eventId); event.setInline(false); event.setImmediate(false); eventService.fireEvent(event); }); } }

Target:
protected void compute(CoreSession session, List<String> ids, Map<String, Serializable> properties) { Map<String, Serializable> actualProperties = new HashMap<>(properties); String eventId = (String) actualProperties.remove(NOTIFY); Collection<DocumentRef> refs = ids.stream().map(IdRef::new).collect(Collectors.toList()); ids.forEach(id -> actualProperties.forEach((k, v) -> session.setDocumentSystemProp(new IdRef(id), k, v))); session.save(); if (eventId != null) { fireEvent(session, eventId, refs); } }