auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void create() { super.create(); Shell shell = getShell(); shell.addShellListener(fActivationListener); PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, "org.eclipse.tracecompass.tmf.ui.widgets.timegraph.dialogs.find_dialog"); fFindField.removeModifyListener(fFindModifyListener); updateCombo(fFindField, fFindHistory); fFindField.addModifyListener(fFindModifyListener); initFindStringFromSelection(); if (fDialogPositionInit != null) { shell.setBounds(fDialogPositionInit); } shell.setText("Find"); }

Target:
public void create() { super.create(); Shell shell = getShell(); shell.addShellListener(fActivationListener); PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, "org.eclipse.tracecompass.tmf.ui.widgets.timegraph.dialogs.find_dialog"); fFindField.removeModifyListener(fFindModifyListener); updateCombo(fFindField, fFindHistory); fFindField.addModifyListener(fFindModifyListener); initFindStringFromSelection(); if (fDialogPositionInit != null) { shell.setBounds(fDialogPositionInit); } shell.setText(Messages.TimeGraphFindDialog_Find_title); }
Source:
public SubTabHostBiosView(DetailModelProvider<HostListModel, HostBiosModel> modelProvider, ApplicationResources resources, ApplicationConstants constants) { super(modelProvider); this.resources = resources; formPanel = new GeneralFormPanel(); initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); Driver.driver.initialize(this); formBuilder = new FormBuilder(formPanel, 3, 6); formBuilder.setColumnsWidth("230px", "120px", "270px"); ArrayList<FormItem> formItems = new ArrayList<FormItem>(); formItems.add(new FormItem(constants.biosManufacturerGeneral(), biosManufacturer, 0, 0)); formItems.add(new FormItem(constants.biosProductNameGeneral(), biosProductName, 1, 0)); formItems.add(new FormItem(constants.biosUUIDGeneral(), biosUUID, 2, 0)); formItems.add(new FormItem(constants.biosVersionGeneral(), biosVersion, 3, 0)); formItems.add(new FormItem(constants.biosSerialNumberGeneral(), biosSerialNumber, 4, 0)); formItems.add(new FormItem(constants.biosFamilyGeneral(), biosFamily, 5, 0)); for (FormItem formItem : formItems) { formBuilder.addFormItem(formItem); } }

Target:
public SubTabHostBiosView(DetailModelProvider<HostListModel, HostBiosModel> modelProvider, ApplicationResources resources, ApplicationConstants constants) { super(modelProvider); this.resources = resources; formPanel = new GeneralFormPanel(); initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); Driver.driver.initialize(this); formBuilder = new FormBuilder(formPanel, 3, 6); formBuilder.setColumnsWidth("230px", "120px", "270px"); formBuilder.addFormItem(new FormItem(constants.biosManufacturerGeneral(), biosManufacturer, 0, 0)); formBuilder.addFormItem(new FormItem(constants.biosProductNameGeneral(), biosProductName, 1, 0)); formBuilder.addFormItem(new FormItem(constants.biosUUIDGeneral(), biosUUID, 2, 0)); formBuilder.addFormItem(new FormItem(constants.biosVersionGeneral(), biosVersion, 3, 0)); formBuilder.addFormItem(new FormItem(constants.biosSerialNumberGeneral(), biosSerialNumber, 4, 0)); formBuilder.addFormItem(new FormItem(constants.biosFamilyGeneral(), biosFamily, 5, 0)); }
Source:
protected void handleMessageInternal(Message<?> message) throws Exception { MessageValues messageToSend = (this.supportsSerializationNatively) ? new MessageValues(message) : serializePayloadIfNecessary(message); this.delegate.handleMessage(embedHeadersIfApplicable(messageToSend)); }

Target:
protected void handleMessageInternal(Message<?> message) throws Exception { Message<?> messageToSend = (this.useNativeEncoding) ? getMessageBuilderFactory().withPayload(message.getPayload()) .copyHeaders(message.getHeaders()).build() : serializeAndEmbedHeadersIfApplicable(message); this.delegate.handleMessage(messageToSend); }
Source:
public DataTransactionResult set(DataHolder dataHolder, SneakingData manipulator, MergeFunction function) { if (dataHolder instanceof Entity) { final ImmutableValue<Boolean> newValue = manipulator.sneaking().asImmutable(); final SneakingData old = from(dataHolder).get(); final ImmutableValue<Boolean> oldValue = old.asImmutable().sneaking(); final SneakingData newData = checkNotNull(function, "function").merge(old, manipulator); final boolean sneaking = newData.sneaking().get(); try { ((Entity) dataHolder).setSneaking(sneaking); return DataTransactionBuilder.successReplaceResult(newValue, oldValue); } catch (Exception e) { DataTransactionBuilder.errorResult(newValue); } } return DataTransactionBuilder.failResult(manipulator.getValues()); }

Target:
public DataTransactionResult set(DataHolder dataHolder, SneakingData manipulator, MergeFunction function) { if (dataHolder instanceof Entity) { final ImmutableValue<Boolean> newValue = manipulator.sneaking().asImmutable(); final SneakingData oldData = from(dataHolder).get(); final ImmutableValue<Boolean> oldValue = oldData.sneaking().asImmutable(); final SneakingData mergedData = checkNotNull(function, "function").merge(oldData, manipulator); final ImmutableValue<Boolean> mergedValue = mergedData.sneaking().asImmutable(); final boolean sneaking = mergedData.sneaking().get(); try { ((Entity) dataHolder).setSneaking(sneaking); return DataTransactionBuilder.successReplaceResult(mergedValue, oldValue); } catch (Exception e) { DataTransactionBuilder.errorResult(newValue); } } return DataTransactionBuilder.failResult(manipulator.getValues()); }
Source:
public void run() { int TARGET = 42; while (continueBusyLoop) { inBusyLoop = true; } Instant osrDeadline = Instant.now().plusSeconds(expectOsr ? 600 : 3); do { inBusyLoop = true; } while (hasJit() && !Main.isInOsrCode("run") && osrDeadline.compareTo(Instant.now()) > 0); if (hasJit()) { boolean inOsr = Main.isInOsrCode("run"); if (allowJit) { inOsr = inOsr || !Main.isInterpreted(); } if (expectOsr && !inOsr) { throw new Error( "Expected to be in OSR but was not. interpreter: " + Main.isInterpreted()); } else if (!expectOsr && inOsr) { throw new Error( "Expected not to be in OSR but was. interpreter: " + Main.isInterpreted()); } } reportValue(TARGET); }

