auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>static KeyStore createTrustStoreFromCertificates(Path path) { KeyStore keyStore; try { keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); keyStore.load(null, null); } catch (IOException | GeneralSecurityException e) { throw Throwables.propagate(e); <START> } <END> for (File currFile : getFilesForPath(path)) { try (InputStream in = Files.newInputStream(currFile.toPath())) { keyStore.setCertificateEntry(currFile.getName(), readX509Certificate(in)); } catch (IOException e) { throw new RuntimeException(String.format( "IOException encountered when opening '%s'", currFile.toPath()), e); } catch (CertificateException | KeyStoreException e) { throw new RuntimeException(String.format( "Could not read file at \"%s\" as an X.509 certificate", currFile.toPath()), e); } } return keyStore; }</code><technical_language>pull out this block of code private static KeyStore createKeyStore()</technical_language>

Target:
static KeyStore createTrustStoreFromCertificates(Path path) { KeyStore keyStore; keyStore = createKeyStore(); for (File currFile : getFilesForPath(path)) { try (InputStream in = Files.newInputStream(currFile.toPath())) { keyStore.setCertificateEntry(currFile.getName(), readX509Certificate(in)); } catch (IOException e) { throw new RuntimeException(String.format( "IOException encountered when opening '%s'", currFile.toPath()), e); } catch (CertificateException | KeyStoreException e) { throw new RuntimeException(String.format( "Could not read file at \"%s\" as an X.509 certificate", currFile.toPath()), e); } } return keyStore; }
Source:
<code>public boolean isAscending(Integer keyColumnPosition) { int i = keyColumnPosition - 1; <START> return !(i < 0 || i >= baseColumnPositions.length) && isAscending[i]; <END> }</code><technical_language>This is harder understand IMO</technical_language>

Target:
public boolean isAscending(Integer keyColumnPosition) { int i = keyColumnPosition.intValue() - 1; if (i < 0 || i >= baseColumnPositions.length) return false; return isAscending[i]; }
Source:
<code>private OAuthRequest(URL authUrl, UserNamespace namespace, String token, String secret) { this.authUrl = authUrl; this.namespace = namespace; this.token = token; <START> this.secret = secret; <END> }</code><technical_language>checkNotNull checks appropriate</technical_language>

Target:
private OAuthRequest(URL authUrl, UserNamespace namespace, String token, String secret) { Preconditions.checkNotNull(authUrl); Preconditions.checkNotNull(namespace); Preconditions.checkNotNull(token); Preconditions.checkNotNull(secret); this.authUrl = authUrl; this.namespace = namespace; this.token = token; this.secret = secret; }
Source:
<code>public static String printXpathBranch(String xpath, File file) throws CheckstyleException, IOException { final XPathEvaluator xpathEvaluator = new XPathEvaluator(); try { final RootNode rootNode = new RootNode(JavaParser.parseFile(file, JavaParser.Options.WITHOUT_COMMENTS)); final XPathExpression xpathExpression = xpathEvaluator.createExpression(xpath); final XPathDynamicContext xpathDynamicContext = xpathExpression.createDynamicContext(rootNode); final List<Item<?>> evaluate = xpathExpression.evaluate(xpathDynamicContext); return evaluate.stream() .map(item -> ((AbstractNode) item).getUnderlyingNode()) .map(AstTreeStringPrinter::printBranch) .collect(Collectors.joining(DELIMITER)); } catch (XPathException ex) { <START> throw new CheckstyleException("Error during xpath evaluation", ex); <END> } }</code><technical_language>simple wrap of exceptions, is signal for bad design. please put context of exception String xpath, File file message of CheckstyleException</technical_language>

Target:
public static String printXpathBranch(String xpath, File file) throws CheckstyleException, IOException { final XPathEvaluator xpathEvaluator = new XPathEvaluator(); try { final RootNode rootNode = new RootNode(JavaParser.parseFile(file, JavaParser.Options.WITH_COMMENTS)); final XPathExpression xpathExpression = xpathEvaluator.createExpression(xpath); final XPathDynamicContext xpathDynamicContext = xpathExpression.createDynamicContext(rootNode); final List<Item<?>> matchingItems = xpathExpression.evaluate(xpathDynamicContext); return matchingItems.stream() .map(item -> ((AbstractNode) item).getUnderlyingNode()) .map(AstTreeStringPrinter::printBranch) .collect(Collectors.joining(DELIMITER)); } catch (XPathException ex) { final String errMsg = String.format(Locale.ROOT, "Error during evaluation for xpath: %s, file: %s", xpath, file.getCanonicalPath()); throw new CheckstyleException(errMsg, ex); } }
Source:
<code>public void triggerSchemaUpdateOnFirstSave() { ManagedProduct p = new ManagedProduct(); p.setId("p-1"); repo.save(p); <START> Iterator<ManagedProduct> iterator = repo.findAll().iterator(); <END> while (iterator.hasNext()) { System.out.println(iterator.next()); } }</code><technical_language>Simple for-each</technical_language>

Target:
public void triggerSchemaUpdateOnFirstSave() { ManagedProduct p = new ManagedProduct(); p.setId("p-1"); repo.save(p); Iterable<ManagedProduct> all = repo.findAll(); for (ManagedProduct product : all) { System.out.println(product); } }
Source:
<code>public Response processEvent(String event) { AlertAlarmNotifier aaNotifier = AlertAlarmNotifier.getInstance(); try { List<Map<String, Object>> eventMapList = Helper.toMapList(event); if (eventMapList != null) { aaNotifier = AlertAlarmNotifier.getInstance(); for ( Map<String, Object> eventMap : eventMapList) { <START> log.handle(Priority.INFO, "event Map = " + eventMap.toString()); <END> if (aaNotifier != null) { aaNotifier.notifyOmsUser(eventMap); } else { log.handle(Priority.INFO, "AlertAlarmNotifier instance is null"); } } } else { log.handle(Priority.INFO, "OMS Event List is null"); } } catch (IOException e) { log.error("process OMS event IO Exception", e); } return Response.status(Status.ACCEPTED).build(); }</code><technical_language>I this is debug, info level logging</technical_language>

