auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void test1a() { List<String> results = new ArrayList<String>(); final BaragonAgentMetadata agentMetadata = new BaragonAgentMetadata(BASE_URI, AGENT_ID, Optional.of(DOMAIN), new BaragonAgentEc2Metadata(Optional.absent(), Optional.of("us-east-1a"), Optional.absent(), Optional.absent(), Optional.absent()), Optional.absent(), Collections .emptyMap(), true); for (String AZ: availabilityZones) { final UpstreamInfo currentUpstream = new UpstreamInfo("testhost:8080", Optional.absent(), Optional.of(AZ)); final PreferSameRackWeightingHelper helper = new PreferSameRackWeightingHelper(configuration, agentMetadata); CharSequence result = helper.preferSameRackWeightingBalanced(upstreams, currentUpstream, null); results.add(result.toString()); } Assert.assertEquals(Arrays.asList("", "", "backup", "backup", "backup"), results); }

Target:
public void test1a() { List<String> results = new ArrayList<>(); final BaragonAgentMetadata agentMetadata = generateBaragonAgentMetadata("us-east-1a"); final PreferSameRackWeightingHelper helper = new PreferSameRackWeightingHelper(CONFIGURATION, agentMetadata); for (String availabilityZone: AVAILABILITY_ZONES) { final UpstreamInfo currentUpstream = new UpstreamInfo("testhost:8080", Optional.absent(), Optional.of(availabilityZone)); CharSequence result = helper.preferSameRackWeighting(UPSTREAMS, currentUpstream, allRacks, capacity, totalPendingLoad, null); results.add(result.toString()); } Assert.assertEquals(Arrays.asList("", "", "backup", "backup", "backup"), results); }
Source:
static void checkValidPositionsArray(int[] positions, int offset, int length) { requireNonNull(positions, "positions array is null"); if (offset < 0 || offset > positions.length) { throw new IndexOutOfBoundsException("Invalid offset " + offset + " for positions array with " + positions.length + " elements"); } if (length < 0 || offset + length > positions.length) { throw new IndexOutOfBoundsException("Invalid length " + length + " for positions array with " + positions.length + " elements and offset " + offset); } }

Target:
static void checkValidPositionsArray(int[] positions, int offset, int length) { requireNonNull(positions, "positions array is null"); if (offset < 0 || offset > positions.length) { throw new IndexOutOfBoundsException(String.format("Invalid offset '%s' for positions array with '%s' elements", offset, positions.length)); } if (length < 0 || offset + length > positions.length) { throw new IndexOutOfBoundsException(String.format("Invalid length '%s' for positions array with '%s' elements and offset: '%s", length, positions.length, offset)); } }
Source:
private void toggleButton(final View parent, final boolean enable) { final View button = parent.findViewById(R.id.button_send); button.setAlpha(enable ? 0.8f : 0.3f); button.setEnabled(enable); }

Target:
private void toggleButton(final View parent, final boolean enable) { final View button = parent.findViewById(R.id.button_send); button.setAlpha(enable ? ALPHA_ENABLED : ALPHA_DISABLED); button.setEnabled(enable); }
Source:
private List<Entity> getEntities(String extensionName, String jobName, InputStream configStream, ClientResponse clientResponse) { JSONObject responseJson; try { responseJson = new JSONObject(clientResponse.getEntity(String.class)); } catch (JSONException e) { OUT.get().print("Submit failed. Failed to get details for the given extension"); throw new FalconCLIException("Submit failed. Failed to get details for the given extension"); } String extensionType; String extensionBuildLocation; try { extensionType = responseJson.get("type").toString(); extensionBuildLocation = responseJson.get("location").toString(); } catch (JSONException e) { OUT.get().print("Error. " + extensionName + " not found "); throw new FalconCLIException("Submit failed. Failed to get details for the given extension"); } List<Entity> entities = null; if (!extensionType.equals(ExtensionType.CUSTOM.name())) { try { entities = ExtensionHandler.loadAndPrepare(extensionName, jobName, configStream, extensionBuildLocation); } catch (Exception e) { OUT.get().println("Error in building the extension"); throw new FalconCLIException("Submit failed. Failed to get details for the given extension"); } if (entities == null || entities.isEmpty()) { OUT.get().println("No entities got built"); throw new FalconCLIException("Submit failed. Failed to get details for the given extension"); } try { EntityUtil.applyTags(extensionName, jobName, entities); } catch (FalconException e) { OUT.get().println("Error in applying tags to generated entities"); throw new FalconCLIException("Submit failed. Failed to get details for the given extension"); } } return entities; }

Target:
private List<Entity> getEntities(String extensionName, String jobName, InputStream configStream, ClientResponse clientResponse) { JSONObject responseJson; try { responseJson = new JSONObject(clientResponse.getEntity(String.class)); } catch (JSONException e) { OUT.get().print("Submit failed. Failed to get details for the given extension"); throw new FalconCLIException("Submit failed. Failed to get details for the given extension"); } String extensionType; String extensionBuildLocation; try { extensionType = responseJson.get("type").toString(); extensionBuildLocation = responseJson.get("location").toString(); } catch (JSONException e) { OUT.get().print("Error. " + extensionName + " not found "); throw new FalconCLIException("Submit failed. Failed to get details for the given extension"); } List<Entity> entities = null; if (!extensionType.equals(ExtensionType.CUSTOM.name())) { try { entities = ExtensionHandler.loadAndPrepare(extensionName, jobName, configStream, extensionBuildLocation); } catch (Exception e) { OUT.get().println("Error in building the extension"); throw new FalconCLIException("Submit failed. Failed to get details for the given extension"); } if (entities == null || entities.isEmpty()) { OUT.get().println("No entities got built"); throw new FalconCLIException("Submit failed. Failed to get details for the given extension"); } } return entities; }
Source:
public void setModel(M model) { this.model = model; if (selectionChangedHandler != null) { selectionChangedHandler.removeHandler(); } selectionChangedHandler = getSelectionModel().addSelectionChangeHandler(e -> processSelectionChanged()); getSelectionModel().setDataDisplay(this.hasDataDelegate); getSelectionModel().setMultiSelectEnabled(true); getModel().getItemsChangedEvent().addListener((ev, sender, args) -> { getSelectionModel().clear(); List<T> items = getModel().getItemsAsList(); List<Integer> itemsToSelect = selectedIndexes.stream().filter(selectedIndex -> selectedIndex > -1 && selectedIndex < items.size() ).collect(Collectors.toList()); itemsToSelect.forEach(item -> getSelectionModel().setSelected(items.get(item), true)); updateInfoPanel(); }); }

