auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public void terminateTest(String testID) { logger.info("terminateTest: " + testID); try { BenchFlowTestState testState = testModelDAO.getTestState(testID); logger.info("Current status: " + testState); switch (testState) { case READY: readyQueue.remove(testID); cancelTask(testID); testModelDAO.setTestState(testID, TERMINATED); testModelDAO.setTestTerminatedState(testID, TestTerminatedState.PARTIALLY_COMPLETE); break; case WAITING: case START: cancelTask(testID); testModelDAO.setTestState(testID, TERMINATED); testModelDAO.setTestTerminatedState(testID, TestTerminatedState.PARTIALLY_COMPLETE); break; case RUNNING: TestRunningState runningState = testModelDAO.getTestRunningState(testID); testModelDAO.setTestRunningState(testID, TestRunningState.TERMINATING); cancelTask(testID); if (runningState == TestRunningState.HANDLE_EXPERIMENT_RESULT || runningState == TestRunningState.DETERMINE_EXECUTE_VALIDATION_SET) { logger.info("Need to execute AbortRunningTask"); AbortRunningTestTask abortRunningTestTask = new AbortRunningTestTask(testID); Future abortRunningTestTaskFuture = taskExecutorService.submit(abortRunningTestTask); try { abortRunningTestTaskFuture.get(); } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); } } <START> handleRunningTest(testID); <END> break; case TERMINATED: break; default: break; } } catch (BenchFlowTestIDDoesNotExistException e) { e.printStackTrace(); } }</code><technical_language>possibly another iteration of outer while loop,</technical_language>

Target:
public void terminateTest(String testID) { logger.info("terminateTest: " + testID); try { BenchFlowTestState testState = testModelDAO.getTestState(testID); logger.info("Current status: " + testState); switch (testState) { case READY: readyQueue.remove(testID); cancelTask(testID); testModelDAO.setTestState(testID, TERMINATED); testModelDAO.setTestTerminatedState(testID, TestTerminatedState.PARTIALLY_COMPLETE); break; case WAITING: case START: cancelTask(testID); testModelDAO.setTestState(testID, TERMINATED); testModelDAO.setTestTerminatedState(testID, TestTerminatedState.PARTIALLY_COMPLETE); break; case RUNNING: TestRunningState runningState = testModelDAO.getTestRunningState(testID); testModelDAO.setTestRunningState(testID, TestRunningState.TERMINATING); cancelTask(testID); if (runningState == TestRunningState.HANDLE_EXPERIMENT_RESULT || runningState == TestRunningState.DETERMINE_EXECUTE_VALIDATION_SET) { logger.info("Need to execute AbortRunningTask"); AbortRunningTestTask abortRunningTestTask = new AbortRunningTestTask(testID); Future abortRunningTestTaskFuture = taskExecutorService.submit(abortRunningTestTask); try { abortRunningTestTaskFuture.get(); } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); } } else { handleRunningTest(testID); } break; case TERMINATED: break; default: break; } } catch (BenchFlowTestIDDoesNotExistException e) { e.printStackTrace(); } }
Source:
<code>public VariantContextBuilder(final VariantContext parent) { <START> if( parent == null ) throw new IllegalArgumentException("BUG: VariantContextBuilder parent argument cannot be null in VariantContextBuilder"); <END> this.alleles = parent.getAlleles(); this.contig = parent.getContig(); this.genotypes = parent.getGenotypes(); this.ID = parent.getID(); this.log10PError = parent.getLog10PError(); this.source = parent.getSource(); this.start = parent.getStart(); this.stop = parent.getEnd(); this.fullyDecoded = parent.isFullyDecoded(); this.attributes(parent.getAttributes()); if (parent.filtersWereApplied()) { this.filters(parent.getFilters()); } else { this.unfiltered(); } }</code><technical_language>fix whitespace, format lines if (parent == null) { throw new ...; }</technical_language>

Target:
public VariantContextBuilder(final VariantContext parent) { if (parent == null) { throw new IllegalArgumentException("BUG: VariantContextBuilder parent argument cannot be null in VariantContextBuilder"); } this.alleles = parent.getAlleles(); this.contig = parent.getContig(); this.genotypes = parent.getGenotypes(); this.ID = parent.getID(); this.log10PError = parent.getLog10PError(); this.source = parent.getSource(); this.start = parent.getStart(); this.stop = parent.getEnd(); this.fullyDecoded = parent.isFullyDecoded(); this.attributes(parent.getAttributes()); if (parent.filtersWereApplied()) { this.filters(parent.getFilters()); } else { this.unfiltered(); } }
Source:
<code>protected Pair<Long, Long> getProcMemoryRequirement() throws Exception { String strXms = getInitialMemorySize(); String strXmx = getMaxMemorySize(); long xms = azkaban.utils.Utils.parseMemString(strXms); long xmx = azkaban.utils.Utils.parseMemString(strXmx); Props azkabanProperties = AzkabanServer.getAzkabanProperties(); if (azkabanProperties != null) { String maxXms = azkabanProperties.getString(DirectoryFlowLoader.JOB_MAX_XMS, DirectoryFlowLoader.MAX_XMS_DEFAULT); String maxXmx = azkabanProperties.getString(DirectoryFlowLoader.JOB_MAX_XMX, DirectoryFlowLoader.MAX_XMX_DEFAULT); <START> long sizeMaxXms = azkaban.utils.Utils.parseMemString(maxXms); <END> long sizeMaxXmx = azkaban.utils.Utils.parseMemString(maxXmx); if (xms > sizeMaxXms) { throw new Exception(String.format("%s: Xms value has exceeded the allowed limit (max Xms = %s)", getId(), maxXms)); } if (xmx > sizeMaxXmx) { throw new Exception(String.format("%s: Xmx value has exceeded the allowed limit (max Xmx = %s)", getId(), maxXms)); } } return new Pair<Long, Long>(xms, xmx); }</code><technical_language>reason need complete package name here</technical_language>