Target:
public Response processEvent(String event) { AlertAlarmNotifier aaNotifier = AlertAlarmNotifier.getInstance(); try { List<Map<String, Object>> eventMapList = Helper.toMapList(event); if (eventMapList != null) { aaNotifier = AlertAlarmNotifier.getInstance(); for ( Map<String, Object> eventMap : eventMapList) { log.handle(Priority.DEBUG, "event Map = " + eventMap.toString()); aaNotifier.notifyOmsUser(eventMap); } } else { log.handle(Priority.ERROR, "Expected OMS Events JSON dictionary list as input to process event: " + event); } } catch (IOException e) { log.error("Error processing OMS Events", e); } return Response.status(Status.ACCEPTED).build(); }
Source:
<code>protected void comparePlans(String sql, Map<String, String> ignoreMap) { CompiledPlan calcitePlan = compileAdHocCalcitePlan(sql, true, true, DeterminismMode.SAFER); <START> System.out.println(calcitePlan.explainedPlan); <END> CompiledPlan voltdbPlan = compileAdHocPlan(sql, true, true); comparePlanTree(calcitePlan.rootPlanGraph, voltdbPlan.rootPlanGraph, ignoreMap); if (calcitePlan.subPlanGraph != null && voltdbPlan.subPlanGraph != null) { comparePlanTree(calcitePlan.subPlanGraph, voltdbPlan.subPlanGraph, ignoreMap); } else if (calcitePlan.subPlanGraph != null || voltdbPlan.subPlanGraph != null) { fail("Two-part MP plans mismatch"); } compareCompiledPlans(calcitePlan, voltdbPlan); }</code><technical_language>remove this line</technical_language>

Target:
protected void comparePlans(String sql, Map<String, String> ignoreMap) { CompiledPlan calcitePlan = compileAdHocCalcitePlan(sql, true, true, DeterminismMode.SAFER); CompiledPlan voltdbPlan = compileAdHocPlan(sql, true, true); comparePlanTree(calcitePlan.rootPlanGraph, voltdbPlan.rootPlanGraph, ignoreMap); if (calcitePlan.subPlanGraph != null && voltdbPlan.subPlanGraph != null) { comparePlanTree(calcitePlan.subPlanGraph, voltdbPlan.subPlanGraph, ignoreMap); } else if (calcitePlan.subPlanGraph != null || voltdbPlan.subPlanGraph != null) { fail(String.format("Two-part MP plans mismatch.\n\nVoltDB plan: %s\n\nCalcite plan:%s\n", voltdbPlan.subPlanGraph.toExplainPlanString(), calcitePlan.subPlanGraph.toExplainPlanString())); } compareCompiledPlans(calcitePlan, voltdbPlan); }
Source:
<code>public void deleteChunks(long commitId, long tableId, Set<Long> chunkIds) { writeMaster(commitId, (dao, commit) -> { checkConflict(dao.tableIdExists(tableId), "Table no longer exists"); dao.updateRollbackInfo(commit.getRollbackInfo() .withWrittenTable(tableId) .toBytes()); }); AtomicLong rowCount = new AtomicLong(); writeShard(commitId, getTableShard(tableId), dao -> { <START> ChunkSummary summary = dao.getChunkSummary(commitId, chunkIds); <END> checkTableConflict(summary.getChunkCount() == chunkIds.size()); rowCount.set(summary.getRowCount()); deleteChunks(dao, commitId, tableId, chunkIds); TableSize tableSize = dao.getTableSize(tableId); long chunkCount = tableSize.getChunkCount() - summary.getChunkCount(); long compressedSize = tableSize.getCompressedSize() - summary.getCompressedSize(); long uncompressedSize = tableSize.getUncompressedSize() - summary.getUncompressedSize(); deleteTableSize(dao, commitId, tableId); dao.insertTableSize(commitId, tableId, chunkCount, compressedSize, uncompressedSize); }); writeMaster(commitId, (dao, commit) -> { TableInfo table = dao.getTableInfo(tableId).builder() .addRowCount(-rowCount.get()) .setUpdateTime(System.currentTimeMillis()) .build(); deleteTable(dao, commitId, tableId); insertTable(dao, commitId, table); }); }</code><technical_language>suffer "mysql commit size" in insert_chunks? deleteChunks smaller commit size</technical_language>

Target:
public void deleteChunks(long commitId, long tableId, Set<Long> chunkIds) { writeMaster(commitId, (dao, commit) -> { checkConflict(dao.tableIdExists(tableId), "Table no longer exists"); dao.updateRollbackInfo(commit.getRollbackInfo() .withWrittenTable(tableId) .toBytes()); }); AtomicLong rowCount = new AtomicLong(); writeShard(commitId, getTableShard(tableId), dao -> { ChunkSummary summary = dao.getChunkSummary(commitId, chunkIds); checkTableConflict(summary.getChunkCount() == chunkIds.size()); rowCount.set(summary.getRowCount()); for (Set<Long> batch : partitionSet(chunkIds, 1000)) { deleteChunks(dao, commitId, tableId, batch); } TableSize tableSize = dao.getTableSize(tableId); long chunkCount = tableSize.getChunkCount() - summary.getChunkCount(); long compressedSize = tableSize.getCompressedSize() - summary.getCompressedSize(); long uncompressedSize = tableSize.getUncompressedSize() - summary.getUncompressedSize(); deleteTableSize(dao, commitId, tableId); dao.insertTableSize(commitId, tableId, chunkCount, compressedSize, uncompressedSize); }); writeMaster(commitId, (dao, commit) -> { TableInfo table = dao.getTableInfo(tableId).builder() .addRowCount(-rowCount.get()) .setUpdateTime(System.currentTimeMillis()) .build(); deleteTable(dao, commitId, tableId); insertTable(dao, commitId, table); }); }
Source:
<code><START> private void log(ITestNGMethod method, String prefix) { <END> if (method.getInstance() != null) { messages.add(prefix + method.getInstance().getClass().getName() + "." + method.getMethodName()); } else { messages.add(prefix + method.getMethodName()); } }</code><technical_language>static</technical_language>

Target:
private static void log(ITestNGMethod method, String prefix) { if (method.getInstance() != null) { messages.add(prefix + method.getInstance().getClass().getName() + "." + method.getMethodName()); } else { messages.add(prefix + method.getMethodName()); } }
Source:
<code>static ISchemeInformation getLoadingSchemeInformation(IScheme scheme) { SchemeInformation schemeInfo = new SchemeInformation(scheme.getName(), scheme.getDescription()); schemeInfo.setHandled(false); <START> schemeInfo.setHandlerLocation("Loading .."); <END> return schemeInfo; }</code><technical_language>Loading... instead of Loading .</technical_language>