Target:
public void setModel(M model) { this.model = model; if (selectionChangedHandler != null) { selectionChangedHandler.removeHandler(); } selectionChangedHandler = getSelectionModel().addSelectionChangeHandler(e -> processSelectionChanged()); getSelectionModel().setDataDisplay(this.hasDataDelegate); getSelectionModel().setMultiSelectEnabled(true); getModel().getItemsChangedEvent().addListener((ev, sender, args) -> { getSelectionModel().clear(); List<T> items = getModel().getItemsAsList(); List<Integer> itemsToSelect = selectedIndexes.stream().filter(selectedIndex -> selectedIndex > -1 && selectedIndex < items.size() ).collect(Collectors.toList()); itemsToSelect.forEach(index -> getSelectionModel().setSelected(items.get(index), true)); updateInfoPanel(); }); }
Source:
public void invoke(MessageContext messageContext) throws Exception { Exchange exchange = getEndpoint().createExchange(ExchangePattern.InOptionalOut); populateExchangeFromMessageContext(messageContext, exchange); getProcessor().process(exchange); Message responseMessage = null; Source responseBody = null; if (exchange.getException() != null) { throw exchange.getException(); } else if (exchange.getPattern().isOutCapable()) { responseMessage = exchange.getOut(Message.class); } else { responseMessage = exchange.getIn(Message.class); } if (responseMessage != null) { responseBody = responseMessage.getBody(Source.class); WebServiceMessage response = messageContext.getResponse(); configuration.getMessageFilter().filterConsumer(exchange, response); XmlConverter xmlConverter = configuration.getXmlConverter(); xmlConverter.toResult(responseBody, response.getPayloadResult()); } }

Target:
public void invoke(MessageContext messageContext) throws Exception { Exchange exchange = getEndpoint().createExchange(ExchangePattern.InOptionalOut); populateExchangeFromMessageContext(messageContext, exchange); getProcessor().process(exchange); if (exchange.getException() != null) { throw exchange.getException(); } else if (exchange.getPattern().isOutCapable()) { Message responseMessage = exchange.hasOut() ? exchange.getOut(Message.class) : exchange.getIn(Message.class); if (responseMessage != null) { Source responseBody = responseMessage.getBody(Source.class); WebServiceMessage response = messageContext.getResponse(); configuration.getMessageFilter().filterConsumer(exchange, response); XmlConverter xmlConverter = configuration.getXmlConverter(); xmlConverter.toResult(responseBody, response.getPayloadResult()); } } }
Source:
public void testGetPossibleAnnotationsForContainers_ListColumns(){ tableIndexDAO.deleteEntityData(Lists.newArrayList(2L,3L)); String annoKey = "myAnnotation"; EntityDTO file1 = createEntityDTO(2L, EntityType.file, 0); file1.setParentId(333L); AnnotationDTO annotationDTO1 = new AnnotationDTO(); annotationDTO1.setKey(annoKey); annotationDTO1.setType(AnnotationType.STRING); annotationDTO1.setEntityId(2L); annotationDTO1.setValue(Arrays.asList("123", "123456")); file1.setAnnotations(Collections.singletonList(annotationDTO1)); EntityDTO file2 = createEntityDTO(3L, EntityType.file, 0); file2.setParentId(222L); AnnotationDTO annotationDTO2 = new AnnotationDTO(); annotationDTO2.setKey(annoKey); annotationDTO2.setType(AnnotationType.STRING); annotationDTO2.setEntityId(3L); annotationDTO2.setValue(Arrays.asList("12", "1234")); file2.setAnnotations(Collections.singletonList(annotationDTO2)); tableIndexDAO.addEntityData(Lists.newArrayList(file1, file2)); Set<Long> containerIds = Sets.newHashSet(222L, 333L); long limit = 5; long offset = 0; List<ColumnModel> columns = tableIndexDAO.getPossibleColumnModelsForContainers(containerIds, ViewTypeMask.File.getMask(), limit, offset); assertNotNull(columns); assertEquals(1, columns.size()); ColumnModel cm = columns.get(0); assertEquals(annoKey, cm.getName()); assertEquals(ColumnType.STRING_LIST, cm.getColumnType()); assertEquals(6L, cm.getMaximumSize()); }

Target:
public void testGetPossibleAnnotationsForContainers_ListColumns(){ tableIndexDAO.deleteEntityData(Lists.newArrayList(2L,3L)); String annoKey = "myAnnotation"; EntityDTO file1 = createEntityDTO(2L, EntityType.file, 0); file1.setParentId(333L); AnnotationDTO annotationDTO1 = new AnnotationDTO(); annotationDTO1.setKey(annoKey); annotationDTO1.setType(AnnotationType.STRING); annotationDTO1.setEntityId(2L); annotationDTO1.setValue(Arrays.asList("123")); file1.setAnnotations(Collections.singletonList(annotationDTO1)); EntityDTO file2 = createEntityDTO(3L, EntityType.file, 0); file2.setParentId(222L); AnnotationDTO annotationDTO2 = new AnnotationDTO(); annotationDTO2.setKey(annoKey); annotationDTO2.setType(AnnotationType.STRING); annotationDTO2.setEntityId(3L); annotationDTO2.setValue(Arrays.asList("12", "123456", "1234")); file2.setAnnotations(Collections.singletonList(annotationDTO2)); EntityDTO file3 = createEntityDTO(4L, EntityType.file, 0); file3.setParentId(222L); AnnotationDTO annotationDTO3 = new AnnotationDTO(); annotationDTO3.setKey(annoKey); annotationDTO3.setType(AnnotationType.STRING); annotationDTO3.setEntityId(3L); annotationDTO3.setValue(Arrays.asList("12345")); file3.setAnnotations(Collections.singletonList(annotationDTO3)); tableIndexDAO.addEntityData(Lists.newArrayList(file1, file2)); Set<Long> containerIds = Sets.newHashSet(222L, 333L); long limit = 5; long offset = 0; List<ColumnModel> columns = tableIndexDAO.getPossibleColumnModelsForContainers(containerIds, ViewTypeMask.File.getMask(), limit, offset); assertNotNull(columns); assertEquals(1, columns.size()); ColumnModel cm = columns.get(0); assertEquals(annoKey, cm.getName()); assertEquals(ColumnType.STRING_LIST, cm.getColumnType()); assertEquals(6L, cm.getMaximumSize()); }
Source:
public CallStatus run() { RequestMetrics.Context context = metrics.startDiagnosticsRequest(); LOGGER.debug("run: diagnostic"); Error.reset(); Error.push("rest"); Error.push(getClass().getSimpleName()); try { Response.Status healthCheckResponse = Response.Status.OK; Map<String, HealthCheck.Result> healthCheckResults = new LinkedHashMap<>(); for (Map.Entry<String, Result> entry : healthCheckRegistry.runHealthChecks().entrySet()) { if (entry.getValue().isHealthy()) { LOGGER.debug("diagnosticCheck is OK", entry.getKey()); healthCheckResults.put(entry.getKey(), entry.getValue()); } else { String errorDetails = entry.getKey().toString() + " " + entry.getValue().getDetails(); Error.push("diagnosticCheck failed! " + errorDetails); LOGGER.debug("diagnosticCheck failed!", errorDetails); healthCheckResults.put(entry.getKey(), entry.getValue()); healthCheckResponse = Response.Status.SERVICE_UNAVAILABLE; } } return new CallStatus(new CrudCheckResponse(healthCheckResults), healthCheckResponse); } catch (Error e) { context.markRequestException(e); LOGGER.error("diagnosticCheck failure: {}", e); return new CallStatus(e); } catch (Exception e) { context.markRequestException(e); LOGGER.error("diagnosticCheck failure: {}", e); return new CallStatus(Error.get(RestCrudConstants.ERR_REST_CHECK_DIAGNOSTICS, e.toString())); } finally { context.endRequestMonitoring(); } }