Target:
protected Pair<Long, Long> getProcMemoryRequirement() throws Exception { String strXms = getInitialMemorySize(); String strXmx = getMaxMemorySize(); long xms = Utils.parseMemString(strXms); long xmx = Utils.parseMemString(strXmx); Props azkabanProperties = AzkabanServer.getAzkabanProperties(); if (azkabanProperties != null) { String maxXms = azkabanProperties.getString(DirectoryFlowLoader.JOB_MAX_XMS, DirectoryFlowLoader.MAX_XMS_DEFAULT); String maxXmx = azkabanProperties.getString(DirectoryFlowLoader.JOB_MAX_XMX, DirectoryFlowLoader.MAX_XMX_DEFAULT); long sizeMaxXms = Utils.parseMemString(maxXms); long sizeMaxXmx = Utils.parseMemString(maxXmx); if (xms > sizeMaxXms) { throw new Exception(String.format("%s: Xms value has exceeded the allowed limit (max Xms = %s)", getId(), maxXms)); } if (xmx > sizeMaxXmx) { throw new Exception(String.format("%s: Xmx value has exceeded the allowed limit (max Xmx = %s)", getId(), maxXms)); } } return new Pair<Long, Long>(xms, xmx); }
Source:
<code>private void clickElement(final String selector) { Actions builder = new Actions(driver); builder.contextClick(wait.forElementClickable(By.cssSelector(selector))) .moveToElement(driver.findElement(By.cssSelector(selector))) <START> .click(wait.forElementClickable(By.cssSelector(selector))) <END> .perform(); }</code><technical_language>is reason wait for element if clickable? Is element in line [#184](<LINK_0></technical_language>

Target:
private void clickElement(final String selector) { WebElement element = wait.forElementClickable(By.cssSelector(selector)); Actions builder = new Actions(driver); builder.contextClick(element) .moveToElement(element) .click(element) .perform(); }
Source:
<code>private void buildInitialIndex() throws CorruptIndexException, IOException { Document meta = new Document(); <START> meta.add(new StringField(F_VERSION, VERSION, Store.YES)); <END> writer.addDocument(meta); writer.commit(); }</code><technical_language>StringFields indexed. need this here. this a StoredField</technical_language>

Target:
private void buildInitialIndex() throws CorruptIndexException, IOException { Document meta = new Document(); meta.add(new StoredField(F_VERSION, VERSION)); writer.addDocument(meta); writer.commit(); }
Source:
<code>public LzoGenericBlockRecordReader(TypeRef<M> typeRef, BinaryConverter<M> binaryConverter) { super(typeRef, new BinaryBlockReader(null, binaryConverter), new GenericWritable<M>(binaryConverter)); <START> LOG.info("LzoGenericBlockRecordReader, type args are " + typeRef.getRawClass()); <END> }</code><technical_language>kill</technical_language>

Target:
public LzoGenericBlockRecordReader(TypeRef<M> typeRef, BinaryConverter<M> binaryConverter) { super(typeRef, new BinaryBlockReader(null, binaryConverter), new GenericWritable<M>(binaryConverter)); }
Source:
<code>public void executeQueryFromFileZeroStatements() throws IOException { HiveShell shell = createHiveShell(); shell.start(); String hql = ""; File file = new File(tempFolder.getRoot(), "script.hql"); Files.write(hql, file, UTF_8); @SuppressWarnings("unused") <START> List<String> results = shell.executeQuery(UTF_8, Paths.get(file.toURI()), "xxx", "yyy"); <END> }</code><technical_language>Remove unused variable declaration annotation is needed</technical_language>

Target:
public void executeQueryFromFileZeroStatements() throws IOException { HiveShell shell = createHiveShell(); shell.start(); String hql = ""; File file = new File(tempFolder.getRoot(), "script.hql"); Files.write(hql, file, UTF_8); shell.executeQuery(UTF_8, Paths.get(file.toURI()), "xxx", "yyy"); }
Source:
<code>public void createKieSessionFromSimpleDrlAndFireRules() { String drl = "package " + RULE_PKG_NAME + ";\n" + "\n" + "rule \"Dummy rule\"\n" + "when\n" + " String( this == \"MyValue\" )\n" + "then\n" + " System.out.println(\"Rule fired!\");\n" + "end"; KieHelper kieHelper = new KieHelper(); kieHelper.addContent(drl, ResourceType.DRL); KieBase kieBase = kieHelper.build(); Assert.assertFalse("At least one KiePackage expected!", kieBase.getKiePackages().isEmpty()); <START> KiePackage testRulePackage = null; <END> for (KiePackage kiePackage : kieBase.getKiePackages()) { if (RULE_PKG_NAME.equals(kiePackage.getName())) { testRulePackage = kiePackage; } } if (testRulePackage == null) { Assert.fail("Expected KiePackage " + RULE_PKG_NAME + " not found in " + kieBase.getKiePackages()); } KieSession kieSession = kieBase.newKieSession(); kieSession.insert("MyValue"); int rulesFired = kieSession.fireAllRules(); Assert.assertEquals("Unexpected number of rules fired!", 1, rulesFired); }</code><technical_language>opt for a 1-liner if this is for Java 8 like: assertTrue( kieBase.getKiePackages().stream().anyMatch(kp -> RULE_PKG_NAME.equals(kp.getName())) ); if prefer</technical_language>

Target:
public void createKieSessionFromSimpleDrlAndFireRules() { String drl = "package " + RULE_PKG_NAME + ";\n" + "\n" + "rule \"Dummy rule\"\n" + "when\n" + " String( this == \"MyValue\" )\n" + "then\n" + " System.out.println(\"Rule fired!\");\n" + "end"; KieHelper kieHelper = new KieHelper(); kieHelper.addContent(drl, ResourceType.DRL); KieBase kieBase = kieHelper.build(); Assert.assertFalse("At least one KiePackage expected!", kieBase.getKiePackages().isEmpty()); Assert.assertTrue("Expected KiePackage " + RULE_PKG_NAME + " not found in " + kieBase.getKiePackages(), kieBase.getKiePackages().stream().anyMatch(kp -> RULE_PKG_NAME.equals(kp.getName())) ); KieSession kieSession = kieBase.newKieSession(); kieSession.insert("MyValue"); int rulesFired = kieSession.fireAllRules(); Assert.assertEquals("Unexpected number of rules fired!", 1, rulesFired); }
Source:
<code>public void mockCreateCharge() { String payload = TestTemplateResourceLoader.load(STRIPE_AUTHORISATION_SUCCESS_RESPONSE); <START> paymentServiceResponse(payload, "/v1/charges", APPLICATION_JSON); <END> }</code><technical_language>payload APPLICATION_FORM_URLENCODED Stripe API <LINK_0></technical_language>

Target:
public void mockCreateCharge() { String payload = TestTemplateResourceLoader.load(STRIPE_AUTHORISATION_SUCCESS_RESPONSE); paymentServiceResponse(payload, "/v1/charges", APPLICATION_FORM_URLENCODED); }
Source:
<code>public void parseOptions(String prefix, OptionSet options) { if ( options.has(prefix + "host")) this.host = (String) options.valueOf(prefix + "host"); if ( options.has(prefix + "password")) this.password = (String) options.valueOf(prefix + "password"); if ( options.has(prefix + "user")) this.user = (String) options.valueOf(prefix + "user"); if ( options.has(prefix + "port")) this.port = Integer.valueOf((String) options.valueOf(prefix + "port")); if ( options.has(prefix + "jdbc_options") ) { <START> String[] opts = ((String) options.valueOf(prefix + "jdbc_options")).replaceAll("\\s+", "").split(","); <END> for ( String opt : opts ) { this.jdbc_options.add(opt); } } }</code><technical_language>replace leading trailing whitespace. Also: leave options ampersand separated</technical_language>

Target:
public void parseOptions(String prefix, OptionSet options) { if ( options.has(prefix + "host")) this.host = (String) options.valueOf(prefix + "host"); if ( options.has(prefix + "password")) this.password = (String) options.valueOf(prefix + "password"); if ( options.has(prefix + "user")) this.user = (String) options.valueOf(prefix + "user"); if ( options.has(prefix + "port")) this.port = Integer.valueOf((String) options.valueOf(prefix + "port")); if ( options.has(prefix + "jdbc_options") ) { String[] opts = ((String) options.valueOf(prefix + "jdbc_options")).split("&"); for ( String opt : opts ) { this.jdbc_options.add(opt.trim()); } } }
Source:
<code>public Response act(final Request req) throws IOException { int attempts = 0; IOException exeption = new IOException(); while (attempts < this.count) { try { return this.take.act(req); } catch (final IOException ex) { <START> attempts = attempts + 1; <END> exeption = ex; this.sleep(); } } throw exeption; }</code><technical_language>@HDouss ++attempts</technical_language>

Target:
public Response act(final Request req) throws IOException { if (this.count <= 0) { throw new IllegalArgumentException( "can't make less than one attempt" ); } int attempts = 0; final List<IOException> failures = new ArrayList<IOException>(this.count); while (attempts < this.count) { try { return this.take.act(req); } catch (final IOException ex) { ++attempts; failures.add(ex); this.sleep(); } } throw new IOException( String.format( "failed after %d attempts: %s", failures.size(), TkRetry.strings(failures) ), failures.get(failures.size() - 1) ); }
Source:
<code>private void refreshReposIfNeeded(Guid storageDomainId, ImageFileType imageType, boolean forceRefresh) { AtomicLong lastRefreshed = domainsLastRefreshedTime.computeIfAbsent(storageDomainId, k -> new AtomicLong(-1)); if (forceRefresh || shouldInvalidateCache(lastRefreshed.longValue())) { synchronized (lastRefreshed) { if (forceRefresh || shouldInvalidateCache(lastRefreshed.longValue())) { boolean refreshSucceeded = refreshRepos(storageDomainId, imageType); lastRefreshed.set(System.currentTimeMillis()); if <START> (forceRefresh && !refreshSucceeded) <END> { throw new EngineException(EngineError.IMAGES_NOT_SUPPORTED_ERROR); } } } } }</code><technical_language>want throw this exception if refresh succeed, of refresh</technical_language>

Target:
private void refreshReposIfNeeded(Guid storageDomainId, ImageFileType imageType, boolean forceRefresh) { MutableLong lastRefreshed = domainsLastRefreshedTime.computeIfAbsent(storageDomainId, k -> new MutableLong(-1)); if (forceRefresh || shouldInvalidateCache(lastRefreshed.longValue())) { synchronized (lastRefreshed) { if (forceRefresh || shouldInvalidateCache(lastRefreshed.longValue())) { boolean refreshSucceeded = refreshRepos(storageDomainId, imageType); lastRefreshed.setValue(System.currentTimeMillis()); if (forceRefresh && !refreshSucceeded) { throw new EngineException(EngineError.IMAGES_NOT_SUPPORTED_ERROR); } } } } }
Source:
<code><START> private boolean isNextSequenceForUnresolvedPartition(TopicPartition topicPartition, int sequence) { <END> if (this.hasUnresolvedSequence(topicPartition)) { return sequence == this.partitionsWithUnresolvedSequences.get(topicPartition); } return false; }</code><technical_language>simplified as: hasUnresolvedSequence(topicPartition) && sequence == this.partitionsWithUnresolvedSequences.get(topicPartition)</technical_language>

Target:
private boolean isNextSequenceForUnresolvedPartition(TopicPartition topicPartition, int sequence) { return this.hasUnresolvedSequence(topicPartition) && sequence == this.partitionsWithUnresolvedSequences.get(topicPartition); }
Source:
<code>private void addConfigsAndUpload(TestExecutionBuilder testExecutionBuilder, Report report, Report.Test test, PerfRepoClient perfRepoClient) throws Exception { addNormalizedConfigs(report, testExecutionBuilder); TestExecution testExecution = testExecutionBuilder.build(); if (testExecution.getParameters() != null) { for (TestExecutionParameter parameter : testExecution.getParameters()) { String value = parameter.getValue(); if (value != null && value.length() > 2047) { <START> parameter.setValue(value.substring(0, 2044) + "..."); <END> } } } try { Long executionId = perfRepoClient.createTestExecution(testExecution); if (executionId == null) { logAndThrowTestExecutionFailure(testExecution); } uploadAttachments(report, perfRepoClient, executionId); } catch (Exception e) { throw new Exception("Error while creating test execution for test " + test.name, e); } }</code><technical_language>nit: good explanation magic numbers</technical_language>

Target:
private void addConfigsAndUpload(TestExecutionBuilder testExecutionBuilder, Report report, Report.Test test, PerfRepoClient perfRepoClient) throws Exception { addNormalizedConfigs(report, testExecutionBuilder); TestExecution testExecution = testExecutionBuilder.build(); if (testExecution.getParameters() != null) { for (TestExecutionParameter parameter : testExecution.getParameters()) { String value = parameter.getValue(); if (value != null && value.length() > MAX_VALUE_LENGTH) { parameter.setValue(value.substring(0, MAX_VALUE_LENGTH - 3) + "..."); } } } try { Long executionId = perfRepoClient.createTestExecution(testExecution); if (executionId == null) { logAndThrowTestExecutionFailure(testExecution); } uploadAttachments(report, perfRepoClient, executionId); } catch (Exception e) { throw new Exception("Error while creating test execution for test " + test.name, e); } }
Source:
<code>public void testWriteToTsv() throws NoSuchMethodException, IOException { List<@NonNull ISegment> fixture = new ArrayList<>(); for (int i = 1; i <= 20; i++) { int start = i; final int delta = i; int end = start + delta * delta; fixture.add(new SystemCall(new SystemCall.InitialInfo(start, <START> "left_pack"), <END> end)); } assertNotNull(fTable); fTable.updateModel(fixture); SWTBotTable tableBot = new SWTBotTable(fTable.getTableViewer().getTable()); SWTBot bot = new SWTBot(); bot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "1", 0, 2)); SWTWorkbenchBot swtWorkbenchBot = new SWTWorkbenchBot(); SWTBotView viewBot = swtWorkbenchBot.viewById(VIEW_ID); List<String> actionResult = Arrays.asList(testToTsv(viewBot)); String absolutePath = TmfTraceManager.getTemporaryDirPath() + File.separator + "syscallLatencyTest.testWriteToTsv.tsv"; TmfFileDialogFactory.setOverrideFiles(absolutePath); SWTBotMenu menuBot = viewBot.viewMenu().menu("Export to TSV"); try { assertTrue(menuBot.isEnabled()); assertTrue(menuBot.isVisible()); menuBot.click(); try (BufferedReader br = new BufferedReader(new FileReader(absolutePath))) { List<String> lines = br.lines().collect(Collectors.toList()); assertEquals("Both reads", actionResult, lines); } } finally { new File(absolutePath).delete(); } }</code><technical_language>actual system call is leftpad :p</technical_language>