Target:
static ISchemeInformation getLoadingSchemeInformation(IScheme scheme) { SchemeInformation schemeInfo = new SchemeInformation(scheme.getName(), scheme.getDescription()); schemeInfo.setHandled(false); schemeInfo.setHandlerLocation("Loading..."); return schemeInfo; }
Source:
<code>private void reset() { topicTitle.setInnerHTML(""); notes.setInnerHTML(""); post.setText("Post"); if (dataProvider != null && dataProvider.getDataDisplays().size() > 0) { dataProvider.removeDataDisplay(messagesCellList); } <START> <END> messagesCellList.setVisibleRangeAndClearData(messagesCellList.getVisibleRange(), true); pager.setVisible(false); notes.setInnerHTML(""); editorTextMap.put(topicId, replyText.getText()); replyText.reset(); replyText.setVisible(false); replyForm.setVisible(false); forumSummarySidePanel.reset(); startPagePost = null ; }</code><technical_language>Remove this if is required</technical_language>

Target:
private void reset() { topicTitle.setInnerHTML(""); post.setText("Post"); if (dataProvider != null && dataProvider.getDataDisplays().size() > 0) { dataProvider.removeDataDisplay(messagesCellList); } messagesCellList.setVisibleRangeAndClearData(messagesCellList.getVisibleRange(), true); pager.setVisible(false); descriptionStartedBy.setInnerHTML(""); descriptionReplies.setInnerHTML(""); descriptionLastPoster.setInnerHTML(""); editorTextMap.put(topicId, replyText.getText()); replyText.reset(); replyText.setVisible(false); replyForm.setVisible(false); forumSummarySidePanel.reset(); startPagePost = null; }
Source:
<code>protected void remove(WebApp webApp) { javascriptConfigService.unregisterServletContext(webApp); try { ServletContext scontext = webApp.getServletContext(); ImmutableScriptResources scriptResources = (ImmutableScriptResources) scontext.getAttribute(SCRIPT_RESOURCES_ATTR); if (scriptResources != null) { javascriptConfigService.remove(scriptResources, scontext.getContextPath()); scontext.removeAttribute(SCRIPT_RESOURCES_ATTR); } } catch (Exception ex) { log.error( <START> "An error occured while removing script resources for the context '" <END> + webApp.getServletContext().getServletContextName() + "'", ex); } String contextPath = webApp.getServletContext().getContextPath(); try { skinService.removeSkins(SkinDependentManager.getPortalSkins(contextPath)); skinService.removeSkins(SkinDependentManager.getPortletSkins(contextPath)); Set<String> supportedSkins = SkinDependentManager.getSkinNames(contextPath); if (supportedSkins != null) { for (String skin : supportedSkins) { if (SkinDependentManager.skinNameIsRemovable(skin, contextPath)) { skinService.removeSupportedSkin(skin); } } } SkinDependentManager.clearAssociatedSkins(contextPath); } catch (Exception e) { log.error(e.getMessage(), e); } skinService.unregisterServletContext(webApp); }</code><technical_language>s/occured/occurred</technical_language>

Target:
protected void remove(WebApp webApp) { javascriptConfigService.unregisterServletContext(webApp); try { ServletContext scontext = webApp.getServletContext(); ImmutableScriptResources scriptResources = (ImmutableScriptResources) scontext.getAttribute(SCRIPT_RESOURCES_ATTR); if (scriptResources != null) { javascriptConfigService.remove(scriptResources, scontext.getContextPath()); scontext.removeAttribute(SCRIPT_RESOURCES_ATTR); } } catch (Exception ex) { log.error( "An error occurred while removing script resources for the context '" + webApp.getServletContext().getServletContextName() + "'", ex); } String contextPath = webApp.getServletContext().getContextPath(); try { skinService.removeSkins(SkinDependentManager.getPortalSkins(contextPath)); skinService.removeSkins(SkinDependentManager.getPortletSkins(contextPath)); Set<String> supportedSkins = SkinDependentManager.getSkinNames(contextPath); if (supportedSkins != null) { for (String skin : supportedSkins) { if (SkinDependentManager.skinNameIsRemovable(skin, contextPath)) { skinService.removeSupportedSkin(skin); } } } SkinDependentManager.clearAssociatedSkins(contextPath); } catch (Exception e) { log.error(e.getMessage(), e); } skinService.unregisterServletContext(webApp); }
Source:
<code>public void generate() throws IOException { Map<String, Object> params = context.getParameters(); Attributes attr = new Attributes(); Object type = params.get("type"); <START> attr.add("type", type == null ? "text" : (String) type) <END> .addDefaultToEmpty("name", params.get("name")) .addIfExists("size", params.get("size")) .addIfExists("maxlength", params.get("maxlength")) .addIfExists("value", params.get("nameValue")) .addIfTrue("disabled", params.get("disabled")) .addIfTrue("readonly", params.get("readonly")) .addIfExists("tabindex", params.get("tabindex")) .addIfExists("id", params.get("id")) .addIfExists("class", params.get("cssClass")) .addIfExists("style", params.get("cssStyle")) .addIfExists("title", params.get("title")); super.start("input", attr); super.end("input"); }</code><technical_language>a safe way, ie. String.valueOf(type)</technical_language>

