<commit_before><?php
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\MinkExtension\Context\MinkContext;
use Behat\Behat\Tester\Exception\PendingException;
use Centreon\Test\Behat\CentreonContext;
use Centreon\Test\Behat\ConfigurationPollersPage;
use Centreon\Test\Behat\MetaServiceConfigurationPage;

/**
 * Defines application features from the specific context.
 */
class MetaServicesApiContext extends CentreonContext
{

    public function __construct()
    {
        parent::__construct();
        $this->jsonreturn = '';
        $this->metaName = 'testmeta';
    }

    /**
     * @Given I have a meta service
     */
    public function iHaveAMetaServices()
    {
        $metaservicePage = new MetaServiceConfigurationPage($this);
        $metaservicePage->setProperties(array(
            'name' => $this->metaName,
            'check_period' => 5,
            'max_check_attempts' => 1,
            'normal_check_interval' => 1,
            'retry_check_interval' => 1));
        $metaservicePage->save();
        (new ConfigurationPollersPage($this))->restartEngine();
    }


    /**
     * @When a call to API configuration services with s equal all is defined
     */
    public function aCallToApiConfigurationServicesWithParameterAll()
    {
        $param = 'all';
        $this -> jsonreturn = $this->callToApiConfigurationServices($param);

    }


    /**
     * @When a call to API configuration services with s equal s is defined
     */
    public function aCallToApiConfigurationServicesWithParameterS()
    {
        $param = 's';
        $this -> jsonreturn = $this->callToApiConfigurationServices($param);

    }


    /**
     * @When a call to API configuration services with s equal m is defined
     */
    public function aCallToApiConfigurationServicesWithParameterM()
    {
        $param = 'm';
        $this -> jsonreturn = $this->callToApiConfigurationServices($param);

    }


    /**
     * @Then the table understands the services and the meta services
     */
    public function theTableUnderstandsTheServicesAndTheMetaServices ()
    {
        $service = 0;
        $meta = 0;
        $json = json_decode( $this -> jsonreturn );

        $i = count($json->items)-1;
        while ((($service ==0 ) && ($meta ==0 )) || (0 <= $i)):
            if ($json->items[$i]->text == '_Module_Meta - '.$this->metaName){
                $meta = 1;
            }elseif (strstr($json->items[$i]->text, 'Centreon-Server -')) {
                $service = 1;
            }
            $i--;
        endwhile;

        if (($service == 0) || ($meta == 0)) {
            throw new Exception('Mauvais service');
        }
    }


    /**
     * @Then the table understands only the services
     */
    public function theTableUnderstandsOnlyTheServices ()
    {
        $service = 0;
        $meta = 0;
        $json = json_decode( $this -> jsonreturn );

        $i = count($json->items)-1;
        while ((($service ==0 ) && ($meta ==0 )) || (0 <= $i)):
            if ($json->items[$i]->text == '_Module_Meta - '.$this->metaName){
                $meta = 1;
            }elseif (strstr($json->items[$i]->text, 'Centreon-Server -')) {
                $service = 1;
            }
            $i--;
        endwhile;

        if (($service == 0) || ($meta == 1)) {
            throw new Exception('Mauvais service');
        }
    }


