auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
<code>public RngDeviceParameters(VmRngDevice rngDevice, boolean vm) { <START> if (rngDevice == null) { <END> throw new IllegalArgumentException("RNG Device must be specified."); } this.rngDevice = rngDevice; isVm = vm; }</code><technical_language>please exceptions in constructor</technical_language>

Target:
public RngDeviceParameters(VmRngDevice rngDevice, boolean vm) { this.rngDevice = rngDevice; isVm = vm; }
Source:
<code>public void testClientsConnections() throws Exception { try (IgniteEx g0 = startGrid(0)) { String host = g0.configuration().getClientConnectorConfiguration().getHost(); if (host == null) host = g0.configuration().getLocalHost(); int port = g0.configuration().getClientConnectorConfiguration().getPort(); try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(host + ":" + port))) { <START> <END> SystemView<ClientConnectionView> conns = g0.context().systemView().view(CLI_CONN_SYS_VIEW); assertEquals(1, conns.size()); ClientConnectionView cliConn = conns.iterator().next(); assertEquals("THIN", cliConn.type()); assertEquals(cliConn.localAddress().getHostName(), cliConn.remoteAddress().getHostName()); assertEquals(g0.configuration().getClientConnectorConfiguration().getPort(), cliConn.localAddress().getPort()); assertEquals(cliConn.version(), DEFAULT_VER.asString()); try (Connection conn = new IgniteJdbcThinDriver().connect("jdbc:ignite:thin://" + host, new Properties())) { assertEquals(2, conns.size()); assertEquals(1, F.size(jdbcConnectionsIterator(conns), alwaysTrue())); ClientConnectionView jdbcConn = jdbcConnectionsIterator(conns).next(); assertEquals("JDBC", jdbcConn.type()); assertEquals(jdbcConn.localAddress().getHostName(), jdbcConn.remoteAddress().getHostName()); assertEquals(g0.configuration().getClientConnectorConfiguration().getPort(), jdbcConn.localAddress().getPort()); assertEquals(jdbcConn.version(), CURRENT_VER.asString()); } } } }</code><technical_language>Redundant NL</technical_language>

Target:
public void testClientsConnections() throws Exception { try (IgniteEx g0 = startGrid(0)) { String host = g0.configuration().getClientConnectorConfiguration().getHost(); if (host == null) host = g0.configuration().getLocalHost(); int port = g0.configuration().getClientConnectorConfiguration().getPort(); SystemView<ClientConnectionView> conns = g0.context().systemView().view(CLI_CONN_SYS_VIEW); try (IgniteClient cli = Ignition.startClient(new ClientConfiguration().setAddresses(host + ":" + port))) { assertEquals(1, conns.size()); ClientConnectionView cliConn = conns.iterator().next(); assertEquals("THIN", cliConn.type()); assertEquals(cliConn.localAddress().getHostName(), cliConn.remoteAddress().getHostName()); assertEquals(g0.configuration().getClientConnectorConfiguration().getPort(), cliConn.localAddress().getPort()); assertEquals(cliConn.version(), ProtocolVersion.CURRENT_VER.toString()); try (Connection conn = new IgniteJdbcThinDriver().connect("jdbc:ignite:thin://" + host, new Properties())) { assertEquals(2, conns.size()); assertEquals(1, F.size(jdbcConnectionsIterator(conns))); ClientConnectionView jdbcConn = jdbcConnectionsIterator(conns).next(); assertEquals("JDBC", jdbcConn.type()); assertEquals(jdbcConn.localAddress().getHostName(), jdbcConn.remoteAddress().getHostName()); assertEquals(g0.configuration().getClientConnectorConfiguration().getPort(), jdbcConn.localAddress().getPort()); assertEquals(jdbcConn.version(), JdbcConnectionContext.CURRENT_VER.asString()); } } boolean res = GridTestUtils.waitForCondition(() -> conns.size() == 0, 5_000); assertTrue(res); } }
Source:
<code>public SnapshotInfo takeSnapshot(SnapshotInfo snapshot) { SnapshotInfo snapshotOnPrimary = null; Object payload = snapshot.getPayload(); CreateSnapshotPayload createSnapshotPayload = null; if (payload != null) { createSnapshotPayload = (CreateSnapshotPayload)payload; if (createSnapshotPayload.getQuiescevm()) { throw new InvalidParameterValueException("can't handle quiescevm equal true for volume snapshot"); } } SnapshotVO snapshotVO = snapshotDao.acquireInLockTable(snapshot.getId()); if (snapshotVO == null) { throw new CloudRuntimeException("Failed to get lock on snapshot:" + snapshot.getId()); } try { VolumeInfo volumeInfo = snapshot.getBaseVolume(); volumeInfo.stateTransit(Volume.Event.SnapshotRequested); SnapshotResult result = null; try { result = snapshotSvr.takeSnapshot(snapshot); if (result.isFailed()) { s_logger.debug("Failed to take snapshot: " + result.getResult()); throw new CloudRuntimeException(result.getResult()); } } finally { if (result != null && result.isSuccess()) { volumeInfo.stateTransit(Volume.Event.OperationSucceeded); } else { volumeInfo.stateTransit(Volume.Event.OperationFailed); } } snapshotOnPrimary = result.getSnapshot(); snapshotOnPrimary.addPayload(snapshot.getPayload()); <START> _snapshotDetailsDao.addDetail(((SnapshotObject)snapshotOnPrimary).getId(), AsyncJob.Constants.MS_ID, Long.toString(MacAddress.getMacAddress().toLong()), false); <END> return snapshotOnPrimary; } finally { if (snapshotVO != null) { snapshotDao.releaseFromLockTable(snapshotOnPrimary.getId()); } } }</code><technical_language>MS ID is computed mac address? is in DB helper methods get</technical_language>