Target:
public CallStatus run() { RequestMetrics.Context context = metrics.startDiagnosticsRequest(); LOGGER.debug("run: diagnostic"); Error.reset(); Error.push("rest"); Error.push(getClass().getSimpleName()); try { Response.Status healthCheckResponse = Response.Status.OK; Map<String, HealthCheck.Result> healthCheckResults = new LinkedHashMap<>(); for (Map.Entry<String, Result> entry : healthCheckRegistry.runHealthChecks().entrySet()) { healthCheckResults.put(entry.getKey(), entry.getValue()); if (entry.getValue().isHealthy()) { LOGGER.debug("diagnosticCheck is OK", entry.getKey()); } else { String errorDetails = entry.getKey().toString() + " " + entry.getValue().getDetails(); Error.push("diagnosticCheck failed! " + errorDetails); LOGGER.debug("diagnosticCheck failed!", errorDetails); healthCheckResponse = Response.Status.SERVICE_UNAVAILABLE; } } return new CallStatus(new CrudCheckResponse(healthCheckResults), healthCheckResponse); } catch (Error e) { context.markRequestException(e); LOGGER.error("diagnosticCheck failure: {}", e); return new CallStatus(e); } catch (Exception e) { context.markRequestException(e); LOGGER.error("diagnosticCheck failure: {}", e); return new CallStatus(Error.get(RestCrudConstants.ERR_REST_CHECK_DIAGNOSTICS, e.toString())); } finally { context.endRequestMonitoring(); } }
Source:
public String toString() { return "There are " + totalConnectionCount + " total connections, " + activeConnectionCount + " are active and " + idleConnectionCount + " are idle."; }

Target:
public String toString() { return "There are " + getTotalConnectionCount() + " total connections, " + getTotalActiveConnectionCount() + " are active and " + getTotalIdleConnectionCount() + " are idle."; }
Source:
protected void onMethodInvocationFound(MethodInvocationTree mit) { ExpressionTree firstArg = mit.arguments().get(0); if (isInappropriateRegexpStringLiteral(firstArg) || isFileSeparator(firstArg)) { reportIssue(firstArg, ""); } }

Target:
protected void onMethodInvocationFound(MethodInvocationTree mit) { ExpressionTree firstArg = mit.arguments().get(0); if (isInappropriateRegexpStringLiteral(firstArg) || isFileSeparator(firstArg)) { reportIssue(firstArg, "Correct this regular expression."); } }
Source:
public String asCql() { StringBuilder builder = new StringBuilder(); builder.append("TRUNCATE "); if (keyspace != null) { builder.append(keyspace.asCql(true)).append("."); } builder.append(table.asCql(true)); return builder.toString(); }

Target:
public String asCql() { StringBuilder builder = new StringBuilder(); builder.append("TRUNCATE "); CqlHelper.qualify(keyspace, table, builder); return builder.toString(); }
Source:
public void updateSignatureState() { final ScriptType type = getType(); if (type != null) { try { final VerifySignature verifySignature = VerifySignature.getInstance(type, getInputStream()); signatureState = (verifySignature == null) ? null : verifySignature.verify(); } catch (final ScriptSignatureException e) { Logger.error(org.eclipse.ease.ui.Activator.PLUGIN_ID, e.getMessage(), e); } } }

Target:
public void updateSignatureState() { final ScriptType type = getType(); if (type != null) { try { final VerifySignature verifySignature = VerifySignature.getInstance(type, getInputStream()); signatureState = (verifySignature == null) ? null : verifySignature.verify(); } catch (final ScriptSignatureException e) { Logger.error(org.eclipse.ease.ui.scripts.Activator.PLUGIN_ID, e.getMessage(), e); } } }
Source:
protected Control createDialogArea(Composite container) { Control c = super.createDialogArea(container); Composite comp = new Composite(container, SWT.NONE); comp.setLayout(new GridLayout(2, false)); addSelectedRadioButton.createWidgets(comp, 2); addSelectedRadioButton.setSelected(selected == Selection.AddSelection); addSelectedRadioButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); if (addSelectedRadioButton.isSelected()) { selected = Selection.AddSelection; } } }); replaceAllRadioButton.createWidgets(comp, 2); replaceAllRadioButton.setSelected(selected == Selection.ReplaceAll); replaceAllRadioButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); if (replaceAllRadioButton.isSelected()) { selected = Selection.ReplaceAll; } } }); if (!isSingletonAttribute) { deleteSelectedRadioButton.createWidgets(comp, 2); deleteSelectedRadioButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); if (deleteSelectedRadioButton.isSelected()) { selected = Selection.DeleteSelected; } } }); } else if (isRemoveAllAllowed) { removeAll.createWidgets(comp, 2); removeAll.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); if (removeAll.isSelected()) { selected = Selection.RemoveAll; } } }); } return c; }