Target:
public void run() { int TARGET = 42; if (hasJit() && expectOsr && !Main.isInterpreted()) { System.out.println("Unexpectedly in jit code prior to restarting the JIT!"); } startJit(); while (continueBusyLoop) { inBusyLoop = true; } Instant osrDeadline = Instant.now().plusSeconds(expectOsr ? 600 : 3); do { inBusyLoop = true; } while (hasJit() && !Main.isInOsrCode("run") && osrDeadline.compareTo(Instant.now()) > 0); if (hasJit()) { boolean inOsr = Main.isInOsrCode("run"); if (expectOsr && !inOsr) { throw new Error( "Expected to be in OSR but was not. interpreter: " + Main.isInterpreted()); } else if (!expectOsr && inOsr) { throw new Error( "Expected not to be in OSR but was. interpreter: " + Main.isInterpreted()); } } reportValue(TARGET); }
Source:
private ObjectId insertMergeResult(TemporaryBuffer buf, Attributes attributes) throws IOException { InputStream in = buf.openInputStream(); try (LfsInputStream is = LFS.getInstance().getCleanFiltered( getRepository(), in, buf.length(), attributes.get(Constants.ATTR_MERGE))) { return getObjectInserter().insert(OBJ_BLOB, is.length, is.stream); } }

Target:
private ObjectId insertMergeResult(TemporaryBuffer buf, Attributes attributes) throws IOException { InputStream in = buf.openInputStream(); try (LfsInputStream is = LfsFactory.getInstance().applyCleanFilter( getRepository(), in, buf.length(), attributes.get(Constants.ATTR_MERGE))) { return getObjectInserter().insert(OBJ_BLOB, is.getLength(), is); } }
Source:
public void ensureMCWUsesRealTail() throws Exception { Map<String, String> map = getDefaultRuntime().getObjectsView().build() .setTypeToken(new TypeToken<SMRMap<String, String>>() { }) .setStreamName("test") .open(); final int initMapSize = 10; for (int x = 0; x < initMapSize; x++) { map.put(String.valueOf(x), String.valueOf(x)); } for (int x = 0; x < initMapSize; x++) { getDefaultRuntime().getSequencerView().next(); } MultiCheckpointWriter mcw = new MultiCheckpointWriter(); mcw.addMap(map); Token trimAddress = mcw.appendCheckpoints(getRuntime(), "author"); Token staleTrimAddress = new Token(trimAddress.getEpoch() - 1, trimAddress.getSequence()); getRuntime().getAddressSpaceView().prefixTrim(staleTrimAddress); }

Target:
public void ensureMCWUsesRealTail() throws Exception { Map<String, String> map = getDefaultRuntime().getObjectsView().build() .setTypeToken(new TypeToken<SMRMap<String, String>>() { }) .setStreamName("test") .open(); final int initMapSize = 10; for (int x = 0; x < initMapSize; x++) { map.put(String.valueOf(x), String.valueOf(x)); } for (int x = 0; x < initMapSize; x++) { getDefaultRuntime().getSequencerView().next(); } MultiCheckpointWriter mcw = new MultiCheckpointWriter(); mcw.addMap(map); Token trimAddress = mcw.appendCheckpoints(getRuntime(), "author"); Token staleTrimAddress = new Token(trimAddress.getEpoch() - 1, trimAddress.getSequence()); getRuntime().getAddressSpaceView().prefixTrim(staleTrimAddress); Token expectedTrimMark = new Token(getRuntime().getLayoutView().getLayout().getEpoch(), staleTrimAddress.getSequence() + 1); assertThat(getRuntime().getAddressSpaceView().getTrimMark()) .isEqualByComparingTo(expectedTrimMark); }
Source:
public void splitUuidConstructor_Test() { final RequestConstructor constructor = new RequestConstructor(SIMPLE_PARAMS, SIMPLE_ARGS, argsToQueryParams(SIMPLE_ARGS), ImmutableList.of(), ""); final ImmutableList<RequestConstructor> result = splitUuidConstructor(constructor); assertThat(result.size(), is(2)); assertTrue(result.get(0).getParameters().stream() .anyMatch(param -> param.getType().equals("UUID"))); assertThat(getQueryParamTypes(result.get(0).getQueryParams()), hasItem("UUID")); assertThat(getAllArgumentTypes(result.get(0).getAssignments()), hasItem("UUID")); result.get(1).getParameters().forEach(param -> assertThat(param.getType(), not("UUID"))); assertThat(getQueryParamTypes(result.get(1).getQueryParams()), not(hasItem("UUID"))); assertThat(getAllArgumentTypes(result.get(1).getAssignments()), not(hasItem("UUID"))); }

Target:
public void splitUuidConstructor_Test() { final RequestConstructor constructor = new RequestConstructor(SIMPLE_PARAMS, SIMPLE_ARGS, argsToQueryParams(SIMPLE_ARGS), ImmutableList.of(), ""); final ImmutableList<RequestConstructor> result = splitUuidConstructor(constructor); assertThat(result).hasSize(2); assertThat(result.get(0).getParameters()).extracting(ConstructorParam::getType).contains("UUID"); assertThat(result.get(0).getQueryParams()).extracting(QueryParam::getType).contains("UUID"); assertThat(result.get(0).getAssignments()).extracting(Arguments::getType).contains("UUID"); assertThat(result.get(1).getParameters()).extracting(ConstructorParam::getType).doesNotContain("UUID"); assertThat(result.get(1).getQueryParams()).extracting(QueryParam::getType).doesNotContain("UUID"); assertThat(result.get(1).getAssignments()).extracting(Arguments::getType).doesNotContain("UUID"); }
Source:
public BiMap<@Nullable String, Integer> getMap() { return fMap; }

