text:
<?xml version="1.0" encoding="utf-8"?>
<section xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="zend.filter.set.boolean"><title>Boolean</title>

    <para>
        This filter changes a given input to be a <constant>BOOLEAN</constant> value. This is often
        useful when working with databases or when processing form values.
    </para>

    <section xml:id="zend.filter.set.boolean.options"><title>Supported options for Zend_Filter_Boolean</title>

        <para>
            The following options are supported for <classname>Zend_Filter_Boolean</classname>:
        </para>

        <itemizedlist>
            <listitem>
                <para>
                    <emphasis><property>casting</property></emphasis>: When this option is set to
                    <constant>TRUE</constant> then any given input will be casted to boolean. This
                    option defaults to <constant>TRUE</constant>.
                </para>
            </listitem>

            <listitem>
                <para>
                    <emphasis><property>locale</property></emphasis>: This option sets the locale
                    which will be used to detect localized input.
                </para>
            </listitem>

            <listitem>
                <para>
                    <emphasis><property>type</property></emphasis>: The <property>type</property>
                    option sets the boolean type which should be used. Read the following for
                    details.
                </para>
            </listitem>
        </itemizedlist>
    </section>

    <section xml:id="zend.filter.set.boolean.default"><title>Default behaviour for Zend_Filter_Boolean</title>

        <para>
            By default, this filter works by casting the input to a <constant>BOOLEAN</constant>
            value; in other words, it operates in a similar fashion to calling
            <command>(boolean) $value</command>.
        </para>

        <programlisting language="php"><![CDATA[
$filter = new Zend_Filter_Boolean();
$value  = '';
$result = $filter->filter($value);
// returns false
]]></programlisting>

        <para>
            This means that without providing any configuration,
            <classname>Zend_Filter_Boolean</classname> accepts all input types and returns a
            <constant>BOOLEAN</constant> just as you would get by type casting to
            <constant>BOOLEAN</constant>.
        </para>
    </section>

    <section xml:id="zend.filter.set.boolean.types"><title>Changing behaviour for Zend_Filter_Boolean</title>

        <para>
            Sometimes casting with <command>(boolean)</command> will not suffice.
            <classname>Zend_Filter_Boolean</classname> allows you to configure specific types to
            convert, as well as which to omit.
        </para>

        <para>
            The following types can be handled:
        </para>

        <itemizedlist>
            <listitem>
                <para>
                    <emphasis>boolean</emphasis>: Returns a boolean value as is.
                </para>
            </listitem>

            <listitem>
                <para>
                    <emphasis>integer</emphasis>: Converts an integer <emphasis>0</emphasis> value
                    to <constant>FALSE</constant>.
                </para>
            </listitem>

            <listitem>
                <para>
                    <emphasis>float</emphasis>: Converts a float <emphasis>0.0</emphasis> value
                    to <constant>FALSE</constant>.
                </para>
            </listitem>

            <listitem>
                <para>
                    <emphasis>string</emphasis>: Converts an empty string <emphasis>''</emphasis> to
                    <constant>FALSE</constant>.
                </para>
            </listitem>

            <listitem>
                <para>
                    <emphasis>zero</emphasis>: Converts a string containing the single character
                    zero (<emphasis>'0'</emphasis>) to <constant>FALSE</constant>.
                </para>
            </listitem>

            <listitem>
                <para>
                    <emphasis>empty_array</emphasis>: Converts an empty <emphasis>array</emphasis>
                    to <constant>FALSE</constant>.
                </para>
            </listitem>

            <listitem>
                <para>
                    <emphasis>null</emphasis>: Converts a <constant>NULL</constant> value
                    to <constant>FALSE</constant>.
                </para>
            </listitem>

            <listitem>
                <para>
                    <emphasis>php</emphasis>: Converts values according to <acronym>PHP</acronym>
                    when casting them to <constant>BOOLEAN</constant>.
                </para>
            </listitem>

            <listitem>
                <para>
                    <emphasis>false_string</emphasis>: Converts a string containing the word "false"
                    to a boolean <constant>FALSE</constant>.
                </para>
            </listitem>

            <listitem>
                <para>
                    <emphasis>yes</emphasis>: Converts a localized string which contains the word
                    "no" to <constant>FALSE</constant>.
                </para>
            </listitem>

            <listitem>
                <para>
                    <emphasis>all</emphasis>: Converts all above types to
                    <constant>BOOLEAN</constant>.
                </para>
            </listitem>
        </itemizedlist>

        <para>
            All other given values will return <constant>TRUE</constant> by default.
        </para>

        <para>
            There are several ways to select which of the above types are filtered. You can give one
            or multiple types and add them, you can give an array, you can use constants, or you can
            give a textual string. See the following examples:
        </para>

        <programlisting language="php"><![CDATA[
// converts 0 to false
$filter = new Zend_Filter_Boolean(Zend_Filter_Boolean::INTEGER);

// converts 0 and '0' to false
$filter = new Zend_Filter_Boolean(
    Zend_Filter_Boolean::INTEGER + Zend_Filter_Boolean::ZERO
);

// converts 0 and '0' to false
$filter = new Zend_Filter_Boolean(array(
    'type' => array(
        Zend_Filter_Boolean::INTEGER,
        Zend_Filter_Boolean::ZERO,
    ),
));

// converts 0 and '0' to false
$filter = new Zend_Filter_Boolean(array(
    'type' => array(
        'integer',
        'zero',
    ),
));
]]></programlisting>

        <para>
            You can also give an instance of <classname>Zend_Config</classname> to set the desired
            types. To set types after instantiation, use the <methodname>setType()</methodname>
            method.
        </para>
    </section>

    <section xml:id="zend.filter.set.boolean.localized"><title>Localized booleans</title>

        <para>
            As mentioned previously, <classname>Zend_Filter_Boolean</classname> can also recognise
            localized "yes" and "no" strings. This means that you can ask your customer in a form
            for "yes" or "no" within his native language and
            <classname>Zend_Filter_Boolean</classname> will convert the response to the appropriate
            boolean value.
        </para>

        <para>
            To set the desired locale, you can either use the <property>locale</property> option, or
            the method <methodname>setLocale()</methodname>.
        </para>

        <programlisting language="php"><![CDATA[
$filter = new Zend_Filter_Boolean(array(
    'type'   => Zend_Filter_Boolean::ALL,
    'locale' => 'de',
));

// returns false
echo $filter->filter('nein');

$filter->setLocale('en');

// returns true
$filter->filter('yes');
]]></programlisting>
    </section>

    <section xml:id="zend.filter.set.boolean.casting"><title>Disable casting</title>

        <para>
            Sometimes it is necessary to recognise only <constant>TRUE</constant> or
            <constant>FALSE</constant> and return all other values without changes.
            <classname>Zend_Filter_Boolean</classname> allows you to do this by setting the
            <property>casting</property> option to <constant>FALSE</constant>.
        </para>

        <para>
            In this case <classname>Zend_Filter_Boolean</classname> will work as described in the
            following table, which shows which values return <constant>TRUE</constant> or
            <constant>FALSE</constant>. All other given values are returned without change when
            <property>casting</property> is set to <constant>FALSE</constant>
        </para>

        <table xml:id="zend.filter.set.boolean.casting.table"><title>Usage without casting</title>

            <tgroup cols="3">
                <thead>
                    <row>
                        <entry>Type</entry>
                        <entry>True</entry>
                        <entry>False</entry>
                    </row>
                </thead>

                <tbody>
                    <row>
                        <entry><constant>Zend_Filter_Boolean::BOOLEAN</constant></entry>
                        <entry><constant>TRUE</constant></entry>
                        <entry><constant>FALSE</constant></entry>
                    </row>

                    <row>
                        <entry><constant>Zend_Filter_Boolean::INTEGER</constant></entry>
                        <entry>0</entry>
                        <entry>1</entry>
                    </row>

                    <row>
                        <entry><constant>Zend_Filter_Boolean::FLOAT</constant></entry>
                        <entry>0.0</entry>
                        <entry>1.0</entry>
                    </row>

                    <row>
                        <entry><constant>Zend_Filter_Boolean::STRING</constant></entry>
                        <entry>""</entry>
                        <entry/>
                    </row>

                    <row>
                        <entry><constant>Zend_Filter_Boolean::ZERO</constant></entry>
                        <entry>"0"</entry>
                        <entry>"1"</entry>
                    </row>

                    <row>
                        <entry><constant>Zend_Filter_Boolean::EMPTY_ARRAY</constant></entry>
                        <entry><methodname>array()</methodname></entry>
                        <entry/>
                    </row>

                    <row>
                        <entry><constant>Zend_Filter_Boolean::NULL</constant></entry>
                        <entry><constant>NULL</constant></entry>
                        <entry/>
                    </row>

                    <row>
                        <entry><constant>Zend_Filter_Boolean::FALSE_STRING</constant></entry>
                        <entry>"false" (case independently)</entry>
                        <entry>"true" (case independently)</entry>
                    </row>

                    <row>
                        <entry><constant>Zend_Filter_Boolean::YES</constant></entry>
                        <entry>localized "yes" (case independently)</entry>
                        <entry>localized "no" (case independently)</entry>
                    </row>
                </tbody>
            </tgroup>
        </table>

        <para>
            The following example shows the behaviour when changing the <property>casting</property>
            option:
        </para>

        <programlisting language="php"><![CDATA[
$filter = new Zend_Filter_Boolean(array(
    'type'    => Zend_Filter_Boolean::ALL,
    'casting' => false,
));

// returns false
echo $filter->filter(0);

// returns true
echo $filter->filter(1);

// returns the value
echo $filter->filter(2);
]]></programlisting>
    </section>
