text:
#ifndef QT3DEXTRAS_QTORUSGEOMETRY_H
#define QT3DEXTRAS_QTORUSGEOMETRY_H

#include <Qt3DExtras/qt3dextras_global.h>
#include <Qt3DRender/qgeometry.h>

QT_BEGIN_NAMESPACE

namespace Qt3DRender {

class QAttribute;

} // Qt3DRender

namespace Qt3DExtras {

class QTorusGeometryPrivate;

class QT3DEXTRASSHARED_EXPORT QTorusGeometry : public Qt3DRender::QGeometry
{
    Q_OBJECT
    Q_PROPERTY(int rings READ rings WRITE setRings NOTIFY ringsChanged)
    Q_PROPERTY(int slices READ slices WRITE setSlices NOTIFY slicesChanged)
    Q_PROPERTY(float radius READ radius WRITE setRadius NOTIFY radiusChanged)
    Q_PROPERTY(float minorRadius READ minorRadius WRITE setMinorRadius NOTIFY minorRadiusChanged)
    Q_PROPERTY(Qt3DRender::QAttribute *positionAttribute READ positionAttribute CONSTANT)
    Q_PROPERTY(Qt3DRender::QAttribute *normalAttribute READ normalAttribute CONSTANT)
    Q_PROPERTY(Qt3DRender::QAttribute *texCoordAttribute READ texCoordAttribute CONSTANT)
    Q_PROPERTY(Qt3DRender::QAttribute *indexAttribute READ indexAttribute CONSTANT)

public:
    explicit QTorusGeometry(QNode *parent = nullptr);
    ~QTorusGeometry();

    void updateVertices();
    void updateIndices();

    int rings() const;
    int slices() const;
    float radius() const;
    float minorRadius() const;

    Qt3DRender::QAttribute *positionAttribute() const;
    Qt3DRender::QAttribute *normalAttribute() const;
    Qt3DRender::QAttribute *texCoordAttribute() const;
    Qt3DRender::QAttribute *indexAttribute() const;

public Q_SLOTS:
    void setRings(int rings);
    void setSlices(int slices);
    void setRadius(float radius);
    void setMinorRadius(float minorRadius);

Q_SIGNALS:
    void radiusChanged(float radius);
    void ringsChanged(int rings);
    void slicesChanged(int slices);
    void minorRadiusChanged(float minorRadius);

protected:
    QTorusGeometry(QTorusGeometryPrivate &dd, QNode *parent = nullptr);

private:
    Q_DECLARE_PRIVATE(QTorusGeometry)
};

} // Qt3DExtras

QT_END_NAMESPACE

#endif // QT3DEXTRAS_QTORUSGEOMETRY_H


text:
package org.hisp.dhis.webapi.controller;

import com.google.common.collect.Lists;
import org.hisp.dhis.common.AuditType;
import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.common.Pager;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.datavalue.DataValueAudit;
import org.hisp.dhis.datavalue.DataValueAuditService;
import org.hisp.dhis.dxf2.webmessage.WebMessageException;
import org.hisp.dhis.fieldfilter.FieldFilterService;
import org.hisp.dhis.node.NodeUtils;
import org.hisp.dhis.node.Preset;
import org.hisp.dhis.node.types.CollectionNode;
import org.hisp.dhis.node.types.RootNode;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.program.ProgramStageInstance;
import org.hisp.dhis.program.ProgramStageInstanceService;
import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
import org.hisp.dhis.trackedentity.TrackedEntityInstance;
import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValueAudit;
import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValueAuditService;
import org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValueAudit;
import org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValueAuditService;
import org.hisp.dhis.webapi.mvc.annotation.ApiVersion;
import org.hisp.dhis.webapi.service.ContextService;
import org.hisp.dhis.webapi.utils.WebMessageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

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

/**
 * @author Morten Olav Hansen <mortenoh@gmail.com>
 */
@Controller
@RequestMapping( value = "/audits", method = RequestMethod.GET )
@ApiVersion( { ApiVersion.Version.DEFAULT, ApiVersion.Version.ALL } )
public class AuditController
{
    @Autowired
    private IdentifiableObjectManager manager;

    @Autowired
    private ProgramStageInstanceService programStageInstanceService;

    @Autowired
    private DataValueAuditService dataValueAuditService;

    @Autowired
    private TrackedEntityDataValueAuditService trackedEntityDataValueAuditService;

    @Autowired
    private TrackedEntityAttributeValueAuditService trackedEntityAttributeValueAuditService;

    @Autowired
    private FieldFilterService fieldFilterService;

    @Autowired
    private ContextService contextService;

    @RequestMapping( value = "dataValue", method = RequestMethod.GET )
    public @ResponseBody RootNode getAggregateDataValueAudit(
        @RequestParam( required = false, defaultValue = "" ) List<String> ds,
        @RequestParam( required = false, defaultValue = "" ) List<String> de,
        @RequestParam( required = false, defaultValue = "" ) List<String> pe,
        @RequestParam( required = false, defaultValue = "" ) List<String> ou,
        @RequestParam( required = false ) String co,
        @RequestParam( required = false ) String cc,
        @RequestParam( required = false ) AuditType auditType,
        @RequestParam( required = false ) boolean skipPaging,
        @RequestParam( required = false, defaultValue = "50" ) int pageSize,
        @RequestParam( required = false, defaultValue = "1" ) int page
    ) throws WebMessageException
    {
        List<String> fields = Lists.newArrayList( contextService.getParameterValues( "fields" ) );

        if ( fields.isEmpty() )
        {
            fields.addAll( Preset.ALL.getFields() );
        }

        List<DataElement> dataElements = new ArrayList<>();
        dataElements.addAll( getDataElements( de ) );
        dataElements.addAll( getDataElementsByDataSet( ds ) );

        List<Period> periods = getPeriods( pe );
        List<OrganisationUnit> organisationUnits = getOrganisationUnit( ou );
        DataElementCategoryOptionCombo categoryOptionCombo = getCategoryOptionCombo( co );
        DataElementCategoryOptionCombo attributeOptionCombo = getAttributeOptionCombo( cc );

        List<DataValueAudit> dataValueAudits;
        Pager pager = null;

        if ( skipPaging )
        {
            dataValueAudits = dataValueAuditService.getDataValueAudits( dataElements, periods,
                organisationUnits, categoryOptionCombo, attributeOptionCombo, auditType );
        }
        else
        {
            int total = dataValueAuditService.countDataValueAudits( dataElements, periods, organisationUnits, categoryOptionCombo,
                attributeOptionCombo, auditType );

            pager = new Pager( page, total, pageSize );

            dataValueAudits = dataValueAuditService.getDataValueAudits( dataElements, periods,
                organisationUnits, categoryOptionCombo, attributeOptionCombo, auditType, pager.getOffset(), pager.getPageSize() );
        }

        RootNode rootNode = NodeUtils.createMetadata();

        if ( pager != null )
        {
            rootNode.addChild( NodeUtils.createPager( pager ) );
        }

        CollectionNode trackedEntityAttributeValueAudits = rootNode.addChild( new CollectionNode( "dataValueAudits", true ) );
        trackedEntityAttributeValueAudits.addChildren( fieldFilterService.filter( DataValueAudit.class,
            dataValueAudits, fields ).getChildren() );

        return rootNode;
    }

    @RequestMapping( value = "trackedEntityDataValue", method = RequestMethod.GET )
    public @ResponseBody RootNode getTrackedEntityDataValueAudit(
        @RequestParam( required = false, defaultValue = "" ) List<String> de,
        @RequestParam( required = false, defaultValue = "" ) List<String> psi,
        @RequestParam( required = false ) AuditType auditType,
        @RequestParam( required = false ) boolean skipPaging,
        @RequestParam( required = false, defaultValue = "50" ) int pageSize,
        @RequestParam( required = false, defaultValue = "1" ) int page
    ) throws WebMessageException
    {
        List<String> fields = Lists.newArrayList( contextService.getParameterValues( "fields" ) );

        if ( fields.isEmpty() )
        {
            fields.addAll( Preset.ALL.getFields() );
        }

        List<DataElement> dataElements = getDataElements( de );
        List<ProgramStageInstance> programStageInstances = getProgramStageInstances( psi );

        List<TrackedEntityDataValueAudit> dataValueAudits;
        Pager pager = null;

        if ( skipPaging )
        {
            dataValueAudits = trackedEntityDataValueAuditService.getTrackedEntityDataValueAudits(
                dataElements, programStageInstances, auditType );
        }
        else
        {
            int total = trackedEntityDataValueAuditService.countTrackedEntityDataValueAudits( dataElements, programStageInstances, auditType );

            pager = new Pager( page, total, pageSize );

            dataValueAudits = trackedEntityDataValueAuditService.getTrackedEntityDataValueAudits(
                dataElements, programStageInstances, auditType, pager.getOffset(), pager.getPageSize() );
        }

        RootNode rootNode = NodeUtils.createMetadata();

        if ( pager != null )
        {
            rootNode.addChild( NodeUtils.createPager( pager ) );
        }

        CollectionNode trackedEntityAttributeValueAudits = rootNode.addChild( new CollectionNode( "trackedEntityDataValueAudits", true ) );
        trackedEntityAttributeValueAudits.addChildren( fieldFilterService.filter( TrackedEntityDataValueAudit.class,
            dataValueAudits, fields ).getChildren() );

        return rootNode;
    }

    @RequestMapping( value = "trackedEntityAttributeValue", method = RequestMethod.GET )
    public @ResponseBody RootNode getTrackedEntityAttributeValueAudit(
        @RequestParam( required = false, defaultValue = "" ) List<String> tea,
        @RequestParam( required = false, defaultValue = "" ) List<String> tei,
        @RequestParam( required = false ) AuditType auditType,
        @RequestParam( required = false ) boolean skipPaging,
        @RequestParam( required = false, defaultValue = "50" ) int pageSize,
        @RequestParam( required = false, defaultValue = "1" ) int page
    ) throws WebMessageException
    {
        List<String> fields = Lists.newArrayList( contextService.getParameterValues( "fields" ) );

        List<TrackedEntityAttribute> trackedEntityAttributes = getTrackedEntityAttributes( tea );
        List<TrackedEntityInstance> trackedEntityInstances = getTrackedEntityInstances( tei );

        List<TrackedEntityAttributeValueAudit> attributeValueAudits;
        Pager pager = null;

        if ( skipPaging )
        {
            attributeValueAudits = trackedEntityAttributeValueAuditService.getTrackedEntityAttributeValueAudits(
                trackedEntityAttributes, trackedEntityInstances, auditType );
        }
        else
        {
            int total = trackedEntityAttributeValueAuditService.countTrackedEntityAttributeValueAudits( trackedEntityAttributes,
                trackedEntityInstances, auditType );

            pager = new Pager( page, total, pageSize );

            attributeValueAudits = trackedEntityAttributeValueAuditService.getTrackedEntityAttributeValueAudits(
                trackedEntityAttributes, trackedEntityInstances, auditType, pager.getOffset(), pager.getPageSize() );
        }

        RootNode rootNode = NodeUtils.createMetadata();

        if ( pager != null )
        {
            rootNode.addChild( NodeUtils.createPager( pager ) );
        }

        CollectionNode trackedEntityAttributeValueAudits = rootNode.addChild( new CollectionNode( "trackedEntityAttributeValueAudits", true ) );
        trackedEntityAttributeValueAudits.addChildren( fieldFilterService.filter( TrackedEntityAttributeValueAudit.class,
            attributeValueAudits, fields ).getChildren() );

        return rootNode;
    }

    //-----------------------------------------------------------------------------------------------------------------
    // Helpers
    //-----------------------------------------------------------------------------------------------------------------

    private List<TrackedEntityInstance> getTrackedEntityInstances( List<String> teiIdentifiers ) throws WebMessageException
    {
        List<TrackedEntityInstance> trackedEntityInstances = new ArrayList<>();

        for ( String tei : teiIdentifiers )
        {
            TrackedEntityInstance trackedEntityInstance = getTrackedEntityInstance( tei );

            if ( trackedEntityInstance != null )
            {
                trackedEntityInstances.add( trackedEntityInstance );
            }
        }

        return trackedEntityInstances;
    }