Target:
public BiMap<String, Integer> getMap() { return ImmutableBiMap.copyOf(fMap); }
Source:
public void init(Map<String, Serializable> args) throws Exception { if (args.containsKey("sftpHostname")) { sftpHostname = args.get("sftpHostname").toString(); } if (args.containsKey("sftpPort")) { sftpPort = Integer.parseInt(args.get("sftpPort").toString()); } if (args.containsKey("sftpMode")) { sftpMode = args.get("sftpMode").toString(); } if (args.containsKey("sftpExtractArchive")) { sftpExtractArchive = Boolean.parseBoolean(args.get("sftpExtractArchive").toString()); } if (args.containsKey(SFTP_LOCAL_RELATIVE_PATH_ARG) && !args.get(SFTP_LOCAL_RELATIVE_PATH_ARG).toString().isEmpty()) { sftpLocalRelativePath = args.get(SFTP_LOCAL_RELATIVE_PATH_ARG).toString(); } else { if (sftpMode.equals("PUT")) { throw new IllegalArgumentException("you have to specify the local relative path. empty value is not allowed."); } sftpLocalRelativePath = getLocalSpace(); } if (args.containsKey("sftpRemoteRelativePath")) { sftpRemoteRelativePath = args.get("sftpRemoteRelativePath").toString(); } sftpUsername = getThirdPartyCredential("SFTP_USERNAME"); sftpPassword = getThirdPartyCredential("SFTP_PASSWORD"); if (sftpUsername == null || sftpPassword == null) { throw new IllegalArgumentException("you first need to add your ftp username and password (SFTP_USERNAME, SFTP_PASSWORD) to the third party credentials"); } }

Target:
public void init(Map<String, Serializable> args) throws Exception { if (args.containsKey("sftpHostname")) { sftpHostname = args.get("sftpHostname").toString(); } if (args.containsKey("sftpPort")) { try { sftpPort = Integer.parseInt(args.get("sftpPort").toString()); } catch (NumberFormatException e) { getOut().println("Invalid port number. Using default sftp port=" + DEFAULT_SFTP_PORT); } } if (args.containsKey("sftpMode")) { sftpMode = args.get("sftpMode").toString(); } if (args.containsKey("sftpExtractArchive")) { sftpExtractArchive = Boolean.parseBoolean(args.get("sftpExtractArchive").toString()); } if (args.containsKey(SFTP_LOCAL_RELATIVE_PATH_ARG) && !args.get(SFTP_LOCAL_RELATIVE_PATH_ARG).toString().isEmpty()) { sftpLocalAbsolutePath = Paths.get(getLocalSpace(), args.get(SFTP_LOCAL_RELATIVE_PATH_ARG).toString()) .toString(); } else { if (sftpMode.equals(PUT)) { throw new IllegalArgumentException("Please specify a local relative path. Empty value is not allowed."); } sftpLocalAbsolutePath = getLocalSpace(); } if (args.containsKey("sftpRemoteRelativePath")) { sftpRemoteRelativePath = args.get("sftpRemoteRelativePath").toString(); } if (args.containsKey("sftpUsername")) { sftpUsername = args.get("sftpUsername").toString(); } if (sftpUsername == null) { throw new IllegalArgumentException("Username is required to access an SFTP server"); } sftpUrlKey = "sftp://" + sftpUsername + "@" + sftpHostname; sftpPassword = getThirdPartyCredential(sftpUrlKey); if (sftpPassword == null) { throw new IllegalArgumentException("Please add your sftp password to 3rd-party credentials under the key :\"" + SFTP_URL_KEY + "\""); } }
Source:
public DmsProject getParentStudyByDataset(Integer datasetId) throws MiddlewareQueryException { try { Criteria criteria = this.getSession().createCriteria(this.getPersistentClass()); criteria.createAlias("relatedTos", "pr"); criteria.add(Restrictions.eq("pr.typeId", TermId.BELONGS_TO_STUDY.getId())); criteria.add(Restrictions.eq("pr.subjectProject.projectId", datasetId)); criteria.setProjection(Projections.property("pr.objectProject")); return (DmsProject) criteria.uniqueResult(); } catch (HibernateException e) { this.logAndThrowException("Error in getParentStudyByDataset= " + datasetId + " query in DmsProjectDao: " + e.getMessage(), e); } return null; }

Target:
public DmsProject getParentStudyByDataset(Integer datasetId) { try { Criteria criteria = this.getSession().createCriteria(this.getPersistentClass()); criteria.createAlias("relatedTos", "pr"); criteria.add(Restrictions.eq("pr.typeId", TermId.BELONGS_TO_STUDY.getId())); criteria.add(Restrictions.eq("pr.subjectProject.projectId", datasetId)); criteria.setProjection(Projections.property("pr.objectProject")); return (DmsProject) criteria.uniqueResult(); } catch (HibernateException e) { this.logAndThrowException("Error in getParentStudyByDataset= " + datasetId + " query in DmsProjectDao: " + e.getMessage(), e); } return null; }
Source:
public void unregisterService(ServiceDescription description) { for (JmDNS instance : jmdnsInstances) { logger.debug("Unregistering service at port (instance {})", description.serviceType, description.servicePort, instance.getName()); ServiceInfo serviceInfo = ServiceInfo.create(description.serviceType, description.serviceName, description.servicePort, 0, 0, description.serviceProperties); instance.unregisterService(serviceInfo); } }

Target:
public void unregisterService(ServiceDescription description) { for (JmDNS instance : jmdnsInstances) { try { logger.debug("Unregistering service at {}:{} ({})", description.serviceType, instance.getInetAddress().getHostAddress(), description.servicePort, instance.getName()); } catch (IOException e) { logger.debug("Unregistering service ({})", description.serviceType, instance.getName()); } ServiceInfo serviceInfo = ServiceInfo.create(description.serviceType, description.serviceName, description.servicePort, 0, 0, description.serviceProperties); instance.unregisterService(serviceInfo); } }
Source:
public void testSecondaryRequestsPropagatedToChildren() throws InterruptedException { Observable<Integer> o1 = Observable.from(Arrays.asList(1, 2, 3)) .delay(100, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.computation()); Observable<Integer> o2 = Observable.from(Arrays.asList(4, 5, 6)) .delay(200, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.computation()); TestSubscriber<Integer> ts = new TestSubscriber<Integer>(); ts.requestMore(1); Observable.amb(o1, o2).subscribe(ts); ts.requestMore(20); ts.awaitTerminalEvent(5, TimeUnit.SECONDS); ts.assertNoErrors(); }