Target:
public SnapshotInfo takeSnapshot(SnapshotInfo snapshot) { SnapshotInfo snapshotOnPrimary = null; Object payload = snapshot.getPayload(); CreateSnapshotPayload createSnapshotPayload = null; if (payload != null) { createSnapshotPayload = (CreateSnapshotPayload)payload; if (createSnapshotPayload.getQuiescevm()) { throw new InvalidParameterValueException("can't handle quiescevm equal true for volume snapshot"); } } SnapshotVO snapshotVO = snapshotDao.acquireInLockTable(snapshot.getId()); if (snapshotVO == null) { throw new CloudRuntimeException("Failed to get lock on snapshot:" + snapshot.getId()); } try { VolumeInfo volumeInfo = snapshot.getBaseVolume(); volumeInfo.stateTransit(Volume.Event.SnapshotRequested); SnapshotResult result = null; try { result = snapshotSvr.takeSnapshot(snapshot); if (result.isFailed()) { s_logger.debug("Failed to take snapshot: " + result.getResult()); throw new CloudRuntimeException(result.getResult()); } } finally { if (result != null && result.isSuccess()) { volumeInfo.stateTransit(Volume.Event.OperationSucceeded); } else { volumeInfo.stateTransit(Volume.Event.OperationFailed); } } snapshotOnPrimary = result.getSnapshot(); snapshotOnPrimary.addPayload(snapshot.getPayload()); _snapshotDetailsDao.addDetail(((SnapshotObject)snapshotOnPrimary).getId(), AsyncJob.Constants.MS_ID, Long.toString(ManagementServerNode.getManagementServerId()), false); return snapshotOnPrimary; } finally { if (snapshotVO != null) { snapshotDao.releaseFromLockTable(snapshot.getId()); } } }
Source:
<code>@Test public void nonNull() throws Exception { JsonAdapter<String> toUpperCase = new JsonAdapter<String>() { @Override public String fromJson(JsonReader reader) throws IOException { return reader.nextString().toUpperCase(Locale.US); } @Override public void toJson(JsonWriter writer, String value) throws IOException { writer.value(value.toUpperCase(Locale.US)); } }.nonNull(); JsonReader reader = factory.newReader("[\"a\", null, \"c\"]"); reader.beginArray(); assertThat(toUpperCase.fromJson(reader)).isEqualTo("A"); try { toUpperCase.fromJson(reader); fail(); } catch (JsonDataException expected) { assertThat(expected).hasMessage("Unexpected null at $[1]"); <START> assertThat(reader.<Object>nextNull()).isNull(); <END> } assertThat(toUpperCase.fromJson(reader)).isEqualTo("C"); reader.endArray(); JsonWriter writer = factory.newWriter(); writer.beginArray(); toUpperCase.toJson(writer, "a"); try { toUpperCase.toJson(writer, null); fail(); } catch (JsonDataException expected) { assertThat(expected).hasMessage("Unexpected null at $[1]"); writer.nullValue(); } toUpperCase.toJson(writer, "c"); writer.endArray(); assertThat(factory.json()).isEqualTo("[\"A\",null,\"C\"]"); }</code><technical_language>interesting: do tests require updating moving Gradle</technical_language>

Target:
@Test public void nonNull() throws Exception { JsonAdapter<String> toUpperCase = new JsonAdapter<String>() { @Override public String fromJson(JsonReader reader) throws IOException { return reader.nextString().toUpperCase(Locale.US); } @Override public void toJson(JsonWriter writer, String value) throws IOException { writer.value(value.toUpperCase(Locale.US)); } }.nonNull(); JsonReader reader = factory.newReader("[\"a\", null, \"c\"]"); reader.beginArray(); assertThat(toUpperCase.fromJson(reader)).isEqualTo("A"); try { toUpperCase.fromJson(reader); fail(); } catch (JsonDataException expected) { assertThat(expected).hasMessage("Unexpected null at $[1]"); assertThat(reader.nextNull()).isNull(); } assertThat(toUpperCase.fromJson(reader)).isEqualTo("C"); reader.endArray(); JsonWriter writer = factory.newWriter(); writer.beginArray(); toUpperCase.toJson(writer, "a"); try { toUpperCase.toJson(writer, null); fail(); } catch (JsonDataException expected) { assertThat(expected).hasMessage("Unexpected null at $[1]"); writer.nullValue(); } toUpperCase.toJson(writer, "c"); writer.endArray(); assertThat(factory.json()).isEqualTo("[\"A\",null,\"C\"]"); }
Source:
<code>public boolean createOzoneVolumeIfNeeded(String userName) throws IOException { boolean newVolumeCreate = true; String ozoneVolumeName = formatOzoneVolumeName(userName); try { OmVolumeArgs args = OmVolumeArgs.newBuilder() .setAdminName(S3_ADMIN_NAME) .setOwnerName(userName) .setVolume(ozoneVolumeName) .setQuotaInBytes(OzoneConsts.MAX_QUOTA_IN_BYTES) .build(); <START> if (isRatisEnabled) { <END> volumeManager.applyCreateVolume(args, volumeManager.createVolume(args)); } volumeManager.createVolume(args); } catch (OMException exp) { newVolumeCreate = false; if (exp.getResult().compareTo(VOLUME_ALREADY_EXISTS) == 0) { if (LOG.isDebugEnabled()) { LOG.debug("Volume already exists. {}", exp.getMessage()); } } else { throw exp; } } return newVolumeCreate; }</code><technical_language>do need call applyCreateVolume separately? Is this pushed Ratis consensus correctly</technical_language>

Target:
public boolean createOzoneVolumeIfNeeded(String userName) throws IOException { boolean newVolumeCreate = true; String ozoneVolumeName = formatOzoneVolumeName(userName); try { OmVolumeArgs args = OmVolumeArgs.newBuilder() .setAdminName(S3_ADMIN_NAME) .setOwnerName(userName) .setVolume(ozoneVolumeName) .setQuotaInBytes(OzoneConsts.MAX_QUOTA_IN_BYTES) .build(); if (isRatisEnabled) { volumeManager.applyCreateVolume(args, volumeManager.createVolume(args)); } else { volumeManager.createVolume(args); } } catch (OMException exp) { newVolumeCreate = false; if (exp.getResult().compareTo(VOLUME_ALREADY_EXISTS) == 0) { if (LOG.isDebugEnabled()) { LOG.debug("Volume already exists. {}", exp.getMessage()); } } else { throw exp; } } return newVolumeCreate; }
Source:
<code>public JSONObject toJSON() throws JSONException { JSONObject rv = new JSONObject(); JSONArray array; rv.put("format", format.ordinal()); rv.put("plainLat", plainLat); rv.put("plainLon", plainLon); rv.put("latHemisphere", latHemisphere); rv.put("lonHemisphere", lonHemisphere); <START> array = new JSONArray(); <END> for (CalculateButton.ButtonData but : buttons) { array.put(but.toJASON()); } rv.put("buttons", array); array = new JSONArray(); for (CalculatorVariable.VariableData equ : equations) { array.put(equ.toJSON()); } rv.put("equations", array); array = new JSONArray(); for (CalculatorVariable.VariableData equ : freeVariables) { array.put(equ.toJSON()); } rv.put("freeVariables", array); rv.put("notes", notes); return rv; }</code><technical_language>remark above, please reuse variables final</technical_language>