</section>


text:
'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = PanelElementEditor;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _panel = require('../panel');

var _panel2 = _interopRequireDefault(_panel);

var _immutable = require('immutable');

var _constants = require('../../../constants');

var _elementEditor = require('./element-editor');

var _elementEditor2 = _interopRequireDefault(_elementEditor);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function PanelElementEditor(_ref, _ref2) {
  var state = _ref.state;
  var projectActions = _ref2.projectActions,
      translator = _ref2.translator;
  var scene = state.scene,
      mode = state.mode;

  if (![_constants.MODE_IDLE, _constants.MODE_2D_ZOOM_IN, _constants.MODE_2D_ZOOM_OUT, _constants.MODE_2D_PAN, _constants.MODE_3D_VIEW, _constants.MODE_3D_FIRST_PERSON, _constants.MODE_WAITING_DRAWING_LINE, _constants.MODE_DRAWING_LINE, _constants.MODE_DRAWING_HOLE, _constants.MODE_DRAWING_ITEM, _constants.MODE_DRAGGING_LINE, _constants.MODE_DRAGGING_VERTEX, _constants.MODE_DRAGGING_ITEM, _constants.MODE_DRAGGING_HOLE, _constants.MODE_ROTATING_ITEM, _constants.MODE_UPLOADING_IMAGE, _constants.MODE_FITTING_IMAGE].includes(mode)) return null;

  var componentRenderer = function componentRenderer(element, layer) {
    return _react2.default.createElement(
      _panel2.default,
      { key: element.id, name: translator.t('Properties: [{0}] {1}', element.type, element.id), opened: true },
      _react2.default.createElement(
        'div',
        { style: { padding: '5px 15px' } },
        _react2.default.createElement(_elementEditor2.default, { element: element, layer: layer, state: state })
      )
    );
  };

  var layerRenderer = function layerRenderer(layer) {
    return (0, _immutable.Seq)().concat(layer.lines, layer.holes, layer.areas, layer.items).filter(function (element) {
      return element.selected;
    }).map(function (element) {
      return componentRenderer(element, layer);
    }).valueSeq();
  };

  return _react2.default.createElement(
    'div',
    null,
    scene.layers.valueSeq().map(layerRenderer)
  );
}

PanelElementEditor.propTypes = {
  state: _propTypes2.default.object.isRequired
};

PanelElementEditor.contextTypes = {
  projectActions: _propTypes2.default.object.isRequired,
  translator: _propTypes2.default.object.isRequired
};

redpajama_set_name: RedPajamaGithub


text:
<?php
namespace Concrete\Core\Search\ItemList\Database;

use Concrete\Core\Search\Column\Set;
use Concrete\Core\Search\ItemList\Column;
use Concrete\Core\Search\StickyRequest;
use Database;
use Concrete\Core\Search\ItemList\ItemList as AbstractItemList;
use Doctrine\DBAL\Logging\EchoSQLLogger;
use Doctrine\DBAL\Query\QueryBuilder;

abstract class ItemList extends AbstractItemList
{
    /** @var \Doctrine\DBAL\Query\QueryBuilder */
    protected $query;

    /** @var  \Concrete\Core\Search\StickyRequest | null */
    protected $searchRequest;

    abstract public function createQuery();

    /**
     * @param \Doctrine\DBAL\Query\QueryBuilder $query
     *
     * @return \Doctrine\DBAL\Query\QueryBuilder
     */
    public function finalizeQuery(\Doctrine\DBAL\Query\QueryBuilder $query)
    {
        return $query;
    }

    public function __construct(StickyRequest $req = null)
    {
        $this->query = Database::get()->createQueryBuilder();
        $this->searchRequest = $req;
        $this->createQuery();
    }

    /**
     * @return StickyRequest|null
     */
    public function getSearchRequest()
    {
        return $this->searchRequest;
    }

    public function getQueryObject()
    {
        return $this->query;
    }

    public function deliverQueryObject()
    {
        // setup the default sorting based on the request.
        $this->setupAutomaticSorting($this->searchRequest);
        $query = clone $this->query;
        $query = $this->finalizeQuery($query);
        return $query;
    }

    public function getOrderByColumns(Set $set)
    {
        $query = $this->deliverQueryObject();
        $orderBy = $query->getQueryPart('orderBy');
        $return = array();
        foreach ($orderBy as $data) {
            $data  = explode(" ", $data);
            $column = $set->getColumnByKey($data[0]);
            if ($column) {
                $column->setColumnSortDirection($data[1]);
                $return[] = $column;
            }
        }
        return $return;
    }

    public function executeGetResults()
    {
        return $this->deliverQueryObject()->execute()->fetchAll();
    }

    public function debugStart()
    {
        if ($this->isDebugged()) {
            Database::get()->getConfiguration()->setSQLLogger(new EchoSQLLogger());
        }
    }

    public function debugStop()
    {
        if ($this->isDebugged()) {
            Database::get()->getConfiguration()->setSQLLogger(null);
        }
    }

    protected function executeSortBy($column, $direction = 'asc')
    {
        if (in_array(strtolower($direction), array('asc', 'desc'))) {
            $this->query->orderBy($column, $direction);
        } else {
            throw new \Exception(t('Invalid SQL in order by'));
        }
    }

    protected function executeSanitizedSortBy($column, $direction = 'asc')
    {
        if (preg_match('/[^0-9a-zA-Z\$\.\_\x{0080}-\x{ffff}]+/u', $column) === 0) {
            $this->executeSortBy($column, $direction);
        } else {
            throw new \Exception(t('Invalid SQL in order by'));
        }
    }

    /**
     * @deprecated
     */
    public function filter($field, $value, $comparison = '=')
    {
        if ($field == false) {
            $this->query->andWhere($value); // ugh
        } else {
            $this->query->andWhere(implode(' ', array(
               $field, $comparison, $this->query->createNamedParameter($value),
            )));
        }
    }

    public function __clone()
    {
        $this->query = clone $this->query;
    }
}


text:
require 'rails_helper'