Target:
public void testSecondaryRequestsPropagatedToChildren() throws InterruptedException { Observable<Integer> o1 = Observable.from(Arrays.asList(1, 2, 3)) .delay(100, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.computation()); Observable<Integer> o2 = Observable.from(Arrays.asList(4, 5, 6)) .delay(200, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.computation()); TestSubscriber<Integer> ts = new TestSubscriber<Integer>() { @Override public void onStart() { request(1); }}; Observable.amb(o1, o2).subscribe(ts); ts.requestMore(20); ts.awaitTerminalEvent(5, TimeUnit.SECONDS); ts.assertNoErrors(); }
Source:
public Map<String, String> getBinaryFulltext(Serializable id) { if (fulltextDescriptor.getFulltextDisabled()) { return null; } RowId rowId = new RowId(Model.FULLTEXT_TABLE_NAME, id); Map<String, String> map = mapper.getBinaryFulltext(rowId); if (fulltextDescriptor.getFulltextStoredInBlob()) { String key = map.get("binarytext"); if (key != null) { DocumentBlobManager blobManager = Framework.getService(DocumentBlobManager.class); try { BlobInfo blobInfo = new BlobInfo(); blobInfo.key = key; Blob blob = blobManager.readBlob(blobInfo, getRepositoryName()); String fulltext = blob.getString(); map.put("binarytext", fulltext); } catch (IOException e) { throw new PropertyException("Cannot read fulltext blob for doc: " + id, e); } } } return map; }

Target:
public Map<String, String> getBinaryFulltext(Serializable id) { if (fulltextDescriptor.getFulltextDisabled()) { return null; } RowId rowId = new RowId(Model.FULLTEXT_TABLE_NAME, id); Map<String, String> map = mapper.getBinaryFulltext(rowId); String fulltext = map.get(BINARY_FULLTEXT_MAIN_KEY); if (fulltextDescriptor.getFulltextStoredInBlob() && fulltext != null) { DocumentBlobManager blobManager = Framework.getService(DocumentBlobManager.class); try { BlobInfo blobInfo = new BlobInfo(); blobInfo.key = fulltext; Blob blob = blobManager.readBlob(blobInfo, getRepositoryName()); fulltext = blob.getString(); map.put(BINARY_FULLTEXT_MAIN_KEY, fulltext); } catch (IOException e) { throw new PropertyException("Cannot read fulltext blob for doc: " + id, e); } } return map; }
Source:
public boolean useBindVariables() { return true; }

Target:
boolean useBindVariables() { return true; }
Source:
public void tableNotAccessibleDoesNotError() throws Exception { when(client.describe_keyspace("system_palantir")) .thenReturn(new KsDef("system_palantir", "", ImmutableList.of())); DummyClientPool clientPool = new DummyClientPool(client); Supplier<Map<String, String>> hostnamesByIpSupplier = new HostnamesByIpSupplier(() -> clientPool); assertThatCode(hostnamesByIpSupplier::get).doesNotThrowAnyException(); assertThat(hostnamesByIpSupplier.get()).isEmpty(); }

Target:
public void tableNotAccessibleDoesNotError() throws Exception { when(client.describe_keyspace("system_palantir")) .thenReturn(new KsDef("system_palantir", "", ImmutableList.of())); assertThatCode(hostnamesByIpSupplier::get).doesNotThrowAnyException(); assertThat(hostnamesByIpSupplier.get()).isEmpty(); }
Source:
public void testMultiPartitionLoad() throws Exception { if (isHSQL()) { System.out.println("Skip testMultiPartitionLoad for HSQL"); return; } Client client = getClient(); VoltTable table; ClientResponse r; table = m_template.clone(100); table.addRow(1, 1, 1, "1", 1.0); table.addRow(2, 1, 2, "2", 2.0); table.addRow(3, 2, 3, "3", 3.0); table.addRow(4, 2, 4, "4", 4.0); r = client.callProcedure("@LoadMultipartitionTable", "REPLICATED", upsertMode, table); assertEquals(ClientResponse.SUCCESS, r.getStatus()); assertEquals(1, r.getResults().length); assertEquals(4, r.getResults()[0].asScalarLong()); assertEquals(4, countReplicatedRows(client)); table = m_template.clone(100); table.addRow(1, 1, 1, "1", 1.0); table.addRow(2, 1, 2, "2", 2.0); table.addRow(3, 2, 3, "3", 3.0); table.addRow(4, 2, 4, "4", 4.0); try { r = client.callProcedure("@LoadMultipartitionTable", "PARTITIONED", upsertMode, table); fail(); } catch (ProcCallException e) { e.printStackTrace(); } table = m_template.clone(100); table.addRow(5, 1, 5, "5", 5.0); table.addRow(5, 1, 5, "5", 5.0); try { r = client.callProcedure("@LoadMultipartitionTable", "REPLICATED", upsertMode, table); fail(); } catch (ProcCallException e) { e.printStackTrace(); } table = m_template.clone(100); table.addRow(6, 1, 5, "6", 5.0); table.addRow(7, 1, 5, "777", 5.0); try { r = client.callProcedure("@LoadMultipartitionTable", "REPLICATED", upsertMode, table); fail(); } catch (ProcCallException e) { e.printStackTrace(); } assertEquals(4, countReplicatedRows(client)); }

Target:
public void testMultiPartitionLoad() throws Exception { if (isHSQL()) { System.out.println("Skip testMultiPartitionLoad for HSQL"); return; } Client client = getClient(); VoltTable table; ClientResponse r; table = m_template.clone(100); table.addRow(1, 1, 1, "1", 1.0); table.addRow(2, 1, 2, "2", 2.0); table.addRow(3, 2, 3, "3", 3.0); table.addRow(4, 2, 4, "4", 4.0); r = client.callProcedure("@LoadMultipartitionTable", "REPLICATED", upsertMode, table); assertEquals(ClientResponse.SUCCESS, r.getStatus()); assertEquals(1, r.getResults().length); assertEquals(4, r.getResults()[0].asScalarLong()); assertEquals(4, countReplicatedRows(client)); table = m_template.clone(100); table.addRow(1, 1, 1, "1", 1.0); table.addRow(2, 1, 2, "2", 2.0); table.addRow(3, 2, 3, "3", 3.0); table.addRow(4, 2, 4, "4", 4.0); try { r = client.callProcedure("@LoadMultipartitionTable", "PARTITIONED", upsertMode, table); fail(); } catch (ProcCallException e) { assertTrue(e.getMessage().contains("no longer supports loading partitioned tables")); } table = m_template.clone(100); table.addRow(5, 1, 5, "5", 5.0); table.addRow(5, 1, 5, "5", 5.0); try { r = client.callProcedure("@LoadMultipartitionTable", "REPLICATED", upsertMode, table); fail(); } catch (ProcCallException e) { assertTrue(e.getMessage().contains("CONSTRAINT VIOLATION")); } table = m_template.clone(100); table.addRow(6, 1, 5, "6", 5.0); table.addRow(7, 1, 5, "777", 5.0); try { r = client.callProcedure("@LoadMultipartitionTable", "REPLICATED", upsertMode, table); fail(); } catch (ProcCallException e) { assertTrue(e.getMessage().contains("SQL ERROR")); } assertEquals(4, countReplicatedRows(client)); }
Source:
public void removeLock(String taskid, TaskLock taskLockToRemove) { Preconditions.checkNotNull(taskid, "taskid"); Preconditions.checkNotNull(taskLockToRemove, "taskLockToRemove"); final Map<Long, TaskLock> taskLocks = getLocksWithIds(taskid); boolean removed = false; for (final Map.Entry<Long, TaskLock> taskLockWithId : taskLocks.entrySet()) { final long id = taskLockWithId.getKey(); final TaskLock taskLock = taskLockWithId.getValue(); if (taskLock.equals(taskLockToRemove)) { log.info("Deleting TaskLock with id[%d]: %s", id, taskLock); handler.removeLock(id); removed = true; } } if (!removed) { log.error("Did not found any TaskLock [%s] to remove", taskLockToRemove); } }