    private TrackedEntityInstance getTrackedEntityInstance( String tei ) throws WebMessageException
    {
        if ( tei == null )
        {
            return null;
        }

        TrackedEntityInstance trackedEntityInstance = manager.get( TrackedEntityInstance.class, tei );

        if ( trackedEntityInstance == null )
        {
            throw new WebMessageException( WebMessageUtils.conflict( "Illegal trackedEntityInstance identifier: " + tei ) );
        }

        return trackedEntityInstance;
    }

    private List<TrackedEntityAttribute> getTrackedEntityAttributes( List<String> teaIdentifiers ) throws WebMessageException
    {
        List<TrackedEntityAttribute> trackedEntityAttributes = new ArrayList<>();

        for ( String tea : teaIdentifiers )
        {
            TrackedEntityAttribute trackedEntityAttribute = getTrackedEntityAttribute( tea );

            if ( trackedEntityAttribute != null )
            {
                trackedEntityAttributes.add( trackedEntityAttribute );
            }
        }

        return trackedEntityAttributes;
    }

    private TrackedEntityAttribute getTrackedEntityAttribute( String tea ) throws WebMessageException
    {
        if ( tea == null )
        {
            return null;
        }

        TrackedEntityAttribute trackedEntityAttribute = manager.get( TrackedEntityAttribute.class, tea );

        if ( trackedEntityAttribute == null )
        {
            throw new WebMessageException( WebMessageUtils.conflict( "Illegal trackedEntityAttribute identifier: " + tea ) );
        }

        return trackedEntityAttribute;
    }

    private List<ProgramStageInstance> getProgramStageInstances( List<String> psIdentifiers ) throws WebMessageException
    {
        List<ProgramStageInstance> programStageInstances = new ArrayList<>();

        for ( String ps : psIdentifiers )
        {
            ProgramStageInstance programStageInstance = getProgramStageInstance( ps );

            if ( programStageInstance != null )
            {
                programStageInstances.add( programStageInstance );
            }
        }

        return programStageInstances;
    }

    private ProgramStageInstance getProgramStageInstance( String ps ) throws WebMessageException
    {
        if ( ps == null )
        {
            return null;
        }

        ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( ps );

        if ( programStageInstance == null )
        {
            throw new WebMessageException( WebMessageUtils.conflict( "Illegal programStageInstance identifier: " + ps ) );
        }

        return programStageInstance;
    }

    private List<DataElement> getDataElementsByDataSet( List<String> dsIdentifiers ) throws WebMessageException
    {
        List<DataElement> dataElements = new ArrayList<>();

        for ( String ds : dsIdentifiers )
        {
            DataSet dataSet = manager.get( DataSet.class, ds );

            if ( dataSet == null )
            {
                throw new WebMessageException( WebMessageUtils.conflict( "Illegal dataSet identifier: " + ds ) );
            }

            dataElements.addAll( dataSet.getDataElements() );
        }

        return dataElements;
    }

    private List<DataElement> getDataElements( List<String> deIdentifier ) throws WebMessageException
    {
        List<DataElement> dataElements = new ArrayList<>();

        for ( String de : deIdentifier )
        {
            DataElement dataElement = getDataElement( de );

            if ( dataElement != null )
            {
                dataElements.add( dataElement );
            }
        }

        return dataElements;
    }

    private DataElement getDataElement( String de ) throws WebMessageException
    {
        if ( de == null )
        {
            return null;
        }

        DataElement dataElement = manager.search( DataElement.class, de );

        if ( dataElement == null )
        {
            throw new WebMessageException( WebMessageUtils.conflict( "Illegal dataElement identifier: " + de ) );
        }

        return dataElement;
    }

    private List<Period> getPeriods( List<String> peIdentifiers ) throws WebMessageException
    {
        List<Period> periods = new ArrayList<>();

        for ( String pe : peIdentifiers )
        {
            Period period = PeriodType.getPeriodFromIsoString( pe );

            if ( period == null )
            {
                throw new WebMessageException( WebMessageUtils.conflict( "Illegal period identifier: " + pe ) );
            }
        }

        return periods;
    }

    private List<OrganisationUnit> getOrganisationUnit( List<String> ou ) throws WebMessageException
    {
        if ( ou == null )
        {
            return new ArrayList<>();
        }

        return manager.getByUid( OrganisationUnit.class, ou );
    }

    private DataElementCategoryOptionCombo getCategoryOptionCombo( @RequestParam String co ) throws WebMessageException
    {
        if ( co == null )
        {
            return null;
        }

        DataElementCategoryOptionCombo categoryOptionCombo = manager.search( DataElementCategoryOptionCombo.class, co );

        if ( categoryOptionCombo == null )
        {
            throw new WebMessageException( WebMessageUtils.conflict( "Illegal categoryOptionCombo identifier: " + co ) );
        }

        return categoryOptionCombo;
    }

    private DataElementCategoryOptionCombo getAttributeOptionCombo( @RequestParam String cc ) throws WebMessageException
    {
        if ( cc == null )
        {
            return null;
        }

        DataElementCategoryOptionCombo attributeOptionCombo = manager.search( DataElementCategoryOptionCombo.class, cc );

        if ( attributeOptionCombo == null )
        {
            throw new WebMessageException( WebMessageUtils.conflict( "Illegal attributeOptionCombo identifier: " + cc ) );
        }

        return attributeOptionCombo;
    }
}

redpajama_set_name: RedPajamaGithub


text:
using System.Threading.Tasks;
using Content.Server.Destructible.Thresholds.Triggers;
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.FixedPoint;
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using static Content.IntegrationTests.Tests.Destructible.DestructibleTestPrototypes;

namespace Content.IntegrationTests.Tests.Destructible
{
    [TestFixture]
    [TestOf(typeof(DamageGroupTrigger))]
    [TestOf(typeof(AndTrigger))]
    public sealed class DestructibleDamageGroupTest
    {
        [Test]
        public async Task AndTest()
        {
            await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true, ExtraPrototypes = Prototypes});
            var server = pairTracker.Pair.Server;

            var testMap = await PoolManager.CreateTestMap(pairTracker);

            var sEntityManager = server.ResolveDependency<IEntityManager>();
            var sPrototypeManager = server.ResolveDependency<IPrototypeManager>();
            var sEntitySystemManager = server.ResolveDependency<IEntitySystemManager>();

            EntityUid sDestructibleEntity = default;
            DamageableComponent sDamageableComponent = null;
            TestDestructibleListenerSystem sTestThresholdListenerSystem = null;
            DamageableSystem sDamageableSystem = null;

            await server.WaitPost(() =>
            {
                var coordinates = testMap.GridCoords;

                sDestructibleEntity = sEntityManager.SpawnEntity(DestructibleDamageGroupEntityId, coordinates);
                sDamageableComponent = IoCManager.Resolve<IEntityManager>().GetComponent<DamageableComponent>(sDestructibleEntity);

                sTestThresholdListenerSystem = sEntitySystemManager.GetEntitySystem<TestDestructibleListenerSystem>();
                sTestThresholdListenerSystem.ThresholdsReached.Clear();

                sDamageableSystem = sEntitySystemManager.GetEntitySystem<DamageableSystem>();
            });

            await server.WaitRunTicks(5);

            await server.WaitAssertion(() =>
            {
                Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
            });

            await server.WaitAssertion(() =>
            {
                var bruteDamageGroup = sPrototypeManager.Index<DamageGroupPrototype>("TestBrute");
                var burnDamageGroup = sPrototypeManager.Index<DamageGroupPrototype>("TestBurn");

                DamageSpecifier bruteDamage = new(bruteDamageGroup, FixedPoint2.New(5));
                DamageSpecifier burnDamage = new(burnDamageGroup, FixedPoint2.New(5));

                // Raise brute damage to 5
                sDamageableSystem.TryChangeDamage(sDestructibleEntity, bruteDamage, true);

                // No thresholds reached yet, the earliest one is at 10 damage
                Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);

                // Raise brute damage to 10
                sDamageableSystem.TryChangeDamage(sDestructibleEntity, bruteDamage, true);

                // No threshold reached, burn needs to be 10 as well
                Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);

                // Raise burn damage to 10
                sDamageableSystem.TryChangeDamage(sDestructibleEntity, burnDamage * 2, true);

                // One threshold reached, brute 10 + burn 10
                Assert.That(sTestThresholdListenerSystem.ThresholdsReached.Count, Is.EqualTo(1));

                // Threshold brute 10 + burn 10
                var msg = sTestThresholdListenerSystem.ThresholdsReached[0];
                var threshold = msg.Threshold;

                // Check that it matches the YAML prototype
                Assert.That(threshold.Behaviors, Is.Empty);
                Assert.NotNull(threshold.Trigger);
                Assert.That(threshold.Triggered, Is.True);
                Assert.IsInstanceOf<AndTrigger>(threshold.Trigger);

                var trigger = (AndTrigger) threshold.Trigger;

                Assert.IsInstanceOf<DamageGroupTrigger>(trigger.Triggers[0]);
                Assert.IsInstanceOf<DamageGroupTrigger>(trigger.Triggers[1]);

                sTestThresholdListenerSystem.ThresholdsReached.Clear();

                // Raise brute damage to 20
                sDamageableSystem.TryChangeDamage(sDestructibleEntity, bruteDamage * 2, true);

                // No new thresholds reached
                Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);

                // Raise burn damage to 20
                sDamageableSystem.TryChangeDamage(sDestructibleEntity, burnDamage * 2, true);

                // No new thresholds reached
                Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);

                // Lower brute damage to 0
                sDamageableSystem.TryChangeDamage(sDestructibleEntity, bruteDamage * -10);
                Assert.That(sDamageableComponent.TotalDamage,Is.EqualTo(FixedPoint2.New(20)));

                // No new thresholds reached, healing should not trigger it
                Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);

                // Raise brute damage back up to 10
                sDamageableSystem.TryChangeDamage(sDestructibleEntity, bruteDamage * 2, true);

                // 10 brute + 10 burn threshold reached, brute was healed and brought back to its threshold amount and slash stayed the same
                Assert.That(sTestThresholdListenerSystem.ThresholdsReached.Count, Is.EqualTo(1));

                sTestThresholdListenerSystem.ThresholdsReached.Clear();

                // Heal both classes of damage to 0
                sDamageableSystem.SetAllDamage(sDamageableComponent, 0);

                // No new thresholds reached, healing should not trigger it
                Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);

                // Raise brute damage to 10
                sDamageableSystem.TryChangeDamage(sDestructibleEntity, bruteDamage * 2, true);

                // No new thresholds reached
                Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);

                // Raise burn damage to 10
                sDamageableSystem.TryChangeDamage(sDestructibleEntity, burnDamage * 2, true);

                // Both classes of damage were healed and then raised again, the threshold should have been reached as triggers once is default false
                Assert.That(sTestThresholdListenerSystem.ThresholdsReached.Count, Is.EqualTo(1));

                // Threshold brute 10 + burn 10
                msg = sTestThresholdListenerSystem.ThresholdsReached[0];
                threshold = msg.Threshold;

                // Check that it matches the YAML prototype
                Assert.That(threshold.Behaviors, Is.Empty);
                Assert.NotNull(threshold.Trigger);
                Assert.That(threshold.Triggered, Is.True);
                Assert.IsInstanceOf<AndTrigger>(threshold.Trigger);

                trigger = (AndTrigger) threshold.Trigger;

                Assert.IsInstanceOf<DamageGroupTrigger>(trigger.Triggers[0]);
                Assert.IsInstanceOf<DamageGroupTrigger>(trigger.Triggers[1]);

                sTestThresholdListenerSystem.ThresholdsReached.Clear();

                // Change triggers once to true
                threshold.TriggersOnce = true;

                // Heal brute and burn back to 0
                sDamageableSystem.SetAllDamage(sDamageableComponent, 0);

                // No new thresholds reached from healing
                Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);

                // Raise brute damage to 10
                sDamageableSystem.TryChangeDamage(sDestructibleEntity, bruteDamage * 2, true);

                // No new thresholds reached
                Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);

                // Raise burn damage to 10
                sDamageableSystem.TryChangeDamage(sDestructibleEntity, burnDamage * 2, true);

                // No new thresholds reached as triggers once is set to true and it already triggered before
                Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
            });
            await pairTracker.CleanReturnAsync();
        }
    }
}