Target:
public JSONObject toJSON() throws JSONException { final JSONObject rv = new JSONObject(); rv.put("format", format.ordinal()); rv.put("plainLat", plainLat); rv.put("plainLon", plainLon); rv.put("latHemisphere", latHemisphere); rv.put("lonHemisphere", lonHemisphere); { final JSONArray array = new JSONArray(); for (final CalculateButton.ButtonData but : buttons) { array.put(but.toJASON()); } rv.put("buttons", array); } { final JSONArray array = new JSONArray(); for (final CalculatorVariable.VariableData equ : equations) { array.put(equ.toJSON()); } rv.put("equations", array); } { final JSONArray array = new JSONArray(); for (final CalculatorVariable.VariableData equ : freeVariables) { array.put(equ.toJSON()); } rv.put("freeVariables", array); } rv.put("notes", notes); return rv; }
Source:
<code>private static void checkRfsSpecified(CassandraKeyValueServiceConfig config, Set<String> dcs, Map<String, String> strategyOptions) { for (String dataCenter : dcs) { <START> if (strategyOptions.get(dataCenter) == null) { <END> logErrorOrThrow("The datacenter for this cassandra cluster is invalid. " + " failed dc: " + dataCenter + " strategyOptions: " + strategyOptions, config.ignoreDatacenterConfigurationChecks()); } } }</code><technical_language>nit: !strategyOptions.containsKey(dataCenter)</technical_language>

Target:
private static void checkRfsSpecified(CassandraKeyValueServiceConfig config, Set<String> dcs, Map<String, String> strategyOptions) { for (String datacenter : dcs) { if (strategyOptions.get(datacenter) == null) { logErrorOrThrow("The datacenter for this cassandra cluster is invalid. " + " failed dc: " + datacenter + " strategyOptions: " + strategyOptions, config.ignoreDatacenterConfigurationChecks()); } } }
Source:
<code>public static void showFeedbackEmailChooser(final Activity activity) { <START> activity.startActivity(Intent.createChooser(getFeedbackEmailIntent(activity), "Choose an email provider:")); <END> activity.overridePendingTransition(0, 0); }</code><technical_language>Activity state util check starting of this, maybe</technical_language>

Target:
public static void showFeedbackEmailChooser(final Activity activity) { if (ActivityStateUtil.isActivityValid(activity)) { activity.startActivity(Intent.createChooser(getFeedbackEmailIntent(activity), "Choose an email provider:")); activity.overridePendingTransition(0, 0); } }
Source:
<code>private void handleParallelVersions(IAtsConfigTxVersion version, IOseeBranch... parallelVersions) { for (IOseeBranch parallelVer : parallelVersions) { boolean found = false; for (IAtsVersion teamDefVer : teamDef.getVersions()) { <START> if (teamDefVer.getBaselineBranchId() != null && teamDefVer.getBaselineBranchId().equals( <END> parallelVer.getId())) { changes.relate(version.getVersion(), AtsRelationTypes.ParallelVersion_Child, teamDefVer); found = true; } } if (!found) { throw new OseeArgumentException("No parallel version %s found for version %s", parallelVer.toStringWithId(), version.getVersion().toStringWithId()); } } }</code><technical_language>Please BranchId.isValid instead of != null for usage of BranchId validity checks In this case simplifies if(teamDefVer.getBaselineBranchId().equals( parallelVer))</technical_language>

Target:
private void handleParallelVersions(IAtsConfigTxVersion version, IOseeBranch... parallelVersions) { for (IOseeBranch parallelVer : parallelVersions) { boolean found = false; for (IAtsVersion teamDefVer : teamDef.getVersions()) { if (teamDefVer.getBaselineBranchId().isValid() && teamDefVer.getBaselineBranchId().equals( parallelVer.getId())) { changes.relate(version.getVersion(), AtsRelationTypes.ParallelVersion_Child, teamDefVer); found = true; } } if (!found) { throw new OseeArgumentException("No parallel version %s found for version %s", parallelVer.toStringWithId(), version.getVersion().toStringWithId()); } } }
Source:
<code>protected boolean isTagSanitizationEnabled() { return !hasFeature(TAGS_BELONG_TO_DOCUMENT) <START> || Framework.getService(ConfigurationService.class).getBoolean(TAG_SANITIZATION_PROP, true); <END> }</code><technical_language>Default false</technical_language>

Target:
protected boolean isTagSanitizationEnabled() { return !hasFeature(TAGS_BELONG_TO_DOCUMENT) || Framework.getService(ConfigurationService.class).isBooleanTrue(TAG_SANITIZATION_PROP); }
Source:
<code>public String getDescription() { <START> return "Compute a TIN from the geometry given in argument.\n " <END> + "The first argument force the intersection of all input edges.\n" + "The second argument is used to delete flat triangles.\n" + "If the geometry contains polygon or ligne the triangulation\n " + "is enforced using a constraint method."; }</code><technical_language>is a TIN? is put acronym in parentheses (TIN)</technical_language>

Target:
public String getDescription() { return "Compute a TIN (Triangular Irregular Network) from the geometry given in argument.\n " + "The first argument force the intersection of all input edges.\n" + "The second argument is used to delete flat triangles.\n" + "If the geometry contains polygon or ligne the triangulation\n " + "is enforced using a constraint method."; }
Source:
<code>public Map<String, Map<String, ServiceAttributes>> getHostGroupBasedServiceAttributes() { Map<String, Set<ServiceComponent>> hgToNonGwServiceComponents = getNonGatewayServicesByHostGroup(); Map<String, Set<ServiceComponent>> hgToNonGwServiceComponentsWithYarnNMs = new HashMap<>(); for (Entry<String, Set<ServiceComponent>> entry : hgToNonGwServiceComponents.entrySet()) { for (ServiceComponent sc : entry.getValue()) { if (sc.getService().equalsIgnoreCase(YarnRoles.YARN) && sc.getComponent() .equalsIgnoreCase(YarnRoles.NODEMANAGER)) { hgToNonGwServiceComponentsWithYarnNMs.put(entry.getKey(), entry.getValue()); break; } } } Map<String, Set<String>> componentsByHostGroup = hgToNonGwServiceComponentsWithYarnNMs.entrySet() .stream().collect( toMap( Entry::getKey, <START> e -> e.getValue().stream() .map(ServiceComponent::getComponent) .collect(Collectors.toUnmodifiableSet()) <END> )); Set<String> computeHostGroups = getRecommendationByBlacklist(BlackListedLoadBasedAutoscaleRole.class, true, componentsByHostGroup); Map<String, Map<String, ServiceAttributes>> result = new HashMap<>(); for (String hg : componentsByHostGroup.keySet()) { Map<String, ServiceAttributes> m; if (computeHostGroups.contains(hg)) { m = Collections.singletonMap(YarnRoles.YARN, new ServiceAttributes(ServiceComponent.of(YarnRoles.YARN, YarnRoles.NODEMANAGER), Collections.singletonMap(YarnConstants.ATTRIBUTE_NAME_NODE_INSTANCE_TYPE, YarnConstants.ATTRIBUTE_NODE_INSTANCE_TYPE_COMPUTE))); } else { m = Collections.singletonMap(YarnRoles.YARN, new ServiceAttributes(ServiceComponent.of(YarnRoles.YARN, YarnRoles.NODEMANAGER), Collections.singletonMap(YarnConstants.ATTRIBUTE_NAME_NODE_INSTANCE_TYPE, YarnConstants.ATTRIBUTE_NODE_INSTANCE_TYPE_WORKER))); } result.put(hg, m); } LOGGER.debug("ServiceAttributes: {}", result); return result; }</code><technical_language>this part moved out named in a separate method</technical_language>