Target:
public void removeLock(String taskid, TaskLock taskLockToRemove) { Preconditions.checkNotNull(taskid, "taskid"); Preconditions.checkNotNull(taskLockToRemove, "taskLockToRemove"); final Map<Long, TaskLock> taskLocks = getLocksWithIds(taskid); boolean removed = false; for (final Map.Entry<Long, TaskLock> taskLockWithId : taskLocks.entrySet()) { final long id = taskLockWithId.getKey(); final TaskLock taskLock = taskLockWithId.getValue(); if (taskLock.equals(taskLockToRemove)) { log.info("Deleting TaskLock with id[%d]: %s", id, taskLock); handler.removeLock(id); removed = true; } } if (!removed) { log.error("Did not find any TaskLock [%s] to remove", taskLockToRemove); } }
Source:
public int length() throws IOException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); this.print(baos); return baos.size(); }

Target:
public int length() throws IOException { return this.asString().length(); }
Source:
protected JoinGroupRequestData.JoinGroupRequestProtocolCollection metadata() { log.debug("Joining group with current subscription: {}", subscriptions.subscription()); this.joinedSubscription = subscriptions.subscription(); subscriptions.resetGroupSubscription(); JoinGroupRequestData.JoinGroupRequestProtocolCollection protocolSet = new JoinGroupRequestData.JoinGroupRequestProtocolCollection(); List<String> topics = new ArrayList<>(joinedSubscription); for (ConsumerPartitionAssignor assignor : assignors) { Subscription subscription = new Subscription(topics, assignor.subscriptionUserData(joinedSubscription), subscriptions.assignedPartitionsList()); ByteBuffer metadata = ConsumerProtocol.serializeSubscription(subscription); protocolSet.add(new JoinGroupRequestData.JoinGroupRequestProtocol() .setName(assignor.name()) .setMetadata(Utils.toArray(metadata))); } return protocolSet; }

Target:
protected JoinGroupRequestData.JoinGroupRequestProtocolCollection metadata() { log.debug("Joining group with current subscription: {}", subscriptions.subscription()); this.joinedSubscription = subscriptions.subscription(); JoinGroupRequestData.JoinGroupRequestProtocolCollection protocolSet = new JoinGroupRequestData.JoinGroupRequestProtocolCollection(); List<String> topics = new ArrayList<>(joinedSubscription); for (ConsumerPartitionAssignor assignor : assignors) { Subscription subscription = new Subscription(topics, assignor.subscriptionUserData(joinedSubscription), subscriptions.assignedPartitionsList()); ByteBuffer metadata = ConsumerProtocol.serializeSubscription(subscription); protocolSet.add(new JoinGroupRequestData.JoinGroupRequestProtocol() .setName(assignor.name()) .setMetadata(Utils.toArray(metadata))); } return protocolSet; }
Source:
public void modelExec(final Runnable runnable, boolean block) { Display displayThread = Display.getCurrent(); if (displayThread == null) { if (!PlatformUI.getWorkbench().isClosing()) { displayThread = Display.getDefault(); } else { throw new OperationCanceledException(); } } if (block) { if (Display.getCurrent() != null) { runnable.run(); } else { displayThread.syncExec(runnable); } } else { displayThread.asyncExec(runnable); } }

Target:
public void modelExec(final Runnable runnable, boolean block) { Display displayThread = Display.getCurrent(); if (displayThread == null) { if (!PlatformUI.getWorkbench().isClosing()) { displayThread = PlatformUI.getWorkbench().getDisplay(); } else { throw new OperationCanceledException(); } } if (block) { if (Display.getCurrent() != null) { runnable.run(); } else { displayThread.syncExec(runnable); } } else { displayThread.asyncExec(runnable); } }
Source:
public void execute() throws BuildException { try { if ( fDomain==null && fWorkstation==null ) { fSardine = SardineFactory.begin(fUsername, fPassword); } else { fSardine = SardineFactory.begin(); fSardine.setCredentials(fUsername, fPassword, fDomain, fWorkstation); } if (fIgnoreCookies) { fSardine.ignoreCookies(); } if (fPreemptiveAuthenticationHost != null && !fPreemptiveAuthenticationHost.isEmpty()) { fSardine.enablePreemptiveAuthentication(fPreemptiveAuthenticationHost); } for (Command command: fCommands) { command.executeCommand(); } } catch (Exception e) { throw new BuildException("failed: " + e.getLocalizedMessage(), e); } }

Target:
public void execute() throws BuildException { try { if (domain == null && workstation == null) { sardine = SardineFactory.begin(username, password); } else { sardine = SardineFactory.begin(); sardine.setCredentials(username, password, domain, workstation); } if (ignoreCookies) { sardine.ignoreCookies(); } if (preemptiveAuthenticationHost != null && !preemptiveAuthenticationHost.isEmpty()) { sardine.enablePreemptiveAuthentication(preemptiveAuthenticationHost); } for (Command command: commands) { command.executeCommand(); } } catch (Exception e) { throw new BuildException("failed: " + e.getLocalizedMessage(), e); } }
Source:
public void throwIfUnsupportedScan(Scan scan) { if (scan.getFilter() != null) { filterAdapter.throwIfUnsupportedFilter(scan, scan.getFilter()); } if (scan.getMaxResultsPerColumnFamily() != -1) { throw new UnsupportedOperationException( "Limiting of max results per column family is not supported."); } }