text:
<?php
namespace Mcwork\Mapper\Assets;

use ContentinumComponents\Storage\StorageDirectory;

class Collections extends StorageDirectory
{

    public function __construct($storageManager)
    {
        $this->setStorage($storageManager);
    }

    public function fetchContent(array $params = null)
    {
        $file = null;
        if (isset($params['article']) && strlen($params['article']) > 1) {
            return new \Zend\Config\Config(include $this->getStorage()->getDocumentRoot() . DS . $this->getEntity()->getCurrentPath() . DS . $params['article'] . '.php', true);
        } else {
            return new \Zend\Config\Config(array());
        }
    }

    /**
     *
     * @param array $params
     * @param string $posts
     */
    public function processRequest(array $params = null, $posts = null)
    {
        return $this->fetchContent($params);
    }
}


text:
require 'spec_helper'
require 'whois/record/parser/whois.nic.it.rb'

describe Whois::Record::Parser::WhoisNicIt, "status_unavailable.expected" do

  subject do
    file = fixture("responses", "whois.nic.it/it/status_unavailable.txt")
    part = Whois::Record::Part.new(body: File.read(file))
    described_class.new(part)
  end

  describe "#status" do
    it do
      expect(subject.status).to eq(:unavailable)
    end
  end
  describe "#available?" do
    it do
      expect(subject.available?).to eq(false)
    end
  end
  describe "#registered?" do
    it do
      expect(subject.registered?).to eq(false)
    end
  end
end


text:
package org.mifos.accounts.loan.business.service;

import static java.util.Arrays.asList;
import static junit.framework.Assert.assertEquals;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;

import junit.framework.Assert;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mifos.accounts.business.AccountActionDateEntity;
import org.mifos.accounts.business.AccountBO;
import org.mifos.accounts.business.AccountPaymentEntity;
import org.mifos.accounts.loan.business.LoanBO;
import org.mifos.accounts.loan.business.LoanScheduleEntity;
import org.mifos.accounts.loan.business.OriginalLoanScheduleEntity;
import org.mifos.accounts.loan.business.ScheduleCalculatorAdaptor;
import org.mifos.accounts.loan.business.ScheduleMapper;
import org.mifos.accounts.loan.business.matchers.OriginalLoanScheduleEntitiesMatcher;
import org.mifos.accounts.loan.persistance.LegacyLoanDao;
import org.mifos.accounts.loan.schedule.calculation.ScheduleCalculator;
import org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm;
import org.mifos.accounts.loan.util.helpers.LoanConstants;
import org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment;
import org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallmentBuilder;
import org.mifos.accounts.productdefinition.util.helpers.InterestType;
import org.mifos.accounts.util.helpers.PaymentData;
import org.mifos.accounts.util.helpers.PaymentStatus;
import org.mifos.application.holiday.business.service.HolidayService;
import org.mifos.application.master.business.InterestTypesEntity;
import org.mifos.application.master.business.MifosCurrency;
import org.mifos.config.business.service.ConfigurationBusinessService;
import org.mifos.config.persistence.ConfigurationPersistence;
import org.mifos.customers.business.CustomerBO;
import org.mifos.customers.personnel.business.PersonnelBO;
import org.mifos.framework.TestUtils;
import org.mifos.framework.exceptions.PersistenceException;
import org.mifos.framework.util.helpers.DateUtils;
import org.mifos.framework.util.helpers.Money;
import org.mifos.platform.validations.ErrorEntry;
import org.mifos.platform.validations.Errors;
import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;

@RunWith(MockitoJUnitRunner.class)
public class LoanBusinessServiceTest {
    private Locale locale;
    private RepaymentScheduleInstallmentBuilder installmentBuilder;
    private MifosCurrency rupee;

    @Mock
    private LoanBusinessService loanBusinessService;

    @Mock
    private LoanBO loanBO;

    @Mock
    private HolidayService holidayService;

    @Mock
    private AccountPaymentEntity accountPaymentEntity;

    @Mock
    ScheduleCalculatorAdaptor scheduleCalculatorAdaptor;

    @Mock
    private PaymentData paymentData;

    @Mock
    private PersonnelBO personnel;

    @Mock
    private LegacyLoanDao legacyLoanDao;
    private Short officeId;

    @Mock
    private ConfigurationBusinessService configService;

    @Before
    public void setupAndInjectDependencies() {
        loanBusinessService = new LoanBusinessService(legacyLoanDao, configService, null, holidayService, scheduleCalculatorAdaptor);
        locale = new Locale("en", "GB");
        installmentBuilder = new RepaymentScheduleInstallmentBuilder(locale);
        rupee = new MifosCurrency(Short.valueOf("1"), "Rupee", BigDecimal.valueOf(1), "INR");
        officeId = Short.valueOf("1");
    }

    @Test
    public void shouldApplyPaymentForInterestRecalculationLoanInterestType() {
        when(loanBO.isDecliningBalanceInterestRecalculation()).thenReturn(true);
        Date transactionDate = new Date();
        Money totalAmount = new Money(rupee, 10.0);
        when(paymentData.getTransactionDate()).thenReturn(transactionDate);
        when(paymentData.getTotalAmount()).thenReturn(totalAmount);
        when(paymentData.getPersonnel()).thenReturn(personnel);
        loanBusinessService.applyPayment(paymentData, loanBO, accountPaymentEntity);
        verify(scheduleCalculatorAdaptor, times(1)).applyPayment(loanBO, totalAmount,
                transactionDate, personnel, accountPaymentEntity, false);
        verify(loanBO, times(1)).isDecliningBalanceInterestRecalculation();
        verify(paymentData).getTransactionDate();
        verify(paymentData).getTotalAmount();
        verify(paymentData).getPersonnel();
    }

    @Test
    public void shouldApplyPaymentForNonInterestRecalculationLoanInterestType() {
        when(loanBO.isDecliningBalanceInterestRecalculation()).thenReturn(false);
        List<AccountActionDateEntity> installments = new ArrayList<AccountActionDateEntity>();
        LoanScheduleEntity installment1 = mock(LoanScheduleEntity.class);
        LoanScheduleEntity installment2 = mock(LoanScheduleEntity.class);
        when(installment1.applyPayment(Mockito.<AccountPaymentEntity>any(), Mockito.<Money>any(), Mockito.eq(personnel), Mockito.<Date>any())).thenReturn(new Money(rupee, 100d));
        when(installment2.applyPayment(Mockito.<AccountPaymentEntity>any(), Mockito.<Money>any(), Mockito.eq(personnel), Mockito.<Date>any())).thenReturn(new Money(rupee, 0d));
        installments.add(installment1);
        installments.add(installment2);
        when(loanBO.getAccountActionDatesSortedByInstallmentId()).thenReturn(installments);
        Date transactionDate = new Date();
        Money totalAmount = new Money(rupee, 10.0);
        when(paymentData.getTransactionDate()).thenReturn(transactionDate);
        when(paymentData.getTotalAmount()).thenReturn(totalAmount);
        when(paymentData.getPersonnel()).thenReturn(personnel);
        loanBusinessService.applyPayment(paymentData, loanBO, accountPaymentEntity);
        verify(scheduleCalculatorAdaptor, times(0)).applyPayment(loanBO, totalAmount,
                transactionDate, personnel, accountPaymentEntity, false);
        verify(loanBO, times(1)).getAccountActionDatesSortedByInstallmentId();
        verify(loanBO, times(1)).isDecliningBalanceInterestRecalculation();
        verify(paymentData).getTransactionDate();
        verify(paymentData).getTotalAmount();
        verify(paymentData).getPersonnel();
        verify(installment1).applyPayment(Matchers.<AccountPaymentEntity>any(), Matchers.<Money>any(), Matchers.eq(personnel), Matchers.<Date>any());
        verify(installment2).applyPayment(Matchers.<AccountPaymentEntity>any(), Matchers.<Money>any(), Matchers.eq(personnel), Matchers.<Date>any());
    }

    @Test
    public void shouldComputeVariableInstallmentScheduleForVariableInstallmentsIfVariableInstallmentsIsEnabled() throws Exception {
        RepaymentScheduleInstallment installment1 =
                getRepaymentScheduleInstallment("01-Sep-2010", 1, "94.4", "4.6", "1", "75", "0", "0");
        RepaymentScheduleInstallment installment2 =
                getRepaymentScheduleInstallment("08-Sep-2010", 2, "94.8", "4.2", "1", "100", "0", "0");
        RepaymentScheduleInstallment installment3 =
                getRepaymentScheduleInstallment("15-Sep-2010", 3, "95.3", "3.7", "1", "100", "0", "0");
        LoanAccountActionForm loanAccountActionForm = mock(LoanAccountActionForm.class);
        List<RepaymentScheduleInstallment> installments = asList(installment1, installment2, installment3);
        when(loanAccountActionForm.getLoanAmount()).thenReturn("1000");
        when(loanAccountActionForm.getLoanAmountValue()).thenReturn(new Money(rupee, "1000"));
        when(loanAccountActionForm.getInterestRate()).thenReturn("24");
        when(loanAccountActionForm.isVariableInstallmentsAllowed()).thenReturn(true);
        when(legacyLoanDao.findBySystemId(anyString())).thenReturn(loanBO);
        when(loanBO.toRepaymentScheduleDto(locale)).thenReturn(installments);
        loanBusinessService.
                applyDailyInterestRatesWhereApplicable(new LoanScheduleGenerationDto(TestUtils.getDate(22, 8, 2010),
                        loanBO, loanAccountActionForm.isVariableInstallmentsAllowed(), loanAccountActionForm.getLoanAmountValue(),
                loanAccountActionForm.getInterestDoubleValue()), locale);
        verify(loanBO).updateInstallmentSchedule(installments);
        verify(loanBO).toRepaymentScheduleDto(locale);
    }

    @Test
    public void shouldComputeVariableInstallmentScheduleForVariableInstallmentsIfVariableInstallmentsIsEnabledAndInstallmentsArePassed() {
        RepaymentScheduleInstallment installment1 =
                getRepaymentScheduleInstallment("01-Sep-2010", 1, "94.4", "4.6", "1", "75", "0", "0");
        RepaymentScheduleInstallment installment2 =
                getRepaymentScheduleInstallment("08-Sep-2010", 2, "94.8", "4.2", "1", "100", "0", "0");
        RepaymentScheduleInstallment installment3 =
                getRepaymentScheduleInstallment("15-Sep-2010", 3, "95.3", "3.7", "1", "100", "0", "0");
        LoanAccountActionForm loanAccountActionForm = mock(LoanAccountActionForm.class);
        List<RepaymentScheduleInstallment> installments = asList(installment1, installment2, installment3);
        when(loanAccountActionForm.getLoanAmount()).thenReturn("1000");
        when(loanAccountActionForm.getLoanAmountValue()).thenReturn(new Money(rupee, "1000"));
        when(loanAccountActionForm.getInterestRate()).thenReturn("24");
        when(loanAccountActionForm.isVariableInstallmentsAllowed()).thenReturn(true);
        loanBusinessService.
                applyDailyInterestRatesWhereApplicable(new LoanScheduleGenerationDto(TestUtils.getDate(22, 8, 2010),
                        loanBO, loanAccountActionForm.isVariableInstallmentsAllowed(), loanAccountActionForm.getLoanAmountValue(),
                loanAccountActionForm.getInterestDoubleValue()), installments);
        verify(loanBO).updateInstallmentSchedule(installments);
    }