Target:
public void testWriteToTsv() throws NoSuchMethodException, IOException { List<@NonNull ISegment> fixture = new ArrayList<>(); for (int i = 1; i <= 20; i++) { int start = i; final int delta = i; int end = start + delta * delta; fixture.add(new SystemCall(new SystemCall.InitialInfo(start, (start %3 != 0) ? "leftpad" : "rightpad"), end)); } assertNotNull(fTable); fTable.updateModel(fixture); SWTBotTable tableBot = new SWTBotTable(fTable.getTableViewer().getTable()); SWTBot bot = new SWTBot(); bot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "1", 0, 2)); SWTWorkbenchBot swtWorkbenchBot = new SWTWorkbenchBot(); SWTBotView viewBot = swtWorkbenchBot.viewById(VIEW_ID); List<String> actionResult = Arrays.asList(testToTsv(viewBot)); String absolutePath = TmfTraceManager.getTemporaryDirPath() + File.separator + "syscallLatencyTest.testWriteToTsv.tsv"; TmfFileDialogFactory.setOverrideFiles(absolutePath); SWTBotMenu menuBot = viewBot.viewMenu().menu("Export to TSV"); try { assertTrue(menuBot.isEnabled()); assertTrue(menuBot.isVisible()); menuBot.click(); try (BufferedReader br = new BufferedReader(new FileReader(absolutePath))) { List<String> lines = br.lines().collect(Collectors.toList()); assertEquals("Both reads", actionResult, lines); } } finally { new File(absolutePath).delete(); } }
Source:
<code>@Test public void testCoalesceWithoutWriting() { tester(false, new JdbcTest.HrSchema()) .query("?") .withRel( builder -> builder .scan("s", "emps") .project(builder.field(4)) .filter( builder.call(SqlStdOperatorTable.GREATER_THAN_OR_EQUAL, builder.call(SqlStdOperatorTable.COALESCE, builder.field(0), builder.literal(0)), builder.literal(500))) .build() ) .planContains("" + " public boolean moveNext() {\n" + " while (inputEnumerator.moveNext()) {\n" + " final Integer inp4_ = (Integer) ((Object[]) inputEnumerator.current())[4];\n" + " if ((inp4_ != null ? inp4_.intValue() : 0) >= 500) {\n" + " return true;\n" + " }\n" + " }\n" + " return false;\n" <START> + " }") <END> .returnsUnordered( "commission=500", "commission=1000"); }</code><technical_language>Ah, if (null) is compiling, thanks for this fix</technical_language>