describe Groups::TransferService, :postgresql do
  let(:user) { create(:user) }
  let(:new_parent_group) { create(:group, :public) }
  let!(:group_member) { create(:group_member, :owner, group: group, user: user) }
  let(:transfer_service) { described_class.new(group, user) }

  shared_examples 'ensuring allowed transfer for a group' do
    context 'with other database than PostgreSQL' do
      before do
        allow(Group).to receive(:supports_nested_groups?).and_return(false)
      end

      it 'should return false' do
        expect(transfer_service.execute(new_parent_group)).to be_falsy
      end

      it 'should add an error on group' do
        transfer_service.execute(new_parent_group)
        expect(transfer_service.error).to eq('Transfer failed: Database is not supported.')
      end
    end

    context "when there's an exception on Gitlab shell directories" do
      let(:new_parent_group) { create(:group, :public) }

      before do
        allow_any_instance_of(described_class).to receive(:update_group_attributes).and_raise(Gitlab::UpdatePathError, 'namespace directory cannot be moved')
        create(:group_member, :owner, group: new_parent_group, user: user)
      end

      it 'should return false' do
        expect(transfer_service.execute(new_parent_group)).to be_falsy
      end

      it 'should add an error on group' do
        transfer_service.execute(new_parent_group)
        expect(transfer_service.error).to eq('Transfer failed: namespace directory cannot be moved')
      end
    end
  end

  describe '#execute' do
    context 'when transforming a group into a root group' do
      let!(:group) { create(:group, :public, :nested) }

      it_behaves_like 'ensuring allowed transfer for a group'

      context 'when the group is already a root group' do
        let(:group) { create(:group, :public) }

        it 'should add an error on group' do
          transfer_service.execute(nil)
          expect(transfer_service.error).to eq('Transfer failed: Group is already a root group.')
        end
      end

      context 'when the user does not have the right policies' do
        let!(:group_member) { create(:group_member, :guest, group: group, user: user) }

        it "should return false" do
          expect(transfer_service.execute(nil)).to be_falsy
        end

        it "should add an error on group" do
          transfer_service.execute(new_parent_group)
          expect(transfer_service.error).to eq("Transfer failed: You don't have enough permissions.")
        end
      end

      context 'when there is a group with the same path' do
        let!(:group) { create(:group, :public, :nested, path: 'not-unique') }

        before do
          create(:group, path: 'not-unique')
        end

        it 'should return false' do
          expect(transfer_service.execute(nil)).to be_falsy
        end

        it 'should add an error on group' do
          transfer_service.execute(nil)
          expect(transfer_service.error).to eq('Transfer failed: The parent group already has a subgroup with the same path.')
        end
      end

      context 'when the group is a subgroup and the transfer is valid' do
        let!(:subgroup1) { create(:group, :private, parent: group) }
        let!(:subgroup2) { create(:group, :internal, parent: group) }
        let!(:project1) { create(:project, :repository, :private, namespace: group) }

        before do
          transfer_service.execute(nil)
          group.reload
        end

        it 'should update group attributes' do
          expect(group.parent).to be_nil
        end

        it 'should update group children path' do
          group.children.each do |subgroup|
            expect(subgroup.full_path).to eq("#{group.path}/#{subgroup.path}")
          end
        end

        it 'should update group projects path' do
          group.projects.each do |project|
            expect(project.full_path).to eq("#{group.path}/#{project.path}")
          end
        end
      end
    end

    context 'when transferring a subgroup into another group' do
      let(:group) { create(:group, :public, :nested) }

      it_behaves_like 'ensuring allowed transfer for a group'

      context 'when the new parent group is the same as the previous parent group' do
        let(:group) { create(:group, :public, :nested, parent: new_parent_group) }

        it 'should return false' do
          expect(transfer_service.execute(new_parent_group)).to be_falsy
        end

        it 'should add an error on group' do
          transfer_service.execute(new_parent_group)
          expect(transfer_service.error).to eq('Transfer failed: Group is already associated to the parent group.')
        end
      end

      context 'when the user does not have the right policies' do
        let!(:group_member) { create(:group_member, :guest, group: group, user: user) }

        it "should return false" do
          expect(transfer_service.execute(new_parent_group)).to be_falsy
        end

        it "should add an error on group" do
          transfer_service.execute(new_parent_group)
          expect(transfer_service.error).to eq("Transfer failed: You don't have enough permissions.")
        end
      end

      context 'when the parent has a group with the same path' do
        before do
          create(:group_member, :owner, group: new_parent_group, user: user)
          group.update_attribute(:path, "not-unique")
          create(:group, path: "not-unique", parent: new_parent_group)
        end

        it 'should return false' do
          expect(transfer_service.execute(new_parent_group)).to be_falsy
        end

        it 'should add an error on group' do
          transfer_service.execute(new_parent_group)
          expect(transfer_service.error).to eq('Transfer failed: The parent group already has a subgroup with the same path.')
        end
      end

      context 'when the parent group has a project with the same path' do
        let!(:group) { create(:group, :public, :nested, path: 'foo') }

        before do
          create(:group_member, :owner, group: new_parent_group, user: user)
          create(:project, path: 'foo', namespace: new_parent_group)
          group.update_attribute(:path, 'foo')
        end

        it 'should return false' do
          expect(transfer_service.execute(new_parent_group)).to be_falsy
        end

        it 'should add an error on group' do
          transfer_service.execute(new_parent_group)
          expect(transfer_service.error).to eq('Transfer failed: Validation failed: Path has already been taken')
        end
      end

      context 'when the group is allowed to be transferred' do
        before do
          create(:group_member, :owner, group: new_parent_group, user: user)
          transfer_service.execute(new_parent_group)
        end

        context 'when the group has a lower visibility than the parent group' do
          let(:new_parent_group) { create(:group, :public) }
          let(:group) { create(:group, :private, :nested) }

          it 'should not update the visibility for the group' do
            group.reload
            expect(group.private?).to be_truthy
            expect(group.visibility_level).not_to eq(new_parent_group.visibility_level)
          end
        end

        context 'when the group has a higher visibility than the parent group' do
          let(:new_parent_group) { create(:group, :private) }
          let(:group) { create(:group, :public, :nested) }

          it 'should update visibility level based on the parent group' do
            group.reload
            expect(group.private?).to be_truthy
            expect(group.visibility_level).to eq(new_parent_group.visibility_level)
          end
        end

        it 'should update visibility for the group based on the parent group' do
          expect(group.visibility_level).to eq(new_parent_group.visibility_level)
        end

        it 'should update parent group to the new parent ' do
          expect(group.parent).to eq(new_parent_group)
        end

        it 'should return the group as children of the new parent' do
          expect(new_parent_group.children.count).to eq(1)
          expect(new_parent_group.children.first).to eq(group)
        end

        it 'should create a redirect for the group' do
          expect(group.redirect_routes.count).to eq(1)
        end
      end

      context 'when transferring a group with group descendants' do
        let!(:subgroup1) { create(:group, :private, parent: group) }
        let!(:subgroup2) { create(:group, :internal, parent: group) }

        before do
          create(:group_member, :owner, group: new_parent_group, user: user)
          transfer_service.execute(new_parent_group)
        end

        it 'should update subgroups path' do
          new_parent_path = new_parent_group.path
          group.children.each do |subgroup|
            expect(subgroup.full_path).to eq("#{new_parent_path}/#{group.path}/#{subgroup.path}")
          end
        end

        it 'should create redirects for the subgroups' do
          expect(group.redirect_routes.count).to eq(1)
          expect(subgroup1.redirect_routes.count).to eq(1)
          expect(subgroup2.redirect_routes.count).to eq(1)
        end

        context 'when the new parent has a higher visibility than the children' do
          it 'should not update the children visibility' do
            expect(subgroup1.private?).to be_truthy
            expect(subgroup2.internal?).to be_truthy
          end
        end

        context 'when the new parent has a lower visibility than the children' do
          let!(:subgroup1) { create(:group, :public, parent: group) }
          let!(:subgroup2) { create(:group, :public, parent: group) }
          let(:new_parent_group) { create(:group, :private) }

          it 'should update children visibility to match the new parent' do
            group.children.each do |subgroup|
              expect(subgroup.private?).to be_truthy
            end
          end
        end
      end

      context 'when transferring a group with project descendants' do
        let!(:project1) { create(:project, :repository, :private, namespace: group) }
        let!(:project2) { create(:project, :repository, :internal, namespace: group) }

        before do
          TestEnv.clean_test_path
          create(:group_member, :owner, group: new_parent_group, user: user)
          transfer_service.execute(new_parent_group)
        end

        it 'should update projects path' do
          new_parent_path = new_parent_group.path
          group.projects.each do |project|
            expect(project.full_path).to eq("#{new_parent_path}/#{group.path}/#{project.name}")
          end
        end

        it 'should create permanent redirects for the projects' do
          expect(group.redirect_routes.count).to eq(1)
          expect(project1.redirect_routes.count).to eq(1)
          expect(project2.redirect_routes.count).to eq(1)
        end

        context 'when the new parent has a higher visibility than the projects' do
          it 'should not update projects visibility' do
            expect(project1.private?).to be_truthy
            expect(project2.internal?).to be_truthy
          end
        end

        context 'when the new parent has a lower visibility than the projects' do
          let!(:project1) { create(:project, :repository, :public, namespace: group) }
          let!(:project2) { create(:project, :repository, :public, namespace: group) }
          let(:new_parent_group) { create(:group, :private) }

          it 'should update projects visibility to match the new parent' do
            group.projects.each do |project|
              expect(project.private?).to be_truthy
            end
          end
        end
      end

      context 'when transferring a group with subgroups & projects descendants' do
        let!(:project1) { create(:project, :repository, :private, namespace: group) }
        let!(:project2) { create(:project, :repository, :internal, namespace: group) }
        let!(:subgroup1) { create(:group, :private, parent: group) }
        let!(:subgroup2) { create(:group, :internal, parent: group) }

        before do
          TestEnv.clean_test_path
          create(:group_member, :owner, group: new_parent_group, user: user)
          transfer_service.execute(new_parent_group)
        end

        it 'should update subgroups path' do
          new_parent_path = new_parent_group.path
          group.children.each do |subgroup|
            expect(subgroup.full_path).to eq("#{new_parent_path}/#{group.path}/#{subgroup.path}")
          end
        end

        it 'should update projects path' do
          new_parent_path = new_parent_group.path
          group.projects.each do |project|
            expect(project.full_path).to eq("#{new_parent_path}/#{group.path}/#{project.name}")
          end
        end

        it 'should create redirect for the subgroups and projects' do
          expect(group.redirect_routes.count).to eq(1)
          expect(subgroup1.redirect_routes.count).to eq(1)
          expect(subgroup2.redirect_routes.count).to eq(1)
          expect(project1.redirect_routes.count).to eq(1)
          expect(project2.redirect_routes.count).to eq(1)
        end
      end

      context 'when transfering a group with nested groups and projects' do
        let!(:group) { create(:group, :public) }
        let!(:project1) { create(:project, :repository, :private, namespace: group) }
        let!(:subgroup1) { create(:group, :private, parent: group) }
        let!(:nested_subgroup) { create(:group, :private, parent: subgroup1) }
        let!(:nested_project) { create(:project, :repository, :private, namespace: subgroup1) }

        before do
          TestEnv.clean_test_path
          create(:group_member, :owner, group: new_parent_group, user: user)
          transfer_service.execute(new_parent_group)
        end

        it 'should update subgroups path' do
          new_base_path = "#{new_parent_group.path}/#{group.path}"
          group.children.each do |children|
            expect(children.full_path).to eq("#{new_base_path}/#{children.path}")
          end

          new_base_path = "#{new_parent_group.path}/#{group.path}/#{subgroup1.path}"
          subgroup1.children.each do |children|
            expect(children.full_path).to eq("#{new_base_path}/#{children.path}")
          end
        end

        it 'should update projects path' do
          new_parent_path = "#{new_parent_group.path}/#{group.path}"
          subgroup1.projects.each do |project|
            project_full_path = "#{new_parent_path}/#{project.namespace.path}/#{project.name}"
            expect(project.full_path).to eq(project_full_path)
          end
        end

        it 'should create redirect for the subgroups and projects' do
          expect(group.redirect_routes.count).to eq(1)
          expect(project1.redirect_routes.count).to eq(1)
          expect(subgroup1.redirect_routes.count).to eq(1)
          expect(nested_subgroup.redirect_routes.count).to eq(1)
          expect(nested_project.redirect_routes.count).to eq(1)
        end
      end

      context 'when updating the group goes wrong' do
        let!(:subgroup1) { create(:group, :public, parent: group) }
        let!(:subgroup2) { create(:group, :public, parent: group) }
        let(:new_parent_group) { create(:group, :private) }
        let!(:project1) { create(:project, :repository, :public, namespace: group) }

        before do
          allow(group).to receive(:save!).and_raise(ActiveRecord::RecordInvalid.new(group))
          TestEnv.clean_test_path
          create(:group_member, :owner, group: new_parent_group, user: user)
          transfer_service.execute(new_parent_group)
        end

        it 'should restore group and projects visibility' do
          subgroup1.reload
          project1.reload
          expect(subgroup1.public?).to be_truthy
          expect(project1.public?).to be_truthy
        end
      end
    end
  end