    @Test
    public void shouldComputeVariableInstallmentScheduleForVariableInstallmentsIfInterestTypeIsDecliningPrincipalBalance() throws Exception {
        RepaymentScheduleInstallment installment1 =
                getRepaymentScheduleInstallment("01-Sep-2010", 1, "94.4", "4.6", "1", "75", "0", "0");
        RepaymentScheduleInstallment installment2 =
                getRepaymentScheduleInstallment("08-Sep-2010", 2, "94.8", "4.2", "1", "100", "0", "0");
        RepaymentScheduleInstallment installment3 =
                getRepaymentScheduleInstallment("15-Sep-2010", 3, "95.3", "3.7", "1", "100", "0", "0");
        LoanAccountActionForm loanAccountActionForm = mock(LoanAccountActionForm.class);
        List<RepaymentScheduleInstallment> installments = asList(installment1, installment2, installment3);
        when(loanAccountActionForm.getLoanAmount()).thenReturn("1000");
        when(loanAccountActionForm.getLoanAmountValue()).thenReturn(new Money(rupee, "1000"));
        when(loanAccountActionForm.getInterestRate()).thenReturn("24");
        when(loanAccountActionForm.isVariableInstallmentsAllowed()).thenReturn(false);
        when(legacyLoanDao.findBySystemId(anyString())).thenReturn(loanBO);
        when(loanBO.toRepaymentScheduleDto(locale)).thenReturn(installments);
        when(loanBO.isDecliningBalanceInterestRecalculation()).thenReturn(true);
        loanBusinessService.applyDailyInterestRatesWhereApplicable(new LoanScheduleGenerationDto(TestUtils.getDate(22, 8, 2010),
                loanBO, loanAccountActionForm.isVariableInstallmentsAllowed(), loanAccountActionForm.getLoanAmountValue(),
                loanAccountActionForm.getInterestDoubleValue()), locale);
        verify(loanBO).updateInstallmentSchedule(installments);
        verify(loanBO).toRepaymentScheduleDto(locale);
    }

    @SuppressWarnings("unchecked")
    @Test
    public void shouldNotComputeVariableInstallmentSchedule() throws Exception {
        LoanAccountActionForm loanAccountActionForm = mock(LoanAccountActionForm.class);
        when(loanAccountActionForm.isVariableInstallmentsAllowed()).thenReturn(false);
        InterestTypesEntity interestTypesEntity = new InterestTypesEntity(InterestType.DECLINING);
        when(loanBO.getInterestType()).thenReturn(interestTypesEntity);
        when(legacyLoanDao.findBySystemId(anyString())).thenReturn(loanBO);

        loanBusinessService.applyDailyInterestRatesWhereApplicable(new LoanScheduleGenerationDto(TestUtils.getDate(22, 8, 2010),
                loanBO, loanAccountActionForm.isVariableInstallmentsAllowed(), loanAccountActionForm.getLoanAmountValue(),
                loanAccountActionForm.getInterestDoubleValue()), locale);
        verify(loanBO, never()).updateInstallmentSchedule(any(List.class));
    }

    @Test
    public void shouldGenerateMonthlyInstallmentScheduleFromRepaymentScheduleUsingDailyInterest() {
        MifosCurrency rupee = new MifosCurrency(Short.valueOf("1"), "Rupee", BigDecimal.valueOf(1), "INR");
        RepaymentScheduleInstallment installment1 =
                getRepaymentScheduleInstallment("25-Sep-2010", 1, "78.6", "20.4", "1", "100", "0", "0");
        RepaymentScheduleInstallment installment2 =
                getRepaymentScheduleInstallment("25-Oct-2010", 2, "182.8", "16.2", "1", "200", "0", "0");
        RepaymentScheduleInstallment installment3 =
                getRepaymentScheduleInstallment("25-Nov-2010", 3, "186.0", "13.0", "1", "200", "0", "0");
        RepaymentScheduleInstallment installment4 =
                getRepaymentScheduleInstallment("25-Dec-2010", 4, "452.6", "8.9", "1", "462.5", "0", "0");
        List<RepaymentScheduleInstallment> installments = asList(installment1, installment2, installment3, installment4);
        Date disbursementDate = TestUtils.getDate(25, 8, 2010);
        final Money loanAmount = new Money(rupee, "1000");
        loanBusinessService.applyDailyInterestRates(new LoanScheduleGenerationDto(disbursementDate, loanAmount, 24d, installments), false);

        assertInstallment(installment1, "78.6", "20.4");
        assertInstallment(installment2, "180.8", "18.2");
        assertInstallment(installment3, "183.9", "15.1");
        assertInstallment(installment4, "556.7", "11.0");
    }

    //Test for the bug fix
    @Test
    public void shouldNotModifyPrincipalEvenIfMiscChargeIsPresent() {
        MifosCurrency rupee = new MifosCurrency(Short.valueOf("1"), "Rupee", BigDecimal.valueOf(1), "INR");
        RepaymentScheduleInstallment installment1 =
                getRepaymentScheduleInstallment("25-Sep-2010", 1, "78.6", "20.4", "1", "200", "100", "0");
        RepaymentScheduleInstallment installment2 =
                getRepaymentScheduleInstallment("25-Oct-2010", 2, "182.8", "16.2", "1", "200", "0", "0");
        RepaymentScheduleInstallment installment3 =
                getRepaymentScheduleInstallment("25-Nov-2010", 3, "186.0", "13.0", "1", "200", "0", "0");
        RepaymentScheduleInstallment installment4 =
                getRepaymentScheduleInstallment("25-Dec-2010", 4, "452.6", "8.9", "1", "462.5", "0", "0");
        List<RepaymentScheduleInstallment> installments = asList(installment1, installment2, installment3, installment4);
        Date disbursementDate = TestUtils.getDate(25, 8, 2010);
        final Money loanAmount = new Money(rupee, "1000");
        loanBusinessService.applyDailyInterestRates(new LoanScheduleGenerationDto(disbursementDate, loanAmount, 24d, installments), false);

        assertInstallment(installment1, "78.6", "20.4");
        assertInstallment(installment2, "180.8", "18.2");
        assertInstallment(installment3, "183.9", "15.1");
        assertInstallment(installment4, "556.7", "11.0");
    }

    @Test
    public void shouldGenerateWeeklyInstallmentScheduleFromRepaymentScheduleUsingDailyInterest() {
        MifosCurrency rupee = new MifosCurrency(Short.valueOf("1"), "Rupee", BigDecimal.valueOf(1), "INR");
        RepaymentScheduleInstallment installment1 =
                getRepaymentScheduleInstallment("01-Sep-2010", 1, "194.4", "4.6", "1", "100", "0", "0");
        RepaymentScheduleInstallment installment2 =
                getRepaymentScheduleInstallment("08-Sep-2010", 2, "195.3", "3.7", "1", "200", "0", "0");
        RepaymentScheduleInstallment installment3 =
                getRepaymentScheduleInstallment("15-Sep-2010", 3, "196.2", "2.8", "1", "200", "0", "0");
        RepaymentScheduleInstallment installment4 =
                getRepaymentScheduleInstallment("22-Sep-2010", 4, "414.1", "1.9", "1", "417.0", "0", "0");
        List<RepaymentScheduleInstallment> installments = asList(installment1, installment2, installment3, installment4);
        Date disbursementDate = TestUtils.getDate(25, 8, 2010);
        final Money loanAmount = new Money(rupee, "1000");
        loanBusinessService.applyDailyInterestRates(new LoanScheduleGenerationDto(disbursementDate, loanAmount, 24d, installments), false);

        assertInstallment(installment1, "94.4", "4.6");
        assertInstallment(installment2, "194.8", "4.2");
        assertInstallment(installment3, "195.7", "3.3");
        assertInstallment(installment4, "515.0", "2.4");
    }

    @Test
    public void shouldGenerateInstallmentScheduleFromRepaymentScheduleUsingDailyInterest() {
        RepaymentScheduleInstallment installment1 =
                getRepaymentScheduleInstallment("01-Sep-2010", 1, "94.4", "4.6", "1", "75", "0", "0");
        RepaymentScheduleInstallment installment2 =
                getRepaymentScheduleInstallment("08-Sep-2010", 2, "94.8", "4.2", "1", "100", "0", "0");
        RepaymentScheduleInstallment installment3 =
                getRepaymentScheduleInstallment("15-Sep-2010", 3, "95.3", "3.7", "1", "100", "0", "0");
        RepaymentScheduleInstallment installment4 =
                getRepaymentScheduleInstallment("15-Oct-2010", 4, "84.9", "14.1", "1", "100", "0", "0");
        RepaymentScheduleInstallment installment5 =
                getRepaymentScheduleInstallment("25-Oct-2010", 5, "94.9", "4.2", "1", "100", "0", "0");
        RepaymentScheduleInstallment installment6 =
                getRepaymentScheduleInstallment("01-Nov-2010", 6, "96.5", "2.5", "1", "100", "0", "0");
        RepaymentScheduleInstallment installment7 =
                getRepaymentScheduleInstallment("18-Nov-2010", 7, "439.2", "4.9", "1", "445.1", "0", "0");
        List<RepaymentScheduleInstallment> installments = asList(installment1, installment2, installment3,
                installment4, installment5, installment6, installment7);
        Date disbursementDate = TestUtils.getDate(25, 8, 2010);
        final Money loanAmount = new Money(rupee, "1000");
        loanBusinessService.applyDailyInterestRates(new LoanScheduleGenerationDto(disbursementDate, loanAmount, 24d, installments), false);

        assertInstallment(installment1, "69.4", "4.6");
        assertInstallment(installment2, "94.7", "4.3");
        assertInstallment(installment3, "95.2", "3.8");
        assertInstallment(installment4, "84.4", "14.6");
        assertInstallment(installment5, "94.7", "4.3");
        assertInstallment(installment6, "96.4", "2.6");
        assertInstallment(installment7, "465.2", "5.2");
    }

    @Test
    public void shouldMaintainInstallmentGapsPostDisbursal() {
        RepaymentScheduleInstallment installment1 =
                getRepaymentScheduleInstallment("01-Sep-2010", 1, "94.4", "4.6", "1", "75", "0", "0");
        RepaymentScheduleInstallment installment2 =
                getRepaymentScheduleInstallment("08-Sep-2010", 2, "94.8", "4.2", "1", "100", "0", "0");
        RepaymentScheduleInstallment installment3 =
                getRepaymentScheduleInstallment("15-Sep-2010", 3, "95.3", "3.7", "1", "100", "0", "0");
        RepaymentScheduleInstallment installment4 =
                getRepaymentScheduleInstallment("15-Oct-2010", 4, "84.9", "14.1", "1", "100", "0", "0");
        RepaymentScheduleInstallment installment5 =
                getRepaymentScheduleInstallment("25-Oct-2010", 5, "94.9", "4.2", "1", "100", "0", "0");
        RepaymentScheduleInstallment installment6 =
                getRepaymentScheduleInstallment("01-Nov-2010", 6, "96.5", "2.5", "1", "100", "0", "0");
        RepaymentScheduleInstallment installment7 =
                getRepaymentScheduleInstallment("18-Nov-2010", 7, "439.2", "4.9", "1", "445.1", "0", "0");
        List<RepaymentScheduleInstallment> installments = asList(installment1, installment2, installment3,
                installment4, installment5, installment6, installment7);
        Date initialDisbursementDate = TestUtils.getDate(25, 8, 2010);
        Date disbursementDate = TestUtils.getDate(30, 8, 2010);
        when(holidayService.isFutureRepaymentHoliday(Matchers.<Calendar>any(), eq(officeId))).thenReturn(true);
        when(holidayService.getNextWorkingDay(Matchers.<Date>any(), eq(officeId))).thenReturn(TestUtils.getDate(6, 9, 2010),
                TestUtils.getDate(13, 9, 2010), TestUtils.getDate(20, 9, 2010), TestUtils.getDate(20, 10, 2010), TestUtils.getDate(30, 10, 2010),
                TestUtils.getDate(6, 11, 2010), TestUtils.getDate(23, 11, 2010));
        loanBusinessService.adjustInstallmentGapsPostDisbursal(installments, initialDisbursementDate, disbursementDate, officeId);
        assertInstallmentDueDate(installment1, "06-Sep-2010");
        assertInstallmentDueDate(installment2, "13-Sep-2010");
        assertInstallmentDueDate(installment3, "20-Sep-2010");
        assertInstallmentDueDate(installment4, "20-Oct-2010");
        assertInstallmentDueDate(installment5, "30-Oct-2010");
        assertInstallmentDueDate(installment6, "06-Nov-2010");
        assertInstallmentDueDate(installment7, "23-Nov-2010");
        verify(holidayService, times(7)).isFutureRepaymentHoliday(Matchers.<Calendar>any(), eq(officeId));
        verify(holidayService, times(7)).getNextWorkingDay(Matchers.<Date>any(), eq(officeId));
    }