Target:
public Map<String, Map<String, ServiceAttributes>> getHostGroupBasedServiceAttributes() { Map<String, Set<String>> componentsByHostGroup = collectComponentsByHostGroupWithYarnNMs(); Set<String> computeHostGroups = getRecommendationByBlacklist(BlackListedLoadBasedAutoscaleRole.class, true, componentsByHostGroup, List.of()); Map<String, Map<String, ServiceAttributes>> result = new HashMap<>(); for (String hg : componentsByHostGroup.keySet()) { String instanceType = computeHostGroups.contains(hg) ? YarnConstants.ATTRIBUTE_NODE_INSTANCE_TYPE_COMPUTE : YarnConstants.ATTRIBUTE_NODE_INSTANCE_TYPE_WORKER; result.put(hg, Collections.singletonMap(YarnRoles.YARN, new ServiceAttributes(ServiceComponent.of(YarnRoles.YARN, YarnRoles.NODEMANAGER), Collections.singletonMap(YarnConstants.ATTRIBUTE_NAME_NODE_INSTANCE_TYPE, instanceType)))); } LOGGER.debug("ServiceAttributes: {}", result); return result; }
Source:
<code>public Object[] fetchChildren(Object o, IProgressMonitor monitor) throws TeamException { if (!(o instanceof ICVSRemoteFolder)) return new Object[0]; try { monitor = Policy.monitorFor(monitor); monitor.beginTask(NLS.bind( CVSUIMessages.RemoteFolderElement_fetchingRemoteChildren, new String[] { getLabel(o) }), 150); ICVSRemoteFolder folder = (ICVSRemoteFolder) o; ICVSRemoteResource[] cachedChildren = CVSUIPlugin .getPlugin() .getRepositoryManager() .getCachedChildrenForTag(folder.getRepository(), folder, <START> folder.getTag(), Policy.subMonitorFor(monitor, 50)); <END> if (cachedChildren.length > 0) { return cachedChildren; } return folder.members(Policy.subMonitorFor(monitor, 100)); } finally { monitor.done(); } }</code><technical_language>Extract block a method. I missed in #fetchDeferredChildren(...) method below</technical_language>

Target:
public Object[] fetchChildren(Object o, IProgressMonitor monitor) throws TeamException { if (!(o instanceof ICVSRemoteFolder)) return new Object[0]; monitor = Policy.monitorFor(monitor); try { ICVSRemoteResource[] cachedChildren = getCachedChildren(o, monitor); if (cachedChildren.length > 0) { return cachedChildren; } return ((ICVSRemoteFolder) o).members(Policy.subMonitorFor(monitor, 50)); } finally { monitor.done(); } }
Source:
<code>public boolean isDebugEnabled() { <START> String logLevelStr = Configuration.getGlobalConfiguration().get(AZURE_LOG_LEVEL); LogLevel currentLogLevel = LogLevel.fromString(logLevelStr); return LogLevel.VERBOSE.getLogLevel() >= currentLogLevel.getLogLevel(); <END> }</code><technical_language>This code is common for is*Enabled() methods. extract this out a method reduce duplication</technical_language>

Target:
public boolean isDebugEnabled() { return isLogLevelEnabledFromEnv(LogLevel.VERBOSE); }
Source:
<code>public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.guide_conclusion, container, false); ((TextView) view.findViewById(R.id.guide_conclusion_text)).setText(Html.fromHtml(mGuide.getConclusion())); mButton = (Button) view.findViewById(R.id.guide_completed_button); mButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Api.call(getActivity(), ApiCall.completeGuide(mGuide.getGuideid())); mButton.setEnabled(false); mButton.setText(getString(R.string.completing)); } }); setCompletedStatus(mGuide.getCompleted()); <START> if (mGuide.isTeardown()) mButton.setVisibility(View.GONE); <END> return view; }</code><technical_language>hiding completion button for teardowns, entire conclusion fragment removed? I is conclusion text want is more sharing controls if add those</technical_language>

Target:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.guide_conclusion, container, false); ((TextView) view.findViewById(R.id.guide_conclusion_text)).setText(Html.fromHtml(mGuide.getConclusion())); mButton = (Button) view.findViewById(R.id.guide_completed_button); mButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Api.call(getActivity(), ApiCall.completeGuide(mGuide.getGuideid())); mButton.setEnabled(false); mButton.setText(R.string.completing); } }); setCompletedStatus(mGuide.getCompleted()); if (mGuide.isTeardown()) mButton.setVisibility(View.GONE); return view; }
Source:
<code>protected void checkVdsClusterChangeSucceeded(final GuideModel guideModel, final String searchStr, final List<VdcActionParametersBase> changeVdsParameterList, final List<VdcActionParametersBase> activateVdsParameterList) { final Map<Guid, Guid> hostClusterIdMap = new HashMap<>(); for (VdcActionParametersBase param : changeVdsParameterList) { hostClusterIdMap.put(((ChangeVDSClusterParameters) param).getVdsId(), ((ChangeVDSClusterParameters) param).getClusterId()); } Frontend.getInstance().runQuery(VdcQueryType.Search, new SearchParameters(searchStr, SearchType.VDS), new AsyncQuery(this, new INewAsyncCallback() { @Override public void onSuccess(Object target, Object returnValue) { <START> ArrayList<VDS> hosts = ((VdcQueryReturnValue) returnValue).getReturnValue(); <END> boolean succeeded = true; for (VDS host : hosts) { if (!host.getVdsGroupId().equals(hostClusterIdMap.get(host.getId()))) { succeeded = false; } } if (!succeeded) { guideModel.getWindow().stopProgress(); guideModel.cancel(); errorPopupManager.show(ConstantsManager.getInstance().getConstants().hostChangeClusterTimeOut()); } else { activateHostsAfterClusterChange(guideModel, searchStr, activateVdsParameterList); } } })); }</code><technical_language>This a List</technical_language>