Target:
protected Control createDialogArea(Composite container) { Control c = super.createDialogArea(container); Composite comp = new Composite(container, SWT.NONE); comp.setLayout(new GridLayout(2, false)); if (!isSingletonAttribute) { addSelectedRadioButton.createWidgets(comp, 2); addSelectedRadioButton.setSelected(selected == Selection.AddSelection); addSelectedRadioButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); if (addSelectedRadioButton.isSelected()) { selected = Selection.AddSelection; } } }); } replaceAllRadioButton.createWidgets(comp, 2); replaceAllRadioButton.setSelected(selected == Selection.ReplaceAll); replaceAllRadioButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); if (replaceAllRadioButton.isSelected()) { selected = Selection.ReplaceAll; } } }); if (!isSingletonAttribute) { deleteSelectedRadioButton.createWidgets(comp, 2); deleteSelectedRadioButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); if (deleteSelectedRadioButton.isSelected()) { selected = Selection.DeleteSelected; } } }); } else if (isRemoveAllAllowed) { removeAll.createWidgets(comp, 2); removeAll.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); if (removeAll.isSelected()) { selected = Selection.RemoveAll; } } }); } return c; }
Source:
protected Object decode(final ChannelHandlerContext ctx, final ByteBuf buffer) throws Exception { final int bufferBytes = buffer.readableBytes(); if (bufferBytes > 0) { ByteBuf lineBuffer = null; do { lineBuffer = (ByteBuf) super.decode(ctx, buffer); if (lineBuffer != null) { final int index = lineBuffer.readableBytes(); final byte[] response = new byte[index]; lineBuffer.getBytes(lineBuffer.readerIndex(), response); if (literalCount == 0 && index > MINIMAL_LITERAL_LENGTH && response[index - LITERAL_INDEX_FROM_TAIL] == '}') { int i; for (i = index - LITERAL_INDEX_FROM_TAIL - 1; i >= 0; i--) { if (response[i] == '{') { break; } } if (i >= 0) { literalCount = ASCIIUtility.parseInt(response, i + 1, index - LITERAL_INDEX_FROM_TAIL); literalBuffer = Unpooled.buffer(index + literalCount); literalBuffer.writeBytes(response); } } else if (literalCount > 0) { literalBuffer.writeBytes(lineBuffer); literalCount = literalCount - index; } } } while (literalCount > 0 && buffer.readableBytes() > 0 && lineBuffer != null); if (literalBuffer != null && literalCount == 0) { ByteBuf lastLineBuffer = (ByteBuf) super.decode(ctx, buffer); final int lastLineIndex = lastLineBuffer.readableBytes(); final byte[] lastLineBytes = new byte[lastLineIndex]; lastLineBuffer.getBytes(lastLineBuffer.readerIndex(), lastLineBytes); literalBuffer.writeBytes(lastLineBytes); ByteBuf result = literalBuffer.copy(); literalCount = 0; literalBuffer = null; return result; } else { return lineBuffer; } } else { return null; } }

Target:
protected Object decode(final ChannelHandlerContext ctx, final ByteBuf buffer) throws Exception { final int bufferBytes = buffer.readableBytes(); if (bufferBytes > 0) { ByteBuf lineBuffer = null; do { lineBuffer = (ByteBuf) super.decode(ctx, buffer); if (lineBuffer != null) { final int readableBytes = lineBuffer.readableBytes(); if (literalCount > 0) { literalCount = literalCount - readableBytes; if (literalCount <= 0) { literalCount = getLiteralCount(lineBuffer, readableBytes, readableBytes + literalCount); } literalBuffer.writeBytes(lineBuffer); } else { literalCount = getLiteralCount(lineBuffer, readableBytes, 0); if (literalCount > 0) { literalBuffer = Unpooled.buffer(readableBytes + literalCount); literalBuffer.writeBytes(lineBuffer); } } } } while (literalCount > 0 && buffer.readableBytes() > 0 && lineBuffer != null); if (literalBuffer != null && literalCount == 0) { final ByteBuf lastLineBuffer = (ByteBuf) super.decode(ctx, buffer); final int lastLineIndex = lastLineBuffer.readableBytes(); final byte[] lastLineBytes = new byte[lastLineIndex]; lastLineBuffer.getBytes(lastLineBuffer.readerIndex(), lastLineBytes); literalBuffer.writeBytes(lastLineBytes); final ByteBuf result = literalBuffer.copy(); literalBuffer = null; return result; } else { return lineBuffer; } } else { return null; } }
Source:
protected String getClassProperty() { return super.getClassProperty() + " " + FEED_CLASS_VALUE; }

Target:
protected String getClassProperty() { return super.getClassProperty() + ' ' + FEED_CLASS_VALUE; }
Source:
public Statement apply(TemplateOptions options) { ImmutableList.Builder<Statement> builder = ImmutableList.builder(); if (options.getRunScript() != null) { builder.add(options.getRunScript()); } if (options.getPrivateKey() != null) { builder.add(new InstallRSAPrivateKey(options.getPrivateKey())); } ImmutableList<Statement> bootstrap = builder.build(); if (!bootstrap.isEmpty()) { if (options.getTaskName() == null && !(options.getRunScript() instanceof InitScript)) { options.nameTask("bootstrap"); } return bootstrap.size() == 1 ? bootstrap.get(0) : new StatementList(bootstrap); } return null; }