    @Test
    public void shouldMaintainInstallmentGapsPostDisbursalWithNewDisbursalDateBeforeOldDisbursalDate() {
        RepaymentScheduleInstallment installment1 =
                getRepaymentScheduleInstallment("01-Sep-2010", 1, "94.4", "4.6", "1", "75", "0", "0");
        RepaymentScheduleInstallment installment2 =
                getRepaymentScheduleInstallment("08-Sep-2010", 2, "94.8", "4.2", "1", "100", "0", "0");
        RepaymentScheduleInstallment installment3 =
                getRepaymentScheduleInstallment("15-Sep-2010", 3, "95.3", "3.7", "1", "100", "0", "0");
        RepaymentScheduleInstallment installment4 =
                getRepaymentScheduleInstallment("15-Oct-2010", 4, "84.9", "14.1", "1", "100", "0", "0");
        RepaymentScheduleInstallment installment5 =
                getRepaymentScheduleInstallment("25-Oct-2010", 5, "94.9", "4.2", "1", "100", "0", "0");
        RepaymentScheduleInstallment installment6 =
                getRepaymentScheduleInstallment("01-Nov-2010", 6, "96.5", "2.5", "1", "100", "0", "0");
        RepaymentScheduleInstallment installment7 =
                getRepaymentScheduleInstallment("18-Nov-2010", 7, "439.2", "4.9", "1", "445.1", "0", "0");
        List<RepaymentScheduleInstallment> installments = asList(installment1, installment2, installment3,
                installment4, installment5, installment6, installment7);
        Date initialDisbursementDate = TestUtils.getDate(25, 8, 2010);
        Date disbursementDate = TestUtils.getDate(20, 8, 2010);
        when(holidayService.isFutureRepaymentHoliday(Matchers.<Calendar>any(), eq(officeId))).thenReturn(true);
        when(holidayService.getNextWorkingDay(Matchers.<Date>any(), eq(officeId))).thenReturn(TestUtils.getDate(27, 8, 2010),
                TestUtils.getDate(3, 9, 2010), TestUtils.getDate(10, 9, 2010), TestUtils.getDate(11, 10, 2010), TestUtils.getDate(21, 10, 2010),
                TestUtils.getDate(28, 10, 2010), TestUtils.getDate(15, 11, 2010));
        loanBusinessService.adjustInstallmentGapsPostDisbursal(installments, initialDisbursementDate, disbursementDate, officeId);
        assertInstallmentDueDate(installment1, "27-Aug-2010");
        assertInstallmentDueDate(installment2, "03-Sep-2010");
        assertInstallmentDueDate(installment3, "10-Sep-2010");
        assertInstallmentDueDate(installment4, "11-Oct-2010");
        assertInstallmentDueDate(installment5, "21-Oct-2010");
        assertInstallmentDueDate(installment6, "28-Oct-2010");
        assertInstallmentDueDate(installment7, "15-Nov-2010");
        verify(holidayService, times(7)).isFutureRepaymentHoliday(Matchers.<Calendar>any(), eq(officeId));
        verify(holidayService, times(7)).getNextWorkingDay(Matchers.<Date>any(), eq(officeId));
    }

    @Test
    public void persistOriginalSchedule() throws PersistenceException {
        Set<LoanScheduleEntity> installments = new LinkedHashSet<LoanScheduleEntity>();
        MifosCurrency mifosCurrency = new MifosCurrency(Short.valueOf("1"), "Rupee", BigDecimal.valueOf(1), "INR");
        Money money = new Money(mifosCurrency,"123");
        AccountBO accountBO = mock(AccountBO.class);
        CustomerBO customerBO = mock(CustomerBO.class);
        when(accountBO.getCurrency()).thenReturn(mifosCurrency);
        LoanScheduleEntity loanScheduleEntity = new LoanScheduleEntity(accountBO, customerBO, new Short("1"),
                                        new java.sql.Date(new Date().getTime()), PaymentStatus.UNPAID, money,money);
        installments.add(loanScheduleEntity);
        when(loanBO.getLoanScheduleEntities()).thenReturn(installments);
        loanBusinessService.persistOriginalSchedule(loanBO);
        ArrayList<OriginalLoanScheduleEntity> expected = new ArrayList<OriginalLoanScheduleEntity>();
        expected.add(new OriginalLoanScheduleEntity(loanScheduleEntity));
        verify(legacyLoanDao).saveOriginalSchedule(Mockito.argThat(
                new OriginalLoanScheduleEntitiesMatcher(expected)
        ));
    }

    @Test
    public void originalLoanScheduleShouldPersistMiscFee() throws PersistenceException {
        Set<LoanScheduleEntity> installments = new LinkedHashSet<LoanScheduleEntity>();
        MifosCurrency mifosCurrency = new MifosCurrency(Short.valueOf("1"), "Rupee", BigDecimal.valueOf(1), "INR");
        Money money = new Money(mifosCurrency,"123");
        AccountBO accountBO = mock(AccountBO.class);
        CustomerBO customerBO = mock(CustomerBO.class);
        when(accountBO.getCurrency()).thenReturn(mifosCurrency);
        LoanScheduleEntity loanScheduleEntity = new LoanScheduleEntity(accountBO, customerBO, new Short("1"),
                                        new java.sql.Date(new Date().getTime()), PaymentStatus.UNPAID, money,money);
        loanScheduleEntity.setMiscFee(money);
        installments.add(loanScheduleEntity);
        when(loanBO.getLoanScheduleEntities()).thenReturn(installments);
        loanBusinessService.persistOriginalSchedule(loanBO);
        ArrayList<OriginalLoanScheduleEntity> expected = new ArrayList<OriginalLoanScheduleEntity>();
        OriginalLoanScheduleEntity originalLoanScheduleEntity = new OriginalLoanScheduleEntity(loanScheduleEntity);
        assertEquals(originalLoanScheduleEntity.getMiscFee(),loanScheduleEntity.getMiscFee());
        expected.add(originalLoanScheduleEntity);
        verify(legacyLoanDao).saveOriginalSchedule(Mockito.argThat(
                new OriginalLoanScheduleEntitiesMatcher(expected)
        ));
    }
    @Test
    public void shouldRetrieveOriginalLoanSchedule() throws PersistenceException {
        Integer accountId = 1;

        ArrayList<OriginalLoanScheduleEntity> expected = new ArrayList<OriginalLoanScheduleEntity>();
        when(legacyLoanDao.getOriginalLoanScheduleEntity(accountId)).thenReturn(expected);
        List<OriginalLoanScheduleEntity> loanScheduleEntities = loanBusinessService.retrieveOriginalLoanSchedule(accountId);
        Assert.assertNotNull(loanScheduleEntities);
        verify(legacyLoanDao).getOriginalLoanScheduleEntity(accountId);
        Assert.assertEquals(expected,loanScheduleEntities);
    }

    @Test
    public void shouldComputeExtraInterestAsOfDateLaterThanLastPaymentDate() {
        Date asOfDate = TestUtils.getDate(10, 9, 2010);
        Date lastPaymentDate = TestUtils.getDate(1, 9, 2010);
        when(accountPaymentEntity.getPaymentDate()).thenReturn(lastPaymentDate);
        when(loanBO.findMostRecentNonzeroPaymentByPaymentDate()).thenReturn(accountPaymentEntity);
        when(loanBO.isDecliningBalanceInterestRecalculation()).thenReturn(true);
        Errors errors = loanBusinessService.computeExtraInterest(loanBO, asOfDate);
        assertThat(errors, is(not(nullValue())));
        assertThat(errors.hasErrors(), is(false));
        verify(scheduleCalculatorAdaptor).computeExtraInterest(loanBO, asOfDate);
    }

    @Test
    public void shouldComputeExtraInterestAsOfDateLaterThanLastPaymentDateAndNoLastPayment() {
        Date asOfDate = TestUtils.getDate(10, 9, 2010);
        when(loanBO.findMostRecentNonzeroPaymentByPaymentDate()).thenReturn(null);
        when(loanBO.isDecliningBalanceInterestRecalculation()).thenReturn(true);
        Errors errors = loanBusinessService.computeExtraInterest(loanBO, asOfDate);
        assertThat(errors, is(not(nullValue())));
        assertThat(errors.hasErrors(), is(false));
        verify(scheduleCalculatorAdaptor).computeExtraInterest(loanBO, asOfDate);
    }

    @Test
    public void shouldComputeExtraInterestAsOfDateEarlierThanLastPaymentDate() {
        Date asOfDate = TestUtils.getDate(1, 9, 2010);
        Date lastPaymentDate = TestUtils.getDate(10, 9, 2010);
        when(accountPaymentEntity.getPaymentDate()).thenReturn(lastPaymentDate);
        when(loanBO.findMostRecentNonzeroPaymentByPaymentDate()).thenReturn(accountPaymentEntity);
        when(loanBO.isDecliningBalanceInterestRecalculation()).thenReturn(true);
        Errors errors = loanBusinessService.computeExtraInterest(loanBO, asOfDate);
        assertThat(errors, is(not(nullValue())));
        assertThat(errors.hasErrors(), is(true));
        List<ErrorEntry> errorEntries = errors.getErrorEntries();
        assertThat(errorEntries, is(not(nullValue())));
        assertThat(errorEntries.size(), is(1));
        assertThat(errorEntries.get(0).getErrorCode(), is(LoanConstants.CANNOT_VIEW_REPAYMENT_SCHEDULE));
        verify(scheduleCalculatorAdaptor, never()).computeExtraInterest(loanBO, asOfDate);
    }

    private void assertInstallmentDueDate(RepaymentScheduleInstallment installment, String expectedDueDate) {
        String actualDueDate = DateUtils.getDBtoUserFormatString(installment.getDueDateValue(), locale);
        assertThat(actualDueDate, is(expectedDueDate));
    }

    private void assertInstallment(RepaymentScheduleInstallment installment, String principal, String interest) {
        assertThat(installment.getPrincipal().toString(Short.valueOf("1")), is(principal));
        assertThat(installment.getInterest().toString(Short.valueOf("1")), is(interest));
    }

    private RepaymentScheduleInstallment getRepaymentScheduleInstallment(String dueDate, int installment,
                                                                         String principal, String interest,
                                                                         String fees, String total, String miscFee, String miscPenality) {
        return installmentBuilder.reset(locale).withInstallment(installment).withDueDateValue(dueDate).
                withPrincipal(new Money(rupee, principal)).withInterest(new Money(rupee, interest)).

                withFees(new Money(rupee, fees)).withMiscFee(new Money(rupee, miscFee)).withMiscPenality(new Money(rupee, miscPenality)).withTotalValue(total).build();
    }

}


text:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html>

<title>Template</title>
<?php $this->load->view('templates/header'); ?>
<link rel="stylesheet" href="<?php echo base_url('assets/css/skin-red-light.min.css')?>">
<link rel="stylesheet" href="<?php echo base_url('assets/css/sweetalert.css')?>">

<?php $this->load->view('admin/templates/menu'); ?>
<?php
	$data['top'] = "Admin";
	$data['titulo'] = "Datos";
	$this->load->view('templates/start_box', $data);