Target:
@Test public void testCoalesceWithoutWriting() { CalciteAssert.that() .with(CalciteConnectionProperty.FORCE_DECORRELATE, false) .withSchema("s", new ReflectiveSchema(new JdbcTest.HrSchema())) .query("?") .withRel( builder -> builder .scan("s", "emps") .project(builder.field(4)) .filter( builder.call(SqlStdOperatorTable.GREATER_THAN_OR_EQUAL, builder.call(SqlStdOperatorTable.COALESCE, builder.field(0), builder.literal(0)), builder.literal(500))) .build() ) .planContains("" + " public boolean moveNext() {\n" + " while (inputEnumerator.moveNext()) {\n" + " final Integer inp4_ = (Integer) ((Object[]) inputEnumerator.current())[4];\n" + " if ((inp4_ != null ? inp4_.intValue() : 0) >= 500) {\n" + " return true;\n" + " }\n" + " }\n" + " return false;\n" + " }") .returnsUnordered( "commission=500", "commission=1000"); }
Source:
<code>public void setFailCaseString(String failCaseString) { if (failCaseString == null) { throw new IllegalArgumentException("failCaseString is null"); } <START> if (!"".equals(failCaseString)) { <END> Config.failCaseString = failCaseString; this.failCaseString = failCaseString; } }</code><technical_language>isEmpty mentioned above</technical_language>

Target:
void setFailCaseString(String failCaseString) { if(failCaseString == null) { throw new IllegalArgumentException("failCaseString is null"); } if(failCaseString.isEmpty()) { throw new IllegalArgumentException("failCaseString is empty"); } Config.failCaseString = failCaseString; this.failCaseString = failCaseString; getConfig().setProperty(FAIL_CASE_STRING, failCaseString); }
Source:
<code>public void queryPageWithComplexStartEndKeyAndJsonArrayValue() { init(); View query = db.view("example/creator_boolean_total") .startKey("uuid" ,false, 1) .endKey("uuid" ,false, 2000); Page page = null; <START> try { <END> page = query.queryPage(30, null, Object.class); } catch (Exception e) { e.printStackTrace(); } assertThat(page.getResultList().size(), is(1)); }</code><technical_language>Remove try/catch again</technical_language>