    /**
     * @Then the table understands only the meta services
     */
    public function theTableUnderstandsOnlyTheMeta ()
    {
        $service = 0;
        $meta = 0;
        $json = json_decode( $this -> jsonreturn );

        $i = count($json->items)-1;
        while ((($service ==0 ) && ($meta ==0 )) || (0 <= $i)):
            if ($json->items[$i]->text == '_Module_Meta - '.$this->metaName){
                $meta = 1;
            }elseif (strstr($json->items[$i]->text, 'Centreon-Server -')) {
                $service = 1;
            }
            $i--;
        endwhile;

        if (($service == 1) || ($meta == 0)) {
            throw new Exception('Mauvais service');
        }<commit_msg>   * Fix host meta name<commit_after><?php
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\MinkExtension\Context\MinkContext;
use Behat\Behat\Tester\Exception\PendingException;
use Centreon\Test\Behat\CentreonContext;
use Centreon\Test\Behat\ConfigurationPollersPage;
use Centreon\Test\Behat\MetaServiceConfigurationPage;

/**
 * Defines application features from the specific context.
 */
class MetaServicesApiContext extends CentreonContext
{

    public function __construct()
    {
        parent::__construct();
        $this->jsonreturn = '';
        $this->metaName = 'testmeta';
    }

    /**
     * @Given I have a meta service
     */
    public function iHaveAMetaServices()
    {
        $metaservicePage = new MetaServiceConfigurationPage($this);
        $metaservicePage->setProperties(array(
            'name' => $this->metaName,
            'check_period' => 5,
            'max_check_attempts' => 1,
            'normal_check_interval' => 1,
            'retry_check_interval' => 1));
        $metaservicePage->save();
        (new ConfigurationPollersPage($this))->restartEngine();
    }


    /**
     * @When a call to API configuration services with s equal all is defined
     */
    public function aCallToApiConfigurationServicesWithParameterAll()
    {
        $param = 'all';
        $this -> jsonreturn = $this->callToApiConfigurationServices($param);

    }


    /**
     * @When a call to API configuration services with s equal s is defined
     */
    public function aCallToApiConfigurationServicesWithParameterS()
    {
        $param = 's';
        $this -> jsonreturn = $this->callToApiConfigurationServices($param);

    }


    /**
     * @When a call to API configuration services with s equal m is defined
     */
    public function aCallToApiConfigurationServicesWithParameterM()
    {
        $param = 'm';
        $this -> jsonreturn = $this->callToApiConfigurationServices($param);

    }


    /**
     * @Then the table understands the services and the meta services
     */
    public function theTableUnderstandsTheServicesAndTheMetaServices ()
    {
        $service = 0;
        $meta = 0;
        $json = json_decode( $this -> jsonreturn );

        $i = count($json->items)-1;
        while ((($service ==0 ) && ($meta ==0 )) || (0 <= $i)):
            if ($json->items[$i]->text == 'Meta - '.$this->metaName){
                $meta = 1;
            }elseif (strstr($json->items[$i]->text, 'Centreon-Server -')) {
                $service = 1;
            }
            $i--;
        endwhile;

        if (($service == 0) || ($meta == 0)) {
            throw new Exception('Mauvais service');
        }
    }


    /**
     * @Then the table understands only the services
     */
    public function theTableUnderstandsOnlyTheServices ()
    {
        $service = 0;
        $meta = 0;
        $json = json_decode( $this -> jsonreturn );

        $i = count($json->items)-1;
        while ((($service ==0 ) && ($meta ==0 )) || (0 <= $i)):
            if ($json->items[$i]->text == 'Meta - '.$this->metaName){
                $meta = 1;
            }elseif (strstr($json->items[$i]->text, 'Centreon-Server -')) {
                $service = 1;
            }
            $i--;
        endwhile;

        if (($service == 0) || ($meta == 1)) {
            throw new Exception('Mauvais service');
        }
    }


    /**
     * @Then the table understands only the meta services
     */
    public function theTableUnderstandsOnlyTheMeta ()
    {
        $service = 0;
        $meta = 0;
        $json = json_decode( $this -> jsonreturn );

        $i = count($json->items)-1;
        while ((($service ==0 ) && ($meta ==0 )) || (0 <= $i)):
            if ($json->items[$i]->text == 'Meta - '.$this->metaName){
                $meta = 1;
            }elseif (strstr($json->items[$i]->text, 'Centreon-Server -')) {
                $service = 1;
            }
            $i--;
        endwhile;

        if (($service == 1) || ($meta == 0)) {
            throw new Exception('Mauvais service');
        }
{'fraction_non_alphanumeric': 0.1469800292255236, 'fraction_numerical': 0.008280565026790063, 'mean_word_length': 2.048626577579807, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 79, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5212958', 'n_tokens_mistral': 2436, 'n_tokens_neox': 2330, 'n_words': 550}