?>

			<?php if(!empty($usuarios)){ ?>

					Select
					<select class="form-control" id="usuarios">
						<?php foreach($usuarios as $u){ ?>
							<option numId="<?=$u->id?>"><?=$u->username?></option>
						<?php } ?>
					</select>

					<button type="button" class="btn btn-primary" id="consultar">Consultar</button>

			<?php } else { ?>

					Select
					<select class="form-control" disabled>
					</select>

			<?php } ?>

				Condominios disponibles
				<select class="form-control" id="condTotal" size="8">
				</select>

			<button class="btn btn-primary" id="leftToRight"></button>

			<button class="btn btn-primary" id="rightToLeft"> </button>

			Condominios del usuario
			<select class="form-control" id="condUser" size="8">
			</select>

				<button type="button" class="btn btn-primary" id="guardar">Guardar</button>

<?php $this->load->view('templates/end_box'); ?>
<?php $this->load->view('templates/footer'); ?>

<?php $this->load->view('templates/footer_libs'); ?>


text:
#ifndef TENSORFLOW_LIB_GTL_OPTIONAL_H_
#define TENSORFLOW_LIB_GTL_OPTIONAL_H_

#include <assert.h>
#include <functional>
#include <initializer_list>
#include <type_traits>
#include <utility>

#include "tensorflow/core/platform/logging.h"

namespace tensorflow {
namespace gtl {

// A value of type gtl::optional<T> holds either a value of T or an
// "empty" value.  When it holds a value of T, it stores it as a direct
// subobject, so sizeof(optional<T>) is approximately sizeof(T)+1. The interface
// is based on the upcoming std::optional<T>, and gtl::optional<T> is
// designed to be cheaply drop-in replaceable by std::optional<T>, once it is
// rolled out.
//
// This implementation is based on the specification in the latest draft as of
// 2017-01-05, section 20.6.
//
// Differences between gtl::optional<T> and std::optional<T> include:
//    - constexpr not used for nonconst member functions.
//      (dependency on some differences between C++11 and C++14.)
//    - nullopt and in_place are not constexpr. We need the inline variable
//      support in C++17 for external linkage.
//    - CHECK instead of throwing std::bad_optional_access.
//    - optional::swap() and swap() relies on std::is_(nothrow_)swappable
//      which is introduced in C++17. So we assume is_swappable is always true
//      and is_nothrow_swappable is same as std::is_trivial.
//    - make_optional cannot be constexpr due to absence of guaranteed copy
//      elision.
//
// Synopsis:
//
//     #include "tensorflow/core/lib/gtl/optional.h"
//
//     tensorflow::gtl::optional<string> f() {
//       string result;
//       if (...) {
//          ...
//          result = ...;
//          return result;
//       } else {
//          ...
//          return tensorflow::gtl::nullopt;
//       }
//     }
//
//     int main() {
//         tensorflow::gtl::optional<string> optstr = f();
//         if (optstr) {
//            // non-empty
//            print(optstr.value());
//         } else {
//            // empty
//            error();
//         }
//     }
template <typename T>
class optional;

// The tag constant `in_place` is used as the first parameter of an optional<T>
// constructor to indicate that the remaining arguments should be forwarded
// to the underlying T constructor.
struct in_place_t {};
extern const in_place_t in_place;

// The tag constant `nullopt` is used to indicate an empty optional<T> in
// certain functions, such as construction or assignment.
struct nullopt_t {
  struct init_t {};
  static init_t init;
  // It must not be default-constructible to avoid ambiguity for opt = {}.
  // Note the non-const reference, it is to eliminate ambiguity for code like:
  // struct S { int value; };
  //
  // void Test() {
  //   optional<S> opt;
  //   opt = {{}};
  // }
  explicit constexpr nullopt_t(init_t& /*unused*/) {}  // NOLINT
};
extern const nullopt_t nullopt;

namespace internal_optional {

// define forward locally because std::forward is not constexpr until C++14
template <typename T>
constexpr T&& forward(typename std::remove_reference<T>::type&
                          t) noexcept {  // NOLINT(runtime/references)
  return static_cast<T&&>(t);
}

struct empty_struct {};
// This class stores the data in optional<T>.
// It is specialized based on whether T is trivially destructible.
// This is the specialization for non trivially destructible type.
template <typename T, bool = std::is_trivially_destructible<T>::value>
class optional_data_dtor_base {
 protected:
  // Whether there is data or not.
  bool engaged_;
  // data storage
  union {
    empty_struct dummy_;
    T data_;
  };

  void destruct() noexcept {
    if (engaged_) {
      data_.~T();
      engaged_ = false;
    }
  }

  // dummy_ must be initialized for constexpr constructor
  constexpr optional_data_dtor_base() noexcept : engaged_(false), dummy_{} {}

  template <typename... Args>
  constexpr explicit optional_data_dtor_base(in_place_t, Args&&... args)
      : engaged_(true), data_(internal_optional::forward<Args>(args)...) {}

  ~optional_data_dtor_base() { destruct(); }
};

// Specialization for trivially destructible type.
template <typename T>
class optional_data_dtor_base<T, true> {
 protected:
  // Whether there is data or not.
  bool engaged_;
  // data storage
  union {
    empty_struct dummy_;
    T data_;
  };
  void destruct() noexcept { engaged_ = false; }

  // dummy_ must be initialized for constexpr constructor
  constexpr optional_data_dtor_base() noexcept : engaged_(false), dummy_{} {}

  template <typename... Args>
  constexpr explicit optional_data_dtor_base(in_place_t, Args&&... args)
      : engaged_(true), data_(internal_optional::forward<Args>(args)...) {}

  ~optional_data_dtor_base() = default;
};

template <typename T>
class optional_data : public optional_data_dtor_base<T> {
 protected:
  using base = optional_data_dtor_base<T>;
  using base::base;

  T* pointer() { return &this->data_; }

  constexpr const T* pointer() const { return &this->data_; }

  template <typename... Args>
  void construct(Args&&... args) {
    new (pointer()) T(std::forward<Args>(args)...);
    this->engaged_ = true;
  }

  template <typename U>
  void assign(U&& u) {
    if (this->engaged_) {
      this->data_ = std::forward<U>(u);
    } else {
      construct(std::forward<U>(u));
    }
  }

  optional_data() = default;

  optional_data(const optional_data& rhs) {
    if (rhs.engaged_) {
      construct(rhs.data_);
    }
  }

  optional_data(optional_data&& rhs) noexcept(
      std::is_nothrow_move_constructible<T>::value) {
    if (rhs.engaged_) {
      construct(std::move(rhs.data_));
    }
  }

  optional_data& operator=(const optional_data& rhs) {
    if (rhs.engaged_) {
      assign(rhs.data_);
    } else {
      this->destruct();
    }
    return *this;
  }