Target:
protected void checkVdsClusterChangeSucceeded(final GuideModel guideModel, final String searchStr, final List<VdcActionParametersBase> changeVdsParameterList, final List<VdcActionParametersBase> activateVdsParameterList) { final Map<Guid, Guid> hostClusterIdMap = new HashMap<>(); for (VdcActionParametersBase param : changeVdsParameterList) { hostClusterIdMap.put(((ChangeVDSClusterParameters) param).getVdsId(), ((ChangeVDSClusterParameters) param).getClusterId()); } Frontend.getInstance().runQuery(VdcQueryType.Search, new SearchParameters(searchStr, SearchType.VDS), new AsyncQuery(this, new INewAsyncCallback() { @Override public void onSuccess(Object target, Object returnValue) { List<VDS> hosts = ((VdcQueryReturnValue) returnValue).getReturnValue(); boolean succeeded = true; for (VDS host : hosts) { if (!host.getVdsGroupId().equals(hostClusterIdMap.get(host.getId()))) { succeeded = false; } } if (!succeeded) { guideModel.getWindow().stopProgress(); guideModel.cancel(); errorPopupManager.show(ConstantsManager.getInstance().getConstants().hostChangeClusterTimeOut()); } else { activateHostsAfterClusterChange(guideModel, searchStr, activateVdsParameterList); } } })); }
Source:
<code>public MessageView(Context context, AttributeSet attrs) { super(context, attrs); <START> setOrientation(VERTICAL); <END> }</code><technical_language>forcing orientation, a good idea super.setOrientation() instead, override setOrientation() method print a log throw exception if mess</technical_language>

Target:
public MessageView(Context context, AttributeSet attrs) { super(context, attrs); super.setOrientation(VERTICAL); }
Source:
<code>public void get_notifications_when_passive_joins() throws Exception { put(0, "clients", "client1", "Mat"); voltron.getClusterControl().startOneServer(); voltron.getClusterControl().waitForRunningPassivesInStandby(); put(0, "clients", "client2", "Garfield"); assertThat(get(1, "clients", "client1"), equalTo("Mat")); Server active = nmsService.readTopology().serverStream().filter(Server::isActive).findFirst().get(); Server passive = nmsService.readTopology().serverStream().filter(server -> !server.isActive()).findFirst().get(); assertThat(active.getState(), equalTo(Server.State.ACTIVE)); assertThat(passive.getState(), equalTo(Server.State.PASSIVE)); List<ContextualNotification> collected = waitForAllNotifications("SERVER_JOINED", "SERVER_STATE_CHANGED", "SERVER_ENTITY_CREATED", "ENTITY_REGISTRY_AVAILABLE", "SERVER_STATE_CHANGED", "SYNC_END"); Set<String> states = collected.stream() .filter(contextualNotification -> contextualNotification.getType().equals("SERVER_STATE_CHANGED")) .map(contextualNotification -> contextualNotification.getAttributes().get("state")) .collect(Collectors.toSet()); assertThat(states, hasItems("SYNCHRONIZING", "PASSIVE")); ContextualNotification stateChanged = collected.stream().filter(n -> n.getType().equals("SERVER_STATE_CHANGED")).findFirst().get(); assertThat(stateChanged.getContext().get(Server.NAME_KEY), equalTo(passive.getServerName())); <START> assertThat(states, hasItems("SYNCHRONIZING", "PASSIVE")); <END> }</code><technical_language>redundant line 80</technical_language>

Target:
public void get_notifications_when_passive_joins() throws Exception { put(0, "clients", "client1", "Mat"); voltron.getClusterControl().startOneServer(); voltron.getClusterControl().waitForRunningPassivesInStandby(); put(0, "clients", "client2", "Garfield"); assertThat(get(1, "clients", "client1"), equalTo("Mat")); Server active = nmsService.readTopology().serverStream().filter(Server::isActive).findFirst().get(); Server passive = nmsService.readTopology().serverStream().filter(server -> !server.isActive()).findFirst().get(); assertThat(active.getState(), equalTo(Server.State.ACTIVE)); assertThat(passive.getState(), equalTo(Server.State.PASSIVE)); List<ContextualNotification> collected = waitForAllNotifications("SERVER_JOINED", "SERVER_STATE_CHANGED", "SERVER_ENTITY_CREATED", "ENTITY_REGISTRY_AVAILABLE", "SERVER_STATE_CHANGED", "SYNC_END"); Set<String> states = collected.stream() .filter(contextualNotification -> contextualNotification.getType().equals("SERVER_STATE_CHANGED")) .map(contextualNotification -> contextualNotification.getAttributes().get("state")) .collect(Collectors.toSet()); assertThat(states, hasItems("SYNCHRONIZING", "PASSIVE")); ContextualNotification stateChanged = collected.stream().filter(n -> n.getType().equals("SERVER_STATE_CHANGED")).findFirst().get(); assertThat(stateChanged.getContext().get(Server.NAME_KEY), equalTo(passive.getServerName())); }
Source:
<code>public DataContext createDataContext(final JavaTypeFactory typeFactory, List<TypedValue> parameters) { class DruidDataContext implements DataContext { private final Map<String, Object> base_context = ImmutableMap.of( DataContext.Variable.UTC_TIMESTAMP.camelName, localNow.getMillis(), DataContext.Variable.CURRENT_TIMESTAMP.camelName, localNow.getMillis(), DataContext.Variable.LOCAL_TIMESTAMP.camelName, new Interval( new DateTime("1970-01-01T00:00:00.000", localNow.getZone()), localNow ).toDurationMillis(), DataContext.Variable.TIME_ZONE.camelName, localNow.getZone().toTimeZone().clone(), DATA_CTX_AUTHENTICATION_RESULT, authenticationResult ); private final Map<String, Object> context; DruidDataContext() { ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder(); builder.putAll(base_context); <START> for (int i = 0; i < parameters.size(); i++) { <END> builder.put("?" + i, parameters.get(i).value); } context = builder.build(); } @Override public SchemaPlus getRootSchema() { throw new UnsupportedOperationException(); } @Override public JavaTypeFactory getTypeFactory() { return typeFactory; } @Override public QueryProvider getQueryProvider() { throw new UnsupportedOperationException(); } @Override public Object get(final String name) { return context.get(name); } } return new DruidDataContext(); }</code><technical_language>Depending implementation size of list, more efficient iterate list values, e.g.: java int i = 0; for (TypedValue parameter : parameters) { builder.put("?" + i, parameter.value); i++; }</technical_language>