Target:
public void generate() throws IOException { Map<String, Object> params = context.getParameters(); Attributes attr = new Attributes(); Object type = params.get("type"); attr.add("type", type == null ? "text" : type.toString()) .addDefaultToEmpty("name", params.get("name")) .addIfExists("size", params.get("size")) .addIfExists("maxlength", params.get("maxlength")) .addIfExists("value", params.get("nameValue")) .addIfTrue("disabled", params.get("disabled")) .addIfTrue("readonly", params.get("readonly")) .addIfExists("tabindex", params.get("tabindex")) .addIfExists("id", params.get("id")) .addIfExists("class", params.get("cssClass")) .addIfExists("style", params.get("cssStyle")) .addIfExists("title", params.get("title")); super.start("input", attr); super.end("input"); }
Source:
<code>public EEFViewDescription convert(SiriusInputDescriptor input) { EEFViewDescription view = this.createView(); Map<String, Object> parameters = new HashMap<>(); parameters.put(IDescriptionConverter.INPUT, input); parameters.put(IDescriptionConverter.VIEW, view); TransformationCache cache = new TransformationCache(); for (PageDescription pageDescription : pageDescriptions) { IDescriptionConverter converter = SiriusPropertiesCorePlugin.getPlugin().getDescriptionConverter(pageDescription); EObject eObject = converter.convert(pageDescription, parameters, cache); if (eObject instanceof EEFPageDescription) { EEFPageDescription convertedPageDescription = (EEFPageDescription) eObject; view.getPages().add(convertedPageDescription); for (GroupDescription groupDescription : pageDescription.getGroups()) { if (!cache.getAllInputs().contains(groupDescription)) { IDescriptionConverter groupConverter = SiriusPropertiesCorePlugin.getPlugin().getDescriptionConverter(groupDescription); EObject group = groupConverter.convert(groupDescription, parameters, cache); if (group instanceof EEFGroupDescription) { view.getGroups().add((EEFGroupDescription) group); convertedPageDescription.getGroups().add((EEFGroupDescription) group); } } else { Optional<Object> output = cache.getOutput(groupDescription); output.filter(EEFGroupDescription.class::isInstance).map(EEFGroupDescription.class::cast).ifPresent(eefGroupDescription -> { convertedPageDescription.getGroups().add(eefGroupDescription); }); } } } } List<IDescriptionLinkResolver> linkResolvers = SiriusPropertiesCorePlugin.getPlugin().getDescriptionConverterLinkResolvers(); <START> for (IDescriptionLinkResolver linkResolver : linkResolvers) { linkResolver.resolve(view, cache); } <END> return view; }</code><technical_language>java8-isation [forEach]</technical_language>

Target:
public EEFViewDescription convert(SiriusInputDescriptor input) { EEFViewDescription view = this.createView(); TransformationCache cache = new TransformationCache(); Map<String, Object> parameters = new HashMap<>(); parameters.put(IDescriptionConverter.INPUT, input); parameters.put(IDescriptionConverter.VIEW, view); pageDescriptions.forEach(pageDescription -> convertPage(input, view, cache, pageDescription, parameters)); List<IDescriptionLinkResolver> linkResolvers = SiriusPropertiesCorePlugin.getPlugin().getDescriptionConverterLinkResolvers(); linkResolvers.forEach(linkResolver -> linkResolver.resolve(view, cache)); return view; }
Source:
<code>public void detachDebuggerFromProcess(final IDMContext dmc, final RequestMonitor rm) { ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class); <START> IMIContainerDMContext contDmc = DMContexts.getAncestorOfType(dmc, IMIContainerDMContext.class); <END> if (controlDmc != null && contDmc != null) { String pid = getGroupToPidMap().get(contDmc.getGroupId()); if (pid != null) { if (!doCanDetachDebuggerFromProcess()) { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Detach not supported.", null)); rm.done(); return; } IMIRunControl runControl = getServicesTracker().getService(IMIRunControl.class); if (runControl != null && !runControl.isTargetAcceptingCommands()) { fBackend.interrupt(); } fCommandControl.queueCommand( fCommandFactory.createMITargetDetach(controlDmc, pid), new DataRequestMonitor<MIInfo>(getExecutor(), rm)); } else { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid group id.", null)); rm.done(); } } else { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid context.", null)); rm.done(); } }</code><technical_language>change? IMIProcessDMContext is a parent of IMIContainerDMContext, if new code works, too, no</technical_language>

Target:
public void detachDebuggerFromProcess(final IDMContext dmc, final RequestMonitor rm) { ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class); IMIProcessDMContext procDmc = DMContexts.getAncestorOfType(dmc, IMIProcessDMContext.class); if (controlDmc != null && procDmc != null) { if (!doCanDetachDebuggerFromProcess()) { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Detach not supported.", null)); rm.done(); return; } IMIRunControl runControl = getServicesTracker().getService(IMIRunControl.class); if (runControl != null && !runControl.isTargetAcceptingCommands()) { fBackend.interrupt(); } fCommandControl.queueCommand( fCommandFactory.createMITargetDetach(controlDmc, procDmc.getProcId()), new DataRequestMonitor<MIInfo>(getExecutor(), rm)); } else { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid context.", null)); rm.done(); } }
Source:
<code>public void testOnRemoveClass() { final ProjectClassListView.LoadClassesHandler handler = new ProjectClassListView.LoadClassesHandler() { @Override public void onLoadClasses() { List<ClassRow> classes = new ArrayList<ClassRow>(); classes.add(classRow1); classes.add(classRow2); presenter.setClasses(classes); } @Override public void onLoadClass(String className) { } }; presenter.addLoadClassesHandler(handler); presenter.onLoadClasses(); verify(view, times(1)).redraw(); assertThat(presenter.getClasses()).hasSize(2); presenter.onRemoveClass(classRow1); verify(view, times(2)).redraw(); assertThat(presenter.getClasses()).hasSize(1); <START> assertThat(presenter.getClasses().contains(classRow1)).isFalse(); <END> presenter.onRemoveClass(classRow2); verify(view, times(3)).redraw(); assertThat(presenter.getClasses()).hasSize(0); assertThat(presenter.getClasses().contains(classRow2)).isFalse(); }</code><technical_language>AssertJ, a lot more useful method. assertThat(something).doesNotContain(somethingElse). :-) I suggest review API, I find useful time-saving in future</technical_language>

Target:
public void testOnRemoveClass() { final ProjectClassListView.LoadClassesHandler handler = new ProjectClassListView.LoadClassesHandler() { @Override public void onLoadClasses() { List<ClassRow> classes = new ArrayList<ClassRow>(); classes.add(classRow1); classes.add(classRow2); presenter.setClasses(classes); } @Override public void onLoadClass(String className) { } }; presenter.addLoadClassesHandler(handler); presenter.onLoadClasses(); verify(view, times(1)).redraw(); assertThat(presenter.getClasses()).hasSize(2); presenter.onRemoveClass(classRow1); verify(view, times(2)).redraw(); assertThat(presenter.getClasses()).hasSize(1); assertThat(presenter.getClasses()).doesNotContain(classRow1); presenter.onRemoveClass(classRow2); verify(view, times(3)).redraw(); assertThat(presenter.getClasses()).hasSize(0); }
Source:
<code>private boolean areAllChildrenIgnored() { for (T child : getFilteredChildren()) { <START> if(isIgnored(child) == false) { <END> return false; } } return true; }</code><technical_language>Space if, please. change if (! isIgnored(child))</technical_language>