Target:
public Statement apply(TemplateOptions options) { ImmutableList.Builder<Statement> builder = ImmutableList.builder(); if (options.getRunScript() != null) { builder.add(options.getRunScript()); } if (options.getPrivateKey() != null) { builder.add(new InstallRSAPrivateKey(options.getPrivateKey())); } ImmutableList<Statement> bootstrap = builder.build(); if (bootstrap.isEmpty()) { return null; } if (options.getTaskName() == null && !(options.getRunScript() instanceof InitScript)) { options.nameTask("bootstrap"); } return bootstrap.size() == 1 ? bootstrap.get(0) : new StatementList(bootstrap); }
Source:
private void consumerLoop() { long lastPeriodicProcess = System.currentTimeMillis(); List<AckEntry> rest = new ArrayList<AckEntry>(INCOMING_QUEUE_LENGTH); while (true) { long now = System.currentTimeMillis(); if ((now - lastPeriodicProcess) > QUEUE_POLL_TIME) { processQueues(); lastPeriodicProcess = now; } AckEntry entry = null; try { entry = incomingQueue.poll(QUEUE_POLL_TIME, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { continue; } if (null != entry) { processIncoming(entry); if (incomingQueue.size() > 0) { incomingQueue.drainTo(rest); for (AckEntry ent : rest) { processIncoming(ent); } rest.clear(); } } if (isShutdown.get()) { if (! incomingQueue.isEmpty()) { continue; } assert incomingQueue.isEmpty(); flush(); return; } } }

Target:
private void consumerLoop() { long lastPeriodicProcess = System.currentTimeMillis(); List<AckEntry> rest = new ArrayList<AckEntry>(INCOMING_QUEUE_LENGTH); while (true) { final long now = System.currentTimeMillis(); if ((now - lastPeriodicProcess) > QUEUE_POLL_TIME) { processQueues(); lastPeriodicProcess = now; } final AckEntry entry; try { entry = incomingQueue.poll(QUEUE_POLL_TIME, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { continue; } if (null != entry) { processIncoming(entry); if (incomingQueue.size() > 0) { incomingQueue.drainTo(rest); for (AckEntry ent : rest) { processIncoming(ent); } rest.clear(); } } if (isShutdown.get()) { if (! incomingQueue.isEmpty()) { continue; } assert incomingQueue.isEmpty(); flush(); return; } } }
Source:
private F<Boolean,Response> listChargesAndRefunds(ChargeSearchParams searchParams, UriInfo uriInfo) { Long totalCount = chargeDao.getTotalFor(searchParams); Long size = searchParams.getDisplaySize(); if (totalCount > 0 && size > 0) { long lastPage = (totalCount + size - 1)/ size; if (searchParams.getPage() > lastPage || searchParams.getPage() < 1) { return success -> notFoundResponse("the requested page not found"); } } List<ChargeEntity> charges = chargeDao.findAllBy(searchParams); List<ChargeResponse> chargesResponse = charges.stream() .map(charge -> chargeService.buildChargeResponse(uriInfo, charge) ).collect(Collectors.toList()); return success -> new ChargesPaginationResponseBuilder(searchParams, uriInfo) .withChargeResponses(chargesResponse) .withTotalCount(totalCount) .buildResponse(); }

Target:
private F<Boolean,Response> listChargesAndRefunds(ChargeSearchParams searchParams, UriInfo uriInfo) { return listCharges(searchParams, uriInfo); }
Source:
public ValueExtractor<?> getCascadedValueExtractor(Class<?> valueType, TypeVariable<?> cascadingTypeParameter) { Map<Class<?>, Map<TypeVariable<?>, TypeVariable<?>>> allBindings = null; if ( cascadingTypeParameter != AnnotatedObject.INSTANCE && cascadingTypeParameter != ArrayElement.INSTANCE ) { allBindings = TypeVariableBindings.getTypeVariableBindings( (Class<?>) cascadingTypeParameter.getGenericDeclaration() ); } List<ValueExtractorDescriptor> typeCompatibleExtractors = valueExtractors.stream() .filter( e -> TypeHelper.isAssignable( TypeHelper.getErasedReferenceType( e.getExtractedType() ), valueType ) ) .collect( Collectors.toList() ); for ( ValueExtractorDescriptor extractorDescriptor : typeCompatibleExtractors ) { TypeVariable<?> cascadingParameterBoundToExtractorType; if ( cascadingTypeParameter != AnnotatedObject.INSTANCE && cascadingTypeParameter != ArrayElement.INSTANCE ) { Map<TypeVariable<?>, TypeVariable<?>> bindingsForExtractorType = allBindings.get( TypeHelper.getErasedReferenceType( extractorDescriptor.getExtractedType() ) ); cascadingParameterBoundToExtractorType = bind( cascadingTypeParameter, bindingsForExtractorType ); } else { cascadingParameterBoundToExtractorType = cascadingTypeParameter; } if ( cascadingParameterBoundToExtractorType.equals( extractorDescriptor.extractedTypeParameter() ) ) { return extractorDescriptor.getValueExtractor(); } } return null; }

Target:
public ValueExtractorDescriptor getCascadedValueExtractor(Class<?> valueType, TypeVariable<?> cascadingTypeParameter) { Map<Class<?>, Map<TypeVariable<?>, TypeVariable<?>>> allBindings = null; if ( cascadingTypeParameter != AnnotatedObject.INSTANCE && cascadingTypeParameter != ArrayElement.INSTANCE ) { allBindings = TypeVariableBindings.getTypeVariableBindings( (Class<?>) cascadingTypeParameter.getGenericDeclaration() ); } List<ValueExtractorDescriptor> typeCompatibleExtractors = valueExtractors.stream() .filter( e -> TypeHelper.isAssignable( TypeHelper.getErasedReferenceType( e.getExtractedType() ), valueType ) ) .collect( Collectors.toList() ); for ( ValueExtractorDescriptor extractorDescriptor : typeCompatibleExtractors ) { TypeVariable<?> cascadingParameterBoundToExtractorType; if ( cascadingTypeParameter != AnnotatedObject.INSTANCE && cascadingTypeParameter != ArrayElement.INSTANCE ) { Map<TypeVariable<?>, TypeVariable<?>> bindingsForExtractorType = allBindings.get( TypeHelper.getErasedReferenceType( extractorDescriptor.getExtractedType() ) ); cascadingParameterBoundToExtractorType = bind( cascadingTypeParameter, bindingsForExtractorType ); } else { cascadingParameterBoundToExtractorType = cascadingTypeParameter; } if ( cascadingParameterBoundToExtractorType.equals( extractorDescriptor.extractedTypeParameter() ) ) { return extractorDescriptor; } } return null; }
Source:
public RemoteSolrCatalogProvider( FilterAdapter filterAdapter, SolrClient client, SolrFilterDelegateFactory solrFilterDelegateFactory, @Nullable DynamicSchemaResolver resolver) { notNull(filterAdapter, "FilterAdapter cannot be null"); notNull(solrFilterDelegateFactory, "SolrFilterDelegateFactory cannot be null"); this.filterAdapter = filterAdapter; this.client = client; this.solrFilterDelegateFactory = solrFilterDelegateFactory; this.resolver = (resolver == null) ? new DynamicSchemaResolver() : resolver; this.provider = new SolrCatalogProvider(client, filterAdapter, solrFilterDelegateFactory, this.resolver); provider.maskId(getId()); }

Target:
public RemoteSolrCatalogProvider( FilterAdapter filterAdapter, SolrClient client, SolrFilterDelegateFactory solrFilterDelegateFactory, @Nullable DynamicSchemaResolver resolver) { this.provider = new SolrCatalogProvider( client, filterAdapter, solrFilterDelegateFactory, (resolver == null) ? new DynamicSchemaResolver() : resolver); provider.maskId(getId()); }
Source:
public void testStatsForValuesNodeWithJustNulls() { PlanNodeStatsEstimate nullAStats = PlanNodeStatsEstimate.builder() .setOutputRowCount(1) .addSymbolStatistics(new Symbol("a"), SymbolStatsEstimate.builder() .setDistinctValuesCount(0) .setNullsFraction(1.0) .setAverageRowSize(0.0) .setHighValue(NaN) .setLowValue(NaN) .build()) .build(); tester().assertStatsFor(pb -> pb .values(ImmutableList.of(pb.symbol("a", BIGINT)), ImmutableList.of( ImmutableList.of(expression("3 + null"))))) .check(outputStats -> outputStats.equalTo(nullAStats)); tester().assertStatsFor(pb -> pb .values(ImmutableList.of(pb.symbol("a", BIGINT)), ImmutableList.of( ImmutableList.of(expression("null"))))) .check(outputStats -> outputStats.equalTo(nullAStats)); tester().assertStatsFor(pb -> pb .values(ImmutableList.of(pb.symbol("a", UNKNOWN)), ImmutableList.of( ImmutableList.of(expression("null"))))) .check(outputStats -> outputStats.equalTo(nullAStats)); }

Target:
public void testStatsForValuesNodeWithJustNulls() { PlanNodeStatsEstimate nullAStats = PlanNodeStatsEstimate.builder() .setOutputRowCount(1) .addSymbolStatistics(new Symbol("a"), SymbolStatsEstimate.zero()) .build(); tester().assertStatsFor(pb -> pb .values(ImmutableList.of(pb.symbol("a", BIGINT)), ImmutableList.of( ImmutableList.of(expression("3 + null"))))) .check(outputStats -> outputStats.equalTo(nullAStats)); tester().assertStatsFor(pb -> pb .values(ImmutableList.of(pb.symbol("a", BIGINT)), ImmutableList.of( ImmutableList.of(expression("null"))))) .check(outputStats -> outputStats.equalTo(nullAStats)); tester().assertStatsFor(pb -> pb .values(ImmutableList.of(pb.symbol("a", UNKNOWN)), ImmutableList.of( ImmutableList.of(expression("null"))))) .check(outputStats -> outputStats.equalTo(nullAStats)); }
Source:
public void testGetColumnText() throws Exception { SevereLoggingMonitor loggingMonitor = TestUtil.severeLoggingStart(); TeamWorkFlowArtifact reqArt = (TeamWorkFlowArtifact) DemoTestUtil.getUncommittedActionWorkflow(DemoWorkType.Requirements); TeamWorkFlowArtifact codeArt = (TeamWorkFlowArtifact) DemoTestUtil.getUncommittedActionWorkflow(DemoWorkType.Code); TeamWorkFlowArtifact toolsArt = DemoTestUtil.getToolsTeamWorkflow(); Collection<IAtsVersion> hV = reqArt.getTeamDefinition().getTeamDefinitionHoldingVersions().getVersions(); IAtsVersion[] holdingVersions = hV.toArray(new IAtsVersion[hV.size()]); IAtsChangeSet changes = AtsClientService.get().createChangeSet("Update Found-In-Version Test"); changes.setRelation(reqArt, XFoundInVersionWidget.FOUND_VERSION_RELATION, holdingVersions[0]); changes.executeIfNeeded(); changes = AtsClientService.get().createChangeSet("Update Found-In-Version Test"); changes.setRelation(codeArt, XFoundInVersionWidget.FOUND_VERSION_RELATION, holdingVersions[1]); changes.executeIfNeeded(); Assert.assertEquals(holdingVersions[0].toString(), FoundInVersionColumnUI.getInstance().getColumnText(reqArt, FoundInVersionColumnUI.getInstance(), 0)); Assert.assertEquals(holdingVersions[1].toString(), FoundInVersionColumnUI.getInstance().getColumnText(codeArt, FoundInVersionColumnUI.getInstance(), 0)); Assert.assertEquals("", FoundInVersionColumnUI.getInstance().getColumnText(toolsArt, FoundInVersionColumnUI.getInstance(), 0)); TestUtil.severeLoggingEnd(loggingMonitor); }

Target:
public void testGetColumnText() throws Exception { SevereLoggingMonitor loggingMonitor = TestUtil.severeLoggingStart(); TeamWorkFlowArtifact codeArt = (TeamWorkFlowArtifact) DemoTestUtil.getUncommittedActionWorkflow(DemoWorkType.Code); IAtsVersion demoVersion = AtsClientService.get().getVersionService().getVersion(DemoArtifactToken.SAW_Bld_1); Assert.assertEquals("", FoundInVersionColumnUI.getInstance().getColumnText(codeArt, FoundInVersionColumnUI.getInstance(), 0)); IAtsChangeSet changes = AtsClientService.get().createChangeSet("Update Found-In-Version Test"); changes.setRelation(codeArt, XFoundInVersionWidget.FOUND_VERSION_RELATION, demoVersion); changes.executeIfNeeded(); Assert.assertEquals(demoVersion.toString(), FoundInVersionColumnUI.getInstance().getColumnText(codeArt, FoundInVersionColumnUI.getInstance(), 0)); TestUtil.severeLoggingEnd(loggingMonitor); }
Source:
private Answer executeRequest(SyncNuageVspCmsIdCommand cmd) { try { isNuageVspManagerLoaded(); if (cmd.getSyncType() == SyncType.AUDIT || cmd.getSyncType() == SyncType.AUDIT_ONLY) { Pair<Boolean, String> answer = _nuageVspManagerClient.auditNuageVspCmsId(cmd.getNuageVspCmsId(), cmd.getSyncType() == SyncType.AUDIT_ONLY); return new SyncNuageVspCmsIdAnswer(answer.getLeft(), answer.getRight(), cmd.getSyncType()); } else if (cmd.getSyncType() == SyncType.REGISTER) { String registeredNuageVspCmsId = _nuageVspManagerClient.registerNuageVspCmsId(); return new SyncNuageVspCmsIdAnswer(StringUtils.isNotBlank(registeredNuageVspCmsId), registeredNuageVspCmsId, cmd.getSyncType()); } else { boolean success = _nuageVspManagerClient.unregisterNuageVspCmsId(cmd.getNuageVspCmsId()); return new SyncNuageVspCmsIdAnswer(success, cmd.getNuageVspCmsId(), cmd.getSyncType()); } } catch (Exception e) { return new SyncNuageVspCmsIdAnswer(false, null, cmd.getSyncType()); } }

Target:
private Answer executeRequest(SyncNuageVspCmsIdCommand cmd) { try { isNuageVspManagerLoaded(); if (cmd.getSyncType() == SyncType.AUDIT || cmd.getSyncType() == SyncType.AUDIT_ONLY) { Pair<Boolean, String> answer = _nuageVspManagerClient.auditNuageVspCmsId(cmd.getNuageVspCmsId(), cmd.getSyncType() == SyncType.AUDIT_ONLY); return new SyncNuageVspCmsIdAnswer(answer.getLeft(), answer.getRight(), cmd.getSyncType()); } else if (cmd.getSyncType() == SyncType.REGISTER) { String registeredNuageVspCmsId = _nuageVspManagerClient.registerNuageVspCmsId(); return new SyncNuageVspCmsIdAnswer(StringUtils.isNotBlank(registeredNuageVspCmsId), registeredNuageVspCmsId, cmd.getSyncType()); } else { boolean success = _nuageVspManagerClient.unregisterNuageVspCmsId(cmd.getNuageVspCmsId()); return new SyncNuageVspCmsIdAnswer(success, cmd.getNuageVspCmsId(), cmd.getSyncType()); } } catch (ExecutionException | ConfigurationException e) { s_logger.error("Failure during " + cmd + " on Nuage VSD " + _hostName, e); return new SyncNuageVspCmsIdAnswer(false, null, cmd.getSyncType()); } }
Source:
public Set<ConnectorPlanOptimizer> getConnectorPlanOptimizers() { RowExpressionToSqlTranslator translator = getRowExpressionToSqlTranslator( functionManager, buildFunctionTranslator(getFunctionTranslators())); return ImmutableSet.of(new JdbcComputePushdown( functionManager, functionResolution, determinismEvaluator, expressionOptimizer, translator)); }

Target:
public Set<ConnectorPlanOptimizer> getConnectorPlanOptimizers() { return ImmutableSet.of(new JdbcComputePushdown( functionManager, functionResolution, determinismEvaluator, expressionOptimizer, identifierQuote, getFunctionTranslators())); }
Source:
private List<EReference> getValidContainmentReferences(EObject eObject) { List<EReference> eReferences = new ArrayList<>(); List<EStructuralFeature> eAllStructuralFeatures = eObject.eClass().getEAllStructuralFeatures(); for (EStructuralFeature eStructuralFeature : eAllStructuralFeatures) { if (eStructuralFeature instanceof EReference) { EReference reference = (EReference) eStructuralFeature; if (reference.isContainment() && this.eReference.getEReferenceType().isSuperTypeOf(reference.getEReferenceType())) { eReferences.add(reference); } } } return eReferences; }

Target:
private List<EReference> getValidContainmentReferences(EObject eObject) { List<EReference> eReferences = new ArrayList<>(); List<EStructuralFeature> eAllStructuralFeatures = eObject.eClass().getEAllStructuralFeatures(); for (EStructuralFeature eStructuralFeature : eAllStructuralFeatures) { if (eStructuralFeature instanceof EReference) { EReference reference = (EReference) eStructuralFeature; if (reference.isContainment() && reference.getEReferenceType().isSuperTypeOf(this.eReference.getEReferenceType())) { eReferences.add(reference); } } } return eReferences; }
Source:
public static Block bingTileCoordinates(@SqlType(BingTileType.NAME) long input) { BingTile tile = BingTile.decode(input); BlockBuilder tileBlockBuilder = BIGINT.createBlockBuilder(new BlockBuilderStatus(), 2); BIGINT.writeLong(tileBlockBuilder, tile.getX()); BIGINT.writeLong(tileBlockBuilder, tile.getY()); return tileBlockBuilder.build(); }

Target:
public static Block bingTileCoordinates(@SqlType(BingTileType.NAME) long input) { BingTile tile = BingTile.decode(input); BlockBuilder tileBlockBuilder = INTEGER.createBlockBuilder(new BlockBuilderStatus(), 2); INTEGER.writeLong(tileBlockBuilder, tile.getX()); INTEGER.writeLong(tileBlockBuilder, tile.getY()); return tileBlockBuilder.build(); }
Source:
private void deleteData(SchemaBuilder schemaBuilder, long viewTTL) throws SQLException { String viewName = schemaBuilder.getEntityTenantViewName(); Properties props = new Properties(); String tenantConnectUrl = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions() .getTenantId(); try (Connection deleteConnection = DriverManager.getConnection(tenantConnectUrl, props); final Statement statement = deleteConnection.createStatement()) { deleteConnection.setAutoCommit(true); final String deleteIfExpiredStatement = String.format("delete from %s where %s", viewName, String.format("((TO_NUMBER(CURRENT_DATE()) - TO_NUMBER(phoenix_row_timestamp())) < %d)" , viewTTL)); Preconditions.checkNotNull(deleteIfExpiredStatement); final PhoenixStatement pstmt = statement.unwrap(PhoenixStatement.class); int deleteCount = pstmt.executeUpdate(deleteIfExpiredStatement); } }

Target:
private void deleteData(SchemaBuilder schemaBuilder, long viewTTL) throws SQLException { String viewName = schemaBuilder.getEntityTenantViewName(); Properties props = new Properties(); String tenantConnectUrl = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions() .getTenantId(); try (Connection deleteConnection = DriverManager.getConnection(tenantConnectUrl, props); final Statement statement = deleteConnection.createStatement()) { deleteConnection.setAutoCommit(true); final String deleteIfExpiredStatement = String.format("delete from %s where %s", viewName, String.format( "((TO_NUMBER(CURRENT_TIME()) - TO_NUMBER(phoenix_row_timestamp())) < %d)", viewTTL)); Preconditions.checkNotNull(deleteIfExpiredStatement); final PhoenixStatement pstmt = statement.unwrap(PhoenixStatement.class); int deleteCount = pstmt.executeUpdate(deleteIfExpiredStatement); } }
Source:
public static void updateId(Connection c, String storageKey, Persistable p) { HashMap<String, Object> map = DatabaseHelper.getMetaFieldsAndValues(p); String[] fieldnames = map.keySet().toArray(new String[0]); Object[] values = map.values().toArray(new Object[0]); Pair<String, String[]> where = org.commcare.modern.database.DatabaseHelper.createWhere(fieldnames, values, p); String query = "UPDATE " + storageKey + " SET " + DatabaseHelper.DATA_COL + " = ? WHERE " + where.first + ";"; PreparedStatement preparedStatement; try { preparedStatement = c.prepareStatement(query); byte[] blob = org.commcare.modern.database.TableBuilder.toBlob(p); preparedStatement.setBinaryStream(1, new ByteArrayInputStream((byte[])blob), ((byte[])blob).length); for (int i = 2; i < where.second.length + 2; i++) { Object obj = where.second[i - 2]; if (obj instanceof String) { preparedStatement.setString(i, (String)obj); } else if (obj instanceof Blob) { preparedStatement.setBlob(i, (Blob)obj); } else if (obj instanceof Integer) { preparedStatement.setInt(i, ((Integer)obj).intValue()); } else if (obj instanceof byte[]) { preparedStatement.setBinaryStream(i, new ByteArrayInputStream((byte[])obj), ((byte[])obj).length); } else if (obj == null) { preparedStatement.setNull(i, 0); } } preparedStatement.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } }

Target:
public static void updateId(Connection c, String storageKey, Persistable p) { HashMap<String, Object> map = DatabaseHelper.getMetaFieldsAndValues(p); String[] fieldNames = map.keySet().toArray(new String[map.keySet().size()]); Object[] values = map.values().toArray(new Object[map.values().size()]); Pair<String, String[]> where = org.commcare.modern.database.DatabaseHelper.createWhere(fieldNames, values, p); String query = "UPDATE " + storageKey + " SET " + DatabaseHelper.DATA_COL + " = ? WHERE " + where.first + ";"; PreparedStatement preparedStatement = null; try { preparedStatement = c.prepareStatement(query); byte[] blob = org.commcare.modern.database.TableBuilder.toBlob(p); preparedStatement.setBinaryStream(1, new ByteArrayInputStream(blob), (blob).length); for (int i = 2; i < where.second.length + 2; i++) { Object obj = where.second[i - 2]; if (obj instanceof String) { preparedStatement.setString(i, (String)obj); } else if (obj instanceof Blob) { preparedStatement.setBlob(i, (Blob)obj); } else if (obj instanceof Integer) { preparedStatement.setInt(i, (Integer)obj); } else if (obj instanceof byte[]) { preparedStatement.setBinaryStream(i, new ByteArrayInputStream((byte[])obj), ((byte[])obj).length); } else if (obj == null) { preparedStatement.setNull(i, 0); } } preparedStatement.executeUpdate(); } catch (SQLException e) { throw new RuntimeException(e); } finally { if (preparedStatement != null) { try { preparedStatement.close(); } catch (SQLException e) { e.printStackTrace(); } } } }
Source:
public void testCatalogCreate()throws Exception { final String bomYaml = "brooklyn.catalog:\n id: simple-tomcat\n version: 1.0\n itemType: template\n" + " iconUrl: <LINK_1>\n name: Simple Tomcat\n license: Apache-2.0\n" + " item:\n brooklyn.config:\n simple.confg: someValue\n services:\n" + " - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer\n id: tomcat\n" + " name: Tomcat\n war: <LINK_0>"; final Response response = api.getCatalogApi().create(bomYaml); Asserts.assertEquals(response.getStatus(),201); }

Target:
public void testCatalogCreate()throws Exception { final Response response = api.getCatalogApi().create(getFileContentsAsString("catalog/test-catalog.bom")); Asserts.assertEquals(response.getStatus(),201); }
Source:
public void shouldThrowExceptionIfNoTypeMappingWasFoundWithoutAffectingContentProviderAsObservable() { final StorIOContentResolver storIOContentResolver = mock(StorIOContentResolver.class); final StorIOContentResolver.Internal internal = mock(StorIOContentResolver.Internal.class); when(storIOContentResolver.internal()).thenReturn(internal); when(storIOContentResolver.delete()).thenReturn(new PreparedDelete.Builder(storIOContentResolver)); final TestSubscriber<DeleteResult> testSubscriber = new TestSubscriber<DeleteResult>(); storIOContentResolver .delete() .object(TestItem.newInstance()) .prepare() .createObservable() .subscribe(testSubscriber); testSubscriber.awaitTerminalEvent(); testSubscriber.assertNoValues(); testSubscriber.assertError(StorIOException.class); verify(storIOContentResolver).delete(); verify(storIOContentResolver).internal(); verify(internal).typeMapping(TestItem.class); verify(internal, never()).delete(any(DeleteQuery.class)); verifyNoMoreInteractions(storIOContentResolver, internal); }

Target:
public void shouldThrowExceptionIfNoTypeMappingWasFoundWithoutAffectingContentProviderAsObservable() { final StorIOContentResolver storIOContentResolver = mock(StorIOContentResolver.class); final StorIOContentResolver.Internal internal = mock(StorIOContentResolver.Internal.class); when(storIOContentResolver.internal()).thenReturn(internal); when(storIOContentResolver.delete()).thenReturn(new PreparedDelete.Builder(storIOContentResolver)); final TestSubscriber<DeleteResult> testSubscriber = new TestSubscriber<DeleteResult>(); storIOContentResolver .delete() .object(TestItem.newInstance()) .prepare() .createObservable() .subscribe(testSubscriber); testSubscriber.awaitTerminalEvent(); testSubscriber.assertNoValues(); TestUtils.checkException(testSubscriber, StorIOException.class, IllegalStateException.class); verify(storIOContentResolver).delete(); verify(storIOContentResolver).internal(); verify(internal).typeMapping(TestItem.class); verify(internal, never()).delete(any(DeleteQuery.class)); verifyNoMoreInteractions(storIOContentResolver, internal); }
Source:
public void submit() { driver.switchTo().defaultContent(); postButton.click(); }

Target:
public void submit() { driver.switchTo().defaultContent(); postButton.click(); PageObjectLogging.log("submit", "message submitted", true); }