Target:
public DataContext createDataContext(final JavaTypeFactory typeFactory, List<TypedValue> parameters) { class DruidDataContext implements DataContext { private final Map<String, Object> base_context = ImmutableMap.of( DataContext.Variable.UTC_TIMESTAMP.camelName, localNow.getMillis(), DataContext.Variable.CURRENT_TIMESTAMP.camelName, localNow.getMillis(), DataContext.Variable.LOCAL_TIMESTAMP.camelName, new Interval( new DateTime("1970-01-01T00:00:00.000", localNow.getZone()), localNow ).toDurationMillis(), DataContext.Variable.TIME_ZONE.camelName, localNow.getZone().toTimeZone().clone(), DATA_CTX_AUTHENTICATION_RESULT, authenticationResult ); private final Map<String, Object> context; DruidDataContext() { ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder(); builder.putAll(base_context); int i = 0; for (TypedValue parameter : parameters) { builder.put("?" + i, parameter.value); i++; } context = builder.build(); } @Override public SchemaPlus getRootSchema() { throw new UnsupportedOperationException(); } @Override public JavaTypeFactory getTypeFactory() { return typeFactory; } @Override public QueryProvider getQueryProvider() { throw new UnsupportedOperationException(); } @Override public Object get(final String name) { return context.get(name); } } return new DruidDataContext(); }
Source:
<code>protected void makeMenuBar() { if (canUpdateProject()) { fileMenuBuilder .addSave(versionRecordManager.newSaveMenuItem(this::saveAction)) .addCopy(versionRecordManager.getCurrentPath(), getRenameValidator()) .addRename(getSaveAndRename()) .addDelete(versionRecordManager.getPathToLatest(), <START> getRenameValidator()); <END> } fileMenuBuilder .addNewTopLevelMenu(versionRecordManager.buildMenu()); }</code><technical_language>Is this intended call getRenameValidator() while building delete action</technical_language>

Target:
protected void makeMenuBar() { if (canUpdateProject()) { fileMenuBuilder .addSave(versionRecordManager.newSaveMenuItem(this::saveAction)) .addCopy(versionRecordManager.getCurrentPath(), getRenameValidator()) .addRename(getSaveAndRename()) .addDelete(versionRecordManager.getPathToLatest(), assetUpdateValidator); } fileMenuBuilder .addNewTopLevelMenu(versionRecordManager.buildMenu()); }
Source:
<code>CosmosBulkItemResponse(String eTag, double requestCharge, ObjectNode resourceObject, int statusCode, Duration retryAfter, int subStatusCode, Map<String, String> responseHeaders, CosmosDiagnostics cosmosDiagnostics) { <START> checkNotNull(statusCode, "expected non-null statusCode"); <END> checkNotNull(responseHeaders, "expected non-null responseHeaders"); this.eTag = eTag; this.requestCharge = requestCharge; this.resourceObject = resourceObject; this.statusCode = statusCode; this.retryAfter = retryAfter; this.subStatusCode = subStatusCode; this.responseHeaders = responseHeaders; this.cosmosDiagnostics = cosmosDiagnostics; }</code><technical_language>nit: statusCode is int, null</technical_language>

Target:
CosmosBulkItemResponse(String eTag, double requestCharge, ObjectNode resourceObject, int statusCode, Duration retryAfter, int subStatusCode, Map<String, String> responseHeaders, CosmosDiagnostics cosmosDiagnostics) { checkNotNull(responseHeaders, "expected non-null responseHeaders"); this.eTag = eTag; this.requestCharge = requestCharge; this.resourceObject = resourceObject; this.statusCode = statusCode; this.retryAfter = retryAfter; this.subStatusCode = subStatusCode; this.responseHeaders = responseHeaders; this.cosmosDiagnostics = cosmosDiagnostics; }
Source:
<code>public void removeRecording (Sid recordingSid) { RecordingsDao recordingsDao = daoManager.getRecordingsDao(); Recording recording = recordingsDao.getRecording(recordingSid); boolean isStoredAtS3 = recording.getS3Uri() != null; if (isStoredAtS3) { if (s3AccessTool != null) { s3AccessTool.removeS3Uri(recording.getS3Uri()); } } else { URI fileUri = recording.getFileUri(); if (fileUri.getScheme().equalsIgnoreCase("file")) { File recordingFile = new File(fileUri); if (recordingFile.exists()) { recordingFile.delete(); } } } <START> recordingsDao.removeRecording(recordingSid); <END> }</code><technical_language>finally physical (file removal) logical (db removal),right</technical_language>

Target:
public void removeRecording (Sid recordingSid) { Recording recording = recordingsDao.getRecording(recordingSid); boolean isStoredAtS3 = recording.getS3Uri() != null; if (isStoredAtS3) { if (s3AccessTool != null) { s3AccessTool.removeS3Uri(recording.getS3Uri()); } } else { if (!recordingsPath.endsWith("/")) recordingsPath += "/"; URI recordingsUri = URI.create(recordingsPath+recordingSid+".wav"); File fileToDelete = new File(recordingsUri); if (fileToDelete.exists()) { fileToDelete.delete(); } } recordingsDao.removeRecording(recordingSid); }
Source:
<code><START> public List<StoreKey> getKeys() { <END> return keys; }</code><technical_language>alternative materializing a list of StoreKeys for CompositeBlobInfo is return a "view" of chunkMetadataList: java public List<StoreKey> getKeys() { return new AbstractList<StoreKey>() { @Override public StoreKey get(int index) { return chunkMetadataList.get(index).getStoreKey(); } @Override public int size() { return chunkMetadataList.size(); } }; } this suffice for cases need getKeys() method, getChunkIdsOnly option in router BlobIdTransformer, of interested in iterating of keys mutating list</technical_language>