Target:
private boolean areAllChildrenIgnored() { for (T child : getFilteredChildren()) { if (!isIgnored(child)) { return false; } } return true; }
Source:
<code>private Set<String> getRefNamesAllUsers(String prefix) throws OrmException { Map<String, Ref> matchingRefs; try { <START> RefDatabase refDb = repoManager.openRepository(allUsers).getRefDatabase(); <END> matchingRefs = refDb.getRefs(prefix); } catch (IOException e) { throw new OrmException(e); } return matchingRefs.keySet(); }</code><technical_language>Missing close of this repo</technical_language>

Target:
private Set<String> getRefNamesAllUsers(String prefix) throws OrmException { Repository repo = null; try { repo = repoManager.openRepository(allUsers); RefDatabase refDb = repo.getRefDatabase(); return refDb.getRefs(prefix).keySet(); } catch (IOException e) { throw new OrmException(e); } finally { if (repo != null) { repo.close(); } } }
Source:
<code>public InsertQuery build() { <START> Checks.checkNotNull(uri, "Please specify uri"); <END> return new InsertQuery( uri ); }</code><technical_language>Static import</technical_language>

Target:
public InsertQuery build() { checkNotNull(uri, "Please specify uri"); return new InsertQuery( uri ); }
Source:
<code>private void writeInputCommand(String value) throws UnsupportedEncodingException { out = new PrintStream(telnet.getOutputStream(), true, "UTF-8"); out.println(value); <START> out.flush(); <END> log.info(value); }</code><technical_language>Out steam closed</technical_language>

Target:
private void writeInputCommand(String value) throws CarbonToolsIntegrationTestException { try { out = new PrintStream(telnet.getOutputStream(), true, "UTF-8"); out.println(value); out.flush(); } catch (UnsupportedEncodingException ex) { log.error("Unsupported encoding UTF-8", ex); throw new CarbonToolsIntegrationTestException("Unsupported encoding UTF-8 ", ex); } log.info(value); }
Source:
<code>public void testGetEPRsForService() throws Exception { EndpointReference[] endpointReference = nHttpListener.getEPRsForService("myservice", HOST); Assert.assertNotNull(endpointReference); Assert.assertEquals("Endpoint reference mismatched", ServiceUtils.getServiceEndpoint("myservice", HOST, PORT), endpointReference[0].getAddress()); endpointReference = nHttpListener.getEPRsForService("t/myservice", HOST); Assert.assertNotNull(endpointReference); Assert.assertEquals("Endpoint reference mismatched", ServiceUtils.getServiceEndpoint("t/myservice", HOST, PORT), endpointReference[0].getAddress()); endpointReference = nHttpListener.getEPRsForService("myservice.endpoint", HOST); <START> Assert.assertNotNull(endpointReference); <END> Assert.assertEquals("Endpoint reference mismatched", ServiceUtils.getServiceEndpoint("myservice.endpoint", HOST, PORT), endpointReference[0].getAddress()); }</code><technical_language>Add assert message</technical_language>

Target:
public void testGetEPRsForService() throws Exception { EndpointReference[] endpointReference = nHttpListener.getEPRsForService("myservice", HOST); Assert.assertNotNull(endpointReference); Assert.assertEquals("Endpoint reference mismatched", ServiceUtils.getServiceEndpoint("myservice", HOST, PORT), endpointReference[0].getAddress()); endpointReference = nHttpListener.getEPRsForService("t/myservice", HOST); Assert.assertNotNull("Endpoint references not found", endpointReference); Assert.assertEquals("Endpoint reference mismatched", ServiceUtils.getServiceEndpoint("t/myservice", HOST, PORT), endpointReference[0].getAddress()); endpointReference = nHttpListener.getEPRsForService("myservice.endpoint", HOST); Assert.assertNotNull("Endpoint references not found", endpointReference); Assert.assertEquals("Endpoint reference mismatched", ServiceUtils.getServiceEndpoint("myservice.endpoint", HOST, PORT), endpointReference[0].getAddress()); }
Source:
<code>protected void notificationBatteryLevel(int batteryLevel) { if ((batteryLevel < 0) || (batteryLevel > 100)) { return; } <START> final String pref = getResources().getString(R.string.pref_battery_level_low_notification_discard); <END> final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); if (batteryLevel > batteryLevelLowThreshold) { if (prefs.contains(pref)) { prefs.edit().remove(pref).commit(); } return; } if (prefs.getBoolean(pref, false)) { return; } AlertDialog.Builder prompt = new AlertDialog.Builder(this); LayoutInflater promptInflater = LayoutInflater.from(this); View messageView = promptInflater.inflate(R.layout.checkbox, null); final CheckBox dontShowAgain = (CheckBox) messageView.findViewById(R.id.skip); prompt.setView(messageView); prompt.setCancelable(false); prompt.setMessage(getResources().getText(R.string.battery_level_low_notification_txt) + "\n" + getResources().getText(R.string.battery_level) + ": " + batteryLevel + "%"); prompt.setTitle(getResources().getText(R.string.battery_level_low_notification_title)); prompt.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (dontShowAgain.isChecked()) { prefs.edit().putBoolean(pref, true).commit(); } return; } }); prompt.show(); }</code><technical_language>rename pref => pref_key</technical_language>