Target:
public void queryPageWithComplexStartEndKeyAndJsonArrayValue() { init(); View query = db.view("example/creator_boolean_total") .startKey("uuid" ,true, 1) .endKey("uuid" ,true, 2000); Page page = query.queryPage(30, null, Object.class); assertThat(page.getResultList().size(), is(2)); Gson gson = new Gson(); ArrayList<JsonArray> expectedJsonArray = new ArrayList<JsonArray>(), actualJsonArray = new ArrayList<JsonArray>(); for(int i = 0; i < page.getResultList().size(); i++) { JsonArray expectedArray = new JsonArray(); expectedArray.add(gson.toJsonTree("key-" + (i + 2))); expectedArray.add(gson.toJsonTree(10.009999999999999787 + i + 1)); expectedJsonArray.add(expectedArray); JsonArray actualArray = new JsonArray(); JsonElement jsonTitleValue = (gson.toJsonTree(page.getResultList().get(i))) .getAsJsonObject().get("title"); actualArray.add(jsonTitleValue); JsonElement jsonTotalValue = (gson.toJsonTree(page.getResultList().get(i))) .getAsJsonObject().get("contentArray").getAsJsonArray().get(0) .getAsJsonObject().get("total"); actualArray.add(jsonTotalValue); actualJsonArray.add(actualArray); } assertJsonArrayKeysAndValues(expectedJsonArray, actualJsonArray); }
Source:
<code>public void testSingleItemObject() { abvsResult.reset(); try { ob.reset(abvsResult); getTaggedValuePointable("id", tvp1); getTaggedValuePointable(1, tvp2); ob.addItem(tvp1, tvp2); ob.finish(); } catch (IOException e) { Assert.fail("Test failed to write the object pointable."); } tvp.set(abvsResult); if (tvp.getTag() != ValueTag.OBJECT_TAG) { Assert.fail("Type tag is incorrect. Expected: " + ValueTag.OBJECT_TAG + " Got: " + tvp.getTag()); } tvp.getValue(op); if (op.getEntryCount() != 1) { Assert.fail("Object size is incorrect. Expected: 1 Got: " + op.getEntryCount()); } try { op.getKeys(tvp); } catch (SystemException e) { Assert.fail("Test failed to write the object pointable."); } if (tvp.getTag() != ValueTag.XS_STRING_TAG) { Assert.fail("Type tag is incorrect. Expected: " + ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag()); } <START> if (!FunctionHelper.arraysEqual(tvp, tvp1)) { <END> Assert.fail("Key is incorrect. Expected: id"); } op.getValue(tvp1, tvp); if (!FunctionHelper.arraysEqual(tvp, tvp2)) { Assert.fail("Value is incorrect for the given key."); } }</code><technical_language>Give tvp1 names describe data represents: key (tvpKey1, etc.)</technical_language>

Target:
public void testSingleItemObject() { abvsResult.reset(); try { ob.reset(abvsResult); getTaggedValuePointable("id", false, tvpKey1); getTaggedValuePointable(1, tvpValue1); ob.addItem(tvpKey1, tvpValue1); ob.finish(); } catch (IOException e) { Assert.fail("Test failed to write the object pointable."); } tvp.set(abvsResult); if (tvp.getTag() != ValueTag.OBJECT_TAG) { Assert.fail("Type tag is incorrect. Expected: " + ValueTag.OBJECT_TAG + " Got: " + tvp.getTag()); } tvp.getValue(op); if (op.getEntryCount() != 1) { Assert.fail("Object size is incorrect. Expected: 1 Got: " + op.getEntryCount()); } try { op.getKeys(tvp); } catch (IOException e) { Assert.fail("Test failed to write the object pointable."); } if (tvp.getTag() != ValueTag.XS_STRING_TAG) { Assert.fail("Type tag is incorrect. Expected: " + ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag()); } if (!compareKeys(tvp, tvpKey1)) { Assert.fail("Key is incorrect. Expected: id"); } if (!op.getValue(tvpKey1, tvp)) { Assert.fail("Value not found for the given key:id"); } if (!FunctionHelper.arraysEqual(tvp, tvpValue1)) { Assert.fail("Value is incorrect for the given key. Expected: 1 with valuetag: " + ValueTag.XS_INT_TAG + " Got valuetag: " + tvp.getTag()); } }
Source:
<code>private void init() { _phaseListeners = new LinkedList<PhaseListener>(ZKBinderPhaseListeners.getSystemPhaseListeners()); String clz = Library.getProperty(PHASE_LISTENER_CLASS_KEY); if (!Strings.isEmpty(clz)) { try { addPhaseListener((PhaseListener) Classes.forNameByThread(clz).newInstance()); } catch (Exception e) { _log.error("Error when initial phase listener:" + clz, e); } } <START> Executions.getCurrent().getDesktop().getWebApp().getConfiguration().registerCallBack("destroy", new DestroyCallback()); <END> }</code><technical_language>Beware of NPE</technical_language>

Target:
private void init() { _phaseListeners = new LinkedList<PhaseListener>(ZKBinderPhaseListeners.getSystemPhaseListeners()); String clz = Library.getProperty(PHASE_LISTENER_CLASS_KEY); if (!Strings.isEmpty(clz)) { try { addPhaseListener((PhaseListener) Classes.forNameByThread(clz).newInstance()); } catch (Exception e) { _log.error("Error when initial phase listener:" + clz, e); } } }
Source:
<code>public void define(String title, final RbDefinition.Callback cb) { Call<Map<String, RbDefinition.Usage[]>> call = webService.define(title); call.enqueue(new Callback<Map<String, RbDefinition.Usage[]>>() { @Override public void onResponse(Call<Map<String, RbDefinition.Usage[]>> call, Response<Map<String, RbDefinition.Usage[]>> response) { if (response.isSuccessful()) { if (response.body() == null) { <START> cb.success(null); <END> return; } responseHeaderHandler.onHeaderCheck(response); cb.success(new RbDefinition(response.body())); } else { Throwable throwable = RetrofitException.httpError(response, retrofit); RbSwitch.INSTANCE.onRbRequestFailed(throwable); cb.failure(throwable); } } @Override public void onFailure(Call<Map<String, RbDefinition.Usage[]>> call, Throwable throwable) { RbSwitch.INSTANCE.onRbRequestFailed(throwable); cb.failure(throwable); } }); }</code><technical_language>this failure</technical_language>