Target:
public void throwIfUnsupportedScan(Scan scan) { if (scan.getFilter() != null) { filterAdapter.throwIfUnsupportedFilter(scan, scan.getFilter()); } if (scan.getMaxResultsPerColumnFamily() != UNSET_MAX_RESULTS_PER_COLUMN_FAMILY) { throw new UnsupportedOperationException( "Limiting of max results per column family is not supported."); } }
Source:
public String getDefaultMongoCollection() { return context.getString(R.string.pref_default_mongodb_collection); }

Target:
private String getDefaultMongoCollection() { return context.getString(R.string.pref_default_mongodb_collection); }
Source:
List<JsonObject> getLanguageMap(Locale locale) { if (!languageMaps.containsKey(locale)) { try { List<JsonObject> set = new ArrayList<>(); for (String namespace : config.getLanguageNamespaces()) { String filename = locale.getLanguage() + "_" + locale.getCountry() + File.separator + namespace + ".json"; Resource r = getBaseDirectory().createRelative(filename); if (!r.exists()) { logger.debug("Fallback locale to language only."); filename = locale.getLanguage() + File.separator + namespace + ".json"; r = getBaseDirectory().createRelative(filename); } logger.info("No locale loaded, trying to load from {}", r); JsonParser parser = new JsonParser(); JsonObject obj = (JsonObject) parser.parse(new InputStreamReader(r.getInputStream(), "UTF-8")); set.add(obj); } languageMaps.put(locale, set); } catch (FileNotFoundException e) { logger.info("Unable to load locale because no messages file was found for locale {}", locale.getDisplayName()); languageMaps.put(locale, null); } catch (JsonIOException | JsonSyntaxException | IOException e) { logger.error("Unable to load locale", e); } } return languageMaps.get(locale); }

Target:
private List<JsonObject> getLanguageMap(Locale locale) { if (!languageMaps.containsKey(locale)) { try { List<JsonObject> set = new ArrayList<>(); for (String namespace : config.getLanguageNamespaces()) { String filename = locale.getLanguage() + "_" + locale.getCountry() + File.separator + namespace + ".json"; Resource r = getBaseDirectory().createRelative(filename); if (!r.exists()) { logger.debug("Fallback locale to language only."); filename = locale.getLanguage() + File.separator + namespace + ".json"; r = getBaseDirectory().createRelative(filename); } logger.info("No locale loaded, trying to load from {}", r); JsonParser parser = new JsonParser(); JsonObject obj = (JsonObject) parser.parse(new InputStreamReader(r.getInputStream(), "UTF-8")); set.add(obj); } languageMaps.put(locale, set); } catch (FileNotFoundException e) { logger.info("Unable to load locale because no messages file was found for locale {}", locale.getDisplayName()); languageMaps.put(locale, null); } catch (JsonIOException | JsonSyntaxException | IOException e) { logger.error("Unable to load locale", e); } } return languageMaps.get(locale); }
Source:
public CoreMessage setAddress(SimpleString address) { if (address == null && this.address == null) { return this; } if (validBuffer && ((address == null && this.address != null) || !address.equals(this.address))) { messageChanged(); } this.address = address; return this; }

Target:
public CoreMessage setAddress(SimpleString address) { if (address == null && this.address == null) { return this; } if (validBuffer && (address == null || !address.equals(this.address))) { messageChanged(); } this.address = address; return this; }
Source:
private void error(String message, Protos.Error.ErrorCode errorCode, CloseReason closeReason) { log.error(message); Protos.Error.Builder errorBuilder; errorBuilder = Protos.Error.newBuilder() .setCode(errorCode) .setExplanation(message != null ? message : ""); conn.sendToClient(Protos.TwoWayChannelMessage.newBuilder() .setError(errorBuilder) .setType(Protos.TwoWayChannelMessage.MessageType.ERROR) .build()); conn.destroyConnection(closeReason); }

Target:
private void error(String message, Protos.Error.ErrorCode errorCode, CloseReason closeReason) { log.error(message); Protos.Error.Builder errorBuilder; errorBuilder = Protos.Error.newBuilder() .setCode(errorCode); if (message != null) { errorBuilder.setExplanation(message); } conn.sendToClient(Protos.TwoWayChannelMessage.newBuilder() .setError(errorBuilder) .setType(Protos.TwoWayChannelMessage.MessageType.ERROR) .build()); conn.destroyConnection(closeReason); }
Source:
public void showPopupMenu(Component invoker, Collection<Action> actions, int x, int y) { JPopupMenu menu = new JPopupMenu(); String assignTo = GanttLanguage.getInstance().getText("assignment.toResource"); JMenu resourcesMenu = new JMenu(assignTo); for (Action action : actions) { if (action == null) { menu.addSeparator(); } else if (AssignmentToggleAction.class.equals(action.getClass())){ resourcesMenu.add( new JCheckBoxMenuItem( action )); continue; } else { Boolean isSelected = (Boolean) action.getValue(Action.SELECTED_KEY); if (isSelected == null) { menu.add(action); } else { menu.add(new JCheckBoxMenuItem(action)); } } } if (resourcesMenu.getItemCount() > 0) menu.add(resourcesMenu); menu.applyComponentOrientation(getLanguage().getComponentOrientation()); menu.show(invoker, x, y); }

Target:
public void showPopupMenu(Component invoker, Collection<Action> actions, int x, int y) { JPopupMenu menu = new JPopupMenu(); String assignTo = GanttLanguage.getInstance().getText("assignments"); JMenu resourcesMenu = new JMenu(assignTo); for (Action action : actions) { if (action == null) { menu.addSeparator(); } else if (AssignmentToggleAction.class.equals(action.getClass())){ resourcesMenu.add(new JCheckBoxMenuItem(action)); continue; } else { Boolean isSelected = (Boolean) action.getValue(Action.SELECTED_KEY); if (isSelected == null) { menu.add(action); } else { menu.add(new JCheckBoxMenuItem(action)); } } } if (resourcesMenu.getItemCount() > 0) { menu.add(resourcesMenu); } menu.applyComponentOrientation(getLanguage().getComponentOrientation()); menu.show(invoker, x, y); }
Source:
public void waitForPostgresToStart() { Stopwatch timer = Stopwatch.createStarted(); boolean succeeded = false; while (!succeeded && timer.elapsed(TimeUnit.SECONDS) < 10) { sleep(10); succeeded = checkPostgresConnection(); } if (!succeeded) { throw new RuntimeException("Postgres did not start in 10 seconds."); } System.out.println("Postgres docker container started in " + timer.elapsed(TimeUnit.MILLISECONDS)); }