Target:
protected void notificationBatteryLevel(int batteryLevel) { if ((batteryLevel < 0) || (batteryLevel > 100)) { return; } final String pref_key = getResources().getString(R.string.pref_battery_level_low_notification_discard); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); int batteryLevelHighThreshold = prefs.getInt(getResources().getString(R.string.pref_battery_level_high_threshold), 75); if ((batteryLevel > batteryLevelHighThreshold) && (prefs.contains(pref_key))) { prefs.edit().remove(pref_key).commit(); return; } int batteryLevelLowThreshold = prefs.getInt(getResources().getString(R.string.pref_battery_level_low_threshold), 15); if (batteryLevel > batteryLevelLowThreshold) { return; } if (prefs.getBoolean(pref_key, false)) { return; } AlertDialog.Builder prompt = new AlertDialog.Builder(this); final CheckBox dontShowAgain = new CheckBox(this); dontShowAgain.setText(getResources().getText(R.string.do_not_show_again)); prompt.setView(dontShowAgain); prompt.setCancelable(false); prompt.setMessage(getResources().getText(R.string.battery_level_low_notification_txt) + "\n" + getResources().getText(R.string.battery_level) + ": " + batteryLevel + "%"); prompt.setTitle(getResources().getText(R.string.warning)); prompt.setPositiveButton(getResources().getText(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (dontShowAgain.isChecked()) { prefs.edit().putBoolean(pref_key, true).commit(); } return; } }); prompt.show(); }
Source:
<code>public void testParquetTupleDomainStruct() { HiveColumnHandle colHandle = new HiveColumnHandle("my_struct", HiveType.valueOf("struct<a:int,b:int>"), parseTypeSignature(StandardTypes.ROW), 0, REGULAR, Optional.empty()); RowType.Field rowField = new RowType.Field(Optional.of("my_struct"), INTEGER); RowType rowType = RowType.from(ImmutableList.of(rowField)); <START> TupleDomain<HiveColumnHandle> domain = <END> TupleDomain.withColumnDomains( ImmutableMap.of(colHandle, Domain.notNull(rowType))); MessageType fileSchema = new MessageType("hive_schema", new GroupType(OPTIONAL, "my_struct", new PrimitiveType(OPTIONAL, INT32, "a"), new PrimitiveType(OPTIONAL, INT32, "b"))); TupleDomain<ColumnDescriptor> tupleDomain = getParquetTupleDomain(fileSchema, fileSchema, domain); assertTrue(tupleDomain.getDomains().get().isEmpty()); }</code><technical_language>put line do L87 L121</technical_language>

Target:
public void testParquetTupleDomainStruct() { HiveColumnHandle columnHandle = new HiveColumnHandle("my_struct", HiveType.valueOf("struct<a:int,b:int>"), parseTypeSignature(StandardTypes.ROW), 0, REGULAR, Optional.empty()); RowType.Field rowField = new RowType.Field(Optional.of("my_struct"), INTEGER); RowType rowType = RowType.from(ImmutableList.of(rowField)); TupleDomain<HiveColumnHandle> domain = TupleDomain.withColumnDomains(ImmutableMap.of(columnHandle, Domain.notNull(rowType))); MessageType fileSchema = new MessageType("hive_schema", new GroupType(OPTIONAL, "my_struct", new PrimitiveType(OPTIONAL, INT32, "a"), new PrimitiveType(OPTIONAL, INT32, "b"))); TupleDomain<ColumnDescriptor> tupleDomain = getParquetTupleDomain(fileSchema, fileSchema, domain); assertTrue(tupleDomain.getDomains().get().isEmpty()); }
Source:
<code>protected void createFieldEditors() { super.createFieldEditors(); Composite parent = getFieldEditorParent(); parent.setLayout(new GridLayout(1, false)); Composite area = new Composite(parent, SWT.NONE); GridLayout gl = new GridLayout(1, false); gl.marginTop = MARGIN; gl.marginLeft = MARGIN; gl.marginRight = MARGIN; area.setLayout(gl); area.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); AutotoolsConfiguration.Option[] options = AutotoolsConfiguration.getChildOptions(catName); for (int i = 0; i < options.length; ++i) { AutotoolsConfiguration.Option option = options[i]; switch (option.getType()) { case IConfigureOption.STRING: case IConfigureOption.INTERNAL: case IConfigureOption.MULTIARG: StringFieldEditor f = new StringFieldEditor(option.getName(), option.getDescription(), area); f.getLabelControl(area).setToolTipText(option.getToolTip()); addField(f); fieldEditors.add(f); break; case IConfigureOption.BIN: case IConfigureOption.FLAGVALUE: BooleanFieldEditor b = new BooleanFieldEditor(option.getName(), option.getDescription(), area); b.getDescriptionControl(area).setToolTipText(option.getToolTip()); addField(b); fieldEditors.add(b); break; case IConfigureOption.FLAG: <START> FieldEditor l = createLabelEditor(area, option.getName()); <END> addField(l); fieldEditors.add(l); break; } } }</code><technical_language>changed getName() instead of getDescription()? For Cflags (a FLAG option), this result in showing "cflags" in case getDescription() get Compiler Flags: in ConfigureMessages.properties. This put was</technical_language>

Target:
protected void createFieldEditors() { super.createFieldEditors(); Composite parent = getFieldEditorParent(); parent.setLayout(new GridLayout(1, false)); Composite area = new Composite(parent, SWT.NONE); GridLayout gl = new GridLayout(1, false); gl.marginTop = MARGIN; gl.marginLeft = MARGIN; gl.marginRight = MARGIN; area.setLayout(gl); area.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); AutotoolsConfiguration.Option[] options = AutotoolsConfiguration.getChildOptions(catName); for (int i = 0; i < options.length; ++i) { AutotoolsConfiguration.Option option = options[i]; switch (option.getType()) { case IConfigureOption.STRING: case IConfigureOption.INTERNAL: case IConfigureOption.MULTIARG: StringFieldEditor f = new StringFieldEditor(option.getName(), option.getDescription(), area); f.getLabelControl(area).setToolTipText(option.getToolTip()); addField(f); fieldEditors.add(f); break; case IConfigureOption.BIN: case IConfigureOption.FLAGVALUE: BooleanFieldEditor b = new BooleanFieldEditor(option.getName(), option.getDescription(), area); b.getDescriptionControl(area).setToolTipText(option.getToolTip()); addField(b); fieldEditors.add(b); break; case IConfigureOption.FLAG: FieldEditor l = createLabelEditor(area, option.getDescription()); addField(l); fieldEditors.add(l); break; } } }
Source:
<code>boolean padBetweenBlocks() { return padBetweenBlocks(blockType) || (blockType == <START> OBJ_BLOCK_TYPE && <END> padBetweenBlocks(keyType)); }</code><technical_language>Do INDEX_BLOCK_TYPE here</technical_language>