end


text:
package fr.insalyon.citi.golo.cli.command;

import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import fr.insalyon.citi.golo.cli.command.spi.CliCommand;

import java.net.URLClassLoader;
import java.util.LinkedList;
import java.util.List;

@Parameters(commandNames = {"run"}, commandDescription = "Runs compiled Golo code")
public class RunCommand implements CliCommand {

  @Parameter(names = "--module", description = "The Golo module with a main function", required = true)
  String module;

  @Parameter(description = "Program arguments")
  List<String> arguments = new LinkedList<>();

  @Parameter(names = "--classpath", variableArity = true, description = "Classpath elements (.jar and directories)")
  List<String> classpath = new LinkedList<>();

  @Override
  public void execute() throws Throwable {

    try {
      this.classpath.add(".");
      URLClassLoader primaryClassLoader = primaryClassLoader(this.classpath);
      Thread.currentThread().setContextClassLoader(primaryClassLoader);
      Class<?> module = Class.forName(this.module, true, primaryClassLoader);
      callRun(module, this.arguments.toArray(new String[this.arguments.size()]));
    } catch (ClassNotFoundException e) {
      System.out.println("The module " + this.module + " could not be loaded.");
    } catch (NoSuchMethodException e) {
      System.out.println("The module " + this.module + " does not have a main method with an argument.");
    }
  }
}


text:
package com.strategicgains.hyperexpress;

/**
 * Includes the standard relation types that us REST folks care about.
 * See the standard list at: http://www.iana.org/assignments/link-relations/link-relations.xml
 *
 * @author toddf
 * @since Oct 22, 2012
 * @see http://www.iana.org/assignments/link-relations/link-relations.xml
 */
public abstract class RelTypes
{
	// SECTION: CONSTANTS

	/**
	 * Refers to a substitute for this context.
	 * @see http://www.w3.org/TR/html5/links.html#link-type-alternate
	 */
	public static final String ALTERNATE = "alternate";

	/**
	 * Refers to an appendix.
	 * @see http://www.w3.org/TR/1999/REC-html401-19991224
	 */
	public static final String APPENDIX = "appendix";

	/**
	 * Refers to a collection of records, documents, or other materials of historical interest.
	 * @see http://www.w3.org/TR/2011/WD-html5-20110113/links.html#rel-archives
	 */
	public static final String ARCHIVES = "archives";

	/**
	 * Refers to the context's author.
	 * @see http://www.w3.org/TR/html5/links.html#link-type-author
	 */
	public static final String AUTHOR = "author";

	/**
	 * Gives a permanent link to use for bookmarking purposes.
	 * @see http://www.w3.org/TR/html5/links.html#link-type-bookmark
	 */
	public static final String BOOKMARK = "bookmark";

	/**
	 * Designates the preferred version of a resource (the IRI and its contents).
	 * @see http://www.iana.org/go/rfc6596
	 */
	public static final String CANONICAL = "canonical";

	/**
	 * Refers to a chapter in a collection of resources.
	 * @see http://www.w3.org/TR/1999/REC-html401-19991224
	 */
	public static final String CHAPTER = "chapter";

	/**
	 * The target IRI points to a resource which represents the collection resource for the context IRI.
	 * @see http://www.iana.org/go/rfc6573
	 */
	public static final String COLLECTION = "collection";

	/**
	 * Refers to a table of contents.
	 * @see http://www.w3.org/TR/1999/REC-html401-19991224
	 */
	public static final String CONTENTS = "contents";

	/**
	 * Refers to a copyright statement that applies to the link's context.
	 * @see http://www.w3.org/TR/1999/REC-html401-19991224
	 */
	public static final String COPYRIGHT = "copyright";

	/**
	 * Refers to a resource containing the most recent item(s) in a collection of resources.
	 * @see http://www.iana.org/go/rfc5005
	 */
	public static final String CURRENT = "current";

	/**
	 * Refers to a resource providing information about the link's context.
	 * @see http://www.w3.org/TR/powder-dr/#assoc-linking
	 */
	public static final String DESCRIBED_BY = "describedby";

	/**
	 * Refers to a list of patent disclosures made with respect to material for which 'disclosure' relation is specified.
	 * @see http://www.iana.org/go/rfc6579
	 */
	public static final String DISCLOSURE = "disclosure";

	/**
	 * Refers to a resource that can be used to edit the link's context.
	 * @see http://www.iana.org/go/rfc5023
	 */
	public static final String EDIT = "edit";

	/**
	 * Refers to a resource that can be used to edit media associated with the link's context.
	 * @see http://www.iana.org/go/rfc5023
	 */
	public static final String EDIT_MEDIA = "edit-media";

	/**
	 * Identifies a related resource that is potentially large and might require special handling.
	 * @see http://www.iana.org/go/rfc4287
	 */
	public static final String ENCLOSURE = "enclosure";

	/**
	 * An IRI that refers to the furthest preceding resource in a series of resources.
	 * @see http://www.iana.org/go/rfc5988
	 */
	public static final String FIRST = "first";

	/**
	 * Refers to a glossary of terms.
	 * @see http://www.w3.org/TR/1999/REC-html401-19991224
	 */
	public static final String GLOSSARY = "glossary";

	/**
	 * Refers to context-sensitive help.
	 * @see http://www.w3.org/TR/html5/links.html#link-type-help
	 */
	public static final String HELP = "help";

	/**
	 * Refers to a resource hosted by the server indicated by the link context.
	 * @see http://www.iana.org/go/rfc6690
	 */
	public static final String HOSTS = "hosts";

	/**
	 * Refers to a hub that enables registration for notification of updates to the context.
	 * @see http://pubsubhubbub.googlecode.com/
	 */
	public static final String HUB = "hub";

	/**
	 * Refers to an icon representing the link's context.
	 * @see http://www.w3.org/TR/html5/links.html#link-type-icon
	 */
	public static final String ICON = "icon";

	/**
	 * Refers to an index.
	 * @see http://www.w3.org/TR/1999/REC-html401-19991224
	 */
	public static final String INDEX = "index";

	/**
	 * The target IRI points to a resource that is a member of the collection represented by the context IRI.
	 * @see http://www.iana.org/go/rfc6573
	 */
	public static final String ITEM = "item";

	/**
	 * An IRI that refers to the furthest following resource in a series of resources.
	 * @see http://www.iana.org/go/rfc5988
	 */
	public static final String LAST = "last";

	/**
	 * Points to a resource containing the latest (e.g., current) version of the context.
	 * @see http://www.iana.org/go/rfc5829
	 */
	public static final String LATEST_VERSION = "latest-version";

	/**
	 * Refers to a license associated with this context.
	 * @see http://www.iana.org/go/rfc4946
	 */
	public static final String LICENSE = "license";

	/**
	 * Refers to a resource that can be used to monitor changes in an HTTP resource.
	 * @see http://www.iana.org/go/rfc5989
	 */
	public static final String MONITOR = "monitor";

	/**
	 * Refers to a resource that can be used to monitor changes in a specified group of HTTP resources.
	 * @see http://www.iana.org/go/rfc5989
	 */
	public static final String MONITOR_GROUP = "monitor-group";

	/**
	 * Indicates that the link's context is a part of a series, and that the next in the series is the link target.
	 * @see http://www.w3.org/TR/html5/links.html#link-type-next
	 */
	public static final String NEXT = "next";

	/**
	 * Refers to the immediately following archive resource.
	 * @see http://www.iana.org/go/rfc5005
	 */
	public static final String NEXT_ARCHIVE = "next-archive";

	/**
	 * Indicates a resource where payment is accepted.
	 * @see http://www.iana.org/go/rfc5988
	 */
	public static final String PAYMENT = "payment";

	/**
	 * Points to a resource containing the predecessor version in the version history.
	 * @see http://www.iana.org/go/rfc5829
	 */
	public static final String PREDECESSOR_VERSION = "predecessor-version";

	/**
	 * Indicates that the link's context is a part of a series, and that the previous in the series is the link target.
	 * @see http://www.w3.org/TR/html5/links.html#link-type-prev
	 */
	public static final String PREV = "prev";

	/**
	 * Refers to the previous resource in an ordered series of resources. Synonym for "prev".
	 * @see http://www.w3.org/TR/1999/REC-html401-19991224
	 */
	public static final String PREVIOUS = "previous";

	/**
	 * Refers to the immediately preceding archive resource.
	 * @see http://www.iana.org/go/rfc5005
	 */
	public static final String PREV_ARCHIVE = "prev-archive";

	/**
	 * Identifies a related resource.
	 * @see http://www.iana.org/go/rfc4287
	 */
	public static final String RELATED = "related";

	/**
	 * Identifies a resource that is a reply to the context of the link.
	 * @see http://www.iana.org/go/rfc4685
	 */
	public static final String REPLIES = "replies";