Target:
public List<StoreKey> getKeys() { return new AbstractList<StoreKey>() { @Override public StoreKey get(int index) { return chunkMetadataList.get(index).getStoreKey(); } @Override public int size() { return chunkMetadataList.size(); } }; }
Source:
<code>public void initialize() { while ( true ) { <START> if ( isMaster() || this.forceInitialization ) <END> { if ( !isInitialized() ) { LOG.info( "Initializing " + getInitializationSubject() ); doInitialize(); LOG.info( getInitializationSubject() + " successfully initialized" ); } return; } else { for ( int i = 0; i < initializationCheckMaxCount; i++ ) { final boolean initialized = isInitialized(); if ( initialized ) { return; } try { LOG.info( "Waiting [" + ( initializationCheckPeriod / 1000 ) + "s] for " + getInitializationSubject() + " to be initialized" ); Thread.sleep( initializationCheckPeriod ); } catch ( InterruptedException e ) { throw new InitializationException( getInitializationSubject() + " initialization check thread interrupted", e ); } } } } }</code><technical_language>switch them. checking boolean is faster checking isMaster</technical_language>

Target:
public void initialize() { while ( true ) { if ( this.forceInitialization || isMaster() ) { if ( !isInitialized() ) { LOG.info( "Initializing " + getInitializationSubject() ); doInitialize(); LOG.info( getInitializationSubject() + " successfully initialized" ); } return; } else { for ( int i = 0; i < initializationCheckMaxCount; i++ ) { final boolean initialized = isInitialized(); if ( initialized ) { return; } try { LOG.info( "Waiting [" + ( initializationCheckPeriod / 1000 ) + "s] for " + getInitializationSubject() + " to be initialized" ); Thread.sleep( initializationCheckPeriod ); } catch ( InterruptedException e ) { throw new InitializationException( getInitializationSubject() + " initialization check thread interrupted", e ); } } } } }
Source:
<code><START> int getMaxLimitForListMode() { <END> return Activator.getDefault().getPreferenceStore() .getInt(UIPreferences.STAGING_VIEW_MAX_LIMIT_LIST_MODE); }</code><technical_language>this method declared private</technical_language>

Target:
private int getMaxLimitForListMode() { return Activator.getDefault().getPreferenceStore() .getInt(UIPreferences.STAGING_VIEW_MAX_LIMIT_LIST_MODE); }
Source:
<code>private void setAttribute() { ITmfStateSystemBuilder ss = (ITmfStateSystemBuilder) fContainer.getStateSystem(); int startingNodeQuark = fScenarioInfo.getQuark(); String subPath = ATTRIBUTE_PATH; int attributeQuark = ss.optQuarkRelative(startingNodeQuark, subPath); if (attributeQuark <START> != <END> ITmfStateSystem.INVALID_ATTRIBUTE) { fScenarioInfo.setScenarioAttribute(UUID.randomUUID().toString()); } else { ITmfStateValue sValue = ss.queryOngoingState(attributeQuark); fScenarioInfo.setScenarioAttribute(String.valueOf(sValue.unboxInt())); } }</code><technical_language>==</technical_language>

Target:
private void setAttribute() { ITmfStateSystemBuilder ss = (ITmfStateSystemBuilder) fContainer.getStateSystem(); int startingNodeQuark = fScenarioInfo.getQuark(); String subPath = ATTRIBUTE_PATH; int attributeQuark = ss.optQuarkRelative(startingNodeQuark, subPath); if (attributeQuark == ITmfStateSystem.INVALID_ATTRIBUTE) { fScenarioInfo.setScenarioAttribute(UUID.randomUUID().toString()); } else { ITmfStateValue value = ss.queryOngoingState(attributeQuark); fScenarioInfo.setScenarioAttribute(String.valueOf(value.unboxInt())); } }
Source:
<code>public static Integer getUploadInterval(final DateTime userLocalDateTime, final SenseUploadConfiguration senseUploadConfiguration, final Long userNextAlarmTimestampMillis) { <START> return adjustUploadIntervalInMinutes( <END> DateTime.now(DateTimeZone.UTC).getMillis(), computeUploadIntervalPerUserPerSetting(userLocalDateTime, senseUploadConfiguration), userNextAlarmTimestampMillis ); }</code><technical_language>Is get out some variables debugging easier</technical_language>

Target:
public static Integer getUploadInterval(final DateTime userLocalDateTime, final SenseUploadConfiguration senseUploadConfiguration, final Long userNextAlarmTimestampMillis) { final Integer adjustedUploadIntervalInMinutes = adjustUploadIntervalInMinutes( DateTime.now(DateTimeZone.UTC).getMillis(), computeUploadIntervalPerUserPerSetting(userLocalDateTime, senseUploadConfiguration), userNextAlarmTimestampMillis ); LOGGER.debug("Adjusted Upload Interval in Minutes: {}", adjustedUploadIntervalInMinutes); return adjustedUploadIntervalInMinutes; }
Source:
<code><START> void mergeSegment(String processorName, int segmentId) { <END> EventProcessor eventProcessor = getEventProcessor(processorName); if (!(eventProcessor instanceof TrackingEventProcessor)) { logger.info("Merge segment requested for processor which is not a Tracking Event Processor"); return; } ((TrackingEventProcessor) eventProcessor).mergeSegment(segmentId).whenComplete( (result, throwable) -> { if (throwable != null) { logger.error("Failed to merge segment for processor [{}]", segmentId, processorName, throwable); return; } if (result) { logger.info("Successfully merged segment of processor [{}]", segmentId, processorName); } else { logger.warn("Was not able to merge segment for processor [{}]", segmentId, processorName); } } ); }</code><technical_language>Return result of merge action</technical_language>

Target:
boolean mergeSegment(String processorName, int segmentId) { EventProcessor eventProcessor = getEventProcessor(processorName); if (!(eventProcessor instanceof TrackingEventProcessor)) { logger.info("Merge segment requested for processor which is not a Tracking Event Processor"); return false; } return ((TrackingEventProcessor) eventProcessor) .mergeSegment(segmentId) .thenApply(result -> { if (result) { logger.info("Successfully merged segment of processor [{}]", segmentId, processorName); } else { logger.warn("Was not able to merge segment for processor [{}]", segmentId, processorName); } return result; }).join(); }
Source:
<code>public Iterator<T> iterator() { T[] ts = Iterators.array( date, dateTime, dateTimeZoned, time, timeZoned, duration ); <START> return new Iterator<T>() <END> { private int current = -1; private int next; @Override public boolean hasNext() { while ( next < ts.length && ts[next] == null ) { next++; } return next < ts.length; } @Override public T next() { if ( !hasNext() ) { throw new NoSuchElementException(); } current = next; next++; return ts[current]; } }; }</code><technical_language>return Iterators.filter( item -> item != null, iterator( date, dateTime, dateTimeZoned, time, timeZoned, duration ) );</technical_language>