Target:
boolean padBetweenBlocks() { return padBetweenBlocks(blockType) || (blockType == INDEX_BLOCK_TYPE && padBetweenBlocks(keyType)); }
Source:
<code>protected boolean queryPrefs() { Timber.d("Querying Prefs."); boolean shouldUpdate = false; if (Preferences.getRootFolderName().isEmpty()) { Timber.d("Where are my files?!"); FragmentActivity activity = requireActivity(); Intent intent = new Intent(activity, ImportActivity.class); startActivity(intent); activity.finish(); } if (plannedRefresh && mTotalCount > -1) { Timber.d("A library display refresh has been planned"); shouldUpdate = true; plannedRefresh = false; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { checkStorage(); } <START> booksPerPage = Preferences.getContentPageQuantity(); <END> if (this.booksPerPage != booksPerPage) { Timber.d("booksPerPage updated."); this.booksPerPage = booksPerPage; setQuery(""); shouldUpdate = true; } return shouldUpdate; }</code><technical_language>meant a local variable</technical_language>

Target:
protected boolean queryPrefs() { Timber.d("Querying Prefs."); boolean shouldUpdate = false; if (Preferences.getRootFolderName().isEmpty()) { Timber.d("Where are my files?!"); FragmentActivity activity = requireActivity(); Intent intent = new Intent(activity, ImportActivity.class); startActivity(intent); activity.finish(); } if (plannedRefresh && mTotalCount > -1) { Timber.d("A library display refresh has been planned"); shouldUpdate = true; plannedRefresh = false; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { checkStorage(); } int settingsBooksPerPage = Preferences.getContentPageQuantity(); if (this.booksPerPage != settingsBooksPerPage) { Timber.d("booksPerPage updated."); this.booksPerPage = settingsBooksPerPage; setQuery(""); shouldUpdate = true; } return shouldUpdate; }
Source:
<code>public String generateSPL(JsonObject graph) throws IOException { JsonObject graphConfig = getGraphConfig(graph); breakoutVersion(graphConfig); stvHelper = new SubmissionTimeValue(graph); new Preprocessor(this, graph).preprocess(); <START> System.out.println(graph); <END> System.out.println(); separateIntoComposites(graph); JsonObject mainCompsiteDef = new JsonObject(); mainCompsiteDef.addProperty(KIND, graph.get("name").getAsString()); mainCompsiteDef.addProperty("public", true); mainCompsiteDef.add("parameters", graph.get("parameters")); mainCompsiteDef.addProperty("__spl_mainComposite", true); mainCompsiteDef.add("operators", graph.get("operators")); composites.add(mainCompsiteDef); StringBuilder sb = new StringBuilder(); generateGraph(graph, sb); setDeployment(graph); return sb.toString(); }</code><technical_language>In case notice this, debugging printlns left in</technical_language>

Target:
public String generateSPL(JsonObject graph) throws IOException { JsonObject graphConfig = getGraphConfig(graph); breakoutVersion(graphConfig); stvHelper = new SubmissionTimeValue(graph); new Preprocessor(this, graph).preprocess(); separateIntoComposites(graph); JsonObject mainCompsiteDef = new JsonObject(); mainCompsiteDef.addProperty(KIND, graph.get("name").getAsString()); mainCompsiteDef.addProperty("public", true); mainCompsiteDef.add("parameters", graph.get("parameters")); mainCompsiteDef.addProperty("__spl_mainComposite", true); mainCompsiteDef.add("operators", graph.get("operators")); composites.add(mainCompsiteDef); stvHelper.addJsonParamDefs(mainCompsiteDef); StringBuilder sb = new StringBuilder(); generateGraph(graph, sb); setDeployment(graph); return sb.toString(); }
Source:
<code>int getSpeed( OSMWay way ) { int speed = PUSHING_SECTION_SPEED; String highwayTag = way.getTag("highway"); Integer highwaySpeed = highwaySpeeds.get(highwayTag); String s = way.getTag("surface"); if (!Helper.isEmpty(s)) { Integer surfaceSpeed = surfaceSpeeds.get(s); if (surfaceSpeed != null) { speed = surfaceSpeed; if (highwaySpeed != null && surfaceSpeed > highwaySpeed) { if (pushingSections.contains(highwayTag)) speed = highwaySpeed; else speed = surfaceSpeed; } } } else { String tt = way.getTag("tracktype"); if (!Helper.isEmpty(tt)) { Integer tInt = trackTypeSpeeds.get(tt); if (tInt != null) speed = tInt; } else if (highwaySpeed != null) { if (!way.hasTag("service")) speed = highwaySpeed; else speed = highwaySpeeds.get("living_street"); } } if ((speed > PUSHING_SECTION_SPEED) && (!way.hasTag("bicycle", intendedValues))) { if (way.hasTag("highway", pushingSections)) { if (way.hasTag("highway", "steps")) speed = PUSHING_SECTION_SPEED / 2; else speed = PUSHING_SECTION_SPEED; } else { <START> if (way.hasTag("bicycle", "dismount")) <END> { speed = PUSHING_SECTION_SPEED; } } } return speed; }</code><technical_language>instead of separate 'if' java if (way.hasTag("highway", pushingSections) || way.hasTag("bicycle", "dismount")) this handle steps properly too</technical_language>

Target:
int getSpeed( OSMWay way ) { int speed = PUSHING_SECTION_SPEED; String highwayTag = way.getTag("highway"); Integer highwaySpeed = highwaySpeeds.get(highwayTag); String s = way.getTag("surface"); if (!Helper.isEmpty(s)) { Integer surfaceSpeed = surfaceSpeeds.get(s); if (surfaceSpeed != null) { speed = surfaceSpeed; if (highwaySpeed != null && surfaceSpeed > highwaySpeed) { if (pushingSectionsHighways.contains(highwayTag)) speed = highwaySpeed; else speed = surfaceSpeed; } } } else { String tt = way.getTag("tracktype"); if (!Helper.isEmpty(tt)) { Integer tInt = trackTypeSpeeds.get(tt); if (tInt != null) speed = tInt; } else if (highwaySpeed != null) { if (!way.hasTag("service")) speed = highwaySpeed; else speed = highwaySpeeds.get("living_street"); } } if ((speed > PUSHING_SECTION_SPEED) && (!way.hasTag("bicycle", intendedValues))) { if (way.hasTag("highway", pushingSectionsHighways) || way.hasTag("bicycle", "dismount")) { speed = PUSHING_SECTION_SPEED; } } return speed; }
Source:
<code>public void propagatesFailingComputationResults() throws ExecutionException, InterruptedException { MultiplexingCompletionService<String, Integer> service = MultiplexingCompletionService.create( ImmutableMap.of(KEY_1, executor1, KEY_2, executor2)); service.submit(KEY_1, () -> 5); service.submit(KEY_2, () -> { throw new IllegalArgumentException("bad"); }); executor1.runUntilIdle(); executor2.runUntilIdle(); assertThat(service.poll().get()).isEqualTo(5); assertThatThrownBy(() -> service.poll().get()) .isInstanceOf(ExecutionException.class) <START> .hasCauseInstanceOf(IllegalArgumentException.class); <END> }</code><technical_language>nit, add message</technical_language>

Target:
public void propagatesFailingComputationResults() throws ExecutionException, InterruptedException { MultiplexingCompletionService<String, Integer> service = MultiplexingCompletionService.create( ImmutableMap.of(KEY_1, executor1, KEY_2, executor2)); service.submit(KEY_1, () -> 5); service.submit(KEY_2, () -> { throw new IllegalArgumentException("bad"); }); executor1.runUntilIdle(); executor2.runUntilIdle(); assertThat(service.poll().get()).isEqualTo(5); assertThatThrownBy(() -> service.poll().get()) .isInstanceOf(ExecutionException.class) .hasCauseInstanceOf(IllegalArgumentException.class) .hasMessageContaining("bad"); }
Source:
<code>public Statement apply(Statement base, Description description) { return new Statement() { @Override public void evaluate() throws Throwable { if (!config.isManualStartup()) { startServer(); } try { base.evaluate(); } finally { <START> eserver.shutdown(); <END> } } }; }</code><technical_language>If isManualStartup is set, server started, this throw NPE. I ran this while rying rule in another test</technical_language>

Target:
public Statement apply(Statement base, Description description) { return new Statement() { @Override public void evaluate() throws Throwable { if (!config.isManualStartup()) { startServer(); } try { base.evaluate(); } finally { stopServer(); if (!config.isKeepElasticHomeAfterShutdown()) { deleteHomeDirectory(); } } } }; }
Source:
<code><START> public List<Identifier> getPatientIdentifierList(Config config, String patientUuid) { <END> String responseJson = getJson(config, "/patient/{patientUuid}/identifier", patientUuid); return ((IdentifierListResult) JsonUtils.readJson(responseJson, IdentifierListResult.class)).getResults(); }</code><technical_language>annotation ovverride</technical_language>

Target:
public List<Identifier> getPatientIdentifierList(Config config, String patientUuid) { String responseJson = getJson(config, "/patient/{patientUuid}/identifier?v=full", patientUuid); return ((IdentifierListResult) JsonUtils.readJson(responseJson, IdentifierListResult.class)).getResults(); }
Source:
<code>public ReflectionBeanMapper(Class<T> type) { this.type = type; <START> for (Field field : type.getDeclaredFields()) { <END> properties.put(field.getName().toLowerCase(), field); } }</code><technical_language>This ignore fields superclasses, leaving uninitialized, is want</technical_language>

Target:
public ReflectionBeanMapper(Class<T> type) { this.type = type; cacheAllFieldsIncludingSuperClass(type); }
Source:
<code>public void searchShouldReturnAResponseWithOneTransaction_whenFilteringByStateFromLedger() { Account account = new Account("123456", TokenPaymentType.CARD); <START> var searchParams = new PaymentSearchParams.Builder() <END> .withState("success") .withPageNumber("1") .withDisplaySize("500") .build(); Response response = paymentSearchService.searchLedgerPayments(account, searchParams); JsonAssert.with(response.getEntity().toString()) .assertThat("count", is(1)) .assertThat("total", is(1)) .assertThat("page", is(1)) .assertThat("results", is(collectionWithSize(equalTo(1)))) .assertThat("results[0]", hasKey("amount")) .assertThat("results[0]", hasKey("state")) .assertThat("results[0]", hasKey("reference")) .assertThat("results[0]", hasKey("email")) .assertThat("results[0].card_details.cardholder_name", is("J Doe")) .assertThat("results[0].card_details", hasKey("first_digits_card_number")) .assertThat("results[0].card_details", hasKey("last_digits_card_number")) .assertThat("results[0].state", hasKey("status")) .assertThat("results[0].state", hasKey("finished")) .assertThat("results[0]", hasKey("_links")) .assertThat("_links", hasKey("self")) .assertThat("_links", hasKey("first_page")) .assertThat("_links", hasKey("last_page")) .assertThat("results[0]._links.capture", is(nullValue())) .assertNotDefined("_links.next_page") .assertNotDefined("_links.prev_page"); }</code><technical_language>TBH I in of tests. single test covers scenarios (that query parameters valid), rest is a lot of duplicate code/json. pact files differ query parameter value(s). benefit of separately</technical_language>

Target:
public void searchShouldReturnAResponseWithOneTransaction_whenFilteringByStateFromLedger() { Account account = new Account("123456", TokenPaymentType.CARD); var searchParams = new PaymentSearchParams.Builder() .withState("success") .withPageNumber("1") .withDisplaySize("500") .build(); Response response = paymentSearchService.searchLedgerPayments(account, searchParams); JsonAssert.with(response.getEntity().toString()) .assertThat("count", is(1)) .assertThat("total", is(1)) .assertThat("page", is(1)) .assertThat("results", is(collectionWithSize(equalTo(1)))) .assertThat("results[0]", hasKey("amount")) .assertThat("results[0]", hasKey("state")) .assertThat("results[0]", hasKey("reference")) .assertThat("results[0]", hasKey("email")) .assertThat("results[0].card_details.cardholder_name", is("J Doe")) .assertThat("results[0].card_details", hasKey("first_digits_card_number")) .assertThat("results[0].card_details", hasKey("last_digits_card_number")) .assertThat("results[0].state", hasKey("status")) .assertThat("results[0].state", hasKey("finished")); }