Target:
public void define(String title, final RbDefinition.Callback cb) { Call<Map<String, RbDefinition.Usage[]>> call = webService.define(title); call.enqueue(new Callback<Map<String, RbDefinition.Usage[]>>() { @Override public void onResponse(Call<Map<String, RbDefinition.Usage[]>> call, Response<Map<String, RbDefinition.Usage[]>> response) { if (response.isSuccessful()) { if (response.body() == null) { cb.failure(new JsonParseException("Response missing required fields")); return; } responseHeaderHandler.onHeaderCheck(response); cb.success(new RbDefinition(response.body())); } else { Throwable throwable = RetrofitException.httpError(response, retrofit); RbSwitch.INSTANCE.onRbRequestFailed(throwable); cb.failure(throwable); } } @Override public void onFailure(Call<Map<String, RbDefinition.Usage[]>> call, Throwable throwable) { RbSwitch.INSTANCE.onRbRequestFailed(throwable); cb.failure(throwable); } }); }
Source:
<code>public final void rightClickBlock(GlowPlayer player, GlowBlock against, BlockFace face, ItemStack holding, Vector clickedLoc) { GlowBlock target = against.getRelative(face); GlowBlockState newState = target.getState(); <START> BlockSlab.SlabPlaceable slabplaceable = BlockSlab.isSlabPlaceable(player, target, against, face, holding); <END> if (against.getType() == Material.LONG_GRASS || slabplaceable == BlockSlab.SlabPlaceable.AGAINSTBLOCK) { target = against; newState = target.getState(); } else if (!target.isEmpty() && !target.isLiquid() && slabplaceable == BlockSlab.SlabPlaceable.NO) { return; } if (!EventFactory.onBlockCanBuild(target, getId(), face).isBuildable()) { return; } placeBlock(player, newState, face, holding, clickedLoc); BlockPlaceEvent event = EventFactory.onBlockPlace(target, newState, against, player); if (event.isCancelled() || !event.canBuild()) { return; } newState.update(true); target.getWorld().playSound(target.getLocation(), Sound.DIG_WOOD, 1, 1); afterPlace(player, target, holding); if (player.getGameMode() != GameMode.CREATIVE) { holding.setAmount(holding.getAmount() - 1); } }</code><technical_language>Incorrect capitalization variable name</technical_language>

Target:
public final void rightClickBlock(GlowPlayer player, GlowBlock against, BlockFace face, ItemStack holding, Vector clickedLoc) { GlowBlock target = against.getRelative(face); GlowBlockState newState = target.getState(); if (canAbsorb(against, face, holding, false)) { target = against; newState = target.getState(); } else if (!target.isEmpty() && !target.isLiquid()) { if (!canAbsorb(target, face.getOppositeFace(), holding, true)) { return; } } if (!EventFactory.onBlockCanBuild(target, getId(), face).isBuildable()) { return; } placeBlock(player, newState, face, holding, clickedLoc); BlockPlaceEvent event = EventFactory.onBlockPlace(target, newState, against, player); if (event.isCancelled() || !event.canBuild()) { return; } newState.update(true); target.getWorld().playSound(target.getLocation(), Sound.DIG_WOOD, 1, 1); afterPlace(player, target, holding); if (player.getGameMode() != GameMode.CREATIVE) { holding.setAmount(holding.getAmount() - 1); } }
Source:
<code>private static boolean isX86(IVMInstall vm) { <START> return (vm instanceof AbstractVMInstall) && PlatformUtil.ARCH_X86.equals(PreferencesUtil.getArchitecture((AbstractVMInstall) vm)); <END> }</code><technical_language>is instanceof needed</technical_language>

Target:
private static boolean isX86(IVMInstall vm) { return PlatformUtil.ARCH_X86.equals(PreferencesUtil.getArchitecture(vm)); }
Source:
<code>public void testNormalOperation() throws Exception { int conns = 5; ArrayList<String> connectionIds = new ArrayList<String>(); for (int i = 0; i < conns; i++) { connectionIds.add(blockingSSLConnect(DEFAULT_SOCKET_BUF_SIZE)); } int responseCount = 0; List<NetworkSend> sends = new ArrayList<NetworkSend>(); for (int i = 0; i < conns; i++) { String connectionId = connectionIds.get(i); sends.add(SelectorTest.createSend(connectionId, connectionId + "&" + 0)); } while (responseCount < conns) { selector.poll(0L, sends); Thread.sleep(100); assertEquals("No disconnects should have occurred.", 0, selector.disconnected().size()); for (NetworkReceive receive : selector.completedReceives()) { <START> ByteBuf payload = receive.getReceivedBytes().content(); <END> String[] pieces = SelectorTest.asString(payload).split("&"); assertEquals("Should be in the form 'conn-counter'", 2, pieces.length); assertEquals("Check the source", receive.getConnectionId(), pieces[0]); assertTrue("Received connectionId is as expected ", connectionIds.contains(receive.getConnectionId())); assertEquals("Check the request counter", 0, Integer.parseInt(pieces[1])); responseCount++; } sends.clear(); for (NetworkSend send : selector.completedSends()) { String dest = send.getConnectionId(); sends.add(SelectorTest.createSend(dest, dest + "&" + 0)); } } }</code><technical_language>release payload</technical_language>

Target:
public void testNormalOperation() throws Exception { int conns = 5; ArrayList<String> connectionIds = new ArrayList<String>(); for (int i = 0; i < conns; i++) { connectionIds.add(blockingSSLConnect(DEFAULT_SOCKET_BUF_SIZE)); } int responseCount = 0; List<NetworkSend> sends = new ArrayList<NetworkSend>(); for (int i = 0; i < conns; i++) { String connectionId = connectionIds.get(i); sends.add(SelectorTest.createSend(connectionId, connectionId + "&" + 0)); } while (responseCount < conns) { selector.poll(0L, sends); Thread.sleep(100); assertEquals("No disconnects should have occurred.", 0, selector.disconnected().size()); for (NetworkReceive receive : selector.completedReceives()) { ByteBuf payload = receive.getReceivedBytes().content(); String[] pieces = SelectorTest.asString(payload).split("&"); assertEquals("Should be in the form 'conn-counter'", 2, pieces.length); assertEquals("Check the source", receive.getConnectionId(), pieces[0]); assertTrue("Received connectionId is as expected ", connectionIds.contains(receive.getConnectionId())); assertEquals("Check the request counter", 0, Integer.parseInt(pieces[1])); responseCount++; receive.getReceivedBytes().release(); } sends.clear(); for (NetworkSend send : selector.completedSends()) { String dest = send.getConnectionId(); sends.add(SelectorTest.createSend(dest, dest + "&" + 0)); } } }
Source:
<code>public final List<? extends Action> getAllActions() { List<Action> _actions = new ArrayList<Action>(getActions()); for (TransientActionFactory<?> taf : ExtensionList.lookup(TransientActionFactory.class)) { if (taf.type().isInstance(this)) { try { _actions.addAll(createFor(taf)); } catch (Exception e) { <START> LOGGER.log(Level.SEVERE, "Actionable#getAllActions: Could not load actions from " + taf + " for " + this, e); <END> } } else if (taf == null) { LOGGER.log(Level.FINE, "Actionable#getAllActions: the Transient Action is null"); } else { LOGGER.log(Level.FINE, "Actionable#getAllActions: " + taf + "is not a Transient Action"); } } return Collections.unmodifiableList(_actions); }</code><technical_language>Unnecessary. log handler automatically includes this information</technical_language>