  optional_data& operator=(optional_data&& rhs) noexcept(
      std::is_nothrow_move_assignable<T>::value&&
          std::is_nothrow_move_constructible<T>::value) {
    if (rhs.engaged_) {
      assign(std::move(rhs.data_));
    } else {
      this->destruct();
    }
    return *this;
  }
};

// ordered by level of restriction, from low to high.
// copyable implies movable.
enum class copy_traits { copyable = 0, movable = 1, non_movable = 2 };

// base class for enabling/disabling copy/move constructor.
template <copy_traits>
class optional_ctor_base;

template <>
class optional_ctor_base<copy_traits::copyable> {
 public:
  constexpr optional_ctor_base() = default;
  optional_ctor_base(const optional_ctor_base&) = default;
  optional_ctor_base(optional_ctor_base&&) = default;
  optional_ctor_base& operator=(const optional_ctor_base&) = default;
  optional_ctor_base& operator=(optional_ctor_base&&) = default;
};

template <>
class optional_ctor_base<copy_traits::movable> {
 public:
  constexpr optional_ctor_base() = default;
  optional_ctor_base(const optional_ctor_base&) = delete;
  optional_ctor_base(optional_ctor_base&&) = default;
  optional_ctor_base& operator=(const optional_ctor_base&) = default;
  optional_ctor_base& operator=(optional_ctor_base&&) = default;
};

template <>
class optional_ctor_base<copy_traits::non_movable> {
 public:
  constexpr optional_ctor_base() = default;
  optional_ctor_base(const optional_ctor_base&) = delete;
  optional_ctor_base(optional_ctor_base&&) = delete;
  optional_ctor_base& operator=(const optional_ctor_base&) = default;
  optional_ctor_base& operator=(optional_ctor_base&&) = default;
};

// base class for enabling/disabling copy/move assignment.
template <copy_traits>
class optional_assign_base;

template <>
class optional_assign_base<copy_traits::copyable> {
 public:
  constexpr optional_assign_base() = default;
  optional_assign_base(const optional_assign_base&) = default;
  optional_assign_base(optional_assign_base&&) = default;
  optional_assign_base& operator=(const optional_assign_base&) = default;
  optional_assign_base& operator=(optional_assign_base&&) = default;
};

template <>
class optional_assign_base<copy_traits::movable> {
 public:
  constexpr optional_assign_base() = default;
  optional_assign_base(const optional_assign_base&) = default;
  optional_assign_base(optional_assign_base&&) = default;
  optional_assign_base& operator=(const optional_assign_base&) = delete;
  optional_assign_base& operator=(optional_assign_base&&) = default;
};

template <>
class optional_assign_base<copy_traits::non_movable> {
 public:
  constexpr optional_assign_base() = default;
  optional_assign_base(const optional_assign_base&) = default;
  optional_assign_base(optional_assign_base&&) = default;
  optional_assign_base& operator=(const optional_assign_base&) = delete;
  optional_assign_base& operator=(optional_assign_base&&) = delete;
};

template <typename T>
constexpr copy_traits get_ctor_copy_traits() {
  return std::is_copy_constructible<T>::value
             ? copy_traits::copyable
             : std::is_move_constructible<T>::value ? copy_traits::movable
                                                    : copy_traits::non_movable;
}

template <typename T>
constexpr copy_traits get_assign_copy_traits() {
  return std::is_copy_assignable<T>::value &&
                 std::is_copy_constructible<T>::value
             ? copy_traits::copyable
             : std::is_move_assignable<T>::value &&
                       std::is_move_constructible<T>::value
                   ? copy_traits::movable
                   : copy_traits::non_movable;
}

// Whether T is constructible or convertible from optional<U>.
template <typename T, typename U>
struct is_constructible_convertible_from_optional
    : std::integral_constant<
          bool, std::is_constructible<T, optional<U>&>::value ||
                    std::is_constructible<T, optional<U>&&>::value ||
                    std::is_constructible<T, const optional<U>&>::value ||
                    std::is_constructible<T, const optional<U>&&>::value ||
                    std::is_convertible<optional<U>&, T>::value ||
                    std::is_convertible<optional<U>&&, T>::value ||
                    std::is_convertible<const optional<U>&, T>::value ||
                    std::is_convertible<const optional<U>&&, T>::value> {};

// Whether T is constructible or convertible or assignable from optional<U>.
template <typename T, typename U>
struct is_constructible_convertible_assignable_from_optional
    : std::integral_constant<
          bool, is_constructible_convertible_from_optional<T, U>::value ||
                    std::is_assignable<T&, optional<U>&>::value ||
                    std::is_assignable<T&, optional<U>&&>::value ||
                    std::is_assignable<T&, const optional<U>&>::value ||
                    std::is_assignable<T&, const optional<U>&&>::value> {};

}  // namespace internal_optional

template <typename T>
class optional : private internal_optional::optional_data<T>,
                 private internal_optional::optional_ctor_base<
                     internal_optional::get_ctor_copy_traits<T>()>,
                 private internal_optional::optional_assign_base<
                     internal_optional::get_assign_copy_traits<T>()> {
  using data_base = internal_optional::optional_data<T>;

 public:
  typedef T value_type;

  // [optional.ctor], constructors

  // A default constructed optional holds the empty value, NOT a default
  // constructed T.
  constexpr optional() noexcept {}

  // An optional initialized with `nullopt` holds the empty value.
  constexpr optional(nullopt_t) noexcept {}  // NOLINT(runtime/explicit)

  // Copy constructor, standard semantics.
  optional(const optional& src) = default;

  // Move constructor, standard semantics.
  optional(optional&& src) = default;

  // optional<T>(in_place, arg1, arg2, arg3) constructs a non-empty optional
  // with an in-place constructed value of T(arg1,arg2,arg3).
  // TODO(b/34201852): Add std::is_constructible<T, Args&&...> SFINAE.
  template <typename... Args>
  constexpr explicit optional(in_place_t, Args&&... args)
      : data_base(in_place_t(), internal_optional::forward<Args>(args)...) {}

  // optional<T>(in_place, {arg1, arg2, arg3}) constructs a non-empty optional
  // with an in-place list-initialized value of T({arg1, arg2, arg3}).
  template <typename U, typename... Args,
            typename = typename std::enable_if<std::is_constructible<
                T, std::initializer_list<U>&, Args&&...>::value>::type>
  constexpr explicit optional(in_place_t, std::initializer_list<U> il,
                              Args&&... args)
      : data_base(in_place_t(), il, internal_optional::forward<Args>(args)...) {
  }

  template <
      typename U = T,
      typename std::enable_if<
          std::is_constructible<T, U&&>::value &&
              !std::is_same<in_place_t, typename std::decay<U>::type>::value &&
              !std::is_same<optional<T>, typename std::decay<U>::type>::value &&
              std::is_convertible<U&&, T>::value,
          bool>::type = false>
  constexpr optional(U&& v)  // NOLINT
      : data_base(in_place_t(), internal_optional::forward<U>(v)) {}

  template <
      typename U = T,
      typename std::enable_if<
          std::is_constructible<T, U&&>::value &&
              !std::is_same<in_place_t, typename std::decay<U>::type>::value &&
              !std::is_same<optional<T>, typename std::decay<U>::type>::value &&
              !std::is_convertible<U&&, T>::value,
          bool>::type = false>
  explicit constexpr optional(U&& v)
      : data_base(in_place_t(), internal_optional::forward<U>(v)) {}

  // Converting copy constructor (implicit)
  template <
      typename U,
      typename std::enable_if<
          std::is_constructible<T, const U&>::value &&
              !internal_optional::is_constructible_convertible_from_optional<
                  T, U>::value &&
              std::is_convertible<const U&, T>::value,
          bool>::type = false>
  optional(const optional<U>& rhs) {  // NOLINT
    if (rhs) {
      this->construct(*rhs);
    }
  }

  // Converting copy constructor (explicit)
  template <
      typename U,
      typename std::enable_if<
          std::is_constructible<T, const U&>::value &&
              !internal_optional::is_constructible_convertible_from_optional<
                  T, U>::value &&
              !std::is_convertible<const U&, T>::value,
          bool>::type = false>
  explicit optional(const optional<U>& rhs) {
    if (rhs) {
      this->construct(*rhs);
    }
  }

  // Converting move constructor (implicit)
  template <
      typename U,
      typename std::enable_if<
          std::is_constructible<T, U&&>::value &&
              !internal_optional::is_constructible_convertible_from_optional<
                  T, U>::value &&
              std::is_convertible<U&&, T>::value,
          bool>::type = false>
  optional(optional<U>&& rhs) {  // NOLINT
    if (rhs) {
      this->construct(std::move(*rhs));
    }
  }

  // Converting move constructor (explicit)
  template <
      typename U,
      typename std::enable_if<
          std::is_constructible<T, U&&>::value &&
              !internal_optional::is_constructible_convertible_from_optional<
                  T, U>::value &&
              !std::is_convertible<U&&, T>::value,
          bool>::type = false>
  explicit optional(optional<U>&& rhs) {
    if (rhs) {
      this->construct(std::move(*rhs));
    }
  }

  // [optional.dtor], destructor, trivial if T is trivially destructible.
  ~optional() = default;

  // [optional.assign], assignment

  // Assignment from nullopt: opt = nullopt
  optional& operator=(nullopt_t) noexcept {
    this->destruct();
    return *this;
  }

  // Copy assignment, standard semantics.
  optional& operator=(const optional& src) = default;

  // Move assignment, standard semantics.
  optional& operator=(optional&& src) = default;

  // Value assignment
  template <
      typename U = T,
      typename = typename std::enable_if<
          !std::is_same<optional<T>, typename std::decay<U>::type>::value &&
          (!std::is_scalar<T>::value ||
           !std::is_same<T, typename std::decay<U>::type>::value) &&
          std::is_constructible<T, U>::value &&
          std::is_assignable<T&, U>::value>::type>
  optional& operator=(U&& v) {
    this->assign(std::forward<U>(v));
    return *this;
  }

  template <typename U,
            typename = typename std::enable_if<
                std::is_constructible<T, const U&>::value &&
                std::is_assignable<T&, const U&>::value &&
                !internal_optional::
                    is_constructible_convertible_assignable_from_optional<
                        T, U>::value>::type>
  optional& operator=(const optional<U>& rhs) {
    if (rhs) {
      this->assign(*rhs);
    } else {
      this->destruct();
    }
    return *this;
  }

  template <typename U,
            typename = typename std::enable_if<
                std::is_constructible<T, U>::value &&
                std::is_assignable<T&, U>::value &&
                !internal_optional::
                    is_constructible_convertible_assignable_from_optional<
                        T, U>::value>::type>
  optional& operator=(optional<U>&& rhs) {
    if (rhs) {
      this->assign(std::move(*rhs));
    } else {
      this->destruct();
    }
    return *this;
  }

  // [optional.mod], modifiers
  // Destroys the inner T value if one is present.
  void reset() noexcept { this->destruct(); }

  // Emplace reconstruction.  (Re)constructs the underlying T in-place with the
  // given arguments forwarded:
  //
  // optional<Foo> opt;
  // opt.emplace(arg1,arg2,arg3);  (Constructs Foo(arg1,arg2,arg3))
  //
  // If the optional is non-empty, and the `args` refer to subobjects of the
  // current object, then behavior is undefined.  This is because the current
  // object will be destructed before the new object is constructed with `args`.
  //
  template <typename... Args,
            typename = typename std::enable_if<
                std::is_constructible<T, Args&&...>::value>::type>
  void emplace(Args&&... args) {
    this->destruct();
    this->construct(std::forward<Args>(args)...);
  }

  // Emplace reconstruction with initializer-list.  See immediately above.
  template <class U, class... Args,
            typename = typename std::enable_if<std::is_constructible<
                T, std::initializer_list<U>&, Args&&...>::value>::type>
  void emplace(std::initializer_list<U> il, Args&&... args) {
    this->destruct();
    this->construct(il, std::forward<Args>(args)...);
  }

  // [optional.swap], swap
  // Swap, standard semantics.
  void swap(optional& rhs) noexcept(
      std::is_nothrow_move_constructible<T>::value&&
          std::is_trivial<T>::value) {
    if (*this) {
      if (rhs) {
        using std::swap;
        swap(**this, *rhs);
      } else {
        rhs.construct(std::move(**this));
        this->destruct();
      }
    } else {
      if (rhs) {
        this->construct(std::move(*rhs));
        rhs.destruct();
      } else {
        // no effect (swap(disengaged, disengaged))
      }
    }
  }

  // [optional.observe], observers
  // You may use `*opt`, and `opt->m`, to access the underlying T value and T's
  // member `m`, respectively.  If the optional is empty, behavior is
  // undefined.
  constexpr const T* operator->() const { return this->pointer(); }
  T* operator->() {
    assert(this->engaged_);
    return this->pointer();
  }
  constexpr const T& operator*() const& { return reference(); }
  T& operator*() & {
    assert(this->engaged_);
    return reference();
  }
  constexpr const T&& operator*() const&& { return std::move(reference()); }
  T&& operator*() && {
    assert(this->engaged_);
    return std::move(reference());
  }

  // In a bool context an optional<T> will return false if and only if it is
  // empty.
  //
  //   if (opt) {
  //     // do something with opt.value();
  //   } else {
  //     // opt is empty
  //   }
  //
  constexpr explicit operator bool() const noexcept { return this->engaged_; }

  // Returns false if and only if *this is empty.
  constexpr bool has_value() const noexcept { return this->engaged_; }

  // Use `opt.value()` to get a reference to underlying value.  The constness
  // and lvalue/rvalue-ness of `opt` is preserved to the view of the T
  // subobject.
  const T& value() const& {
    CHECK(*this) << "Bad optional access";
    return reference();
  }
  T& value() & {
    CHECK(*this) << "Bad optional access";
    return reference();
  }
  T&& value() && {  // NOLINT(build/c++11)
    CHECK(*this) << "Bad optional access";
    return std::move(reference());
  }
  const T&& value() const&& {  // NOLINT(build/c++11)
    CHECK(*this) << "Bad optional access";
    return std::move(reference());
  }

  // Use `opt.value_or(val)` to get either the value of T or the given default
  // `val` in the empty case.
  template <class U>
  constexpr T value_or(U&& v) const& {
    return static_cast<bool>(*this) ? **this
                                    : static_cast<T>(std::forward<U>(v));
  }
  template <class U>
  T value_or(U&& v) && {  // NOLINT(build/c++11)
    return static_cast<bool>(*this) ? std::move(**this)
                                    : static_cast<T>(std::forward<U>(v));
  }

 private:
  // Private accessors for internal storage viewed as reference to T.
  constexpr const T& reference() const { return *this->pointer(); }
  T& reference() { return *(this->pointer()); }

  // T constraint checks.  You can't have an optional of nullopt_t, in_place_t
  // or a reference.
  static_assert(
      !std::is_same<nullopt_t, typename std::remove_cv<T>::type>::value,
      "optional<nullopt_t> is not allowed.");
  static_assert(
      !std::is_same<in_place_t, typename std::remove_cv<T>::type>::value,
      "optional<in_place_t> is not allowed.");
  static_assert(!std::is_reference<T>::value,
                "optional<reference> is not allowed.");
};

// [optional.specalg]
// Swap, standard semantics.
// This function shall not participate in overload resolution unless
// is_move_constructible_v<T> is true and is_swappable_v<T> is true.
// NOTE: we assume is_swappable is always true. There will be a compiling error
// if T is actually not Swappable.
template <typename T,
          typename std::enable_if<std::is_move_constructible<T>::value,
                                  bool>::type = false>
void swap(optional<T>& a, optional<T>& b) noexcept(noexcept(a.swap(b))) {
  a.swap(b);
}

// NOTE: make_optional cannot be constexpr in C++11 because the copy/move
// constructor is not constexpr and we don't have guaranteed copy elision
// util C++17. But they are still declared constexpr for consistency with
// the standard.

// make_optional(v) creates a non-empty optional<T> where the type T is deduced
// from v.  Can also be explicitly instantiated as make_optional<T>(v).
template <typename T>
constexpr optional<typename std::decay<T>::type> make_optional(T&& v) {
  return optional<typename std::decay<T>::type>(std::forward<T>(v));
}

template <typename T, typename... Args>
constexpr optional<T> make_optional(Args&&... args) {
  return optional<T>(in_place_t(), internal_optional::forward<Args>(args)...);
}

template <typename T, typename U, typename... Args>
constexpr optional<T> make_optional(std::initializer_list<U> il,
                                    Args&&... args) {
  return optional<T>(in_place_t(), il,
                     internal_optional::forward<Args>(args)...);
}

// Relational operators. Empty optionals are considered equal to each
// other and less than non-empty optionals. Supports relations between
// optional<T> and optional<T>, between optional<T> and T, and between
// optional<T> and nullopt.
// Note: We're careful to support T having non-bool relationals.

// Relational operators [optional.relops]
// The C++17 (N4606) "Returns:" statements are translated into code
// in an obvious way here, and the original text retained as function docs.
// Returns: If bool(x) != bool(y), false; otherwise if bool(x) == false, true;
// otherwise *x == *y.
template <class T>
constexpr bool operator==(const optional<T>& x, const optional<T>& y) {
  return static_cast<bool>(x) != static_cast<bool>(y)
             ? false
             : static_cast<bool>(x) == false ? true : *x == *y;
}
// Returns: If bool(x) != bool(y), true; otherwise, if bool(x) == false, false;
// otherwise *x != *y.
template <class T>
constexpr bool operator!=(const optional<T>& x, const optional<T>& y) {
  return static_cast<bool>(x) != static_cast<bool>(y)
             ? true
             : static_cast<bool>(x) == false ? false : *x != *y;
}
// Returns: If !y, false; otherwise, if !x, true; otherwise *x < *y.
template <class T>
constexpr bool operator<(const optional<T>& x, const optional<T>& y) {
  return !y ? false : !x ? true : *x < *y;
}
// Returns: If !x, false; otherwise, if !y, true; otherwise *x > *y.
template <class T>
constexpr bool operator>(const optional<T>& x, const optional<T>& y) {
  return !x ? false : !y ? true : *x > *y;
}
// Returns: If !x, true; otherwise, if !y, false; otherwise *x <= *y.
template <class T>
constexpr bool operator<=(const optional<T>& x, const optional<T>& y) {
  return !x ? true : !y ? false : *x <= *y;
}
// Returns: If !y, true; otherwise, if !x, false; otherwise *x >= *y.
template <class T>
constexpr bool operator>=(const optional<T>& x, const optional<T>& y) {
  return !y ? true : !x ? false : *x >= *y;
}

// Comparison with nullopt [optional.nullops]
// The C++17 (N4606) "Returns:" statements are used directly here.
template <class T>
constexpr bool operator==(const optional<T>& x, nullopt_t) noexcept {
  return !x;
}
template <class T>
constexpr bool operator==(nullopt_t, const optional<T>& x) noexcept {
  return !x;
}
template <class T>
constexpr bool operator!=(const optional<T>& x, nullopt_t) noexcept {
  return static_cast<bool>(x);
}
template <class T>
constexpr bool operator!=(nullopt_t, const optional<T>& x) noexcept {
  return static_cast<bool>(x);
}
template <class T>
constexpr bool operator<(const optional<T>& x, nullopt_t) noexcept {
  return false;
}
template <class T>
constexpr bool operator<(nullopt_t, const optional<T>& x) noexcept {
  return static_cast<bool>(x);
}
template <class T>
constexpr bool operator<=(const optional<T>& x, nullopt_t) noexcept {
  return !x;
}
template <class T>
constexpr bool operator<=(nullopt_t, const optional<T>& x) noexcept {
  return true;
}
template <class T>
constexpr bool operator>(const optional<T>& x, nullopt_t) noexcept {
  return static_cast<bool>(x);
}
template <class T>
constexpr bool operator>(nullopt_t, const optional<T>& x) noexcept {
  return false;
}
template <class T>
constexpr bool operator>=(const optional<T>& x, nullopt_t) noexcept {
  return true;
}
template <class T>
constexpr bool operator>=(nullopt_t, const optional<T>& x) noexcept {
  return !x;
}

// Comparison with T [optional.comp_with_t]
// The C++17 (N4606) "Equivalent to:" statements are used directly here.
template <class T>
constexpr bool operator==(const optional<T>& x, const T& v) {
  return static_cast<bool>(x) ? *x == v : false;
}
template <class T>
constexpr bool operator==(const T& v, const optional<T>& x) {
  return static_cast<bool>(x) ? v == *x : false;
}
template <class T>
constexpr bool operator!=(const optional<T>& x, const T& v) {
  return static_cast<bool>(x) ? *x != v : true;
}
template <class T>
constexpr bool operator!=(const T& v, const optional<T>& x) {
  return static_cast<bool>(x) ? v != *x : true;
}
template <class T>
constexpr bool operator<(const optional<T>& x, const T& v) {
  return static_cast<bool>(x) ? *x < v : true;
}
template <class T>
constexpr bool operator<(const T& v, const optional<T>& x) {
  return static_cast<bool>(x) ? v < *x : false;
}
template <class T>
constexpr bool operator<=(const optional<T>& x, const T& v) {
  return static_cast<bool>(x) ? *x <= v : true;
}
template <class T>
constexpr bool operator<=(const T& v, const optional<T>& x) {
  return static_cast<bool>(x) ? v <= *x : false;
}
template <class T>
constexpr bool operator>(const optional<T>& x, const T& v) {
  return static_cast<bool>(x) ? *x > v : false;
}
template <class T>
constexpr bool operator>(const T& v, const optional<T>& x) {
  return static_cast<bool>(x) ? v > *x : true;
}
template <class T>
constexpr bool operator>=(const optional<T>& x, const T& v) {
  return static_cast<bool>(x) ? *x >= v : false;
}
template <class T>
constexpr bool operator>=(const T& v, const optional<T>& x) {
  return static_cast<bool>(x) ? v >= *x : true;
}

}  // namespace gtl
}  // namespace tensorflow