Target:
public Iterator<T> iterator() { return Iterators.filter( Objects::nonNull, Iterators.iterator( date, dateTime, dateTimeZoned, time, timeZoned, duration ) ); }
Source:
<code>public void bindEntity(Class<?> cls) { if (entityBindings.getOrDefault(lookupEntityClass(cls), EMPTY_BINDING) != EMPTY_BINDING) { return; } <START> entityBindings.remove(lookupEntityClass(cls)); <END> Annotation annotation = getFirstAnnotation(cls, Arrays.asList(Include.class, Exclude.class)); Include include = annotation instanceof Include ? (Include) annotation : null; Exclude exclude = annotation instanceof Exclude ? (Exclude) annotation : null; Entity entity = (Entity) getFirstAnnotation(cls, Arrays.asList(Entity.class)); if (exclude != null) { log.trace("Exclude {}", cls.getName()); return; } if (include == null) { log.trace("Missing include {}", cls.getName()); return; } String name; if (entity == null || "".equals(entity.name())) { name = StringUtils.uncapitalize(cls.getSimpleName()); } else { name = entity.name(); } String type; if ("".equals(include.type())) { type = name; } else { type = include.type(); } Class<?> duplicate = bindJsonApiToEntity.put(type, cls); if (duplicate != null && !duplicate.equals(cls)) { log.error("Duplicate binding for {}, {}", type, cls, duplicate); throw new DuplicateMappingException(type + " " + cls.getName() + ":" + duplicate.getName()); } entityBindings.putIfAbsent(lookupEntityClass(cls), new EntityBinding(this, cls, type, name)); if (include.rootLevel()) { bindEntityRoots.add(cls); } }</code><technical_language>this added? This unnecessary</technical_language>

Target:
public void bindEntity(Class<?> cls) { if (entityBindings.getOrDefault(lookupEntityClass(cls), EMPTY_BINDING) != EMPTY_BINDING) { return; } Annotation annotation = getFirstAnnotation(cls, Arrays.asList(Include.class, Exclude.class)); Include include = annotation instanceof Include ? (Include) annotation : null; Exclude exclude = annotation instanceof Exclude ? (Exclude) annotation : null; Entity entity = (Entity) getFirstAnnotation(cls, Arrays.asList(Entity.class)); if (exclude != null) { log.trace("Exclude {}", cls.getName()); return; } if (include == null) { log.trace("Missing include {}", cls.getName()); return; } String name; if (entity == null || "".equals(entity.name())) { name = StringUtils.uncapitalize(cls.getSimpleName()); } else { name = entity.name(); } String type; if ("".equals(include.type())) { type = name; } else { type = include.type(); } Class<?> duplicate = bindJsonApiToEntity.put(type, cls); if (duplicate != null && !duplicate.equals(cls)) { log.error("Duplicate binding for {}, {}", type, cls, duplicate); throw new DuplicateMappingException(type + " " + cls.getName() + ":" + duplicate.getName()); } entityBindings.putIfAbsent(lookupEntityClass(cls), new EntityBinding(this, cls, type, name)); if (include.rootLevel()) { bindEntityRoots.add(cls); } }
Source:
<code>public Response registerPill(final byte[] body) { final MorpheusCommand.Builder builder = pair(body, senseKeyStore, PairAction.PAIR_PILL); final Optional<AccessToken> accessTokenOptional = this.tokenStore.getClientDetailsByToken( new ClientCredentials(new OAuthScope[]{OAuthScope.AUTH}, builder.getAccountId()), DateTime.now()); <START> String senseId = "Unknown sense"; <END> if(accessTokenOptional.isPresent()) { final Long accountId = accessTokenOptional.get().accountId; final List<DeviceAccountPair> deviceAccountPairs = this.deviceDAO.getSensesForAccountId(accountId); if(deviceAccountPairs.size() > 0){ senseId = deviceAccountPairs.get(0).externalDeviceId; } } return signAndSend(senseId, builder, senseKeyStore); }</code><technical_language>throw exception if Sense is</technical_language>

Target:
public Response registerPill(final byte[] body) { final MorpheusCommand.Builder builder = pair(body, senseKeyStore, PairAction.PAIR_PILL); final Optional<AccessToken> accessTokenOptional = this.tokenStore.getClientDetailsByToken( new ClientCredentials(new OAuthScope[]{OAuthScope.AUTH}, builder.getAccountId()), DateTime.now()); if(!accessTokenOptional.isPresent()) { throw new WebApplicationException(Response.Status.BAD_REQUEST); } final Long accountId = accessTokenOptional.get().accountId; final List<DeviceAccountPair> deviceAccountPairs = this.deviceDAO.getSensesForAccountId(accountId); if(deviceAccountPairs.size() == 0) { throw new WebApplicationException(Response.Status.BAD_REQUEST); } final String senseId = deviceAccountPairs.get(0).externalDeviceId; return signAndSend(senseId, builder, senseKeyStore); }
Source:
<code>public final void testQueryQueries() throws DbException, CatalogException { <START> Schema schema = new Schema(ImmutableList.of(Type.LONG_TYPE, Type.STRING_TYPE), ImmutableList.of("id", "raw")); <END> CatalogQueryScan scan = new CatalogQueryScan("select query_id, raw_query from queries", schema, catalog); scan.open(null); assertEquals(false, scan.eos()); TupleBatch tb = scan.nextReady(); assertEquals(false, scan.eos()); assertEquals(1, tb.numTuples()); assertEquals(schema, tb.getSchema()); tb = scan.nextReady(); assertEquals(true, scan.eos()); }</code><technical_language>Schema.ofFields(), Schema.of() (we need do public exposure of Schema constructor)</technical_language>

Target:
public final void testQueryQueries() throws DbException, CatalogException { Schema schema = Schema.ofFields(Type.LONG_TYPE, "id", Type.STRING_TYPE, "raw"); CatalogQueryScan scan = new CatalogQueryScan("select query_id, raw_query from queries", schema, catalog); scan.open(null); assertEquals(false, scan.eos()); TupleBatch tb = scan.nextReady(); assertEquals(false, scan.eos()); assertEquals(1, tb.numTuples()); assertEquals(schema, tb.getSchema()); tb = scan.nextReady(); assertEquals(true, scan.eos()); }