Target:
public void waitForPostgresToStart() { Stopwatch timer = Stopwatch.createStarted(); boolean succeeded = false; while (!succeeded && timer.elapsed(TimeUnit.SECONDS) < 10) { sleep(10); succeeded = checkPostgresConnection(); } if (!succeeded) { throw new RuntimeException("Postgres did not start in 10 seconds."); } logger.info("Postgres docker container started in {}", timer.elapsed(TimeUnit.MILLISECONDS)); }
Source:
public String getImageUrl(String imageName) { for (WebElement elem:imagesNewFiles) { String href = elem.findElement(parentBy).getAttribute("href"); if (href.contains(imageName)){ return href; } } return null; }

Target:
public String getImageUrl(String imageName) { for (WebElement elem:imagesNewFiles) { String href = elem.findElement(parentBy).getAttribute("href"); if (href.contains(imageName)){ return href; } } throw new RuntimeException("there is no " + imageName + " on Special:NewFiles page"); }
Source:
public void propagate(int i, int mask) throws ContradictionException { if (i == 2) { sdm.freeze(); sdm.forEach(elemRem, SetEventType.REMOVE_FROM_ENVELOPE); sdm.unfreeze(); } if (iv.isInstantiated()) { set.addToKernel(iv.getValue(), aCause); setPassive(); } }

Target:
public void propagate(int i, int mask) throws ContradictionException { if (i == 0) { sdm.freeze(); sdm.forEach(elemRem, SetEventType.REMOVE_FROM_ENVELOPE); sdm.unfreeze(); } if (iv.isInstantiated()) { set.addToKernel(iv.getValue(), aCause); setPassive(); } }
Source:
protected RequestCondition<?> getCustomTypeCondition(Class<?> handlerType) { SiteMapping typeAnnotation = AnnotationUtils.findAnnotation(handlerType, SiteMapping.class); if (typeAnnotation == null) { return null; } return new SiteRequestCondition(siteSet, siteResolver, ImmutableSet.copyOf(typeAnnotation.value()), ImmutableSet.copyOf(typeAnnotation.excluded())); }

Target:
protected RequestCondition<?> getCustomTypeCondition(Class<?> handlerType) { SiteMapping typeAnnotation = AnnotationUtils.findAnnotation(handlerType, SiteMapping.class); if (typeAnnotation == null) { return null; } if (typeAnnotation.value().length == 0) { return SiteRequestCondition.createByExcluded(siteSet, siteResolver, ImmutableSet.copyOf(typeAnnotation.excluded())); } return SiteRequestCondition.create(siteSet, siteResolver, ImmutableSet.copyOf(typeAnnotation.value()), ImmutableSet.copyOf(typeAnnotation.excluded())); }
Source:
private void setGlobalOption(ProcessType processType, Item item, String talendStudioVersion) throws PersistenceException { ElementParameterType property = TalendFileFactory.eINSTANCE.createElementParameterType(); property.setName(CHECKBOX_DATASET); property.setField("CHECK"); property.setValue("false"); boolean isParameterAlreadyAdded = processType.getParameters().getElementParameter().stream().anyMatch(x -> "USE_DATASET_API".equals(((ElementParameterTypeImpl) x).getName())); if (!isParameterAlreadyAdded && !talendStudioVersion.startsWith("7.3.1") && !talendStudioVersion.startsWith("7.4.1")) { processType.getParameters().getElementParameter().add(property); } ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance(); factory.save(item, true); }

Target:
private void setGlobalOption(ProcessType processType, Item item, String talendStudioVersion) throws PersistenceException { ElementParameterType property = TalendFileFactory.eINSTANCE.createElementParameterType(); property.setName(CHECKBOX_DATASET); property.setField("CHECK"); property.setValue("false"); boolean isParameterAlreadyAdded = processType.getParameters().getElementParameter().stream().anyMatch(x -> "USE_DATASET_API".equals(((ElementParameterTypeImpl) x).getName())); if (!isParameterAlreadyAdded && talendStudioVersion.compareTo("7.3.1") < 0) { processType.getParameters().getElementParameter().add(property); } ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance(); factory.save(item, true); }
Source:
public Slice get(Slice key, long timeBucket, ReadSource readSource) { if (key.getClass() == Slice.class) { key = new SerializeSlice(key); } switch (readSource) { case MEMORY: return getFromMemory(key); case READERS: return getFromReaders(key, timeBucket); case ALL: default: Slice value = getFromMemory(key); if (value != null) { return value; } return getFromReaders(key, timeBucket); } }

Target:
public Slice get(Slice key, long timeBucket, ReadSource readSource) { releaseMemory(); key = SliceUtils.toBufferSlice(key); switch (readSource) { case MEMORY: return getFromMemory(key); case READERS: return getFromReaders(key, timeBucket); case ALL: default: Slice value = getFromMemory(key); if (value != null) { return value; } return getFromReaders(key, timeBucket); } }
Source:
protected void init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, boolean outputExpectsExpiredEvents, SiddhiAppContext siddhiAppContext) { this.outputExpectsExpiredEvents = outputExpectsExpiredEvents; this.siddhiAppContext = siddhiAppContext; currentEventQueue = new SnapshotableStreamEventQueue(streamEventClonerHolder); if (outputExpectsExpiredEvents) { expiredEventQueue = new SnapshotableStreamEventQueue(streamEventClonerHolder); } if (attributeExpressionExecutors.length == 1) { length = (Integer) (((ConstantExpressionExecutor) attributeExpressionExecutors[0]).getValue()); } else if (attributeExpressionExecutors.length == 0) { length = -1; } else { throw new SiddhiAppValidationException("Length batch window should have at most one parameter (<int> " + "chunkLength), but found " + attributeExpressionExecutors.length + " input attributes"); } }

Target:
protected void init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, boolean outputExpectsExpiredEvents, SiddhiAppContext siddhiAppContext) { this.outputExpectsExpiredEvents = outputExpectsExpiredEvents; this.siddhiAppContext = siddhiAppContext; currentEventQueue = new SnapshotableStreamEventQueue(streamEventClonerHolder); if (outputExpectsExpiredEvents) { expiredEventQueue = new SnapshotableStreamEventQueue(streamEventClonerHolder); } if (attributeExpressionExecutors.length == 1) { length = (Integer) (((ConstantExpressionExecutor) attributeExpressionExecutors[0]).getValue()); } else if (attributeExpressionExecutors.length == 0) { length = 0; } else { throw new SiddhiAppValidationException("Batch window should have at most one parameter (<int> " + "chunkLength), but found " + attributeExpressionExecutors.length + " input attributes"); } if (length < 0) { throw new SiddhiAppValidationException("Batch window should have at most one parameter (<int> " + "chunkLength) greater than zero. But found value 'chunkLength = " + length + " ' "); } }
Source:
public void configurePipeline(PipelineConfigurer pipelineConfigurer) { FailureCollector collector = pipelineConfigurer.getStageConfigurer().getFailureCollector(); config.validate(collector); FileFormat format = getFileFormat(); if (format != null) { ValidatingOutputFormatProvider outputFormatProvider = pipelineConfigurer.usePlugin("outputformat", format.name().toLowerCase(), FORMAT_PLUGIN_ID, config.getProperties()); FormatContext context = new FormatContext(collector, pipelineConfigurer.getStageConfigurer().getInputSchema()); validateOutputFormatProvider(context, format, outputFormatProvider); } }