namespace std {

// Normally std::hash specializations are not recommended in tensorflow code,
// but we allow this as it is following a standard library component.
template <class T>
struct hash<::tensorflow::gtl::optional<T>> {
  size_t operator()(const ::tensorflow::gtl::optional<T>& opt) const {
    if (opt) {
      return hash<T>()(*opt);
    } else {
      return static_cast<size_t>(0x297814aaad196e6dULL);
    }
  }
};

}  // namespace std

#endif  // TENSORFLOW_LIB_GTL_OPTIONAL_H_


text:
import React from 'react';
import { shallow } from 'enzyme';
import each from 'jest-each';

import createMarker from 'react-content-marker';

import { optionPattern } from './optionPattern';

describe('optionPattern', () => {
  each([
    ['--help', 'Type --help for this help'],
    ['-S', 'Short -S ones also'],
  ]).it('marks `%s` in `%s`', (mark, content) => {
    const Marker = createMarker([optionPattern]);
    const wrapper = shallow(<Marker>{content}</Marker>);
    expect(wrapper.find('mark')).toHaveLength(1);
    expect(wrapper.find('mark').text()).toEqual(mark);
  });
});


text:
package edu.uci.ics.asterix.common.feeds.message;

import javax.xml.bind.DatatypeConverter;

import org.json.JSONException;
import org.json.JSONObject;

import edu.uci.ics.asterix.common.feeds.FeedConnectionId;
import edu.uci.ics.asterix.common.feeds.FeedConstants;
import edu.uci.ics.asterix.common.feeds.FeedId;

public class FeedTupleCommitAckMessage extends FeedMessage {

    private static final long serialVersionUID = 1L;

    private final FeedConnectionId connectionId;
    private int intakePartition;
    private int base;
    private byte[] commitAcks;

    public FeedTupleCommitAckMessage(FeedConnectionId connectionId, int intakePartition, int base, byte[] commitAcks) {
        super(MessageType.COMMIT_ACK);
        this.connectionId = connectionId;
        this.intakePartition = intakePartition;
        this.base = base;
        this.commitAcks = commitAcks;
    }

    @Override
    public JSONObject toJSON() throws JSONException {
        JSONObject obj = new JSONObject();
        obj.put(FeedConstants.MessageConstants.MESSAGE_TYPE, messageType.name());
        obj.put(FeedConstants.MessageConstants.DATAVERSE, connectionId.getFeedId().getDataverse());
        obj.put(FeedConstants.MessageConstants.FEED, connectionId.getFeedId().getFeedName());
        obj.put(FeedConstants.MessageConstants.DATASET, connectionId.getDatasetName());
        obj.put(FeedConstants.MessageConstants.INTAKE_PARTITION, intakePartition);
        obj.put(FeedConstants.MessageConstants.BASE, base);
        String commitAcksString = DatatypeConverter.printBase64Binary(commitAcks);
        obj.put(FeedConstants.MessageConstants.COMMIT_ACKS, commitAcksString);
        return obj;
    }

    public static FeedTupleCommitAckMessage read(JSONObject obj) throws JSONException {
        FeedId feedId = new FeedId(obj.getString(FeedConstants.MessageConstants.DATAVERSE),
                obj.getString(FeedConstants.MessageConstants.FEED));
        FeedConnectionId connectionId = new FeedConnectionId(feedId,
                obj.getString(FeedConstants.MessageConstants.DATASET));
        int intakePartition = obj.getInt(FeedConstants.MessageConstants.INTAKE_PARTITION);
        int base = obj.getInt(FeedConstants.MessageConstants.BASE);
        String commitAcksString = obj.getString(FeedConstants.MessageConstants.COMMIT_ACKS);
        byte[] commitAcks = DatatypeConverter.parseBase64Binary(commitAcksString);
        return new FeedTupleCommitAckMessage(connectionId, intakePartition, base, commitAcks);
    }

    public FeedConnectionId getConnectionId() {
        return connectionId;
    }

    public int getIntakePartition() {
        return intakePartition;
    }

    public byte[] getCommitAcks() {
        return commitAcks;
    }

    public void reset(int intakePartition, int base, byte[] commitAcks) {
        this.intakePartition = intakePartition;
        this.base = base;
        this.commitAcks = commitAcks;
    }

    public int getBase() {
        return base;
    }

    public void setBase(int base) {
        this.base = base;
    }

}


text:
exports.isArray = Array.isArray; // lodash.isarray is deprecated
exports.isEmpty = require('cloudant-sync.isempty');
exports.isFunction = require('cloudant-sync.isfunction');
exports.isObject = require('cloudant-sync.isobject');
exports.isString = require('cloudant-sync.isstring');


text:
class Yaz < Formula
  desc "Toolkit for Z39.50/SRW/SRU clients/servers"
  homepage "https://www.indexdata.com/yaz"
  url "http://ftp.indexdata.dk/pub/yaz/yaz-5.23.1.tar.gz"
  sha256 "4fb3b1ffcec4b9a56b892c47a0a645142e45418ce5ef6a835aeebc723f7d147e"

  bottle do
    cellar :any
    sha256 "79bff14a9d7cd50bbf71ae91b9b91d6e670b3b44d98271acbb6632aff30831c9" => :sierra
    sha256 "1895528299deb6423bed5bbd9806693d57cc2af083eb335500510dbe9c5e388e" => :el_capitan
    sha256 "020e949b02beddcf499e676b5920ec22d64030ce10d67420ca2a22cbf7900b76" => :yosemite
  end

  head do
    url "https://github.com/indexdata/yaz.git"
    depends_on "automake" => :build
    depends_on "autoconf" => :build
    depends_on "libtool" => :build
  end

  depends_on "pkg-config" => :build
  depends_on "icu4c" => :recommended

  def install
    system "./buildconf.sh" if build.head?
    system "./configure", "--disable-dependency-tracking",
                          "--prefix=#{prefix}",
                          "--with-xml2"
    system "make", "install"
  end

  test do
    # This test converts between MARC8, an obscure mostly-obsolete library
    # text encoding supported by yaz-iconv, and UTF8.
    marc8file = testpath/"marc8.txt"
    marc8file.write "$1!0-!L,i$3i$si$Ki$Ai$O!+=(B"
    result = shell_output("#{bin}/yaz-iconv -f marc8 -t utf8 #{marc8file}")
    result.force_encoding(Encoding::UTF_8) if result.respond_to?(:force_encoding)
    assert_equal "世界こんにちは!", result

    # Test ICU support if building with ICU by running yaz-icu
    # with the example icu_chain from its man page.
    if build.with? "icu4c"
      # The input string should be transformed to be:
      # * without control characters (tab)
      # * split into tokens at word boundaries (including -)
      # * without whitespace and Punctuation
      # * xy transformed to z
      # * lowercase
      configurationfile = testpath/"icu-chain.xml"
      configurationfile.write <<-EOS.undent
        <?xml version="1.0" encoding="UTF-8"?>
        <icu_chain locale="en">
          <transform rule="[:Control:] Any-Remove"/>
          <tokenize rule="w"/>
          <transform rule="[[:WhiteSpace:][:Punctuation:]] Remove"/>
          <transliterate rule="xy > z;"/>
          <display/>
          <casemap rule="l"/>
        </icu_chain>
      EOS

      inputfile = testpath/"icu-test.txt"
      inputfile.write "yaz-ICU	xy!"

      expectedresult = <<-EOS.undent
        1 1 'yaz' 'yaz'
        2 1 '' ''
        3 1 'icuz' 'ICUz'
        4 1 '' ''
      EOS

      result = shell_output("#{bin}/yaz-icu -c #{configurationfile} #{inputfile}")
      assert_equal expectedresult, result
    end
  end
end