text:
title: DefaultNode
note: Auto generated by tickdoc

menu:
  kapacitor_1_1:
    name: Default
    identifier: default_node
    weight: 40
    parent: nodes
---

Defaults fields and tags on data points.

Example:

```javascript
    stream
        |default()
            .field('value', 0.0)
            .tag('host', '')
```

The above example will set the field `value` to float64(0) if it does not already exist
It will also set the tag `host` to string("") if it does not already exist.

Available Statistics:

* fields_defaulted -- number of fields that were missing
* tags_defaulted -- number of tags that were missing

Index
-----

### Properties

-	[Field](/kapacitor/v1.1/nodes/default_node/#field)
-	[Tag](/kapacitor/v1.1/nodes/default_node/#tag)

### Chaining Methods

-	[Alert](/kapacitor/v1.1/nodes/default_node/#alert)
-	[Bottom](/kapacitor/v1.1/nodes/default_node/#bottom)
-	[Combine](/kapacitor/v1.1/nodes/default_node/#combine)
-	[Count](/kapacitor/v1.1/nodes/default_node/#count)
-	[CumulativeSum](/kapacitor/v1.1/nodes/default_node/#cumulativesum)
-	[Deadman](/kapacitor/v1.1/nodes/default_node/#deadman)
-	[Default](/kapacitor/v1.1/nodes/default_node/#default)
-	[Delete](/kapacitor/v1.1/nodes/default_node/#delete)
-	[Derivative](/kapacitor/v1.1/nodes/default_node/#derivative)
-	[Difference](/kapacitor/v1.1/nodes/default_node/#difference)
-	[Distinct](/kapacitor/v1.1/nodes/default_node/#distinct)
-	[Elapsed](/kapacitor/v1.1/nodes/default_node/#elapsed)
-	[Eval](/kapacitor/v1.1/nodes/default_node/#eval)
-	[First](/kapacitor/v1.1/nodes/default_node/#first)
-	[Flatten](/kapacitor/v1.1/nodes/default_node/#flatten)
-	[GroupBy](/kapacitor/v1.1/nodes/default_node/#groupby)
-	[HoltWinters](/kapacitor/v1.1/nodes/default_node/#holtwinters)
-	[HoltWintersWithFit](/kapacitor/v1.1/nodes/default_node/#holtwinterswithfit)
-	[HttpOut](/kapacitor/v1.1/nodes/default_node/#httpout)
-	[InfluxDBOut](/kapacitor/v1.1/nodes/default_node/#influxdbout)
-	[Join](/kapacitor/v1.1/nodes/default_node/#join)
-	[K8sAutoscale](/kapacitor/v1.1/nodes/default_node/#k8sautoscale)
-	[Last](/kapacitor/v1.1/nodes/default_node/#last)
-	[Log](/kapacitor/v1.1/nodes/default_node/#log)
-	[Max](/kapacitor/v1.1/nodes/default_node/#max)
-	[Mean](/kapacitor/v1.1/nodes/default_node/#mean)
-	[Median](/kapacitor/v1.1/nodes/default_node/#median)
-	[Min](/kapacitor/v1.1/nodes/default_node/#min)
-	[Mode](/kapacitor/v1.1/nodes/default_node/#mode)
-	[MovingAverage](/kapacitor/v1.1/nodes/default_node/#movingaverage)
-	[Percentile](/kapacitor/v1.1/nodes/default_node/#percentile)
-	[Sample](/kapacitor/v1.1/nodes/default_node/#sample)
-	[Shift](/kapacitor/v1.1/nodes/default_node/#shift)
-	[Spread](/kapacitor/v1.1/nodes/default_node/#spread)
-	[Stats](/kapacitor/v1.1/nodes/default_node/#stats)
-	[Stddev](/kapacitor/v1.1/nodes/default_node/#stddev)
-	[Sum](/kapacitor/v1.1/nodes/default_node/#sum)
-	[Top](/kapacitor/v1.1/nodes/default_node/#top)
-	[Union](/kapacitor/v1.1/nodes/default_node/#union)
-	[Where](/kapacitor/v1.1/nodes/default_node/#where)
-	[Window](/kapacitor/v1.1/nodes/default_node/#window)

Properties
----------

Property methods modify state on the calling node.
They do not add another node to the pipeline, and always return a reference to the calling node.
Property methods are marked using the `.` operator.

### Field

Define a field default.

```javascript
node.field(name string, value interface{})
```

### Tag

Define a tag default.

```javascript
node.tag(name string, value string)
```

Chaining Methods
----------------

Chaining methods create a new node in the pipeline as a child of the calling node.
They do not modify the calling node.
Chaining methods are marked using the `|` operator.

### Alert

Create an alert node, which can trigger alerts.

```javascript
node|alert()
```

Returns: [AlertNode](/kapacitor/v1.1/nodes/alert_node/)

### Bottom

Select the bottom `num` points for `field` and sort by any extra tags or fields.

```javascript
node|bottom(num int64, field string, fieldsAndTags ...string)
```

Returns: [InfluxQLNode](/kapacitor/v1.1/nodes/influx_q_l_node/)

### Combine

Combine this node with itself. The data are combined on timestamp.

```javascript
node|combine(expressions ...ast.LambdaNode)
```

Returns: [CombineNode](/kapacitor/v1.1/nodes/combine_node/)

### Count

Count the number of points.

```javascript
node|count(field string)
```

Returns: [InfluxQLNode](/kapacitor/v1.1/nodes/influx_q_l_node/)

### CumulativeSum

Compute a cumulative sum of each point that is received.
A point is emitted for every point collected.

```javascript
node|cumulativeSum(field string)
```

Returns: [InfluxQLNode](/kapacitor/v1.1/nodes/influx_q_l_node/)

### Deadman

Helper function for creating an alert on low throughput, a.k.a. deadman's switch.

- Threshold -- trigger alert if throughput drops below threshold in points/interval.
- Interval -- how often to check the throughput.
- Expressions -- optional list of expressions to also evaluate. Useful for time of day alerting.

Example:

```javascript
    var data = stream
        |from()...
    // Trigger critical alert if the throughput drops below 100 points per 10s and checked every 10s.
    data
        |deadman(100.0, 10s)
    //Do normal processing of data
    data...
```

The above is equivalent to this
Example:

```javascript
    var data = stream
        |from()...
    // Trigger critical alert if the throughput drops below 100 points per 10s and checked every 10s.
    data
        |stats(10s)
            .align()
        |derivative('emitted')
            .unit(10s)
            .nonNegative()
        |alert()
            .id('node \'stream0\' in task \'{{ .TaskName }}\'')
            .message('{{ .ID }} is {{ if eq .Level "OK" }}alive{{ else }}dead{{ end }}: {{ index .Fields "emitted" | printf "%0.3f" }} points/10s.')
            .crit(lambda: "emitted" <= 100.0)
    //Do normal processing of data
    data...
```

The `id` and `message` alert properties can be configured globally via the 'deadman' configuration section.

Since the [AlertNode](/kapacitor/v1.1/nodes/alert_node/) is the last piece it can be further modified as usual.
Example:

```javascript
    var data = stream
        |from()...
    // Trigger critical alert if the throughput drops below 100 points per 10s and checked every 10s.
    data
        |deadman(100.0, 10s)
            .slack()
            .channel('#dead_tasks')
    //Do normal processing of data
    data...
```

You can specify additional lambda expressions to further constrain when the deadman's switch is triggered.
Example:

```javascript
    var data = stream
        |from()...
    // Trigger critical alert if the throughput drops below 100 points per 10s and checked every 10s.
    // Only trigger the alert if the time of day is between 8am-5pm.
    data
        |deadman(100.0, 10s, lambda: hour("time") >= 8 AND hour("time") <= 17)
    //Do normal processing of data
    data...
```

```javascript
node|deadman(threshold float64, interval time.Duration, expr ...ast.LambdaNode)
```

Returns: [AlertNode](/kapacitor/v1.1/nodes/alert_node/)

### Default

Create a node that can set defaults for missing tags or fields.

```javascript
node|default()
```

Returns: [DefaultNode](/kapacitor/v1.1/nodes/default_node/)

### Delete

Create a node that can delete tags or fields.

```javascript
node|delete()
```

Returns: [DeleteNode](/kapacitor/v1.1/nodes/delete_node/)

### Derivative

Create a new node that computes the derivative of adjacent points.

```javascript
node|derivative(field string)
```

Returns: [DerivativeNode](/kapacitor/v1.1/nodes/derivative_node/)

### Difference

Compute the difference between points independent of elapsed time.

```javascript
node|difference(field string)
```

Returns: [InfluxQLNode](/kapacitor/v1.1/nodes/influx_q_l_node/)

### Distinct

Produce batch of only the distinct points.

```javascript
node|distinct(field string)
```

Returns: [InfluxQLNode](/kapacitor/v1.1/nodes/influx_q_l_node/)

### Elapsed

Compute the elapsed time between points

```javascript
node|elapsed(field string, unit time.Duration)
```

Returns: [InfluxQLNode](/kapacitor/v1.1/nodes/influx_q_l_node/)

### Eval

Create an eval node that will evaluate the given transformation function to each data point.
A list of expressions may be provided and will be evaluated in the order they are given.
The results are available to later expressions.

```javascript
node|eval(expressions ...ast.LambdaNode)
```

Returns: [EvalNode](/kapacitor/v1.1/nodes/eval_node/)

### First

Select the first point.

```javascript
node|first(field string)
```

Returns: [InfluxQLNode](/kapacitor/v1.1/nodes/influx_q_l_node/)

### Flatten

Flatten points with similar times into a single point.

```javascript
node|flatten()
```

Returns: [FlattenNode](/kapacitor/v1.1/nodes/flatten_node/)

### GroupBy

Group the data by a set of tags.

Can pass literal * to group by all dimensions.
Example:

```javascript
    |groupBy(*)
```

```javascript
node|groupBy(tag ...interface{})
```

Returns: [GroupByNode](/kapacitor/v1.1/nodes/group_by_node/)

### HoltWinters

Compute the holt-winters forecast of a data set.

```javascript
node|holtWinters(field string, h int64, m int64, interval time.Duration)
```

Returns: [InfluxQLNode](/kapacitor/v1.1/nodes/influx_q_l_node/)

### HoltWintersWithFit

Compute the holt-winters forecast of a data set.
This method also outputs all the points used to fit the data in addition to the forecasted data.

```javascript
node|holtWintersWithFit(field string, h int64, m int64, interval time.Duration)
```

Returns: [InfluxQLNode](/kapacitor/v1.1/nodes/influx_q_l_node/)

### HttpOut

Create an HTTP output node that caches the most recent data it has received.
The cached data are available at the given endpoint.
The endpoint is the relative path from the API endpoint of the running task.
For example, if the task endpoint is at `/kapacitor/v1/tasks/<task_id>` and endpoint is
`top10`, then the data can be requested from `/kapacitor/v1/tasks/<task_id>/top10`.

```javascript
node|httpOut(endpoint string)
```

Returns: [HTTPOutNode](/kapacitor/v1.1/nodes/http_out_node/)

### InfluxDBOut

Create an influxdb output node that will store the incoming data into InfluxDB.

```javascript
node|influxDBOut()
```

Returns: [InfluxDBOutNode](/kapacitor/v1.1/nodes/influx_d_b_out_node/)

### Join

Join this node with other nodes. The data are joined on timestamp.

```javascript
node|join(others ...Node)
```

Returns: [JoinNode](/kapacitor/v1.1/nodes/join_node/)

### K8sAutoscale

Create a node that can trigger autoscale events for a kubernetes cluster.

```javascript
node|k8sAutoscale()
```

Returns: [K8sAutoscaleNode](/kapacitor/v1.1/nodes/k8s_autoscale_node/)

### Last

Select the last point.

```javascript
node|last(field string)
```

Returns: [InfluxQLNode](/kapacitor/v1.1/nodes/influx_q_l_node/)

### Log

Create a node that logs all data it receives.

```javascript
node|log()
```

Returns: [LogNode](/kapacitor/v1.1/nodes/log_node/)

### Max

Select the maximum point.

```javascript
node|max(field string)
```

Returns: [InfluxQLNode](/kapacitor/v1.1/nodes/influx_q_l_node/)

### Mean

Compute the mean of the data.

```javascript
node|mean(field string)
```

Returns: [InfluxQLNode](/kapacitor/v1.1/nodes/influx_q_l_node/)

### Median

Compute the median of the data. Note, this method is not a selector,
if you want the median point use `.percentile(field, 50.0)`.

```javascript
node|median(field string)
```

Returns: [InfluxQLNode](/kapacitor/v1.1/nodes/influx_q_l_node/)

### Min

Select the minimum point.

```javascript
node|min(field string)
```

Returns: [InfluxQLNode](/kapacitor/v1.1/nodes/influx_q_l_node/)

### Mode

Compute the mode of the data.

```javascript
node|mode(field string)
```

Returns: [InfluxQLNode](/kapacitor/v1.1/nodes/influx_q_l_node/)

### MovingAverage

Compute a moving average of the last window points.
No points are emitted until the window is full.

```javascript
node|movingAverage(field string, window int64)
```

Returns: [InfluxQLNode](/kapacitor/v1.1/nodes/influx_q_l_node/)

### Percentile

Select a point at the given percentile. This is a selector function, no interpolation between points is performed.

```javascript
node|percentile(field string, percentile float64)
```

Returns: [InfluxQLNode](/kapacitor/v1.1/nodes/influx_q_l_node/)

### Sample

Create a new node that samples the incoming points or batches.

One point will be emitted every count or duration specified.

```javascript
node|sample(rate interface{})
```

Returns: [SampleNode](/kapacitor/v1.1/nodes/sample_node/)

### Shift

Create a new node that shifts the incoming points or batches in time.

```javascript
node|shift(shift time.Duration)
```

Returns: [ShiftNode](/kapacitor/v1.1/nodes/shift_node/)

### Spread

Compute the difference between `min` and `max` points.

```javascript
node|spread(field string)
```

Returns: [InfluxQLNode](/kapacitor/v1.1/nodes/influx_q_l_node/)

### Stats

Create a new stream of data that contains the internal statistics of the node.
The interval represents how often to emit the statistics based on real time.
This means the interval time is independent of the times of the data points the source node is receiving.

```javascript
node|stats(interval time.Duration)
```

Returns: [StatsNode](/kapacitor/v1.1/nodes/stats_node/)

### Stddev

Compute the standard deviation.

```javascript
node|stddev(field string)
```

Returns: [InfluxQLNode](/kapacitor/v1.1/nodes/influx_q_l_node/)

### Sum

Compute the sum of all values.

```javascript
node|sum(field string)
```

Returns: [InfluxQLNode](/kapacitor/v1.1/nodes/influx_q_l_node/)

### Top

Select the top `num` points for `field` and sort by any extra tags or fields.

```javascript
node|top(num int64, field string, fieldsAndTags ...string)
```

Returns: [InfluxQLNode](/kapacitor/v1.1/nodes/influx_q_l_node/)

### Union

Perform the union of this node and all other given nodes.

```javascript
node|union(node ...Node)
```

Returns: [UnionNode](/kapacitor/v1.1/nodes/union_node/)

### Where

Create a new node that filters the data stream by a given expression.

```javascript
node|where(expression ast.LambdaNode)
```

Returns: [WhereNode](/kapacitor/v1.1/nodes/where_node/)

### Window

Create a new node that windows the stream by time.

NOTE: Window can only be applied to stream edges.

```javascript
node|window()
```

Returns: [WindowNode](/kapacitor/v1.1/nodes/window_node/)


text:
package org.apache.cassandra.db.filter;

import java.nio.ByteBuffer;

import org.apache.cassandra.db.Column;
import org.apache.cassandra.db.ColumnFamily;
import org.apache.cassandra.db.DeletionInfo;
import org.apache.cassandra.db.marshal.CompositeType;
import org.apache.cassandra.utils.ByteBufferUtil;

public class ColumnCounter
{
    protected int live;
    protected int ignored;
    protected final long timestamp;

    public ColumnCounter(long timestamp)
    {
        this.timestamp = timestamp;
    }

    public void count(Column column, DeletionInfo.InOrderTester tester)
    {
        if (!isLive(column, tester, timestamp))
            ignored++;
        else
            live++;
    }

    protected static boolean isLive(Column column, DeletionInfo.InOrderTester tester, long timestamp)
    {
        return column.isLive(timestamp) && (!tester.isDeleted(column));
    }

    public int live()
    {
        return live;
    }

    public int ignored()
    {
        return ignored;
    }

    public ColumnCounter countAll(ColumnFamily container)
    {
        if (container == null)
            return this;

        DeletionInfo.InOrderTester tester = container.inOrderDeletionTester();
        for (Column c : container)
            count(c, tester);
        return this;
    }

    public static class GroupByPrefix extends ColumnCounter
    {
        private final CompositeType type;
        private final int toGroup;
        private ByteBuffer[] previous;
        private boolean previousGroupIsStatic;

        /**
         * A column counter that count only 1 for all the columns sharing a
         * given prefix of the key.
         *
         * @param type the type of the column name. This can be null if {@code
         *             toGroup} is 0, otherwise it should be a composite.
         * @param toGroup the number of composite components on which to group
         *                column. If 0, all columns are grouped, otherwise we group
         *                those for which the {@code toGroup} first component are equals.
         */
        public GroupByPrefix(long timestamp, CompositeType type, int toGroup)
        {
            super(timestamp);
            this.type = type;
            this.toGroup = toGroup;

            assert toGroup == 0 || type != null;
        }

        public void count(Column column, DeletionInfo.InOrderTester tester)
        {
            if (!isLive(column, tester, timestamp))
            {
                ignored++;
                return;
            }

            if (toGroup == 0)
            {
                live = 1;
                return;
            }

            ByteBuffer[] current = type.split(column.name());
            assert current.length >= toGroup;

            if (previous == null)
            {
                // Only the first group can be static
                previousGroupIsStatic = type.isStaticName(column.name());
            }
            else
            {
                boolean isSameGroup = previousGroupIsStatic == type.isStaticName(column.name());
                if (isSameGroup)
                {
                    for (int i = 0; i < toGroup; i++)
                    {
                        if (ByteBufferUtil.compareUnsigned(previous[i], current[i]) != 0)
                        {
                            isSameGroup = false;
                            break;
                        }
                    }
                }

                if (isSameGroup)
                    return;

                // We want to count the static group as 1 (CQL) row only if it's the only
                // group in the partition. So, since we have already counted it at this point,
                // just don't count the 2nd group if there is one and the first one was static
                if (previousGroupIsStatic)
                {
                    previous = current;
                    previousGroupIsStatic = false;
                    return;
                }
            }

            live++;
            previous = current;
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
package com.ilivoo.xag.model.core.condition.model;

import com.ilivoo.xag.model.player.model.Player;

public abstract class PlayerCondition extends AbstractCondition<Player> {

	@Override
	public abstract boolean verify(Player player);
}


text:
import csv

# load
######

def load_txt(filename):
  raw_data = []
  with open(filename, 'r') as f:
    for line in f:
      raw_data.append(line)
  return raw_data

def load_csv(filename):
  with open(filename, 'rb') as f:
    table = list(csv.reader(f, skipinitialspace=True, delimiter=',', quotechar='"'))
    header = table[0]
    return header, table[1:]


text:
<?php
/**
 * DO NOT EDIT THIS FILE!
 *
 * This file was automatically generated from external sources.
 *
 * Any manual change here will be lost the next time the SDK
 * is updated. You've been warned!
 */

namespace DTS\eBaySDK\Trading\Types;

/**
 *
 * @property string $AccountID
 * @property \DTS\eBaySDK\Trading\Types\AccountSummaryType $AccountSummary
 * @property \DTS\eBaySDK\Trading\Enums\CurrencyCodeType $Currency
 * @property \DTS\eBaySDK\Trading\Types\AccountEntriesType $AccountEntries
 * @property \DTS\eBaySDK\Trading\Types\PaginationResultType $PaginationResult
 * @property boolean $HasMoreEntries
 * @property integer $EntriesPerPage
 * @property integer $PageNumber
 */
class GetAccountResponseType extends \DTS\eBaySDK\Trading\Types\AbstractResponseType
{
    /**
     * @var array Properties belonging to objects of this class.
     */
    private static $propertyTypes = [
        'AccountID' => [
            'type' => 'string',
            'repeatable' => false,
            'attribute' => false,
            'elementName' => 'AccountID'
        ],
        'AccountSummary' => [
            'type' => 'DTS\eBaySDK\Trading\Types\AccountSummaryType',
            'repeatable' => false,
            'attribute' => false,
            'elementName' => 'AccountSummary'
        ],
        'Currency' => [
            'type' => 'string',
            'repeatable' => false,
            'attribute' => false,
            'elementName' => 'Currency'
        ],
        'AccountEntries' => [
            'type' => 'DTS\eBaySDK\Trading\Types\AccountEntriesType',
            'repeatable' => false,
            'attribute' => false,
            'elementName' => 'AccountEntries'
        ],
        'PaginationResult' => [
            'type' => 'DTS\eBaySDK\Trading\Types\PaginationResultType',
            'repeatable' => false,
            'attribute' => false,
            'elementName' => 'PaginationResult'
        ],
        'HasMoreEntries' => [
            'type' => 'boolean',
            'repeatable' => false,
            'attribute' => false,
            'elementName' => 'HasMoreEntries'
        ],
        'EntriesPerPage' => [
            'type' => 'integer',
            'repeatable' => false,
            'attribute' => false,
            'elementName' => 'EntriesPerPage'
        ],
        'PageNumber' => [
            'type' => 'integer',
            'repeatable' => false,
            'attribute' => false,
            'elementName' => 'PageNumber'
        ]
    ];

    /**
     * @param array $values Optional properties and values to assign to the object.
     */
    public function __construct(array $values = [])
    {
        list($parentValues, $childValues) = self::getParentValues(self::$propertyTypes, $values);

        parent::__construct($parentValues);

        if (!array_key_exists(__CLASS__, self::$properties)) {
            self::$properties[__CLASS__] = array_merge(self::$properties[get_parent_class()], self::$propertyTypes);
        }

        if (!array_key_exists(__CLASS__, self::$xmlNamespaces)) {
            self::$xmlNamespaces[__CLASS__] = 'xmlns="urn:ebay:apis:eBLBaseComponents"';
        }

        $this->setValues(__CLASS__, $childValues);
    }
}


text:
package org.drools.core.world.impl;

import java.util.HashMap;
import java.util.Map;

import org.drools.core.command.GetDefaultValue;
import org.drools.core.command.impl.ContextImpl;
import org.kie.api.command.Command;
import org.kie.api.command.ExecutableCommand;
import org.kie.api.runtime.CommandExecutor;
import org.kie.api.runtime.Context;
import org.kie.internal.command.ContextManager;

public class ContextManagerImpl
        implements ContextManager, GetDefaultValue, CommandExecutor {

    private Context root;
    private Map<String, Context> contexts;

    public static String ROOT = "ROOT";

    private CommandExecutionHandler executionHandler = new DefaultCommandExecutionHandler();

    private Object lastReturnValue;

    public ContextManagerImpl() {
        this( new HashMap<String, Context>() );
    }

    public ContextManagerImpl( Map<String, Context> contexts ) {
        this.root = new ContextImpl( ROOT,
                                     this );

        this.root.set( "world",
                       this );

        this.contexts = contexts;
        this.contexts.put( ROOT,
                           this.root );
    }

    public <T> T execute( Command<T> command ) {
        return null;
    }

    public void setCommandExecutionHandler( CommandExecutionHandler executionHandler ) {
        this.executionHandler = executionHandler;
    }

    public Context createContext( String identifier ) {
        Context ctx = this.contexts.get( identifier );
        if ( ctx == null ) {
            ctx = new ContextImpl( identifier, this, root );
            this.contexts.put( identifier, ctx );
        }

        return ctx;
    }

    public Context getContext( String identifier ) {
        return this.contexts.get( identifier );
    }

    public Context getRootContext() {
        return this.root;
    }

    public Object getLastReturnValue() {
        return this.lastReturnValue;
    }

    public static interface CommandExecutionHandler {
        public Object execute( ExecutableCommand command,
                               Context context );
    }

    public static class DefaultCommandExecutionHandler
            implements
            CommandExecutionHandler {
        public Object execute( ExecutableCommand command,
                               Context context ) {
            return command.execute( context );
        }
    }

    public Object getObject() {
        return lastReturnValue;
    }

    public ContextManager getContextManager() {
        return this;
    }

    public String getName() {
        return root.getName();
    }

    public Object get( String identifier ) {
        return root.get( identifier );
    }

    public void set( String identifier, Object value ) {
        root.set( identifier, value );
    }

    public void remove( String identifier ) {
        root.remove( identifier );
    }
}


text:
; Unshipped analyzer release
; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md

### New Rules
Rule ID | Category | Severity | Notes
--------|----------|----------|-------
EPC11 | CodeSmell | Warning | SuspiciousEqualsMethodAnalyzer
EPC12 | CodeSmell | Warning | SuspiciousExceptionHandlingAnalyzer
EPC13 | CodeSmell | Warning | UnobservedResultAnalyzer
EPC14 | CodeSmell | Info | RemoveConfigureAwaitAnalyzer
EPC15 | CodeSmell | Warning | AddConfigureAwaitAnalyzer
EPC16 | CodeSmell | Warning | NullConditionalOperatorAnalyzer
EPC17 | CodeSmell | Warning | AsyncVoidLambdaAnalyzer
EPC18 | CodeSmell | Warning | TaskInstanceToStringConversionAnalyzer
EPC19 | CodeSmell | Warning | CancellationTokenRegistrationAnalyzer
ERP021 | CodeSmell | Warning | ThrowExAnalyzer
ERP022 | CodeSmell | Warning | SwallowAllExceptionsAnalyzer
ERP031 | Concurrency | Warning | ConcurrentCollectionAnalyzer


text:
package services_test

import (
	. "github.com/cloudfoundry/cf-acceptance-tests/cats_suite_helpers"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	. "github.com/onsi/gomega/gbytes"
	. "github.com/onsi/gomega/gexec"

	"github.com/cloudfoundry-incubator/cf-test-helpers/cf"
	"github.com/cloudfoundry-incubator/cf-test-helpers/workflowhelpers"
	"github.com/cloudfoundry/cf-acceptance-tests/helpers/app_helpers"
	"github.com/cloudfoundry/cf-acceptance-tests/helpers/assets"
	"github.com/cloudfoundry/cf-acceptance-tests/helpers/random_name"
	. "github.com/cloudfoundry/cf-acceptance-tests/helpers/services"
)

var _ = ServicesDescribe("Purging service instances", func() {
	var broker ServiceBroker
	var appName, instanceName string

	AfterEach(func() {
		app_helpers.AppReport(broker.Name, Config.DefaultTimeoutDuration())
		broker.Destroy()
	})

	Context("for public brokers", func() {
		BeforeEach(func() {
			broker = NewServiceBroker(
				random_name.CATSRandomName("BRKR"),
				assets.NewAssets().ServiceBroker,
				TestSetup,
			)
			broker.Push(Config)
			broker.Configure()
			workflowhelpers.AsUser(TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), func() {
				broker.Create()
				broker.PublicizePlans()
			})
			appName = random_name.CATSRandomName("APP")
			instanceName = random_name.CATSRandomName("SVIN")
		})

		AfterEach(func() {
			app_helpers.AppReport(appName, Config.DefaultTimeoutDuration())
			Expect(cf.Cf("delete", appName, "-f", "-r").Wait(Config.DefaultTimeoutDuration())).To(Exit(0))
			Expect(cf.Cf("delete-service", instanceName, "-f").Wait(Config.DefaultTimeoutDuration())).To(Exit(0))
		})

		It("removes the service instance", func() {
			By("Having a bound service instance")
			createApp := cf.Cf("push", appName, "--no-start", "-b", Config.GetRubyBuildpackName(), "-m", DEFAULT_MEMORY_LIMIT, "-p", assets.NewAssets().Dora, "-d", Config.GetAppsDomain()).Wait(Config.DefaultTimeoutDuration())
			Expect(createApp).To(Exit(0), "failed creating app")
			app_helpers.SetBackend(appName)
			Expect(cf.Cf("start", appName).Wait(Config.CfPushTimeoutDuration())).To(Exit(0))

			broker.CreateServiceInstance(instanceName)

			services := cf.Cf("services").Wait(Config.DefaultTimeoutDuration())
			Expect(services).To(Exit(0))
			Expect(services).To(Say(instanceName))

			bindService := cf.Cf("bind-service", appName, instanceName).Wait(Config.DefaultTimeoutDuration())
			Expect(bindService).To(Exit(0), "failed binding app to service")

			By("Making the broker unavailable")
			Expect(cf.Cf("delete", broker.Name, "-f", "-r").Wait(Config.DefaultTimeoutDuration())).To(Exit(0))

			By("Purging the service instance")
			workflowhelpers.AsUser(TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), func() {
				TestSetup.RegularUserContext().TargetSpace()
				Expect(cf.Cf("purge-service-instance", instanceName, "-f").Wait(Config.DefaultTimeoutDuration())).To(Exit(0))
			})

			By("Ensuring the service instance is gone")
			services = cf.Cf("services").Wait(Config.DefaultTimeoutDuration())
			Expect(services).To(Exit(0))
			Expect(services).NotTo(Say(instanceName))
			Expect(services).NotTo(Say(appName))
		})
	})

	Context("for space scoped brokers", func() {
		BeforeEach(func() {
			broker = NewServiceBroker(
				random_name.CATSRandomName("BRKR"),
				assets.NewAssets().ServiceBroker,
				TestSetup,
			)
			TestSetup.RegularUserContext().TargetSpace()
			broker.Push(Config)
			broker.Configure()
			broker.CreateSpaceScoped()
			appName = random_name.CATSRandomName("APP")
			instanceName = random_name.CATSRandomName("SVIN")
		})

		AfterEach(func() {
			app_helpers.AppReport(appName, Config.DefaultTimeoutDuration())
			Expect(cf.Cf("delete", appName, "-f", "-r").Wait(Config.DefaultTimeoutDuration())).To(Exit(0))
			Expect(cf.Cf("delete-service", instanceName, "-f").Wait(Config.DefaultTimeoutDuration())).To(Exit(0))
		})

		It("removes the service instance", func() {
			workflowhelpers.AsUser(TestSetup.RegularUserContext(), TestSetup.ShortTimeout(), func() {
				By("Having a bound service instance")
				createApp := cf.Cf("push", appName, "--no-start", "-b", Config.GetRubyBuildpackName(), "-m", DEFAULT_MEMORY_LIMIT, "-p", assets.NewAssets().Dora, "-d", Config.GetAppsDomain()).Wait(Config.DefaultTimeoutDuration())
				Expect(createApp).To(Exit(0), "failed creating app")
				app_helpers.SetBackend(appName)
				Expect(cf.Cf("start", appName).Wait(Config.CfPushTimeoutDuration())).To(Exit(0))

				broker.CreateServiceInstance(instanceName)

				services := cf.Cf("services").Wait(Config.DefaultTimeoutDuration())
				Expect(services).To(Exit(0))
				Expect(services).To(Say(instanceName))

				bindService := cf.Cf("bind-service", appName, instanceName).Wait(Config.DefaultTimeoutDuration())
				Expect(bindService).To(Exit(0), "failed binding app to service")

				By("Making the broker unavailable")
				Expect(cf.Cf("delete", broker.Name, "-f", "-r").Wait(Config.DefaultTimeoutDuration())).To(Exit(0))

				By("Purging the service instance")
				Expect(cf.Cf("purge-service-instance", instanceName, "-f").Wait(Config.DefaultTimeoutDuration())).To(Exit(0))

				By("Ensuring the service instance is gone")
				services = cf.Cf("services").Wait(Config.DefaultTimeoutDuration())
				Expect(services).To(Exit(0))
				Expect(services).NotTo(Say(instanceName))
				Expect(services).NotTo(Say(appName))
			})
		})
	})
})


text:
@interface PodsDummy_Pods_QuickLayoutTvOSDemo : NSObject
@end
@implementation PodsDummy_Pods_QuickLayoutTvOSDemo
@end


text:
package com.edmunds.etm.common.api;

import com.google.common.collect.Lists;
import java.util.Collections;
import java.util.List;
import org.testng.annotations.Test;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;

/**
 * @author Ryan Holmes
 */
@Test
public class FixedUrlTokenTest {

    public void testConstructOk() {
        UrlToken token = new FixedUrlToken("test", "v1", "v2", "v3");
        assertNotNull(token);

        token = new FixedUrlToken("test", Collections.singletonList("v1"));
        assertNotNull(token);

        token = new FixedUrlToken("test");
        assertNotNull(token);
    }

    @Test(expectedExceptions = {IllegalArgumentException.class})
    public void testConstructFailNullName() {
        UrlToken token = new FixedUrlToken(null, "v1");
    }

    @Test(expectedExceptions = {IllegalArgumentException.class})
    public void testConstructFailEmptyName() {
        UrlToken token = new FixedUrlToken("", "v1");
    }

    public void testToRegex() {
        UrlToken token = new FixedUrlToken("test", "v1", "v2", "v3");
        assertEquals(token.toRegex(), "(v1|v2|v3)");

        List<String> values = Lists.newArrayList("v1", "v2", "v3");
        token = new FixedUrlToken("test", values);
        assertEquals(token.toRegex(), "(v1|v2|v3)");

    }

    public void testToRegexEscaping() {
        UrlToken token = new FixedUrlToken("test", "^[a-z]\\d{9}$");
        assertEquals(token.toRegex(), "(\\^\\[a-z\\]\\d\\{9\\}\\$)");
    }
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<billStatus>
  <bill>
    <subjects>
      <billSubjects>
        <legislativeSubjects />
        <policyArea>
          <name>Education</name>
        </policyArea>
      </billSubjects>
    </subjects>
    <relatedBills>
      <item>
        <latestAction>
          <actionDate>2017-05-17</actionDate>
          <text>Referred to House Budget</text>
        </latestAction>
        <type>HR</type>
        <latestTitle>Bank on Students Emergency Loan Refinancing Act</latestTitle>
        <relationshipDetails>
          <item>
            <type>Related document</type>
            <identifiedBy>Senate</identifiedBy>
          </item>
        </relationshipDetails>
        <number>2477</number>
        <congress>115</congress>
      </item>
      <item>
        <latestAction>
          <actionDate>2017-04-26</actionDate>
          <text>Referred to the House Committee on Ways and Means.</text>
        </latestAction>
        <type>HR</type>
        <latestTitle>Paying a Fair Share Act of 2017</latestTitle>
        <relationshipDetails>
          <item>
            <type>Related bill</type>
            <identifiedBy>CRS</identifiedBy>
          </item>
        </relationshipDetails>
        <number>2159</number>
        <congress>115</congress>
      </item>
      <item>
        <latestAction>
          <actionDate>2017-04-27</actionDate>
          <text>Read twice and referred to the Committee on Finance.</text>
        </latestAction>
        <type>S</type>
        <latestTitle>Paying a Fair Share Act of 2017</latestTitle>
        <relationshipDetails>
          <item>
            <type>Related bill</type>
            <identifiedBy>CRS</identifiedBy>
          </item>
        </relationshipDetails>
        <number>955</number>
        <congress>115</congress>
      </item>
      <item>
        <latestAction>
          <actionDate>2017-07-10</actionDate>
          <text>Read twice and referred to the Committee on Health, Education, Labor, and Pensions. (Sponsor introductory remarks on measure: CR S3886-3887)</text>
        </latestAction>
        <type>S</type>
        <latestTitle>Student Loan Relief Act of 2017</latestTitle>
        <relationshipDetails>
          <item>
            <type>Related bill</type>
            <identifiedBy>CRS</identifiedBy>
          </item>
        </relationshipDetails>
        <number>1521</number>
        <congress>115</congress>
      </item>
      <item>
        <latestAction>
          <actionDate>2017-07-25</actionDate>
          <text>Referred to the House Committee on Education and the Workforce.</text>
        </latestAction>
        <type>HR</type>
        <latestTitle>Student Loan Relief Act of 2017</latestTitle>
        <relationshipDetails>
          <item>
            <type>Related bill</type>
            <identifiedBy>CRS</identifiedBy>
          </item>
        </relationshipDetails>
        <number>3390</number>
        <congress>115</congress>
      </item>
    </relatedBills>
    <notes />
    <titles>
      <item>
        <chamberName />
        <title>Bank on Students Emergency Loan Refinancing Act</title>
        <titleType>(Extracted from GPO) Short Titles as Introduced</titleType>
        <parentTitleType />
        <chamberCode />
      </item>
      <item>
        <chamberName />
        <title>Bank on Students Emergency Loan Refinancing Act</title>
        <titleType>Short Titles as Introduced</titleType>
        <parentTitleType />
        <chamberCode />
      </item>
      <item>
        <chamberName />
        <title>A bill to amend the Higher Education Act of 1965 to provide for the refinancing of certain Federal student loans, and for other purposes.</title>
        <titleType>Official Title as Introduced</titleType>
        <parentTitleType />
        <chamberCode />
      </item>
      <item>
        <chamberName />
        <title>Bank on Students Emergency Loan Refinancing Act</title>
        <titleType>Display Title</titleType>
        <parentTitleType />
        <chamberCode />
      </item>
    </titles>
    <laws />
    <introducedDate>2017-05-17</introducedDate>
    <cboCostEstimates />
    <title>Bank on Students Emergency Loan Refinancing Act</title>
    <recordedVotes />
    <billType>S</billType>
    <summaries>
      <billSummaries />
    </summaries>
    <actions>
      <actionTypeCounts>
        <referredToCommittee>1</referredToCommittee>
        <introducedInSenate>1</introducedInSenate>
      </actionTypeCounts>
      <actionByCounts>
        <senate>2</senate>
      </actionByCounts>
      <item>
        <actionDate>2017-05-17</actionDate>
        <committee>
          <systemCode>ssfi00</systemCode>
          <name>Finance Committee</name>
        </committee>
        <links>
          <link>
            <url>https://www.congress.gov/congressional-record/volume-163/senate-section/page/S3015</url>
            <name>S3015</name>
          </link>
        </links>
        <sourceSystem>
          <name>Senate</name>
          0
        </sourceSystem>
        <text>Read twice and referred to the Committee on Finance. (Sponsor introductory remarks on measure: CR S3015)</text>
        <type>IntroReferral</type>
      </item>
      <item>
        <actionDate>2017-05-17</actionDate>
        <text>Introduced in Senate</text>
        <sourceSystem>
          <name>Library of Congress</name>
          9
        </sourceSystem>
        <actionCode>10000</actionCode>
        <committee />
        <links />
        <type>IntroReferral</type>
      </item>
    </actions>
    <version>1.0.0</version>
    <billNumber>1162</billNumber>
    <createDate>2017-05-18T00:26:39Z</createDate>
    <cosponsors>
      <item>
        <state>NY</state>
        <middleName>E.</middleName>
        <identifiers>
          <gpoId>8279</gpoId>
          <lisID>1036</lisID>
          <bioguideId>S000148</bioguideId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>CHARLES</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Schumer, Charles E. [D-NY]</fullName>
        <lastName>SCHUMER</lastName>
        <party>D</party>
        <bioguideId>S000148</bioguideId>
      </item>
      <item>
        <state>WA</state>
        <middleName />
        <identifiers>
          <bioguideId>M001111</bioguideId>
          <lisID>1409</lisID>
          <gpoId>8237</gpoId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>PATTY</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Murray, Patty [D-WA]</fullName>
        <lastName>MURRAY</lastName>
        <party>D</party>
        <bioguideId>M001111</bioguideId>
      </item>
      <item>
        <state>WI</state>
        <middleName />
        <identifiers>
          <lisID>1558</lisID>
          <gpoId>8215</gpoId>
          <bioguideId>B001230</bioguideId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>TAMMY</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Baldwin, Tammy [D-WI]</fullName>
        <lastName>BALDWIN</lastName>
        <party>D</party>
        <bioguideId>B001230</bioguideId>
      </item>
      <item>
        <state>CO</state>
        <middleName>F.</middleName>
        <identifiers>
          <bioguideId>B001267</bioguideId>
          <gpoId>8302</gpoId>
          <lisID>1965</lisID>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>Michael</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Bennet, Michael F. [D-CO]</fullName>
        <lastName>Bennet</lastName>
        <party>D</party>
        <bioguideId>B001267</bioguideId>
      </item>
      <item>
        <state>CT</state>
        <middleName />
        <identifiers>
          <gpoId>8332</gpoId>
          <bioguideId>B001277</bioguideId>
          <lisID>2076</lisID>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>Richard</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Blumenthal, Richard [D-CT]</fullName>
        <lastName>Blumenthal</lastName>
        <party>D</party>
        <bioguideId>B001277</bioguideId>
      </item>
      <item>
        <state>NJ</state>
        <middleName>A.</middleName>
        <identifiers>
          <bioguideId>B001288</bioguideId>
          <lisID>2194</lisID>
          <gpoId />
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>Cory</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Booker, Cory A. [D-NJ]</fullName>
        <lastName>Booker</lastName>
        <party>D</party>
        <bioguideId>B001288</bioguideId>
      </item>
      <item>
        <state>OH</state>
        <middleName />
        <identifiers>
          <lisID>136</lisID>
          <bioguideId>B000944</bioguideId>
          <gpoId>8309</gpoId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>SHERROD</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Brown, Sherrod [D-OH]</fullName>
        <lastName>BROWN</lastName>
        <party>D</party>
        <bioguideId>B000944</bioguideId>
      </item>
      <item>
        <state>MD</state>
        <middleName>L.</middleName>
        <identifiers>
          <bioguideId>C000141</bioguideId>
          <lisID>174</lisID>
          <gpoId>8287</gpoId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>BENJAMIN</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Cardin, Benjamin L. [D-MD]</fullName>
        <lastName>CARDIN</lastName>
        <party>D</party>
        <bioguideId>C000141</bioguideId>
      </item>
      <item>
        <state>PA</state>
        <middleName />
        <identifiers>
          <bioguideId>C001070</bioguideId>
          <lisID>1828</lisID>
          <gpoId>8282</gpoId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>Bob</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Casey, Robert P., Jr. [D-PA]</fullName>
        <lastName>Casey</lastName>
        <party>D</party>
        <bioguideId>C001070</bioguideId>
      </item>
      <item>
        <state>IL</state>
        <middleName />
        <identifiers>
          <lisID>2123</lisID>
          <gpoId />
          <bioguideId>D000622</bioguideId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>Tammy</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Duckworth, Tammy [D-IL]</fullName>
        <lastName>Duckworth</lastName>
        <party>D</party>
        <bioguideId>D000622</bioguideId>
      </item>
      <item>
        <state>IL</state>
        <middleName>J.</middleName>
        <identifiers>
          <lisID>326</lisID>
          <gpoId>8326</gpoId>
          <bioguideId>D000563</bioguideId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>RICHARD</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Durbin, Richard J. [D-IL]</fullName>
        <lastName>DURBIN</lastName>
        <party>D</party>
        <bioguideId>D000563</bioguideId>
      </item>
      <item>
        <state>MN</state>
        <middleName />
        <identifiers>
          <lisID>1969</lisID>
          <bioguideId>F000457</bioguideId>
          <gpoId>8339</gpoId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>Al</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Franken, Al [D-MN]</fullName>
        <lastName>Franken</lastName>
        <party>D</party>
        <bioguideId>F000457</bioguideId>
      </item>
      <item>
        <state>NY</state>
        <middleName>E.</middleName>
        <identifiers>
          <bioguideId>G000555</bioguideId>
          <lisID>1866</lisID>
          <gpoId>8336</gpoId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>Kirsten</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Gillibrand, Kirsten E. [D-NY]</fullName>
        <lastName>Gillibrand</lastName>
        <party>D</party>
        <bioguideId>G000555</bioguideId>
      </item>
      <item>
        <state>CA</state>
        <middleName>D.</middleName>
        <identifiers>
          <lisID>2301</lisID>
          <bioguideId>H001075</bioguideId>
          <gpoId />
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>Kamala</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Harris, Kamala D. [D-CA]</fullName>
        <lastName>Harris</lastName>
        <party>D</party>
        <bioguideId>H001075</bioguideId>
      </item>
      <item>
        <state>NH</state>
        <middleName>Wood</middleName>
        <identifiers>
          <gpoId />
          <bioguideId>H001076</bioguideId>
          <lisID>2302</lisID>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>Margaret</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Hassan, Margaret Wood [D-NH]</fullName>
        <lastName>Hassan</lastName>
        <party>D</party>
        <bioguideId>H001076</bioguideId>
      </item>
      <item>
        <state>NM</state>
        <middleName />
        <identifiers>
          <lisID>1937</lisID>
          <bioguideId>H001046</bioguideId>
          <gpoId>8056</gpoId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>Martin</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Heinrich, Martin [D-NM]</fullName>
        <lastName>Heinrich</lastName>
        <party>D</party>
        <bioguideId>H001046</bioguideId>
      </item>
      <item>
        <state>ND</state>
        <middleName />
        <identifiers>
          <bioguideId>H001069</bioguideId>
          <gpoId />
          <lisID>2174</lisID>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>Heidi</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Heitkamp, Heidi [D-ND]</fullName>
        <lastName>Heitkamp</lastName>
        <party>D</party>
        <bioguideId>H001069</bioguideId>
      </item>
      <item>
        <state>HI</state>
        <middleName>K.</middleName>
        <identifiers>
          <bioguideId>H001042</bioguideId>
          <lisID>1844</lisID>
          <gpoId>7913</gpoId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>Mazie</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Hirono, Mazie K. [D-HI]</fullName>
        <lastName>Hirono</lastName>
        <party>D</party>
        <bioguideId>H001042</bioguideId>
      </item>
      <item>
        <state>MN</state>
        <middleName />
        <identifiers>
          <lisID>1826</lisID>
          <gpoId>8249</gpoId>
          <bioguideId>K000367</bioguideId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>Amy</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Klobuchar, Amy [D-MN]</fullName>
        <lastName>Klobuchar</lastName>
        <party>D</party>
        <bioguideId>K000367</bioguideId>
      </item>
      <item>
        <state>VT</state>
        <middleName>JOSEPH</middleName>
        <identifiers>
          <gpoId>8244</gpoId>
          <lisID>1383</lisID>
          <bioguideId>L000174</bioguideId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>PATRICK</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Leahy, Patrick J. [D-VT]</fullName>
        <lastName>LEAHY</lastName>
        <party>D</party>
        <bioguideId>L000174</bioguideId>
      </item>
      <item>
        <state>WV</state>
        <middleName />
        <identifiers>
          <gpoId>8256</gpoId>
          <lisID>1983</lisID>
          <bioguideId>M001183</bioguideId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>Joe</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Manchin, Joe, III [D-WV]</fullName>
        <lastName>Manchin</lastName>
        <party>D</party>
        <bioguideId>M001183</bioguideId>
      </item>
      <item>
        <state>MA</state>
        <middleName>J.</middleName>
        <identifiers>
          <bioguideId>M000133</bioguideId>
          <gpoId>7972</gpoId>
          <lisID>735</lisID>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>EDWARD</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Markey, Edward J. [D-MA]</fullName>
        <lastName>MARKEY</lastName>
        <party>D</party>
        <bioguideId>M000133</bioguideId>
      </item>
      <item>
        <state>NJ</state>
        <middleName />
        <identifiers>
          <lisID>791</lisID>
          <gpoId>8239</gpoId>
          <bioguideId>M000639</bioguideId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>ROBERT</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Menendez, Robert [D-NJ]</fullName>
        <lastName>MENENDEZ</lastName>
        <party>D</party>
        <bioguideId>M000639</bioguideId>
      </item>
      <item>
        <state>OR</state>
        <middleName />
        <identifiers>
          <bioguideId>M001176</bioguideId>
          <lisID>1900</lisID>
          <gpoId>8238</gpoId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>Jeff</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Merkley, Jeff [D-OR]</fullName>
        <lastName>Merkley</lastName>
        <party>D</party>
        <bioguideId>M001176</bioguideId>
      </item>
      <item>
        <state>CT</state>
        <middleName />
        <identifiers>
          <lisID>1837</lisID>
          <bioguideId>M001169</bioguideId>
          <gpoId>7870</gpoId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>Christopher</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Murphy, Christopher [D-CT]</fullName>
        <lastName>Murphy</lastName>
        <party>D</party>
        <bioguideId>M001169</bioguideId>
      </item>
      <item>
        <state>MI</state>
        <middleName>C.</middleName>
        <identifiers>
          <lisID>1929</lisID>
          <bioguideId>P000595</bioguideId>
          <gpoId>7994</gpoId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>Gary</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Peters, Gary C. [D-MI]</fullName>
        <lastName>Peters</lastName>
        <party>D</party>
        <bioguideId>P000595</bioguideId>
      </item>
      <item>
        <state>RI</state>
        <middleName>F.</middleName>
        <identifiers>
          <lisID>949</lisID>
          <gpoId>8272</gpoId>
          <bioguideId>R000122</bioguideId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>JOHN</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Reed, Jack [D-RI]</fullName>
        <lastName>REED</lastName>
        <party>D</party>
        <bioguideId>R000122</bioguideId>
      </item>
      <item>
        <state>VT</state>
        <middleName />
        <identifiers>
          <lisID>1010</lisID>
          <gpoId>8270</gpoId>
          <bioguideId>S000033</bioguideId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>BERNARD</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Sanders, Bernard [I-VT]</fullName>
        <lastName>SANDERS</lastName>
        <party>I</party>
        <bioguideId>S000033</bioguideId>
      </item>
      <item>
        <state>NH</state>
        <middleName />
        <identifiers>
          <gpoId>8276</gpoId>
          <lisID>1901</lisID>
          <bioguideId>S001181</bioguideId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>Jeanne</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Shaheen, Jeanne [D-NH]</fullName>
        <lastName>Shaheen</lastName>
        <party>D</party>
        <bioguideId>S001181</bioguideId>
      </item>
      <item>
        <state>MI</state>
        <middleName>ANN</middleName>
        <identifiers>
          <bioguideId>S000770</bioguideId>
          <lisID>1531</lisID>
          <gpoId>8261</gpoId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>DEBORAH</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Stabenow, Debbie [D-MI]</fullName>
        <lastName>STABENOW</lastName>
        <party>D</party>
        <bioguideId>S000770</bioguideId>
      </item>
      <item>
        <state>NM</state>
        <middleName />
        <identifiers>
          <bioguideId>U000039</bioguideId>
          <gpoId>8260</gpoId>
          <lisID>1567</lisID>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>TOM</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Udall, Tom [D-NM]</fullName>
        <lastName>UDALL</lastName>
        <party>D</party>
        <bioguideId>U000039</bioguideId>
      </item>
      <item>
        <state>MD</state>
        <middleName />
        <identifiers>
          <bioguideId>V000128</bioguideId>
          <lisID>1729</lisID>
          <gpoId>7983</gpoId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>Chris</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Van Hollen, Chris [D-MD]</fullName>
        <lastName>Van Hollen</lastName>
        <party>D</party>
        <bioguideId>V000128</bioguideId>
      </item>
      <item>
        <state>RI</state>
        <middleName />
        <identifiers>
          <lisID>1823</lisID>
          <bioguideId>W000802</bioguideId>
          <gpoId>8264</gpoId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>Sheldon</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Whitehouse, Sheldon [D-RI]</fullName>
        <lastName>Whitehouse</lastName>
        <party>D</party>
        <bioguideId>W000802</bioguideId>
      </item>
      <item>
        <state>OR</state>
        <middleName />
        <identifiers>
          <bioguideId>W000779</bioguideId>
          <lisID>1247</lisID>
          <gpoId>8265</gpoId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>RON</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Wyden, Ron [D-OR]</fullName>
        <lastName>WYDEN</lastName>
        <party>D</party>
        <bioguideId>W000779</bioguideId>
      </item>
      <item>
        <state>NV</state>
        <middleName />
        <identifiers>
          <lisID>2299</lisID>
          <gpoId />
          <bioguideId>C001113</bioguideId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>Catherine</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. Cortez Masto, Catherine  [D-NV]</fullName>
        <lastName>Cortez Masto</lastName>
        <party>D</party>
        <bioguideId>C001113</bioguideId>
      </item>
      <item>
        <state>MO</state>
        <middleName />
        <identifiers>
          <gpoId>8252</gpoId>
          <lisID>1820</lisID>
          <bioguideId>M001170</bioguideId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-05-17</sponsorshipDate>
        <firstName>Claire</firstName>
        <isOriginalCosponsor>True</isOriginalCosponsor>
        <fullName>Sen. McCaskill, Claire [D-MO]</fullName>
        <lastName>McCaskill</lastName>
        <party>D</party>
        <bioguideId>M001170</bioguideId>
      </item>
      <item>
        <state>WA</state>
        <middleName />
        <identifiers>
          <gpoId>8288</gpoId>
          <bioguideId>C000127</bioguideId>
          <lisID>172</lisID>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-06-29</sponsorshipDate>
        <firstName>MARIA</firstName>
        <isOriginalCosponsor>False</isOriginalCosponsor>
        <fullName>Sen. Cantwell, Maria [D-WA]</fullName>
        <lastName>CANTWELL</lastName>
        <party>D</party>
        <bioguideId>C000127</bioguideId>
      </item>
      <item>
        <state>CA</state>
        <middleName />
        <identifiers>
          <lisID>1332</lisID>
          <bioguideId>F000062</bioguideId>
          <gpoId>8338</gpoId>
        </identifiers>
        <sponsorshipWithdrawnDate />
        <sponsorshipDate>2017-10-02</sponsorshipDate>
        <firstName>DIANNE</firstName>
        <isOriginalCosponsor>False</isOriginalCosponsor>
        <fullName>Sen. Feinstein, Dianne [D-CA]</fullName>
        <lastName>FEINSTEIN</lastName>
        <party>D</party>
        <bioguideId>F000062</bioguideId>
      </item>
    </cosponsors>
    <sponsors>
      <item>
        <state>MA</state>
        <party>D</party>
        <middleName>A.</middleName>
        <bioguideId>W000817</bioguideId>
        <fullName>Sen. Warren, Elizabeth [D-MA]</fullName>
        <identifiers>
          <bioguideId>W000817</bioguideId>
          <lisID>2182</lisID>
          <gpoId />
        </identifiers>
        <firstName>Elizabeth</firstName>
        <byRequestType />
        <lastName>Warren</lastName>
      </item>
    </sponsors>
    <committeeReports />
    <committees>
      <billCommittees>
        <item>
          <type>Standing</type>
          <chamber>Senate</chamber>
          <systemCode>ssfi00</systemCode>
          <name>Finance Committee</name>
          <subcommittees />
          <activities>
            <item>
              <name>Referred to</name>
              <date>2017-05-17T19:28:35Z</date>
            </item>
          </activities>
        </item>
      </billCommittees>
    </committees>
    <updateDate>2017-10-03T05:19:02Z</updateDate>
    <congress>115</congress>
    <policyArea>
      <name>Education</name>
    </policyArea>
    <originChamber>Senate</originChamber>
    <calendarNumbers />
    <latestAction>
      <text>Read twice and referred to the Committee on Finance. (Sponsor introductory remarks on measure: CR S3015)</text>
      <actionDate>2017-05-17</actionDate>
      <links />
    </latestAction>
    <amendments />
  </bill>
  <dublinCore xmlns:dc="http://purl.org/dc/elements/1.1/">
    <dc:format>text/xml</dc:format>
    <dc:language>EN</dc:language>
    <dc:rights>Pursuant to Title 17 Section 105 of the United States Code, this file is not subject to copyright protection and is in the public domain.</dc:rights>
    <dc:contributor>Congressional Research Service, Library of Congress</dc:contributor>
    <dc:description>This file contains bill summaries and statuses for federal legislation. A bill summary describes the most significant provisions of a piece of legislation and details the effects the legislative text may have on current law and federal programs. Bill summaries are authored by the Congressional Research Service (CRS) of the Library of Congress. As stated in Public Law 91-510 (2 USC 166 (d)(6)), one of the duties of CRS is "to prepare summaries and digests of bills and resolutions of a public general nature introduced in the Senate or House of Representatives". For more information, refer to the User Guide that accompanies this file.</dc:description>
  </dublinCore>
</billStatus>


text:
package com.hazelcast.spi.impl.operationservice.impl;

import com.hazelcast.internal.serialization.InternalSerializationService;
import com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder;
import com.hazelcast.internal.serialization.impl.HeapData;
import com.hazelcast.logging.ILogger;
import com.hazelcast.logging.Logger;
import com.hazelcast.cluster.Address;
import com.hazelcast.internal.nio.Connection;
import com.hazelcast.internal.nio.EndpointManager;
import com.hazelcast.internal.nio.Packet;
import com.hazelcast.nio.serialization.Portable;
import com.hazelcast.nio.serialization.PortableReader;
import com.hazelcast.nio.serialization.PortableWriter;
import com.hazelcast.spi.impl.operationservice.Operation;
import com.hazelcast.spi.impl.operationservice.impl.responses.BackupAckResponse;
import com.hazelcast.spi.impl.operationservice.impl.responses.CallTimeoutResponse;
import com.hazelcast.spi.impl.operationservice.impl.responses.ErrorResponse;
import com.hazelcast.spi.impl.operationservice.impl.responses.NormalResponse;
import com.hazelcast.test.HazelcastParallelParametersRunnerFactory;
import com.hazelcast.test.annotation.ParallelJVMTest;
import com.hazelcast.test.annotation.QuickTest;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
import org.junit.runners.Parameterized.UseParametersRunnerFactory;
import org.mockito.ArgumentCaptor;

import java.io.IOException;
import java.nio.ByteOrder;

import static com.hazelcast.spi.impl.operationservice.OperationAccessor.setCallId;
import static com.hazelcast.spi.impl.operationservice.OperationAccessor.setCallerAddress;
import static com.hazelcast.spi.impl.operationservice.OperationAccessor.setConnection;
import static java.nio.ByteOrder.BIG_ENDIAN;
import static java.nio.ByteOrder.LITTLE_ENDIAN;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@RunWith(Parameterized.class)
@UseParametersRunnerFactory(HazelcastParallelParametersRunnerFactory.class)
@Category({QuickTest.class, ParallelJVMTest.class})
public class OutboundResponseHandlerTest {

    @Parameter
    public ByteOrder byteOrder;

    private OutboundResponseHandler handler;
    private InternalSerializationService serializationService;
    private ILogger logger = Logger.getLogger(OutboundResponseHandlerTest.class);
    private Address thatAddress;
    private EndpointManager endpointManager;
    private Connection connection;

    @Parameters(name = "{0}")
    public static Object[][] parameters() {
        return new Object[][]{
                {BIG_ENDIAN},
                {LITTLE_ENDIAN},
        };
    }

    @Before
    public void setup() throws Exception {
        Address thisAddress = new Address("127.0.0.1", 5701);
        thatAddress = new Address("127.0.0.1", 5702);
        serializationService = new DefaultSerializationServiceBuilder().setByteOrder(byteOrder).build();
        endpointManager = mock(EndpointManager.class);
        connection = mock(Connection.class);
        when(connection.getEndpointManager()).thenReturn(endpointManager);
        handler = new OutboundResponseHandler(thisAddress, serializationService, logger);
    }

    @Test
    public void sendResponse_whenNormalResponse() {
        NormalResponse response = new NormalResponse("foo", 10, 1, false);
        Operation op = createDummyOperation(response.getCallId());

        ArgumentCaptor<Packet> argument = ArgumentCaptor.forClass(Packet.class);
        when(endpointManager.transmit(argument.capture(), eq(thatAddress))).thenReturn(true);

        // make the call
        handler.sendResponse(op, response);

        // verify that the right object was send
        assertEquals(serializationService.toData(response), argument.getValue());
    }

    @Test
    public void sendResponse_whenPortable() {
        Object response = new PortableAddress("Sesame Street", 1);
        Operation op = createDummyOperation(10);

        ArgumentCaptor<Packet> argument = ArgumentCaptor.forClass(Packet.class);
        when(endpointManager.transmit(argument.capture(), eq(thatAddress))).thenReturn(true);

        // make the call
        handler.sendResponse(op, response);

        // verify that the right object was send
        NormalResponse expected = new NormalResponse(response, op.getCallId(), 0, op.isUrgent());
        assertEquals(serializationService.toData(expected), argument.getValue());
    }

    @Test
    public void sendResponse_whenOrdinaryValue() {
        Object response = "foobar";
        Operation op = createDummyOperation(10);

        ArgumentCaptor<Packet> argument = ArgumentCaptor.forClass(Packet.class);
        when(endpointManager.transmit(argument.capture(), eq(thatAddress))).thenReturn(true);

        // make the call
        handler.sendResponse(op, response);

        // verify that the right object was send
        NormalResponse expected = new NormalResponse(response, op.getCallId(), 0, op.isUrgent());
        assertEquals(serializationService.toData(expected), argument.getValue());
    }

    @Test
    public void sendResponse_whenNull() {
        Operation op = createDummyOperation(10);

        ArgumentCaptor<Packet> argument = ArgumentCaptor.forClass(Packet.class);
        when(endpointManager.transmit(argument.capture(), eq(thatAddress))).thenReturn(true);

        // make the call
        handler.sendResponse(op, null);

        // verify that the right object was send
        NormalResponse expected = new NormalResponse(null, op.getCallId(), 0, op.isUrgent());
        assertEquals(serializationService.toData(expected), argument.getValue());
    }

    @Test
    public void sendResponse_whenTimeoutResponse() {
        CallTimeoutResponse response = new CallTimeoutResponse(10, false);

        Operation op = createDummyOperation(10);

        ArgumentCaptor<Packet> argument = ArgumentCaptor.forClass(Packet.class);
        when(endpointManager.transmit(argument.capture(), eq(thatAddress))).thenReturn(true);

        // make the call
        handler.sendResponse(op, response);

        // verify that the right object was send
        assertEquals(serializationService.toData(response), argument.getValue());
    }

    @Test
    public void sendResponse_whenErrorResponse() {
        ErrorResponse response = new ErrorResponse(new Exception(), 10, false);

        Operation op = createDummyOperation(10);

        ArgumentCaptor<Packet> argument = ArgumentCaptor.forClass(Packet.class);
        when(endpointManager.transmit(argument.capture(), eq(thatAddress))).thenReturn(true);

        // make the call
        handler.sendResponse(op, response);

        // verify that the right object was send
        assertEquals(serializationService.toData(response), argument.getValue());
    }

    @Test
    public void sendResponse_whenThrowable() {
        Exception exception = new Exception();

        Operation op = createDummyOperation(10);

        ArgumentCaptor<Packet> argument = ArgumentCaptor.forClass(Packet.class);
        when(endpointManager.transmit(argument.capture(), eq(thatAddress))).thenReturn(true);

        // make the call
        handler.sendResponse(op, exception);

        // verify that the right object was send
        ErrorResponse expectedResponse = new ErrorResponse(exception, op.getCallId(), op.isUrgent());
        assertEquals(serializationService.toData(expectedResponse), argument.getValue());
    }

    @Test
    public void toBackupAckPacket() {
        testToBackupAckPacket(1, false);
        testToBackupAckPacket(2, true);
    }

    private void testToBackupAckPacket(int callId, boolean urgent) {
        Packet packet = handler.toBackupAckPacket(callId, urgent);
        HeapData expected = serializationService.toData(new BackupAckResponse(callId, urgent));
        assertEquals(expected, new HeapData(packet.toByteArray()));
    }

    @Test
    public void toNormalResponsePacket_whenNormalValues() {
        testToNormalResponsePacket("foo", 1, 0, false);
        testToNormalResponsePacket("foo", 2, 0, true);
        testToNormalResponsePacket("foo", 3, 2, false);
    }

    @Test
    public void toNormalResponsePacket_whenNullValue() {
        testToNormalResponsePacket(null, 1, 2, false);
    }

    @Test
    public void toNormalResponsePacket_whenDataValue() {
        testToNormalResponsePacket(serializationService.toBytes("foobar"), 1, 2, false);
    }

    private void testToNormalResponsePacket(Object value, int callId, int backupAcks, boolean urgent) {
        Packet packet = handler.toNormalResponsePacket(callId, backupAcks, urgent, value);
        HeapData expected = serializationService.toData(new NormalResponse(value, callId, backupAcks, urgent));
        assertEquals(expected, new HeapData(packet.toByteArray()));
    }

    static class PortableAddress implements Portable {

        private String street;

        private int no;

        PortableAddress() {
        }

        PortableAddress(String street, int no) {
            this.street = street;
            this.no = no;
        }

        @Override
        public int getClassId() {
            return 2;
        }

        @Override
        public void writePortable(PortableWriter writer) throws IOException {
            writer.writeInt("no", no);
            writer.writeUTF("street", street);
        }

        @Override
        public void readPortable(PortableReader reader) throws IOException {
            street = reader.readUTF("street");
            no = reader.readInt("no");
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) {
                return true;
            }
            if (o == null || getClass() != o.getClass()) {
                return false;
            }

            PortableAddress that = (PortableAddress) o;
            if (no != that.no) {
                return false;
            }
            if (street != null ? !street.equals(that.street) : that.street != null) {
                return false;
            }
            return true;
        }

        @Override
        public int hashCode() {
            int result = street != null ? street.hashCode() : 0;
            result = 31 * result + no;
            return result;
        }

        @Override
        public int getFactoryId() {
            return 1;
        }
    }

    private Operation createDummyOperation(long i) {
        Operation op = new DummyOperation();
        setCallId(op, i);
        setCallerAddress(op, thatAddress);
        setConnection(op, connection);
        return op;
    }
}


text:
using BlackFox.U2F.Gnubby.Messages;
using JetBrains.Annotations;

namespace BlackFox.U2F.Key
{
    /// <summary>
    /// A physical U2F Key device.
    /// </summary>
	public interface IU2FKey
	{
		[NotNull]
		KeyRegisterResponse Register([NotNull] KeyRegisterRequest keyRegisterRequest);

        [NotNull]
        KeySignResponse Authenticate([NotNull] KeySignRequest keySignRequest);
	}
}


text:
FactoryGirl.define do
  factory :pending_shipment, class: Shipment do
    shipped false
  end
  factory :completed_shipment, class: Shipment do
    shipped true
  end
end


text:
package examples.gobot;

import basestation.BaseStation;
import basestation.bot.commands.FourWheelMovement;
import basestation.vision.VisionCoordinate;
import basestation.vision.VisionObject;
import minibot.BaseHTTPInterface;

import java.util.ArrayList;
import java.util.List;

/**
 * GoBot is an extension to the base minibot. It can either be controlled by a human user
 * or by the AI algorithm to race around a course.
 */
public class GoBot extends Thread {

    public static final int WAITING = 0;
    public static final int HUMAN_PLAYING = 1;
    public static final int BOT_PLAYING = 2;
    public static final int AITYPE_BASIC = 0;
    public static final int AITYPE_ADVANCED = 1;
    private final AIUtil ai;
    private final Navigator navigator;
    public double driveAngle_prev = 0;
    public double driveAngle_prevp = 0;
    FourWheelMovement fwm;
    int index;
    private int numLaps;
    private Course course;
    private int lapsDone;
    private boolean reachedMiddle;
    private boolean crossedLapLine;
    private long startTime;
    private ArrayList<Long> lapTimes;
    private boolean inTrack;
    private int botState;
    private int lastBotState;
    private float humanTime;
    private float botTime;
    private int aiType;

    /**
     * This constructor initializes the default fields of a gobot.
     */
    public GoBot() {
        this.numLaps = 1;
        this.lapsDone = 0;
        this.crossedLapLine = false;
        this.reachedMiddle = false;
        this.startTime = 0L;
        this.inTrack = true;
        this.lapTimes = new ArrayList<>();
        this.course = new Course();
        this.botState = WAITING; //waiting state
        this.lastBotState = -1;
        this.ai = new AIUtil(5, 0, Math.PI);
        this.fwm = fwm;
        this.navigator = new Navigator();
        this.aiType = AITYPE_BASIC;
        navigator.start();
    }

    /**
     * This constructor initializes a gobot with arguments passed in for numLaps and aiType
     *
     * @param numLaps represents the number of laps that must be completed to finish the race
     * @param aiType  0 means that the gobot AI will run off the simple algorithm, 1 will be advanced algorithm
     */
    public GoBot(int numLaps, int aiType) {
        this();
        this.numLaps = numLaps;
        this.aiType = aiType;
    }

    /**
     * Sets the course field for the minibot
     *
     * @param c
     */
    public void setCourse(Course c) {
        this.course = c;
        this.ai.course = c;
    }

    /**
     * @return the start time for the race
     */
    public long getStartTime() {
        return this.startTime;
    }

    /**
     * Sets the start time for the race
     *
     * @param time
     */
    public void setStartTime(long time) {
        this.startTime = time;
    }

    /**
     * @return returns the number of laps completed for the race
     */
    public int getLapsDone() {
        return this.lapsDone;
    }

    /**
     * lapTimes stores the NanoTime that the bot crossed the finish line at, and convertNanoTimeLapsToSeconds
     * converts all the nanoTimes in the list to seconds
     *
     * @return ArrayList of how long each lap took to complete in seconds
     */
    public ArrayList<Double> convertNanoTimeLapsToSeconds() {
        ArrayList<Double> lapTimeInSec = new ArrayList<>();
        for (int i = 0; i < lapTimes.size(); i++) {
            if (i == 0) {
                lapTimeInSec.add((double) (lapTimes.get(0) - getStartTime()) / 1000000000);
            } else {
                lapTimeInSec.add((double) (lapTimes.get(i) - lapTimes.get(i - 1)) / 1000000000);
            }
        }
        return lapTimeInSec;
    }

    /**
     * @return string representation of printing out lap times in seconds
     */
    public String lapTimes() {
        ArrayList<Double> lapTimeInSec = convertNanoTimeLapsToSeconds();
        String output = "";
        for (int i = 0; i < lapTimeInSec.size(); i++) {
            output += "Lap " + (i + 1) + ": " + lapTimeInSec.get(i) + "seconds\n";
        }
        return output;
    }

    /**
     * @return the total time the race took in seconds
     */
    public float totalTime() {
        float sum = 0;
        for (int i = 0; i < lapTimes.size(); i++) {
            if (i == 0) {
                sum += lapTimes.get(i) - this.startTime;
            } else
                sum += (lapTimes.get(i) - lapTimes.get(i - 1));
        }
        return sum / 1000000000;
    }

    /**
     * Sets the bot state (human or AI)
     *
     * @param state
     */
    public void setBotState(int state) {
        this.botState = state;
    }

    /**
     * Prints the bot state
     */
    private void printState() {
        System.out.printf("HUMAN: %s, AI: %s", humanTime, botTime);
    }

    /**
     * Runs the goBot (human or AI) on the course
     */
    @Override
    public void run() {
        this.fwm = (FourWheelMovement)
                BaseStation
                        .getInstance().getBotManager().getAllTrackedBots()
                        .iterator().next().getCommandCenter();

        while (true) {
            if (lastBotState != botState) {
                this.startTime = System.nanoTime();
            }
            lastBotState = botState;
            if (botState == HUMAN_PLAYING) {
                if (lapsDone >= numLaps) {
                    // Finished!
                    botState = WAITING;
                    humanTime = totalTime();
                    lapTimes.clear();
                    lapsDone = 0;
                    printState();
                } else {
                    List<VisionObject> vl = BaseStation.getInstance().getVisionManager()
                            .getAllLocationData();
                    if (vl.size() != 0) {
                        VisionCoordinate vc = vl.get(0).coord;
                        if (this.course.isInsideTrack(vc)) {
                            inTrack = true;
                            if (course.getStartArea().contains(vc.x, vc.y)) {
                                if (!crossedLapLine && !reachedMiddle) {
                                    this.crossedLapLine = true;
                                } else if (crossedLapLine && reachedMiddle) {
                                    this.lapsDone++;
                                    this.reachedMiddle = false;
                                    this.lapTimes.add(System.nanoTime());
                                }
                            } else if (course.getMiddleArea().contains(vc.x, vc.y)) {
                                if (!reachedMiddle) {
                                    this.reachedMiddle = true;
                                }
                            }
                        } else {
                            System.out.println("Out of bounds");
                            inTrack = false;
                        }
                    }
                }
            } else if (botState == BOT_PLAYING) { //ASSUMING CCL TRACK
                if (lapsDone >= numLaps) {
                    // Finished!
                    botState = WAITING;
                    botTime = totalTime();
                    lapTimes.clear();
                    lapsDone = 0;
                    printState();
                } else if (aiType == AITYPE_BASIC) {
                    List<VisionObject> vl = BaseStation.getInstance().getVisionManager()
                            .getAllLocationData();
                    if (vl.size() != 0) {
                        VisionCoordinate vc = vl.get(0).coord;
                        inTrack = this.course.isInsideTrack(vc);
                        if (navigator.destinationReached()) {
                            //int max = BaseHTTPInterface.innerTrackCoords
                            // .size(); for tracing inner track
                            int max = BaseHTTPInterface.advancedAI.size();
                            if (max != 0) {
                                //navigator.goToDestination(BaseHTTPInterface
                                // .innerTrackCoords.get(index)); for tracing
                                // inner track
                                navigator.goToDestination(BaseHTTPInterface
                                        .advancedAI.get(index));
                                System.out.println(navigator.destination);
                                index = (index + 1) % max;
                            }
                        }
                        if (course.getStartArea().contains(vc.x, vc.y)) {
                            if (!crossedLapLine && !reachedMiddle) {
                                this.crossedLapLine = true;
                            } else if (crossedLapLine && reachedMiddle) {
                                this.lapsDone++;
                                this.reachedMiddle = false;
                                this.lapTimes.add(System.nanoTime());
                                System.out.println(lapTimes());
                            }
                        } else if (course.getMiddleArea().contains(vc.x, vc.y)) {
                            if (!reachedMiddle) {
                                this.reachedMiddle = true;
                            }
                        }
                    }
                } else {
                    navigator.run();
                }

            } else {
                return;
            }
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    private class Navigator extends Thread {
        private static final double DISTANCE_THRESHOLD = 0.08;
        private static final double ANGLE_THRESHOLD = Math.PI / (10);
        private static final int MAX_SPEED = 100;
        private static final int MIN_SPEED = 50;
        private boolean destinationReached;
        private VisionCoordinate destination;

        @Override
        public void run() {
            while (true) {
                calcRoute();
                try {
                    Thread.sleep(20);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }

        public boolean destinationReached() {
            return destination == null || destinationReached;
        }

        public void goToDestination(VisionCoordinate vc) {
            this.destination = vc;
            destinationReached = false;
        }

        private double mod(double a, double n) {
            return a - Math.floor(a / n) * n;
        }

        public void calcRoute() {
            if (fwm == null) return;
            VisionCoordinate vc;
            List<VisionObject> locs = BaseStation.getInstance()
                    .getVisionManager
                            ().getAllLocationData();

            if (locs.size() == 0 || locs.get(0) == null) {
                vc = null;
                fwm.setWheelPower(0, 0, 0, 0);
                return;
            } else {
                vc = locs.get(0).coord;
            }

            if (aiType == AITYPE_BASIC) {
                if (destinationReached()) return;
                if (destination == null) {
                    return;
                }
                double spectheta = vc.getThetaOrZero();
                double toAngle = vc.getAngleTo(destination);
                double angle = mod((toAngle - spectheta + Math.PI), 2 * Math.PI);
                double dist = vc.getDistanceTo(destination);
                if (!inTrack) return;
                else {
                    if (dist > DISTANCE_THRESHOLD) {
                        if (Math.abs(angle) > ANGLE_THRESHOLD) {
                            // Need to rotate to face destination

                            // Calculate angular speed
                            double angSpeed = MIN_SPEED;
                            if (Math.abs(angle) > Math.toRadians(20)) {
                                angSpeed = MIN_SPEED + (MAX_SPEED - MIN_SPEED) *
                                        (Math.abs(angle) - Math.toRadians(20)) /
                                        Math.toRadians(160.);
                            }

                            if (angSpeed > MAX_SPEED) angSpeed = MAX_SPEED;

                            // Rotate in proper direction
                            if (angle < 0) {
                                //turn CCW
                                fwm.setWheelPower(angSpeed,
                                        -angSpeed, angSpeed, -angSpeed);
                            } else {
                                //turn CW
                                fwm.setWheelPower(-angSpeed,
                                        angSpeed, -angSpeed, angSpeed);
                            }
                        } else {
                            if (dist > DISTANCE_THRESHOLD) {
                                // Facing destination, need to move forward

                                // Calculate Forward speed
                                double speed = MIN_SPEED;
                                if (dist > 0.2) {
                                    speed = MIN_SPEED + (MAX_SPEED - MIN_SPEED) * (dist - 0.2) * 3;
                                }

                                if (speed > MAX_SPEED) speed = MAX_SPEED;

                                // Move forward
                                fwm.setWheelPower(speed, speed,
                                        speed, speed);
                            } else {
                                fwm.setWheelPower(0, 0, 0, 0);
                                destinationReached = true;
                            }
                        }
                    } else {
                        fwm.setWheelPower(0, 0, 0, 0);
                        destinationReached = true;
                    }
                }
            } else {
                double driveAngle = ai.calculateDriveAngle();
                double MIDDLE = Math.PI / 2;
                double QUARTER = MIDDLE - MIDDLE * .1;
                double THREEQUARTER = MIDDLE + MIDDLE * .1;
                int POWER = 70;
                if (driveAngle_prev - driveAngle_prevp < 0.001 && driveAngle_prev - driveAngle < 0.001) {
                    fwm.setWheelPower(POWER, POWER, 70, 70);
                } else if (driveAngle < QUARTER) {
                    fwm.setWheelPower(POWER, -POWER, POWER, -POWER);
                } else if (driveAngle < THREEQUARTER) {
                    fwm.setWheelPower(POWER, POWER, POWER, POWER);
                } else {
                    fwm.setWheelPower(-POWER, POWER, -POWER, POWER);
                }
                driveAngle_prevp = driveAngle_prev;
                driveAngle_prev = driveAngle;
            }
        }
    }
}


text:
SOURCE = $(shell find src -name '*.lhs' -o -name '*.hs')

.PHONY: clean build

dev: $(SOURCE)
			cabal install
setup:
			cabal sandbox init
			cabal install --only-dependencies --enable-tests

compile:
			cabal build

build: clean
			cabal build

clean:
			cabal clean

dependencies:
			cabal install --only-dependencies

test-setup:
			cabal install --only-dependencies --enable-tests --flags=doctests

test-compile:
			cabal configure --enable-tests --flags=doctests
			cabal build

test: test-compile
			cabal test --show-details=always

doctest:
			@(doctest -XOverloadedStrings $(SOURCE))


text:
<!DOCTYPE HTML>
<html lang="en">
<head>
  <title>4LF - by Ravinder</title>
  <meta charset="UTF-8" />
  <script type="text/javascript" src="js/phaser.min.js"></script>
  <script type="text/javascript" src="js/basketball.js"></script>
  <link href="mygame.css" media="all" rel="stylesheet" type="text/css">

</head>
<body>
  <p id="title"> Gotta catch 'em all! </p>

</body>
</html>


text:
<?php

	Class extension_export_ensemble extends Extension{

		public function about(){
			return array('name' => 'Export Ensemble',
						 'version' => '1.5',
						 'release-date' => '2009-03-06',
						 'author' => array('name' => 'Alistair Kearney',
										   'website' => 'http://pointybeard.com',
										   'email' => 'alistair@pointybeard.com')
				 		);
		}

		public function getSubscribedDelegates(){
			return array(
						array(
							'page' => '/system/preferences/',
							'delegate' => 'AddCustomPreferenceFieldsets',
							'callback' => 'appendPreferences'
						),

					);
		}

		public function install(){

			if(!class_exists('ZipArchive')){
				Administration::instance()->Page->pageAlert(__('Export Ensemble cannot be installed, since the "ZipArchive" class is not available. Ensure that PHP was compiled with the --enable-zip flag.'), AdministrationPage::PAGE_ALERT_ERROR);
				return false;
			}

			return true;
		}

		private function __addFolderToArchive(&$archive, $path, $parent=NULL){
			$iterator = new DirectoryIterator($path);
			foreach($iterator as $file){
				if($file->isDot() || preg_match('/^\./', $file->getFilename())) continue;

				elseif($file->isDir()){
					$this->__addFolderToArchive($archive, $file->getPathname(), $parent);
				}

				else $archive->addFile($file->getPathname(), ltrim(str_replace($parent, NULL, $file->getPathname()), '/'));
			}
		}

		private function __export(){
			$sql_schema = $sql_data = NULL;

			require_once(dirname(__FILE__) . '/lib/class.mysqldump.php');

			$dump = new MySQLDump($this->_Parent->Database);

			$tables = array(
				'tbl_authors',
				'tbl_cache',
				'tbl_entries',
				'tbl_extensions',
				'tbl_extensions_delegates',
				'tbl_fields',
				'tbl_fields_%',
				'tbl_forgotpass',
				'tbl_pages',
				'tbl_pages_types',
				'tbl_sections',
				'tbl_sections_association'
			);

			## Grab the schema
			foreach($tables as $t) $sql_schema .= $dump->export($t, MySQLDump::STRUCTURE_ONLY);
			$sql_schema = str_replace('`' . $this->_Parent->Configuration->get('tbl_prefix', 'database'), '`tbl_', $sql_schema);

			$sql_schema = preg_replace('/AUTO_INCREMENT=\d+/i', '', $sql_schema);

			$tables = array(
				'tbl_entries',
				'tbl_extensions',
				'tbl_extensions_delegates',
				'tbl_fields',
				'tbl_pages',
				'tbl_pages_types',
				'tbl_sections',
				'tbl_sections_association'
			);

			## Field data and entry data schemas needs to be apart of the workspace sql dump
			$sql_data  = $dump->export('tbl_fields_%', MySQLDump::ALL);
			$sql_data .= $dump->export('tbl_entries_%', MySQLDump::ALL);

			## Grab the data
			foreach($tables as $t) $sql_data .= $dump->export($t, MySQLDump::DATA_ONLY);
			$sql_data = str_replace('`' . $this->_Parent->Configuration->get('tbl_prefix', 'database'), '`tbl_', $sql_data);

			$config_string = NULL;
			$config = $this->_Parent->Configuration->get();

			unset($config['symphony']['build']);
			unset($config['symphony']['cookie_prefix']);
			unset($config['general']['useragent']);
			unset($config['file']['write_mode']);
			unset($config['directory']['write_mode']);
			unset($config['database']['host']);
			unset($config['database']['port']);
			unset($config['database']['user']);
			unset($config['database']['password']);
			unset($config['database']['db']);
			unset($config['database']['tbl_prefix']);
			unset($config['region']['timezone']);

			foreach($config as $group => $set){
				foreach($set as $key => $val) $config_string .= "		\$conf['".$group."']['".$key."'] = '".$val."';" . self::CRLF;
			}

			$install_template = str_replace(

									array(
										'',
										'',
										'',
										'',
										''
									),

									array(
										$this->_Parent->Configuration->get('build', 'symphony'),
										$this->_Parent->Configuration->get('version', 'symphony'),
										base64_encode($sql_schema),
										base64_encode($sql_data),
										trim($config_string),
									),

									file_get_contents(dirname(__FILE__) . '/lib/installer.tpl')
			);

			$archive = new ZipArchive;
			$res = $archive->open(TMP . '/ensemble.tmp.zip', ZipArchive::CREATE);

			if ($res === TRUE) {

				$archive->addFromString('install.php', $install_template);
				$archive->addFile(DOCROOT . '/index.php', 'index.php');

				if(is_file(DOCROOT . '/README')) $archive->addFile(DOCROOT . '/README', 'README');
				if(is_file(DOCROOT . '/LICENCE')) $archive->addFile(DOCROOT . '/LICENCE', 'LICENCE');
				if(is_file(DOCROOT . '/update.php')) $archive->addFile(DOCROOT . '/update.php', 'update.php');

				$this->__addFolderToArchive($archive, EXTENSIONS, DOCROOT);
				$this->__addFolderToArchive($archive, SYMPHONY, DOCROOT);
				$this->__addFolderToArchive($archive, WORKSPACE, DOCROOT);

			}

			$archive->close();

			header('Content-type: application/octet-stream');
			header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
		    header('Content-disposition: attachment; filename='.Lang::createFilename($this->_Parent->Configuration->get('sitename', 'general')).'-ensemble.zip');
		    header('Pragma: no-cache');

			readfile(TMP . '/ensemble.tmp.zip');
			unlink(TMP . '/ensemble.tmp.zip');
			exit();

		}

		public function __SavePreferences($context){
			$this->__export();
		}

		public function appendPreferences($context){

			if(isset($_POST['action']['export'])){
				$this->__SavePreferences($context);
			}

			$group = new XMLElement('fieldset');
			$group->setAttribute('class', 'settings');
			$group->appendChild(new XMLElement('legend', 'Export Ensemble'));

			$div = new XMLElement('div', NULL, array('id' => 'file-actions', 'class' => 'label'));
			$span = new XMLElement('span');

			if(!class_exists('ZipArchive')){
				$span->appendChild(new XMLElement('p', 'Warning: It appears you do not have the "ZipArchive" class available. Ensure that PHP was compiled with --enable-zip'));
			}
			else{
				$span->appendChild(new XMLElement('button', 'Create', array('name' => 'action[export]', 'type' => 'submit')));
			}

			$div->appendChild($span);

			$div->appendChild(new XMLElement('p', 'Packages entire site as a .zip archive for download.', array('class' => 'help')));

			$group->appendChild($div);
			$context['wrapper']->appendChild($group);

		}
	}


text:
package org.apache.camel.impl;

import java.util.EventObject;

import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.model.ProcessorDefinition;
import org.apache.camel.spi.Breakpoint;

/**
 * A support class for {@link Breakpoint} implementations to use as base class.
 * <p/>
 * Will be in active state.
 *
 * @version $Revision$
 */
public abstract class BreakpointSupport implements Breakpoint {

    private State state = State.Active;

    public State getState() {
        return state;
    }

    public void suspend() {
        state = State.Suspended;
    }

    public void activate() {
        state = State.Active;
    }

    public void beforeProcess(Exchange exchange, Processor processor, ProcessorDefinition definition) {
        // noop
    }

    public void afterProcess(Exchange exchange, Processor processor, ProcessorDefinition definition, long timeTaken) {
        // noop
    }

    public void onEvent(Exchange exchange, EventObject event, ProcessorDefinition definition) {
        // noop
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval"
    android:useLevel="false" >
    <solid android:color="@color/material_red" />
    <padding
        android:left="2dp"
        android:top="1dp"
        android:right="2dp"
        android:bottom="1dp" />
    <solid
        android:color="@color/material_red" />
    <stroke
        android:width="1dp"
        android:color="@color/white" />
    <size android:width="30dp"
        android:height="30dp" />
</shape>