	/**
	 * Refers to a resource that can be used to search through the link's context and related resources.
	 * @see http://www.opensearch.org/Specifications/OpenSearch/1.1
	 */
	public static final String SEARCH = "search";

	/**
	 * Refers to a section in a collection of resources.
	 * @see http://www.w3.org/TR/1999/REC-html401-19991224
	 */
	public static final String SECTION = "section";

	/**
	 * Conveys an identifier for the link's context.
	 * @see http://www.iana.org/go/rfc4287
	 */
	public static final String SELF = "self";

	/**
	 * Indicates a URI that can be used to retrieve a service document.
	 * @see http://www.iana.org/go/rfc5023
	 */
	public static final String SERVICE = "service";

	/**
	 * Refers to the first resource in a collection of resources.
	 * @see http://www.w3.org/TR/1999/REC-html401-19991224
	 */
	public static final String START = "start";

	/**
	 * Refers to a stylesheet.
	 * @see http://www.w3.org/TR/html5/links.html#link-type-stylesheet
	 */
	public static final String STYLE_SHEET = "stylesheet";

	/**
	 * Refers to a resource serving as a subsection in a collection of resources.
	 * @see http://www.w3.org/TR/1999/REC-html401-19991224
	 */
	public static final String SUB_SECTION = "subsection";

	/**
	 * Points to a resource containing the successor version in the version history.
	 * @see http://www.iana.org/go/rfc5829
	 */
	public static final String SUCCESSOR_VERSION = "successor-version";

	/**
	 * Gives a tag (identified by the given address) that applies to the current document.
	 * @see http://www.w3.org/TR/html5/links.html#link-type-tag
	 */
	public static final String TAG = "tag";

	/**
	 * Points to a resource containing the version history for the context.
	 * @see http://www.iana.org/go/rfc5829
	 */
	public static final String VERSION_HISTORY = "version-history";

	/**
	 * Refers to a parent document in a hierarchy of documents.
	 * @see http://www.iana.org/go/rfc5988
	 */
	public static final String UP = "up";

	/**
	 * Identifies a resource that is the source of the information in the link's context.
	 * @see http://www.iana.org/go/rfc4287
	 */
	public static final String VIA = "via";

	/**
	 * Points to a working copy for this resource.
	 * @see http://www.iana.org/go/rfc5829
	 */
	public static final String WORKING_COPY = "working-copy";

	// SECTION: CONSTRUCTORS - PRIVATE

	/**
	 * Points to the versioned resource from which this working copy was obtained.
	 * @see http://www.iana.org/go/rfc5829
	 */
	public static final String WORKING_COPY_OF = "working-copy-of";

	private RelTypes()
	{
		// prevents instantiation.
	}
}


text:
package org.orekit.estimation.sequential;

import org.hipparchus.linear.RealMatrix;
import org.orekit.propagation.SpacecraftState;

/** Abstract provider handling a predefined initial covariance matrix.
 * <p>
 * This class always provides a predefined initial noise matrix.
 * </p>
 * @author Luc Maisonobe
 * @since 9.2
 */
public abstract class AbstractCovarianceMatrixProvider implements CovarianceMatrixProvider {

    /** Initial process noise. */
    private final RealMatrix initialNoiseMatrix;

    /** Simple constructor.
     * @param initialNoiseMatrix initial process noise
     */
    protected AbstractCovarianceMatrixProvider(final RealMatrix initialNoiseMatrix) {
        this.initialNoiseMatrix = initialNoiseMatrix;
    }

    /** {@inheritDoc} */
    @Override
    public RealMatrix getInitialCovarianceMatrix(final SpacecraftState initial) {
        return initialNoiseMatrix;
    }

}


text:
/*
 * Open Source Software published under the Apache Licence, Version 2.0.
 */

package io.github.vocabhunter.gui.model;

import io.github.vocabhunter.analysis.marked.WordState;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.NumberBinding;
import javafx.beans.binding.NumberExpression;
import javafx.beans.property.SimpleIntegerProperty;

import java.util.Collections;
import java.util.EnumMap;
import java.util.Map;

public class ProgressModel {
    private static final double PERCENT = 100;

    private final SimpleIntegerProperty known = new SimpleIntegerProperty();

    private final SimpleIntegerProperty unknown = new SimpleIntegerProperty();

    private final SimpleIntegerProperty unseenUnfiltered = new SimpleIntegerProperty();

    private final SimpleIntegerProperty unseenFiltered = new SimpleIntegerProperty();

    private final Map<WordState, SimpleIntegerProperty> properties;

    private final NumberBinding marked = known.add(unknown);

    private final NumberBinding totalVisible = known.add(unknown).add(unseenUnfiltered);

    private final NumberBinding total = totalVisible.add(unseenFiltered);

    private final NumberBinding knownPercent = bindPercentage(known, total);

    private final NumberBinding unknownPercent = bindPercentage(unknown, total);

    private final NumberBinding unseenUnfilteredPercent = bindPercentage(unseenUnfiltered, total);

    private final NumberBinding unseenUnfilteredPercentVisible = bindPercentage(unseenUnfiltered, totalVisible);

    private final NumberBinding unseenFilteredPercent = bindPercentage(unseenFiltered, total);

    private final NumberBinding markedPercentVisible = bindPercentage(marked, totalVisible);

    private NumberBinding bindPercentage(final NumberExpression property, final NumberBinding total) {
        return Bindings.when(property.isEqualTo(0)).then(0).otherwise(property.multiply(PERCENT).divide(total));
    }

    public SimpleIntegerProperty knownProperty() {
        return known;
    }

    public SimpleIntegerProperty unknownProperty() {
        return unknown;
    }

    public SimpleIntegerProperty unseenUnfilteredProperty() {
        return unseenUnfiltered;
    }

    public NumberBinding unseenUnfilteredPercentVisibleProperty() {
        return unseenUnfilteredPercentVisible;
    }

    public SimpleIntegerProperty unseenFilteredProperty() {
        return unseenFiltered;
    }

    public NumberBinding markedProperty() {
        return marked;
    }

    public NumberBinding totalProperty() {
        return total;
    }

    public NumberBinding knownPercentProperty() {
        return knownPercent;
    }

    public NumberBinding unknownPercentProperty() {
        return unknownPercent;
    }

    public NumberBinding unseenUnfilteredPercentProperty() {
        return unseenUnfilteredPercent;
    }

    public NumberBinding unseenFilteredPercentProperty() {
        return unseenFilteredPercent;
    }

    public NumberBinding markedPercentVisibleProperty() {
        return markedPercentVisible;
    }

    public ProgressModel() {
        Map<WordState, SimpleIntegerProperty> map = new EnumMap<>(WordState.class);

        map.put(WordState.KNOWN, known);
        map.put(WordState.UNKNOWN, unknown);
        map.put(WordState.UNSEEN, unseenUnfiltered);
        this.properties = Collections.unmodifiableMap(map);
    }

    public void updateProgress(final int known, final int unknown, final int unseenUnfiltered, final int unseenFiltered) {
        this.known.set(known);
        this.unknown.set(unknown);
        this.unseenUnfiltered.set(unseenUnfiltered);
        this.unseenFiltered.set(unseenFiltered);
    }

    public void updateWord(final WordState oldState, final WordState newState) {
        SimpleIntegerProperty oldValue = properties.get(oldState);
        SimpleIntegerProperty newValue = properties.get(newState);

        updateValue(oldValue, -1);
        updateValue(newValue, 1);
    }

    private void updateValue(final SimpleIntegerProperty property, final int delta) {
        property.set(property.get() + delta);
    }
}


text:
namespace Microsoft.Graph
{
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Runtime.Serialization;
    using Newtonsoft.Json;

    /// <summary>
    /// The type DateTimeTimeZone.
    /// </summary>
    [JsonObject(MemberSerialization = MemberSerialization.OptIn)]
    [JsonConverter(typeof(DerivedTypeConverter))]
    public partial class DateTimeTimeZone
    {

        /// <summary>
        /// Gets or sets dateTime.
        /// </summary>
        [JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "dateTime", Required = Required.Default)]
        public string DateTime { get; set; }

        /// <summary>
        /// Gets or sets timeZone.
        /// </summary>
        [JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "timeZone", Required = Required.Default)]
        public string TimeZone { get; set; }

        /// <summary>
        /// Gets or sets additional data.
        /// </summary>
        [JsonExtensionData(ReadData = true)]
        public IDictionary<string, object> AdditionalData { get; set; }

    }
}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

namespace Nane.Core.Repository
{
    public interface IRepository<T>
    {
        IEnumerable<T> GetAll(Expression<Func<T, bool>> filter = null,
        Func<IQueryable<T>, IOrderedQueryable<T>> orderBy = null,
        string includeProperties = "");
        T GetById(object id);
        T Insert(T obj);
        void Delete(object id);
        void Delete(T obj);
        void Update(T obj);
        int Count();
        void SaveChanges();
    }
}


text:
> Visualize your Trello boards as lists