Target:
public final List<? extends Action> getAllActions() { List<Action> _actions = new ArrayList<Action>(getActions()); for (TransientActionFactory<?> taf : ExtensionList.lookup(TransientActionFactory.class)) { if (taf.type().isInstance(this)) { try { Collection<? extends Action> newActions = createFor(taf); for (Action action : newActions) { if (action instanceof Action) { _actions.add(action); } else { LOGGER.log(Level.WARNING, "Not action found in " + this.getClass().getName() + "in TransientActionFactory " + taf.getClass().getName()); } } } catch (Exception e) { if (this instanceof Saveable) OldDataMonitor.report((Saveable) this, Collections.<Throwable>singleton(e)); LOGGER.log(Level.SEVERE, "Could not load actions from " + taf + " for " + this, e); } } } return Collections.unmodifiableList(_actions); }
Source:
<code>private SortedSet<Type> getExtraImports(TypeElement element) { SortedSet<Type> extraImports = new TreeSet<Type>(); MapperConfiguration mapperConfiguration = MapperConfiguration.getInstanceOn( element ); for ( TypeMirror extraImport : mapperConfiguration.imports() ) { Type type = typeFactory.getType( extraImport ); extraImports.add( type ); } <START> if ( !"*".equals( mapperConfiguration.implementationPackage() ) ) { <END> extraImports.add( typeFactory.getType( element ) ); } return extraImports; }</code><technical_language>a left-over previous name I think, right</technical_language>

Target:
private SortedSet<Type> getExtraImports(TypeElement element) { SortedSet<Type> extraImports = new TreeSet<Type>(); MapperConfiguration mapperConfiguration = MapperConfiguration.getInstanceOn( element ); for ( TypeMirror extraImport : mapperConfiguration.imports() ) { Type type = typeFactory.getType( extraImport ); extraImports.add( type ); } if ( !"default".equals( mapperConfiguration.implementationPackage() ) ) { extraImports.add( typeFactory.getType( element ) ); } return extraImports; }
Source:
<code>public void testEntrySetAfterRemoveInBranchedTransaction() throws Exception { cache.put(1, "v1"); cache.put(2, "v2"); tm().begin(); try { assertEquals("v1", cache.get(1)); Transaction suspended = tm().suspend(); tm().begin(); try { cache.remove(1); } finally { tm().commit(); tm().resume(suspended); Set<Map.Entry<Object, Object>> entrySet = cache.entrySet(); assertEquals(2, entrySet.size()); for (Map.Entry<Object, Object> entry : entrySet) { Object key = entry.getKey(); Object value = entry.getValue(); if (entry.getKey().equals(1)) { assertEquals("v1", value); } else if (key.equals(2)) { assertEquals("v2", value); } else { fail("Unexpected entry found: " + entry); } } entrySet.contains(new ImmortalCacheEntry(1, "v1")); <START> entrySet.contains(new ImmortalCacheEntry(2, "v2")); <END> } } finally { tm().commit(); } }</code><technical_language>Missing assertTrue</technical_language>

Target:
public void testEntrySetAfterRemoveInBranchedTransaction() throws Exception { cache.put(1, "v1"); cache.put(2, "v2"); tm().begin(); try { assertEquals("v1", cache.get(1)); Transaction suspended = tm().suspend(); tm().begin(); try { cache.remove(1); } finally { tm().commit(); tm().resume(suspended); Set<Map.Entry<Object, Object>> entrySet = cache.entrySet(); assertEquals(2, entrySet.size()); for (Map.Entry<Object, Object> entry : entrySet) { Object key = entry.getKey(); Object value = entry.getValue(); if (entry.getKey().equals(1)) { assertEquals("v1", value); } else if (key.equals(2)) { assertEquals("v2", value); } else { fail("Unexpected entry found: " + entry); } } assertTrue(entrySet.contains(new ImmortalCacheEntry(1, "v1"))); assertTrue(entrySet.contains(new ImmortalCacheEntry(2, "v2"))); } } finally { tm().commit(); } }
Source:
<code>public ValidationResult vmNotHavingPciPassthroughDevices() { for (VM vm : vms) { if (getHostDeviceManager().checkVmNeedsPciDevices(vm.getId())) { return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_VM_HAS_ATTACHED_PCI_HOST_DEVICES, <START> String.format("$VmName %s", vm.getName())); <END> } } return ValidationResult.VALID; }</code><technical_language>I VmName in included in error message.. if right do is include in message set</technical_language>

Target:
public ValidationResult vmNotHavingPciPassthroughDevices() { for (VM vm : vms) { if (getHostDeviceManager().checkVmNeedsPciDevices(vm.getId())) { return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_VM_HAS_ATTACHED_PCI_HOST_DEVICES); } } return ValidationResult.VALID; }
Source:
<code>protected boolean isJoinedCourse(String courseId) { if (student == null) { return logic.getStudentForGoogleId(courseId, account.googleId) != null; <START> } else { <END> return true; } }</code><technical_language>remove else</technical_language>

Target:
protected boolean isJoinedCourse(String courseId) { if (student == null) { return logic.getStudentForGoogleId(courseId, account.googleId) != null; } return true; }
Source:
<code>protected void updateProtocols() { protocols = new UniqueEList<>(); if (trigger != null) { for (Port port : trigger.getPorts()) { UMLRTPort facade = <START> UMLRTPort.getInstance(port); <END> UMLRTProtocol protocol = facade.getType(); if (protocol != null) { protocols.add(protocol); } } } }</code><technical_language>This return null if port is a valid UML-RT port (in particular, if is missing RTPort stereotype application for some reason)</technical_language>