Target:
public void configurePipeline(PipelineConfigurer pipelineConfigurer) { FailureCollector collector = pipelineConfigurer.getStageConfigurer().getFailureCollector(); config.validate(collector); FileFormat format = config.getFormat(); ValidatingOutputFormat validatingOutputFormat = pipelineConfigurer.usePlugin(ValidatingOutputFormat.PLUGIN_TYPE, format.name().toLowerCase(), FORMAT_PLUGIN_ID, config.getProperties()); FormatContext context = new FormatContext(collector, pipelineConfigurer.getStageConfigurer().getInputSchema()); validateOutputFormatProvider(context, format, validatingOutputFormat); }
Source:
public GatewayResponse<WorldpayOrderStatusResponse> authorise(CardAuthorisationGatewayRequest request) { if (!WorldpayOrderBuilder.isExemptionEngineEnabled(request)) { ChargeEntity charge = request.getCharge(); charge.setExemption3ds(EXEMPTION_NOT_REQUESTED); chargeDao.merge(charge); } GatewayResponse<WorldpayOrderStatusResponse> response = worldpayAuthoriseHandler.authorise(request); if (response.getBaseResponse().map(WorldpayOrderStatusResponse::isSoftDecline).orElse(false)) { var authorisationRequestSummary = generateAuthorisationRequestSummary(request.getCharge(), request.getAuthCardDetails()); authorisationLogger.logChargeAuthorisation( LOGGER, authorisationRequestSummary, request.getCharge(), authorisationService.extractTransactionId(request.getCharge().getExternalId(), response) .orElse("missing transaction ID"), response, request.getCharge().getChargeStatus(), request.getCharge().getChargeStatus()); response = worldpayAuthoriseHandler.authorise(request, true); } return response; }

Target:
public GatewayResponse<WorldpayOrderStatusResponse> authorise(CardAuthorisationGatewayRequest request) { boolean exemptionEngineEnabled = isExemptionEngineEnabled(request); if (!exemptionEngineEnabled) { ChargeEntity charge = request.getCharge(); charge.setExemption3ds(EXEMPTION_NOT_REQUESTED); chargeDao.merge(charge); LOGGER.info("Updated exemption_3ds of charge to - charge_external_id={}", EXEMPTION_NOT_REQUESTED, charge.getExternalId()); } GatewayResponse<WorldpayOrderStatusResponse> response = worldpayAuthoriseHandler.authorise(request, exemptionEngineEnabled); if (response.getBaseResponse().map(WorldpayOrderStatusResponse::isSoftDecline).orElse(false)) { var authorisationRequestSummary = generateAuthorisationRequestSummary(request.getCharge(), request.getAuthCardDetails()); authorisationLogger.logChargeAuthorisation( LOGGER, authorisationRequestSummary, request.getCharge(), authorisationService.extractTransactionId(request.getCharge().getExternalId(), response) .orElse("missing transaction ID"), response, request.getCharge().getChargeStatus(), request.getCharge().getChargeStatus()); response = worldpayAuthoriseHandler.authorise(request, false); } return response; }
Source:
public void testResolveWithInterceptor() throws IOException { String regexStr = "^/user/(?<username>\\w+)"; String dstPathStr = "/namenode1/testResolve/$username"; RegexMountPointResolvedDstPathReplaceInterceptor interceptor = new RegexMountPointResolvedDstPathReplaceInterceptor("_", "-"); String settingsStr = interceptor.serializeToString(); RegexMountPoint regexMountPoint = new RegexMountPoint(inodeTree, regexStr, dstPathStr, settingsStr); regexMountPoint.initialize(); InodeTree.ResolveResult resolveResult = regexMountPoint.resolve("/user/hadoop_user1/file_index", true); Assert.assertEquals(resolveResult.kind, InodeTree.ResultKind.EXTERNAL_DIR); Assert.assertTrue( resolveResult.targetFileSystem instanceof TestRegexMountPointFileSystem); Assert.assertTrue(resolveResult.resolvedPath.equals("/user/hadoop_user1")); Assert.assertTrue( resolveResult.targetFileSystem instanceof TestRegexMountPointFileSystem); Assert.assertTrue( ((TestRegexMountPointFileSystem) resolveResult.targetFileSystem) .getUri().toString().equals("/namenode1/testResolve/hadoop-user1")); Assert.assertTrue( resolveResult.remainingPath.toString().equals("/file_index")); }

Target:
public void testResolveWithInterceptor() throws IOException { String regexStr = "^/user/(?<username>\\w+)"; String dstPathStr = "/namenode1/testResolve/$username"; RegexMountPointResolvedDstPathReplaceInterceptor interceptor = new RegexMountPointResolvedDstPathReplaceInterceptor("_", "-"); String settingsStr = interceptor.serializeToString(); RegexMountPoint regexMountPoint = new RegexMountPoint(inodeTree, regexStr, dstPathStr, settingsStr); regexMountPoint.initialize(); InodeTree.ResolveResult resolveResult = regexMountPoint.resolve("/user/hadoop_user1/file_index", true); Assert.assertEquals(resolveResult.kind, InodeTree.ResultKind.EXTERNAL_DIR); Assert.assertTrue( resolveResult.targetFileSystem instanceof TestRegexMountPointFileSystem); Assert.assertEquals("/user/hadoop_user1", resolveResult.resolvedPath); Assert.assertTrue( resolveResult.targetFileSystem instanceof TestRegexMountPointFileSystem); Assert.assertEquals("/namenode1/testResolve/hadoop-user1", ((TestRegexMountPointFileSystem) resolveResult.targetFileSystem) .getUri().toString()); Assert.assertEquals("/file_index", resolveResult.remainingPath.toString()); }