## Dependencies
* [Node.js](https://nodejs.org)

## Running
1. clone this repo
2. `npm install`
3. open http://localhost:1337/

## To do
- [ ] A nice logo
- [ ] Styles
- [ ] Tests

## Author
Renan Couto

## License
MIT


text:
package consulo.dotnet.module.extension;

import java.util.Map;

import javax.annotation.Nonnull;
import com.intellij.openapi.roots.OrderRootType;
import consulo.module.extension.ModuleExtension;

/**
 * @author VISTALL
 * @since 09.06.2015
 */
public interface DotNetModuleExtensionWithLibraryProviding<T extends DotNetModuleExtensionWithLibraryProviding<T>> extends ModuleExtension<T>
{
	@Nonnull
	Map<String, String> getAvailableSystemLibraries();

	@Nonnull
	String[] getSystemLibraryUrls(@Nonnull String name, @Nonnull OrderRootType orderRootType);
}


text:
#include <aws/inspector/model/Exclusion.h>
#include <aws/core/utils/json/JsonSerializer.h>

#include <utility>

using namespace Aws::Utils::Json;
using namespace Aws::Utils;

namespace Aws
{
namespace Inspector
{
namespace Model
{

Exclusion::Exclusion() :
    m_arnHasBeenSet(false),
    m_titleHasBeenSet(false),
    m_descriptionHasBeenSet(false),
    m_recommendationHasBeenSet(false),
    m_scopesHasBeenSet(false),
    m_attributesHasBeenSet(false)
{
}

Exclusion::Exclusion(JsonView jsonValue) :
    m_arnHasBeenSet(false),
    m_titleHasBeenSet(false),
    m_descriptionHasBeenSet(false),
    m_recommendationHasBeenSet(false),
    m_scopesHasBeenSet(false),
    m_attributesHasBeenSet(false)
{
  *this = jsonValue;
}

Exclusion& Exclusion::operator =(JsonView jsonValue)
{
  if(jsonValue.ValueExists("arn"))
  {
    m_arn = jsonValue.GetString("arn");

    m_arnHasBeenSet = true;
  }

  if(jsonValue.ValueExists("title"))
  {
    m_title = jsonValue.GetString("title");

    m_titleHasBeenSet = true;
  }

  if(jsonValue.ValueExists("description"))
  {
    m_description = jsonValue.GetString("description");

    m_descriptionHasBeenSet = true;
  }

  if(jsonValue.ValueExists("recommendation"))
  {
    m_recommendation = jsonValue.GetString("recommendation");

    m_recommendationHasBeenSet = true;
  }

  if(jsonValue.ValueExists("scopes"))
  {
    Array<JsonView> scopesJsonList = jsonValue.GetArray("scopes");
    for(unsigned scopesIndex = 0; scopesIndex < scopesJsonList.GetLength(); ++scopesIndex)
    {
      m_scopes.push_back(scopesJsonList[scopesIndex].AsObject());
    }
    m_scopesHasBeenSet = true;
  }

  if(jsonValue.ValueExists("attributes"))
  {
    Array<JsonView> attributesJsonList = jsonValue.GetArray("attributes");
    for(unsigned attributesIndex = 0; attributesIndex < attributesJsonList.GetLength(); ++attributesIndex)
    {
      m_attributes.push_back(attributesJsonList[attributesIndex].AsObject());
    }
    m_attributesHasBeenSet = true;
  }

  return *this;
}

JsonValue Exclusion::Jsonize() const
{
  JsonValue payload;

  if(m_arnHasBeenSet)
  {
   payload.WithString("arn", m_arn);

  }

  if(m_titleHasBeenSet)
  {
   payload.WithString("title", m_title);

  }

  if(m_descriptionHasBeenSet)
  {
   payload.WithString("description", m_description);

  }

  if(m_recommendationHasBeenSet)
  {
   payload.WithString("recommendation", m_recommendation);

  }

  if(m_scopesHasBeenSet)
  {
   Array<JsonValue> scopesJsonList(m_scopes.size());
   for(unsigned scopesIndex = 0; scopesIndex < scopesJsonList.GetLength(); ++scopesIndex)
   {
     scopesJsonList[scopesIndex].AsObject(m_scopes[scopesIndex].Jsonize());
   }
   payload.WithArray("scopes", std::move(scopesJsonList));

  }

  if(m_attributesHasBeenSet)
  {
   Array<JsonValue> attributesJsonList(m_attributes.size());
   for(unsigned attributesIndex = 0; attributesIndex < attributesJsonList.GetLength(); ++attributesIndex)
   {
     attributesJsonList[attributesIndex].AsObject(m_attributes[attributesIndex].Jsonize());
   }
   payload.WithArray("attributes", std::move(attributesJsonList));

  }

  return payload;
}

} // namespace Model
} // namespace Inspector
} // namespace Aws


text:
Aria.classDefinition({
    $classpath : "test.performance.interceptors.EnableMethodEventsPrefTestCase",
    $extends : "aria.jsunit.TemplateTestCase",
    $constructor : function () {
        this.$TemplateTestCase.constructor.call(this);
        this.setTestEnv({
            template : "test.performance.interceptors.MyParentTemplate",
            moduleCtrl : {
                classpath : "test.performance.interceptors.EnableModuleEventsModuleCtrl"
            }
        });
    },
    $prototype : {
        runTemplateTest : function () {
            this._testDefault();
        },
        _testDefault : function () {
            this.synEvent.click(this.getInputField("startBtn"), {
                fn : this._onBtnClicked,
                scope : this
            });
        },
        _onBtnClicked : function () {
            var data = this.templateCtxt.moduleCtrl.getData("calls");
            this.assertTrue(data.callBegin == 502);
            this.assertTrue(data.calls == 502);
            this.assertTrue(data.callEnd == 502);
            this.notifyTemplateTestEnd();
        }
    }
});


text:
<?php

namespace Thor\Language;

/**
 * Language model test
 *
 */
class LanguageTest extends PackageTestCase
{

    /**
     * Setup the test environment.
     */
    public function setUp()
    {
        parent::setUp();
        $this->prepareDatabase();
    }

    public function testLanguagesTableHas5Records()
    {
        $this->assertCount(5, Language::all());
    }

    /**
     * @covers \Thor\Language\Language::scopeSorted
     */
    public function testScopeSorted()
    {
        $lang = Language::sorted()->first();
        $this->assertInstanceOf('Thor\\Language\\Language', $lang);
        $this->assertEquals('en', $lang->code);
        $this->assertEquals('en_US', $lang->locale);
        $this->assertEquals(true, $lang->is_active);
        $this->assertEquals(1, $lang->sorting);
    }

    /**
     * @covers \Thor\Language\Language::scopeActive
     */
    public function testScopeActive()
    {
        $lang = Language::find(2);
        $lang->is_active = false;
        $lang->save();

        $langs = Language::active()->get();
        $this->assertCount(4, $langs);
        $this->assertEquals('en', $langs->first()->code);
    }

    /**
     * @covers \Thor\Language\Language::scopeToAssoc
     */
    public function testScopeToAssoc()
    {
        $langs = Language::toAssoc();
        $this->assertCount(5, $langs);
        $this->assertArrayHasKey('es', $langs);
        $this->assertArrayHasKey('en', $langs);
    }

    /**
     * @covers \Thor\Language\Language::scopeByCode
     */
    public function testScopeByCode()
    {
        $lang = Language::byCode('en')->first();
        $this->assertInstanceOf('Thor\\Language\\Language', $lang);
        $this->assertEquals(1, $lang->id);
        $this->assertEquals('en', $lang->code);
        $this->assertEquals('en_US', $lang->locale);
    }

    /**
     * @covers \Thor\Language\Language::scopeByLocale
     */
    public function testScopeByLocale()
    {
        $lang = Language::byLocale('es_ES')->first();
        $this->assertInstanceOf('Thor\\Language\\Language', $lang);
        $this->assertEquals(2, $lang->id);
        $this->assertEquals('es', $lang->code);
        $this->assertEquals('es_ES', $lang->locale);
    }

}


text:
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.09.17 at 10:17:07 AM IST
//

package com.pacificmetrics.saaif.tutorial;

import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlElementRefs;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

/**
 *
Java class for anonymous complex type.
 *
 *
The following schema fragment specifies the expected content contained within this class.
 *
 *

 * <complexType>
 *   <complexContent>
 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       <sequence>
 *         <group ref="{http://www.w3.org/1999/xhtml}head.misc"/>
 *         <choice>
 *           <sequence>
 *             <element ref="{http://www.w3.org/1999/xhtml}title"/>
 *             <group ref="{http://www.w3.org/1999/xhtml}head.misc"/>
 *             <sequence minOccurs="0">
 *               <element ref="{http://www.w3.org/1999/xhtml}base"/>
 *               <group ref="{http://www.w3.org/1999/xhtml}head.misc"/>
 *             </sequence>
 *           </sequence>
 *           <sequence>
 *             <element ref="{http://www.w3.org/1999/xhtml}base"/>
 *             <group ref="{http://www.w3.org/1999/xhtml}head.misc"/>
 *             <element ref="{http://www.w3.org/1999/xhtml}title"/>
 *             <group ref="{http://www.w3.org/1999/xhtml}head.misc"/>
 *           </sequence>
 *         </choice>
 *       </sequence>
 *       <attGroup ref="{http://www.w3.org/1999/xhtml}i18n"/>
 *       <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}ID" />
 *       <attribute name="profile" type="{http://www.w3.org/1999/xhtml}URI" />
 *     </restriction>
 *   </complexContent>
 * </complexType>
 *

 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "content"
})
@XmlRootElement(name = "head")
public class Head {

    @XmlElementRefs({
        @XmlElementRef(name = "meta", namespace = "http://www.w3.org/1999/xhtml", type = Meta.class, required = false),
        @XmlElementRef(name = "title", namespace = "http://www.w3.org/1999/xhtml", type = Title.class, required = false),
        @XmlElementRef(name = "base", namespace = "http://www.w3.org/1999/xhtml", type = Base.class, required = false),
        @XmlElementRef(name = "script", namespace = "http://www.w3.org/1999/xhtml", type = Script.class, required = false),
        @XmlElementRef(name = "style", namespace = "http://www.w3.org/1999/xhtml", type = Style.class, required = false),
        @XmlElementRef(name = "object", namespace = "http://www.w3.org/1999/xhtml", type = com.pacificmetrics.saaif.tutorial.Object.class, required = false),
        @XmlElementRef(name = "link", namespace = "http://www.w3.org/1999/xhtml", type = Link.class, required = false)
    })
    protected List<java.lang.Object> content;
    @XmlAttribute(name = "id")
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    @XmlID
    @XmlSchemaType(name = "ID")
    protected String id;
    @XmlAttribute(name = "profile")
    protected String profile;
    @XmlAttribute(name = "lang")
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    protected String langCode;
    @XmlAttribute(name = "lang", namespace = "http://www.w3.org/XML/1998/namespace")
    protected String lang;
    @XmlAttribute(name = "dir")
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    protected String dir;

    /**
     * Gets the rest of the content model.
     *
     *

     * You are getting this "catch-all" property because of the following reason:
     * The field name "Base" is used by two different parts of a schema. See:
     * line 658 of http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd
     * line 653 of http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd
     *

     * To get rid of this property, apply a property customization to one
     * of both of the following declarations to change their names:
     * Gets the value of the content property.
     *
     *

     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a set method for the content property.
     *
     *

     * For example, to add a new item, do as follows:
     *

     *    getContent().add(newItem);
     *

     *
     *
     *

     * Objects of the following type(s) are allowed in the list
     * {@link Meta }
     * {@link Script }
     * {@link Base }
     * {@link Title }
     * {@link Style }
     * {@link com.pacificmetrics.saaif.tutorial.Object }
     * {@link Link }
     *
     *
     */
    public List<java.lang.Object> getContent() {
        if (content == null) {
            content = new ArrayList<java.lang.Object>();
        }
        return this.content;
    }

    /**
     * Gets the value of the id property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getId() {
        return id;
    }

    /**
     * Sets the value of the id property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setId(String value) {
        this.id = value;
    }

    /**
     * Gets the value of the profile property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getProfile() {
        return profile;
    }

    /**
     * Sets the value of the profile property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setProfile(String value) {
        this.profile = value;
    }

    /**
     * Gets the value of the langCode property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getLangCode() {
        return langCode;
    }

    /**
     * Sets the value of the langCode property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setLangCode(String value) {
        this.langCode = value;
    }

    /**
     * Gets the value of the lang property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getLang() {
        return lang;
    }

    /**
     * Sets the value of the lang property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setLang(String value) {
        this.lang = value;
    }

    /**
     * Gets the value of the dir property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getDir() {
        return dir;
    }

    /**
     * Sets the value of the dir property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setDir(String value) {
        this.dir = value;
    }

}


text:
"""Tests for certbot.crypto_util."""
import logging
import os
import unittest

import OpenSSL
import mock
import zope.component

from certbot import errors
from certbot import interfaces
from certbot import util
import certbot.tests.util as test_util

RSA256_KEY = test_util.load_vector('rsa256_key.pem')
RSA256_KEY_PATH = test_util.vector_path('rsa256_key.pem')
RSA512_KEY = test_util.load_vector('rsa512_key.pem')
RSA2048_KEY_PATH = test_util.vector_path('rsa2048_key.pem')
CERT_PATH = test_util.vector_path('cert_512.pem')
CERT = test_util.load_vector('cert_512.pem')
SS_CERT_PATH = test_util.vector_path('cert_2048.pem')
SS_CERT = test_util.load_vector('cert_2048.pem')

class InitSaveKeyTest(test_util.TempDirTestCase):
    """Tests for certbot.crypto_util.init_save_key."""
    def setUp(self):
        super(InitSaveKeyTest, self).setUp()

        logging.disable(logging.CRITICAL)
        zope.component.provideUtility(
            mock.Mock(strict_permissions=True), interfaces.IConfig)

    def tearDown(self):
        super(InitSaveKeyTest, self).tearDown()

        logging.disable(logging.NOTSET)

    @classmethod
    def _call(cls, key_size, key_dir):
        from certbot.crypto_util import init_save_key
        return init_save_key(key_size, key_dir, 'key-certbot.pem')

    @mock.patch('certbot.crypto_util.make_key')
    def test_success(self, mock_make):
        mock_make.return_value = b'key_pem'
        key = self._call(1024, self.tempdir)
        self.assertEqual(key.pem, b'key_pem')
        self.assertTrue('key-certbot.pem' in key.file)
        self.assertTrue(os.path.exists(os.path.join(self.tempdir, key.file)))

    @mock.patch('certbot.crypto_util.make_key')
    def test_key_failure(self, mock_make):
        mock_make.side_effect = ValueError
        self.assertRaises(ValueError, self._call, 431, self.tempdir)

class InitSaveCSRTest(test_util.TempDirTestCase):
    """Tests for certbot.crypto_util.init_save_csr."""

    def setUp(self):
        super(InitSaveCSRTest, self).setUp()

        zope.component.provideUtility(
            mock.Mock(strict_permissions=True), interfaces.IConfig)

    @mock.patch('acme.crypto_util.make_csr')
    @mock.patch('certbot.crypto_util.util.make_or_verify_dir')
    def test_it(self, unused_mock_verify, mock_csr):
        from certbot.crypto_util import init_save_csr

        mock_csr.return_value = b'csr_pem'

        csr = init_save_csr(
            mock.Mock(pem='dummy_key'), 'example.com', self.tempdir)

        self.assertEqual(csr.data, b'csr_pem')
        self.assertTrue('csr-certbot.pem' in csr.file)

class ValidCSRTest(unittest.TestCase):
    """Tests for certbot.crypto_util.valid_csr."""

    @classmethod
    def _call(cls, csr):
        from certbot.crypto_util import valid_csr
        return valid_csr(csr)

    def test_valid_pem_true(self):
        self.assertTrue(self._call(test_util.load_vector('csr_512.pem')))

    def test_valid_pem_san_true(self):
        self.assertTrue(self._call(test_util.load_vector('csr-san_512.pem')))

    def test_valid_der_false(self):
        self.assertFalse(self._call(test_util.load_vector('csr_512.der')))

    def test_empty_false(self):
        self.assertFalse(self._call(''))

    def test_random_false(self):
        self.assertFalse(self._call('foo bar'))

class CSRMatchesPubkeyTest(unittest.TestCase):
    """Tests for certbot.crypto_util.csr_matches_pubkey."""

    @classmethod
    def _call(cls, *args, **kwargs):
        from certbot.crypto_util import csr_matches_pubkey
        return csr_matches_pubkey(*args, **kwargs)

    def test_valid_true(self):
        self.assertTrue(self._call(
            test_util.load_vector('csr_512.pem'), RSA512_KEY))

    def test_invalid_false(self):
        self.assertFalse(self._call(
            test_util.load_vector('csr_512.pem'), RSA256_KEY))

class ImportCSRFileTest(unittest.TestCase):
    """Tests for certbot.certbot_util.import_csr_file."""

    @classmethod
    def _call(cls, *args, **kwargs):
        from certbot.crypto_util import import_csr_file
        return import_csr_file(*args, **kwargs)

    def test_der_csr(self):
        csrfile = test_util.vector_path('csr_512.der')
        data = test_util.load_vector('csr_512.der')
        data_pem = test_util.load_vector('csr_512.pem')

        self.assertEqual(
            (OpenSSL.crypto.FILETYPE_PEM,
             util.CSR(file=csrfile,
                      data=data_pem,
                      form="pem"),
             ["Example.com"],),
            self._call(csrfile, data))

    def test_pem_csr(self):
        csrfile = test_util.vector_path('csr_512.pem')
        data = test_util.load_vector('csr_512.pem')

        self.assertEqual(
            (OpenSSL.crypto.FILETYPE_PEM,
             util.CSR(file=csrfile,
                      data=data,
                      form="pem"),
             ["Example.com"],),
            self._call(csrfile, data))

    def test_bad_csr(self):
        self.assertRaises(errors.Error, self._call,
                          test_util.vector_path('cert_512.pem'),
                          test_util.load_vector('cert_512.pem'))

class MakeKeyTest(unittest.TestCase):  # pylint: disable=too-few-public-methods
    """Tests for certbot.crypto_util.make_key."""

    def test_it(self):  # pylint: disable=no-self-use
        from certbot.crypto_util import make_key
        # Do not test larger keys as it takes too long.
        OpenSSL.crypto.load_privatekey(
            OpenSSL.crypto.FILETYPE_PEM, make_key(1024))

class VerifyCertSetup(unittest.TestCase):
    """Refactoring for verification tests."""

    def setUp(self):
        super(VerifyCertSetup, self).setUp()

        self.renewable_cert = mock.MagicMock()
        self.renewable_cert.cert = SS_CERT_PATH
        self.renewable_cert.chain = SS_CERT_PATH
        self.renewable_cert.privkey = RSA2048_KEY_PATH
        self.renewable_cert.fullchain = test_util.vector_path('cert_fullchain_2048.pem')

        self.bad_renewable_cert = mock.MagicMock()
        self.bad_renewable_cert.chain = SS_CERT_PATH
        self.bad_renewable_cert.cert = SS_CERT_PATH
        self.bad_renewable_cert.fullchain = SS_CERT_PATH

class VerifyRenewableCertTest(VerifyCertSetup):
    """Tests for certbot.crypto_util.verify_renewable_cert."""

    def setUp(self):
        super(VerifyRenewableCertTest, self).setUp()

    def _call(self, renewable_cert):
        from certbot.crypto_util import verify_renewable_cert
        return verify_renewable_cert(renewable_cert)

    def test_verify_renewable_cert(self):
        self.assertEqual(None, self._call(self.renewable_cert))

    @mock.patch('certbot.crypto_util.verify_renewable_cert_sig', side_effect=errors.Error(""))
    def test_verify_renewable_cert_failure(self, unused_verify_renewable_cert_sign):
        self.assertRaises(errors.Error, self._call, self.bad_renewable_cert)

class VerifyRenewableCertSigTest(VerifyCertSetup):
    """Tests for certbot.crypto_util.verify_renewable_cert."""

    def setUp(self):
        super(VerifyRenewableCertSigTest, self).setUp()

    def _call(self, renewable_cert):
        from certbot.crypto_util import verify_renewable_cert_sig
        return verify_renewable_cert_sig(renewable_cert)

    def test_cert_sig_match(self):
        self.assertEqual(None, self._call(self.renewable_cert))

    def test_cert_sig_mismatch(self):
        self.bad_renewable_cert.cert = test_util.vector_path('cert_512_bad.pem')
        self.assertRaises(errors.Error, self._call, self.bad_renewable_cert)

class VerifyFullchainTest(VerifyCertSetup):
    """Tests for certbot.crypto_util.verify_fullchain."""

    def setUp(self):
        super(VerifyFullchainTest, self).setUp()

    def _call(self, renewable_cert):
        from certbot.crypto_util import verify_fullchain
        return verify_fullchain(renewable_cert)

    def test_fullchain_matches(self):
        self.assertEqual(None, self._call(self.renewable_cert))

    def test_fullchain_mismatch(self):
        self.assertRaises(errors.Error, self._call, self.bad_renewable_cert)

    def test_fullchain_ioerror(self):
        self.bad_renewable_cert.chain = "dog"
        self.assertRaises(errors.Error, self._call, self.bad_renewable_cert)

class VerifyCertMatchesPrivKeyTest(VerifyCertSetup):
    """Tests for certbot.crypto_util.verify_cert_matches_priv_key."""

    def setUp(self):
        super(VerifyCertMatchesPrivKeyTest, self).setUp()

    def _call(self, renewable_cert):
        from certbot.crypto_util import verify_cert_matches_priv_key
        return verify_cert_matches_priv_key(renewable_cert.cert, renewable_cert.privkey)

    def test_cert_priv_key_match(self):
        self.renewable_cert.cert = SS_CERT_PATH
        self.renewable_cert.privkey = RSA2048_KEY_PATH
        self.assertEqual(None, self._call(self.renewable_cert))

    def test_cert_priv_key_mismatch(self):
        self.bad_renewable_cert.privkey = RSA256_KEY_PATH
        self.bad_renewable_cert.cert = SS_CERT_PATH

        self.assertRaises(errors.Error, self._call, self.bad_renewable_cert)

class ValidPrivkeyTest(unittest.TestCase):
    """Tests for certbot.crypto_util.valid_privkey."""

    @classmethod
    def _call(cls, privkey):
        from certbot.crypto_util import valid_privkey
        return valid_privkey(privkey)

    def test_valid_true(self):
        self.assertTrue(self._call(RSA512_KEY))

    def test_empty_false(self):
        self.assertFalse(self._call(''))

    def test_random_false(self):
        self.assertFalse(self._call('foo bar'))

class GetSANsFromCertTest(unittest.TestCase):
    """Tests for certbot.crypto_util.get_sans_from_cert."""

    @classmethod
    def _call(cls, *args, **kwargs):
        from certbot.crypto_util import get_sans_from_cert
        return get_sans_from_cert(*args, **kwargs)

    def test_single(self):
        self.assertEqual([], self._call(test_util.load_vector('cert_512.pem')))

    def test_san(self):
        self.assertEqual(
            ['example.com', 'www.example.com'],
            self._call(test_util.load_vector('cert-san_512.pem')))

class GetNamesFromCertTest(unittest.TestCase):
    """Tests for certbot.crypto_util.get_names_from_cert."""

    @classmethod
    def _call(cls, *args, **kwargs):
        from certbot.crypto_util import get_names_from_cert
        return get_names_from_cert(*args, **kwargs)

    def test_single(self):
        self.assertEqual(
            ['example.com'],
            self._call(test_util.load_vector('cert_512.pem')))

    def test_san(self):
        self.assertEqual(
            ['example.com', 'www.example.com'],
            self._call(test_util.load_vector('cert-san_512.pem')))

    def test_common_name_sans_order(self):
        # Tests that the common name comes first
        # followed by the SANS in alphabetical order
        self.assertEqual(
            ['example.com'] + ['{0}.example.com'.format(c) for c in 'abcd'],
            self._call(test_util.load_vector('cert-5sans_512.pem')))

    def test_parse_non_cert(self):
        self.assertRaises(OpenSSL.crypto.Error, self._call, "hello there")

class CertLoaderTest(unittest.TestCase):
    """Tests for certbot.crypto_util.pyopenssl_load_certificate"""

    def test_load_valid_cert(self):
        from certbot.crypto_util import pyopenssl_load_certificate

        cert, file_type = pyopenssl_load_certificate(CERT)
        self.assertEqual(cert.digest('sha256'),
                         OpenSSL.crypto.load_certificate(file_type, CERT).digest('sha256'))

    def test_load_invalid_cert(self):
        from certbot.crypto_util import pyopenssl_load_certificate
        bad_cert_data = CERT.replace(b"BEGIN CERTIFICATE", b"ASDFASDFASDF!!!")
        self.assertRaises(
            errors.Error, pyopenssl_load_certificate, bad_cert_data)

class NotBeforeTest(unittest.TestCase):
    """Tests for certbot.crypto_util.notBefore"""

    def test_notBefore(self):
        from certbot.crypto_util import notBefore
        self.assertEqual(notBefore(CERT_PATH).isoformat(),
                         '2014-12-11T22:34:45+00:00')

class NotAfterTest(unittest.TestCase):
    """Tests for certbot.crypto_util.notAfter"""

    def test_notAfter(self):
        from certbot.crypto_util import notAfter
        self.assertEqual(notAfter(CERT_PATH).isoformat(),
                         '2014-12-18T22:34:45+00:00')

class Sha256sumTest(unittest.TestCase):
    """Tests for certbot.crypto_util.notAfter"""

    def test_sha256sum(self):
        from certbot.crypto_util import sha256sum
        self.assertEqual(sha256sum(CERT_PATH),
            '914ffed8daf9e2c99d90ac95c77d54f32cbd556672facac380f0c063498df84e')

if __name__ == '__main__':
    unittest.main()  # pragma: no cover


text:
/* @flow */

import React from 'react-native';
import oembed from '../extras/oembed/oembed';
import EmbedThumbnail from './EmbedThumbnail';
import EmbedTitle from './EmbedTitle';
import EmbedSummary from './EmbedSummary';
import Linking from '../modules/Linking';

const {
	TouchableOpacity,
	View
} = React;

export default class Embed extends React.Component {
	static propTypes = {
		data: React.PropTypes.object,
		url: React.PropTypes.string.isRequired,
		showThumbnail: React.PropTypes.bool,
		showTitle: React.PropTypes.bool,
		showSummary: React.PropTypes.bool,
		openOnPress: React.PropTypes.bool,
		containerStyle: React.PropTypes.any,
		thumbnailStyle: React.PropTypes.any,
		titleStyle: React.PropTypes.any,
		summaryStyle: React.PropTypes.any
	};

	static defaultProps = {
		openOnPress: true
	};

	state = {
		embed: null
	};

	componentWillMount() {
		this._fetchData();
	}

	componentDidMount() {
		this._mounted = true;
	}

	componentWillUnmount() {
		this._mounted = false;
	}

	_handlePress = () => {
		Linking.openURL(this.props.url);
	};

	_fetchData = () => {
		if (this.props.data) {
			this.setState({
				embed: this.props.data
			});
		} else {
			this._fetchEmbedData(this.props.url);
		}
	};

	_fetchEmbedData = async url => {
		try {
			const embed = await oembed.get(url);

			if (this._mounted) {
				this.setState({
					embed
				});
			}
		} catch (e) {
			// Ignore
		}
	};

	render() {
		const { embed } = this.state;

		if (typeof embed === 'object' && embed !== null) {
			const embedItem = (
				<View>
					{this.props.showThumbnail !== false ?
						<EmbedThumbnail embed={embed} style={this.props.thumbnailStyle} /> :
						null
					}

					{this.props.showTitle !== false ?
						<EmbedTitle embed={embed} style={this.props.titleStyle} /> :
						null
					}

					{this.props.showSummary !== false ?
						<EmbedSummary embed={embed} style={this.props.summaryStyle} /> :
						null
					}
				</View>
			);

			if (this.props.openOnPress === false) {
				return (
					<View {...this.props}>
						{embedItem}
					</View>
				);
			} else {
				return (
					<TouchableOpacity {...this.props} onPress={this._handlePress}>
						{embedItem}
					</TouchableOpacity>
				);
			}
		} else {
			return null;
		}
	}
}