Target:
protected void updateProtocols() { protocols = new UniqueEList<>(); if (trigger != null) { for (Port port : trigger.getPorts()) { UMLRTPort facade = UMLRTPort.getInstance(port); if (facade != null) { UMLRTProtocol protocol = facade.getType(); if (protocol != null) { protocols.add(protocol); } } } } }
Source:
<code>public static TaskDefinition updateTaskProperties(TaskDefinition taskDefinition, DataSourceProperties dataSourceProperties, boolean setDatabaseCredentials) { Assert.notNull(taskDefinition, "taskDefinition must not be null"); Assert.notNull(dataSourceProperties, "dataSourceProperties must not be null"); TaskDefinition.TaskDefinitionBuilder builder = TaskDefinition.TaskDefinitionBuilder.from(taskDefinition); if(setDatabaseCredentials) { if (StringUtils.hasText(dataSourceProperties.getPassword())) { builder.setProperty("spring.datasource.password", dataSourceProperties.getPassword()); } builder.setProperty("spring.datasource.username", dataSourceProperties.getUsername()); } if(!taskDefinition.getProperties().containsKey("spring.datasource.url")) { builder.setProperty("spring.datasource.url", dataSourceProperties.getUrl()); } <START> if(!(taskDefinition.getProperties().containsKey("spring.datasource.driverClassName") || <END> taskDefinition.getProperties().containsKey("spring.datasource.driver-class-name"))) { builder.setProperty("spring.datasource.driverClassName", dataSourceProperties.getDriverClassName()); } builder.setTaskName(taskDefinition.getTaskName()); builder.setDslText(taskDefinition.getDslText()); return builder.build(); }</code><technical_language>Do need resolve this Relaxed names other combinations of property names users task definition properties</technical_language>

Target:
public static TaskDefinition updateTaskProperties(TaskDefinition taskDefinition, DataSourceProperties dataSourceProperties, boolean setDatabaseCredentials) { Assert.notNull(taskDefinition, "taskDefinition must not be null"); Assert.notNull(dataSourceProperties, "dataSourceProperties must not be null"); TaskDefinition.TaskDefinitionBuilder builder = TaskDefinition.TaskDefinitionBuilder.from(taskDefinition); if(setDatabaseCredentials) { if (StringUtils.hasText(dataSourceProperties.getPassword())) { builder.setProperty("spring.datasource.password", dataSourceProperties.getPassword()); } builder.setProperty("spring.datasource.username", dataSourceProperties.getUsername()); } if(!isPropertyPresent("spring.datasource.url", taskDefinition)) { builder.setProperty("spring.datasource.url", dataSourceProperties.getUrl()); } if(!isPropertyPresent("spring.datasource.driverClassName", taskDefinition)) { builder.setProperty("spring.datasource.driverClassName", dataSourceProperties.getDriverClassName()); } builder.setTaskName(taskDefinition.getTaskName()); builder.setDslText(taskDefinition.getDslText()); return builder.build(); }
Source:
<code>public void test0() throws InterruptedException { <START> log.info("Test1 table with cache"); <END> SiddhiManager siddhiManager = new SiddhiManager(); String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "@Store(type=\"testWithCache\", @Cache(size=\"10\"))\n" + "define table StockTable (symbol string, price float, volume long); "; String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;"; SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query); InputHandler stockStream = siddhiAppRuntime.getInputHandler("StockStream"); siddhiAppRuntime.start(); stockStream.send(new Object[]{"WSO2", 55.6f, 100L}); stockStream.send(new Object[]{"IBM", 75.6f, 100L}); stockStream.send(new Object[]{"WSO3", 57.6f, 100L}); Thread.sleep(500); Event[] events = siddhiAppRuntime.query("" + "from StockTable "); EventPrinter.print(events); AssertJUnit.assertEquals(3, events.length); events = siddhiAppRuntime.query("" + "from StockTable " + "on price > 75 "); EventPrinter.print(events); AssertJUnit.assertEquals(1, events.length); events = siddhiAppRuntime.query("" + "from StockTable " + "on price > volume*3/4 "); EventPrinter.print(events); AssertJUnit.assertEquals(1, events.length); siddhiAppRuntime.shutdown(); }</code><technical_language>consistent log test0</technical_language>

Target:
public void test0() throws InterruptedException { log.info("Test0 table with cache"); SiddhiManager siddhiManager = new SiddhiManager(); String streams = "" + "define stream StockStream (symbol string, price float, volume long); " + "@Store(type=\"testWithCache\", @Cache(size=\"10\"))\n" + "define table StockTable (symbol string, price float, volume long); "; String query = "" + "@info(name = 'query1') " + "from StockStream " + "insert into StockTable ;"; SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query); InputHandler stockStream = siddhiAppRuntime.getInputHandler("StockStream"); siddhiAppRuntime.start(); stockStream.send(new Object[]{"WSO2", 55.6f, 100L}); stockStream.send(new Object[]{"IBM", 75.6f, 100L}); stockStream.send(new Object[]{"WSO3", 57.6f, 100L}); Thread.sleep(500); Event[] events = siddhiAppRuntime.query("" + "from StockTable "); EventPrinter.print(events); AssertJUnit.assertEquals(3, events.length); events = siddhiAppRuntime.query("" + "from StockTable " + "on price > 75 "); EventPrinter.print(events); AssertJUnit.assertEquals(1, events.length); events = siddhiAppRuntime.query("" + "from StockTable " + "on price > volume*3/4 "); EventPrinter.print(events); AssertJUnit.assertEquals(1, events.length); siddhiAppRuntime.shutdown(); }
Source:
<code>public void importFileUpload(FileUploadEvent event) { importCertFile = event.getFile(); if (importCertFile != null) { importCertificate = new ArrayList<>(); Certificate cert = service.createCertificate(importCertFile.getContents()); cert.setAlias(ALIAS_PLACEHOLDER); checkCertValidity(cert); <START> if (cert.getExpiresInDays() > 30 && cert.getExpiresInDays() <= 90) { <END> HelperUtil.addMessageInfo(IMPORT_CERT_EXPIRY_MSG, "This Certificate is expiring soon."); } if (!expiredCert) { importCertificate.add(cert); } } }</code><technical_language>Optional: Suggest move this "expire soon" logic if (!expiredCert) reduce unnecessary check if allow user import expired cert</technical_language>

Target:
public void importFileUpload(FileUploadEvent event) { importCertFile = event.getFile(); expiredCert = false; if (importCertFile != null) { importCertificate = new ArrayList<>(); Certificate cert = service.createCertificate(importCertFile.getContents()); cert.setAlias(ALIAS_PLACEHOLDER); checkCertValidity(cert); if (!expiredCert) { if (cert.getExpiresInDays() > 30 && cert.getExpiresInDays() <= 90) { HelperUtil.addMessageInfo(IMPORT_CERT_EXPIRY_MSG, "This Certificate is expiring soon."); } importCertificate.add(cert); } } }