text:
<?php

namespace Symfony\Bridge\Doctrine\ArgumentResolver;

use Doctrine\DBAL\Types\ConversionException;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\NoResultException;
use Doctrine\Persistence\ManagerRegistry;
use Doctrine\Persistence\ObjectManager;
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

/**
 * Yields the entity matching the criteria provided in the route.
 *
 * @author Fabien Potencier <fabien@symfony.com>
 * @author Jérémy Derussé <jeremy@derusse.com>
 */
final class EntityValueResolver implements ArgumentValueResolverInterface
{
    public function __construct(
        private ManagerRegistry $registry,
        private ?ExpressionLanguage $expressionLanguage = null,
        private MapEntity $defaults = new MapEntity(),
    ) {
    }

    /**
     * {@inheritdoc}
     */
    public function supports(Request $request, ArgumentMetadata $argument): bool
    {
        if (!$this->registry->getManagerNames()) {
            return false;
        }

        $options = $this->getOptions($argument);
        if (!$options->class || $options->disabled) {
            return false;
        }

        // Doctrine Entity?
        if (!$objectManager = $this->getManager($options->objectManager, $options->class)) {
            return false;
        }

        return !$objectManager->getMetadataFactory()->isTransient($options->class);
    }

    /**
     * {@inheritdoc}
     */
    public function resolve(Request $request, ArgumentMetadata $argument): iterable
    {
        $options = $this->getOptions($argument);
        $name = $argument->getName();
        $class = $options->class;

        $errorMessage = null;
        if (null !== $options->expr) {
            if (null === $object = $this->findViaExpression($class, $request, $options->expr, $options)) {
                $errorMessage = sprintf('The expression "%s" returned null', $options->expr);
            }
            // find by identifier?
        } elseif (false === $object = $this->find($class, $request, $options, $name)) {
            // find by criteria
            if (false === $object = $this->findOneBy($class, $request, $options)) {
                if (!$argument->isNullable()) {
                    throw new \LogicException(sprintf('Unable to guess how to get a Doctrine instance from the request information for parameter "%s".', $name));
                }

                $object = null;
            }
        }

        if (null === $object && !$argument->isNullable()) {
            $message = sprintf('"%s" object not found by the "%s" Argument Resolver.', $class, self::class);
            if ($errorMessage) {
                $message .= ' '.$errorMessage;
            }

            throw new NotFoundHttpException($message);
        }

        return [$object];
    }

    private function getManager(?string $name, string $class): ?ObjectManager
    {
        if (null === $name) {
            return $this->registry->getManagerForClass($class);
        }

        if (!isset($this->registry->getManagerNames()[$name])) {
            return null;
        }

        try {
            return $this->registry->getManager($name);
        } catch (\InvalidArgumentException) {
            return null;
        }
    }

    private function find(string $class, Request $request, MapEntity $options, string $name): false|object|null
    {
        if ($options->mapping || $options->exclude) {
            return false;
        }

        $id = $this->getIdentifier($request, $options, $name);
        if (false === $id || null === $id) {
            return false;
        }

        $objectManager = $this->getManager($options->objectManager, $class);
        if ($options->evictCache && $objectManager instanceof EntityManagerInterface) {
            $cacheProvider = $objectManager->getCache();
            if ($cacheProvider && $cacheProvider->containsEntity($class, $id)) {
                $cacheProvider->evictEntity($class, $id);
            }
        }

        try {
            return $objectManager->getRepository($class)->find($id);
        } catch (NoResultException|ConversionException) {
            return null;
        }
    }

    private function getIdentifier(Request $request, MapEntity $options, string $name): mixed
    {
        if (\is_array($options->id)) {
            $id = [];
            foreach ($options->id as $field) {
                // Convert "%s_uuid" to "foobar_uuid"
                if (str_contains($field, '%s')) {
                    $field = sprintf($field, $name);
                }

                $id[$field] = $request->attributes->get($field);
            }

            return $id;
        }

        if (null !== $options->id) {
            $name = $options->id;
        }

        if ($request->attributes->has($name)) {
            return $request->attributes->get($name);
        }

        if (!$options->id && $request->attributes->has('id')) {
            return $request->attributes->get('id');
        }

        return false;
    }

    private function findOneBy(string $class, Request $request, MapEntity $options): false|object|null
    {
        if (null === $mapping = $options->mapping) {
            $keys = $request->attributes->keys();
            $mapping = $keys ? array_combine($keys, $keys) : [];
        }

        foreach ($options->exclude as $exclude) {
            unset($mapping[$exclude]);
        }

        if (!$mapping) {
            return false;
        }

        // if a specific id has been defined in the options and there is no corresponding attribute
        // return false in order to avoid a fallback to the id which might be of another object
        if (\is_string($options->id) && null === $request->attributes->get($options->id)) {
            return false;
        }

        $criteria = [];
        $objectManager = $this->getManager($options->objectManager, $class);
        $metadata = $objectManager->getClassMetadata($class);

        foreach ($mapping as $attribute => $field) {
            if (!$metadata->hasField($field) && (!$metadata->hasAssociation($field) || !$metadata->isSingleValuedAssociation($field))) {
                continue;
            }

            $criteria[$field] = $request->attributes->get($attribute);
        }

        if ($options->stripNull) {
            $criteria = array_filter($criteria, static fn ($value) => null !== $value);
        }

        if (!$criteria) {
            return false;
        }

        try {
            return $objectManager->getRepository($class)->findOneBy($criteria);
        } catch (NoResultException|ConversionException) {
            return null;
        }
    }

    private function findViaExpression(string $class, Request $request, string $expression, MapEntity $options): ?object
    {
        if (!$this->expressionLanguage) {
            throw new \LogicException(sprintf('You cannot use the "%s" if the ExpressionLanguage component is not available. Try running "composer require symfony/expression-language".', __CLASS__));
        }

        $repository = $this->getManager($options->objectManager, $class)->getRepository($class);
        $variables = array_merge($request->attributes->all(), ['repository' => $repository]);

        try {
            return $this->expressionLanguage->evaluate($expression, $variables);
        } catch (NoResultException|ConversionException) {
            return null;
        }
    }

    private function getOptions(ArgumentMetadata $argument): MapEntity
    {
        /** @var MapEntity $options */
        $options = $argument->getAttributes(MapEntity::class, ArgumentMetadata::IS_INSTANCEOF)[0] ?? $this->defaults;

        return $options->withDefaults($this->defaults, $argument->getType());
    }
}


text:
<k-new-query class="content" [hidden]="tabs._temp_tab_index != 0"></k-new-query>
<k-controller-center class="content" [hidden]="tabs._temp_tab_index != 1"></k-controller-center>
<k-saved class="content" *ngIf="tabs._temp_tab_index == 2"></k-saved>
<!--<router-outlet></router-outlet>-->

redpajama_set_name: RedPajamaGithub


text:
"""
File: test_create_preset.py
Date: 2015/06/15 10:15:40
"""
import os
import sys
import unittest
import json
import time
import media_config
import re
import mediaBase
import random

_NOW_PATH = os.path.dirname(os.path.abspath(__file__)) + '/'
_COMMON_PATH = _NOW_PATH + '../../../'
sys.path.insert(0, _COMMON_PATH)

from baidubce.services.media import media_client
from baidubce.exception import BceHttpClientError
from baidubce.exception import BceServerError
from baidubce.exception import BceClientError
import nose
from nose import tools
from nose.tools import assert_raises
from nose.tools import assert_is_none
from nose.tools import raises

class TestCreatePreset(mediaBase.MediaBase):
    """test create preset"""
    def __init__(self):
        """construction """
        mediaBase.MediaBase.__init__(self)
        self.pre = self.prefix + 'createpreset'
        self.preset_name = self.convertName(self.pre)
        self.container = 'mp4'
        self.client = media_client.MediaClient(media_config.config)
        self.key = 'watermark.jpg'
        self.watermark_id = None

    def setUp(self):
        """create env"""
        #time.sleep(1)
        succ = True
        try:
            self.watermark_id = self.client.create_watermark(self.watermarkBucket,
                   self.key).watermark_id
        except Exception as e:
            print(e.message)
            succ = False
        nose.tools.assert_true(succ)

    def tearDown(self):
        """clear env"""
        result = self.client.list_presets()
        for each_val in result.presets:
            preset_name = each_val.preset_name
            if(preset_name.startswith(self.pre)):
                resp = self.client.delete_preset(preset_name)
                nose.tools.assert_is_not_none(resp)

        if self.watermark_id:
            resp = self.client.delete_watermark(self.watermark_id)
            nose.tools.assert_is_not_none(resp)
            self.watermark_id = None

        #result = self.client.list_watermarks()
        #for each_val in result.watermarks:
        #    resp = self.client.delete_watermark(each_val.watermark_id)
        #    nose.tools.assert_is_not_none(resp)

    def test_create_preset_with_name_none(self):
        """create preset with preset name none"""
        preset_name = None
        with nose.tools.assert_raises_regexp(ValueError,
                'arg "preset_name" should not be None'):
            ret = self.client.create_preset(preset_name, self.container)

    def create_preset_with_name_different(self, name):
        """test create preset with nama different"""
        with nose.tools.assert_raises_regexp(BceHttpClientError,
                'BceServerError: preset name must match pattern:'):
            ret = self.client.create_preset(name, self.container, True)

    def test_create_preset_with_name_empty(self):
        """create preset with preset name empty"""
        preset_name = ''
        with nose.tools.assert_raises_regexp(BceClientError,
                'preset_name can\'t be empty string'):
            ret = self.client.create_preset(preset_name, self.container, True)

    def test_create_preset_with_container_empty(self):
        """create preset with preset container empty"""
        container = ''
        with nose.tools.assert_raises_regexp(BceClientError,
                'container can\'t be empty string'):
            ret = self.client.create_preset(self.preset_name, container)

    def test_create_preset_with_container_ahls(self):
        """create preset with container a-hls"""
        container = 'a-hls'
        ret = self.client.create_preset(self.preset_name, container, True)
        nose.tools.assert_is_not_none(ret)

    def test_create_preset_with_name_chinese(self):
        """create preset with chinese name"""
        preset_name = '创建模板'
        self.create_preset_with_name_different(preset_name)

    def test_create_preset_with_upper_letter(self):
        """create preset with upper case letter"""
        preset_name = 'CREATEPRESET'
        self.create_preset_with_name_different(preset_name)

    def test_create_preset_with_pure_digital(self):
        """create preset with pure digital"""
        preset_name = '123456'
        self.create_preset_with_name_different(preset_name)

    def test_create_preset_with_first_not_char(self):
        """create preset with name first not char"""
        preset_name = '123preset'
        self.create_preset_with_name_different(preset_name)

    def test_create_preset_with_mid_lined(self):
        """create preset with name include mid lined"""
        preset_name = 'preset-1-2'
        self.create_preset_with_name_different(preset_name)

    def test_create_preset_with_blank(self):
        """create preset with name include blank"""
        preset_name = 'preset name'
        self.create_preset_with_name_different(preset_name)

    def test_create_preset_with_name_more_40_chars(self):
        """create preset with name more than 40 cahrs"""
        preset_name = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
        self.create_preset_with_name_different(preset_name)

    def test_create_preset_with_name_equal_40_chars(self):
        """create preset with name equal 40 chars"""
        print(len(self.preset_name))
        nose.tools.assert_equal(len(self.preset_name), 40)
        transmux = True
        resp = self.client.create_preset(self.preset_name, self.container, transmux)
        nose.tools.assert_is_not_none(resp)

###############test desc#################
    def random_str(self, random_len=8):
        """return random string"""
        str = ''
        chars = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789'
        length = len(chars) - 1
        for i in range(random_len):
            str += chars[random.randint(0, length)]
        return str

    def test_create_preset_with_desc_more_128_chars(self):
        """create preset with description more than 128 cahrs"""
        transmux = True
        desc = self.random_str(129)
        with nose.tools.assert_raises_regexp(BceHttpClientError,
                'BceServerError: description:description=size must be between 0 and 128'):
            resp = self.client.create_preset(self.preset_name,
                   self.container, transmux, description=desc)

    def test_create_preset_with_desc_equal_128_chars(self):
        """create preset with description equal 128 chars"""
        transmux = True
        desc = self.random_str(128)
        resp = self.client.create_preset(self.preset_name,
                self.container, transmux, description=desc)
        nose.tools.assert_is_not_none(resp)

    def test_create_preset_with_desc_special_chars(self):
        """create preset with description special chars"""
        transmux = True
        desc = '~=-@-45 //\vthis is a special desc 含有中文特殊字符~!@#$#$$%(()()@####\\'
        resp = self.client.create_preset(self.preset_name,
                self.container, transmux, description=desc)
        nose.tools.assert_is_not_none(resp)

    def test_create_preset_with_none_desc(self):
        """create preset with description special chars"""
        transmux = True
        desc = None
        resp = self.client.create_preset(self.preset_name,
                self.container, transmux, description=desc)
        nose.tools.assert_is_not_none(resp)

    def test_create_preset_none_container(self):
        """create preset with container none"""
        self.container = None
        try:
            resp = self.client.create_preset(self.preset_name, self.container, True)
        except ValueError as e:
            assert e.message.startswith('arg "container" should not be None')

    def test_create_preset_with_container_not_in_enum(self):
        """create preset with container not in enum"""
        transmux = True
        try:
            resp = self.client.create_preset(self.preset_name,
                   'ceshimp4', transmux)
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith(
                        'Could not read JSON: Can not construct instance of')
            else:
                assert True == False, 'not throw BceServerError'

    def test_create_preset_with_transmux_is_false(self):
        """create preset with container is false"""
        audio = {'bitRateInBps': 25600}
        resp = self.client.create_preset(self.preset_name, 'mp3', audio=audio)
        nose.tools.assert_is_not_none(resp)

    def test_create_preset_with_transmux_not_in_enum(self):
        """create preset with transmux not in enum"""
        try:
            resp = self.client.create_preset(self.preset_name, 'mp4', 'test')
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith(
                        'Could not read JSON: Can not construct instance of')
            else:
                assert True == False, 'not throw BceServerError'

    def test_create_preset_with_transmux_is_false_with_no_audio_and_video(self):
        """create preset with transmux is false with no audio and video"""
        try:
            resp = self.client.create_preset(self.preset_name, 'mp4')
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith(
                        'video and audio cannot both be set to null when transmux equals false')
            else:
                assert True == False, 'not throw BceServerError'

############test clip###############
    def test_create_preset_with_clip_normal(self):
        """create preset with clip normal"""
        clip = {'startTimeInSecond': 0,
                'durationInSecond': 60
                }
        resp = self.client.create_preset(self.preset_name, self.container, True, clip=clip)
        nose.tools.assert_is_not_none(resp)

    def test_create_preset_with_clip_duration_equal_0(self):
        """create preset with clip duration equal 0"""
        clip = {'startTimeInSecond': 0,
                'durationInSecond': 0
                }
        try:
            resp = self.client.create_preset(self.preset_name, self.container, True, clip=clip)
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith(
                        'clip.durationInSecond:clip.durationInSecond=must be greater than or ')
            else:
                assert True == False, 'not throw BceServerError'

    def test_create_preset_with_startTimeInSecond_is_negative(self):
        """create preset with startTimeInSecond is negative"""
        clip = {'startTimeInSecond': -1,
                'durationInSecond': 60
                }
        try:
            resp = self.client.create_preset(self.preset_name, self.container, True, clip=clip)
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith(
                        'clip.startTimeInSecond:clip.startTimeInSecond=')
            else:
                assert True == False, 'not throw BceServerError'

    def test_create_preset_with_startTimeInSecond_is_positive(self):
        """create preset with startTimeInSecond is positive"""
        clip = {'startTimeInSecond': 10,
                'durationInSecond': 60
                }
        resp = self.client.create_preset(self.preset_name, self.container, True, clip=clip)
        nose.tools.assert_is_not_none(resp)

    def test_create_preset_with_startTimeInSecond_is_string(self):
        """create preset with startTimeInSecond is string"""
        clip = {'startTimeInSecond': 'abc',
                'durationInSecond': 60
                }
        try:
            resp = self.client.create_preset(self.preset_name, self.container, True, clip=clip)
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith(
                        'Could not read JSON: Can not construct instance of')
            else:
                assert True == False, 'not throw BceServerError'

    def test_create_preset_with_durationInSecond_is_negative(self):
        """create preset with durationInSecond is snegative"""
        clip = {'startTimeInSecond': 10,
                'durationInSecond': -1
                }
        try:
            resp = self.client.create_preset(self.preset_name, self.container, True, clip=clip)
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith(
                        'clip.durationInSecond:clip.durationInSecond=')
            else:
                assert True == False, 'not throw BceServerError'

    def test_create_preset_with_durationInSecond_is_string(self):
        """create preset with durationInSecond is string"""
        clip = {'startTimeInSecond': 10,
                'durationInSecond': 'abc'
                }
        try:
            resp = self.client.create_preset(self.preset_name, self.container, True, clip=clip)
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith(
                        'Could not read JSON: Can not construct instance of')
            else:
                assert True == False, 'not throw BceServerError'

################test audio################3

    def test_create_preset_with_audio_bitrateinbps_less_than_1000(self):
        """audio bitrateinbps less than 1000"""
        audio = {'bitRateInBps': 10}
        try:
            resp = self.client.create_preset(self.preset_name, self.container, audio=audio)
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith(
                        'audio.bitRateInBps:audio.bitRateInBps=must be greater than or equal')
            else:
                assert True == False, 'not throw BceServerError'

    def test_create_preset_with_audio_bitrateinbps_not_integer(self):
        """audio bitrateinbps not integer"""
        audio = {'bitRateInBps': 1000.34}
        resp = self.client.create_preset(self.preset_name, self.container, audio=audio)
        nose.tools.assert_is_not_none(resp)

    def test_create_preset_with_audio_bitrateinbps_is_none(self):
        """audio bitrateinbps none"""
        audio = {'sampleRateInHz': 22050}
        try:
            resp = self.client.create_preset(self.preset_name, self.container, audio=audio)
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith(
                        'audio.bitRateInBps:audio.bitRateInBps=may not be null')
            else:
                assert True == False, 'not throw BceServerError'

    def test_create_preset_with_audio_samplerateinhz_not_in_enum(self):
        """audio sampleRateInHz not in enum"""
        audio = {
            'bitRateInBps': 1989,
            'sampleRateInHz': 22051}
        try:
            resp = self.client.create_preset(self.preset_name, self.container, audio=audio)
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith(
                        'audio.sampleRateInHz should in [22050, 32000, 44100, 48000, 96000]')
            else:
                assert True == False, 'not throw BceServerError'

    def test_create_preset_with_audio_samplerateinhz_not_integer(self):
        """audio bitrateinbps not integer"""
        audio = {
            'bitRateInBps': 1989,
            'sampleRateInHz': 32000.56}
        resp = self.client.create_preset(self.preset_name, self.container, audio=audio)
        nose.tools.assert_is_not_none(resp)

    def test_create_preset_with_audio_channels_not_in_enum(self):
        """audio channel not in enum"""
        audio = {
            'bitRateInBps': 1989,
            'sampleRateInHz': 44100,
            'channels': 5}
        try:
            resp = self.client.create_preset(self.preset_name, self.container, audio=audio)
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith(
                        'audio.channels:audio.channels=')
            else:
                assert True == False, 'not throw BceServerError'

    def test_create_preset_with_audio_chanel_not_integer(self):
        """audio bitrateinbps not integer"""
        audio = {
            'bitRateInBps': 1989,
            'sampleRateInHz': 48000,
            'channels': 2.89}
        resp = self.client.create_preset(self.preset_name, self.container, audio=audio)
        nose.tools.assert_is_not_none(resp)

    def test_create_preset_with_audio_normal(self):
        """audio normal"""
        audio = {
            'bitRateInBps': 1989,
            'sampleRateInHz': 96000,
            'channels': 1}
        resp = self.client.create_preset(self.preset_name, self.container, audio=audio)
        nose.tools.assert_is_not_none(resp)

#####################test video##############
    def test_create_preset_with_video_normal(self):
        """create preset with video normal"""
        video = {
            'bitRateInBps': 32000
        }
        resp = self.client.create_preset(self.preset_name, self.container, video=video)
        nose.tools.assert_is_not_none(resp)

    def test_create_preset_with_bitrateinbps_less_than_32000(self):
        """create preset with video bitrateinbps less than 32000"""
        video = {
            'bitRateInBps': 3200
        }
        try:
            resp = self.client.create_preset(self.preset_name, self.container, video=video)
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith(
                        'video.bitRateInBps:video.bitRateInBps=must be greater than or equal to ')
            else:
                assert True == False

    def test_create_preset_with_video_profile_not_in_enum(self):
        """create preset with video profile not in enum"""
        options = {'profile': 'baseline1'}
        video = {
            'codecOptions': options,
            'bitRateInBps': 32000
        }
        try:
            resp = self.client.create_preset(self.preset_name, self.container, video=video)
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith(
                        'Could not read JSON: Can not construct instance of ')
            else:
                assert True == False

    def test_create_preset_with_video_maxframerate_not_in_enum(self):
        """create preset with video max frame rate not in enum"""
        video = {
            'bitRateInBps': 32000,
            'maxFrameRate': 12
        }
        try:
            resp = self.client.create_preset(self.preset_name, self.container, video=video)
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith(
                        'video.maxFrameRate should in [10.0, 15.0, 20.0, 23.97, 24.0, 25')
            else:
                assert True == False

    def test_create_preset_with_video_maxwidth_less_128(self):
        """create preset with video max width less than 128"""
        video = {
            'bitRateInBps': 32000,
            'maxWidthInPixel': 127.5
        }
        try:
            resp = self.client.create_preset(self.preset_name, self.container, video=video)
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith(
                        'video.maxWidthInPixel:video.maxWidthInPixel=must be greater than or ')
            else:
                assert True == False

    def test_create_preset_with_video_maxwidth_more_4096(self):
        """create preset with video max width more than 4096"""
        video = {
            'bitRateInBps': 32000,
            'maxWidthInPixel': 4097
        }
        try:
            resp = self.client.create_preset(self.preset_name, self.container, video=video)
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith(
                        'video.maxWidthInPixel:video.maxWidthInPixel=must be less than or equal')
            else:
                assert True == False

    def test_create_preset_with_video_maxheight_less_96(self):
        """create preset with video max height less than 96"""
        video = {
            'bitRateInBps': 32000,
            'maxHeightInPixel': 95.9
        }
        try:
            resp = self.client.create_preset(self.preset_name, self.container, video=video)
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith(
                        'video.maxHeightInPixel:video.maxHeightInPixel=must be greater than or ')
            else:
                assert True == False

    def test_create_preset_with_video_maxheight_more_3072(self):
        """create preset with video max height more than 3072"""
        video = {
            'bitRateInBps': 32000,
            'maxHeightInPixel': 3073
        }
        try:
            resp = self.client.create_preset(self.preset_name, self.container, video=video)
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith(
                        'video.maxHeightInPixel:video.maxHeightInPixel=must be less than or ')
            else:
                assert True == False

    def test_create_preset_with_video_sizingpolicy_not_in_enum(self):
        """create preset with video sizing policy not in enum"""
        video = {
            'bitRateInBps': 32000,
            'sizingPolicy': 'shrinkToFit11'
        }
        try:
            resp = self.client.create_preset(self.preset_name, self.container, video=video)
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith(
                        'Could not read JSON: Can not construct instance of com.baidu.bce')
            else:
                assert True == False

####################test encryption############

    def test_create_preset_with_encryption_aeskey_more_than_16chars(self):
        """create preset with video sizing policy not in enum"""
        video = {
            'bitRateInBps': 32000,
            'sizingPolicy': 'shrinkToFit'
        }
        encryption = {
            'strategy': 'Fixed',
            'aesKey': 'abcdefghij1234567'
        }
        try:
            resp = self.client.create_preset(self.preset_name,
                    self.container, video=video, encryption=encryption)
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith(
                        'encryption.aesKey:encryption.aesKey=must match')
            else:
                assert True == False

    def test_create_preset_with_encryption_steategy_none(self):
        """create preset with video sizing policy not in enum"""
        encryption = {
            'aesKey': 'abcdefghij123456'
        }
        try:
            resp = self.client.create_preset(self.preset_name,
                    self.container, True, encryption=encryption)
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith(
                        'encryption.strategy:encryption.strategy=may not be null')
            else:
                assert True == False

################test other####################

    def test_create_preset_duplication(self):
        """duplication preset"""
        resp = self.client.create_preset(self.preset_name, self.container, True)
        nose.tools.assert_is_not_none(resp)
        try:
            resp = self.client.create_preset(self.preset_name, self.container, True)
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith(
                        'duplicated preset name:')
            else:
                assert True == False, 'not throw BceServerError'

    def test_create_preset_with_all_params(self):
        """create preset with all params"""
        desc = 'this is a description with creating preset all params'
        clip = {
            'startTimeInSecond':0,
            'durationInSecond': 50
        }
        audio = {
            'bitRateInBps': 1980,
            'sampleRateInHz': 32000,
            'channels': 1,
        }
        codecOptions = {'profile': 'baseline'}
        video = {
            'codec': 'h264',
            'codecOptions': codecOptions,
            'bitRateInBps': 32000,
            'maxFrameRate': 30,
            'maxWidthInPixel': 4096,
            'maxHeightInPixel': 96,
            'sizingPolicy': 'stretch'
        }
        encryption = {
            'aesKey': 'abcdefghij123456',
            'strategy': 'Fixed'
        }
        resp = self.client.create_preset(self.preset_name, self.container, False,
                description=desc, clip=clip, audio=audio, video=video,
                watermark_id=self.watermark_id, encryption=encryption)
        nose.tools.assert_is_not_none(resp)

    def test_create_preset_with_watermark(self):
        """test create preset with transmux true but have watermark"""
        try:
            resp = self.client.create_preset(self.preset_name, self.container, \
                True, watermark_id=self.watermark_id)
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith(
                        'watermark is not supported in Transmux mode')
            else:
                assert True == False, 'not throw BceServerError'

    def test_create_preset_with_watermark_deleted(self):
        """test create preset with watermark deleted"""
        resp = self.client.delete_watermark(self.watermark_id)
        codecOptions = {'profile': 'baseline'}
        video = {
            'codec': 'h264',
            'codecOptions': codecOptions,
            'bitRateInBps': 32000,
            'maxFrameRate': 30,
            'maxWidthInPixel': 4096,
            'maxHeightInPixel': 96,
            'sizingPolicy': 'stretch'
        }
        with nose.tools.assert_raises_regexp(BceHttpClientError,
                'BceServerError: watermark: %s does not exist' % self.watermark_id):
            resp = self.client.create_preset(self.preset_name, self.container, \
                False, video=video, watermark_id=self.watermark_id)
            print(resp.content)
        self.watermark_id = None

    def test_create_preset_with_watermarkid_empty(self):
        """test create preset with watermarkid empty"""
        codecOptions = {'profile': 'baseline'}
        video = {
            'codec': 'h264',
            'codecOptions': codecOptions,
            'bitRateInBps': 32000,
            'maxFrameRate': 30,
            'maxWidthInPixel': 4096,
            'maxHeightInPixel': 96,
            'sizingPolicy': 'stretch'
        }
        try:
            resp = self.client.create_preset(self.preset_name, self.container, \
                False, video=video, watermark_id='')
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith('watermark: ')
            else:
                assert True == False, 'not throw BceServerError'

    def test_create_preset_with_watermarkid_none(self):
        """test create preset with watermarkid none"""
        resp = self.client.create_preset(self.preset_name, self.container,
                True, watermark_id=None)
        nose.tools.assert_is_not_none(resp)


text:
Displays the list of events fetched for an asset identified as a "ChronicleAsset" type of indicator, when its product ID is passed as an asset identifier.
## Script Data
---

| **Name** | **Description** |
| --- | --- |
| Script Type | python3 |
| Tags | dynamic-indicator-section |
| Cortex XSOAR Version | 5.0.0 |

## Dependencies
---
This script uses the following commands and scripts.
***gcb-list-events**

## Inputs
---
There are no inputs for this script.

## Outputs
---
There are no outputs for this script.


text:
package user

import (
    "github.com/gin-gonic/gin"
    "net/http"
    "log"
)

func getIndex(c *gin.Context) {
    log.Println("user index")
    c.String(http.StatusOK, "Hello %s", c.Param("name"))
}


text:
package com.smartdevicelink.protocol.heartbeat;

import android.os.Handler;
import android.os.Looper;

import androidx.annotation.RestrictTo;

@RestrictTo(RestrictTo.Scope.LIBRARY)
public class HeartbeatMonitor implements IHeartbeatMonitor {

    public static final int HEARTBEAT_INTERVAL = 5000;
    public static final int HEARTBEAT_INTERVAL_MAX = Integer.MAX_VALUE;

    private final Object heartbeatThreadHandlerLock = new Object();
    private final Object listenerLock = new Object();

    private int mHeartBeatInterval = HEARTBEAT_INTERVAL;
    private final boolean mHeartBeatAck = true;

    private IHeartbeatMonitorListener mListener;
    private volatile boolean mIsAckReceived;
    private volatile boolean isHeartbeatReceived;
    private Thread mHeartbeatThread;
    private Looper mHeartbeatThreadLooper;
    private Handler mHeartbeatThreadHandler;

    public HeartbeatMonitor() {
    }

    // Methods used to retrieve values for unit testing only.
    // See com/smartdevicelink/tests/protocol/heartbeat/HeartbeatMonitorTests.
    public Runnable getHeartbeatRunnable() {
        return heartbeatTimeoutRunnable;
    }

    public boolean isHeartbeatReceived() {
        return isHeartbeatReceived;
    }

    private final Runnable heartbeatTimeoutRunnable = new Runnable() {

        @Override
        public void run() {
            try {
                synchronized (listenerLock) {
                    if (isHeartbeatReceived) {
                        if (mListener != null) {
                            mListener.sendHeartbeat(HeartbeatMonitor.this);
                        } else {

                        }
                        isHeartbeatReceived = false;
                    } else {
                        if (mListener != null) {
                            mListener.heartbeatTimedOut(HeartbeatMonitor.this);
                        }
                    }
                }
            } catch (Exception ex) {
                stop();
            }
        }
    };

    private final Runnable heartbeatAckTimeoutRunnable = new Runnable() {

        @Override
        public void run() {

            try {
                synchronized (listenerLock) {
                    if (mIsAckReceived) {
                        if (mListener != null) {
                            mListener.sendHeartbeat(HeartbeatMonitor.this);
                        } else {
                        }
                        mIsAckReceived = false;
                    } else {
                        if (mListener != null) {
                            mListener.heartbeatTimedOut(HeartbeatMonitor.this);
                        }
                        stop();
                    }
                }

            } catch (Exception ex) {
                stop();
            }

            rescheduleHeartbeat();
        }

        private void rescheduleHeartbeat() {
            synchronized (heartbeatThreadHandlerLock) {
                if (mHeartbeatThreadHandler != null) {
                    if (!Thread.interrupted()) {
                        if (!mHeartbeatThreadHandler.postDelayed(this, mHeartBeatInterval)) {
                        }
                    } else {
                    }
                } else {
                    stop();
                }
            }
        }
    };

    @Override
    public void start() {

        synchronized (heartbeatThreadHandlerLock) {

            if (mHeartbeatThread != null) {
                return;
            }

            mHeartbeatThread = new Thread(new Runnable() {

                @Override
                public void run() {

                    while (!Thread.interrupted()) {
                        Looper.prepare();
                        mHeartbeatThreadLooper = Looper.myLooper();

                        mHeartbeatThreadHandler = new Handler();
                        mIsAckReceived = true;
                        isHeartbeatReceived = true;

                        if (!mHeartbeatThreadHandler.postDelayed(
                                heartbeatAckTimeoutRunnable, mHeartBeatInterval)) {
                        }
                        Looper.loop();
                    }
                }

            }, "HeartbeatThread");
            mHeartbeatThread.setPriority(Thread.MAX_PRIORITY);
            mHeartbeatThread.start();
        }
    }

    @Override
    public void stop() {

        synchronized (heartbeatThreadHandlerLock) {

            if (mHeartbeatThread == null) {
                mHeartbeatThreadHandler = null;
                mHeartbeatThreadLooper = null;
                return;
            }

            mHeartbeatThread.interrupt();
            mHeartbeatThread = null;

            if (mHeartbeatThreadHandler != null) {
                mHeartbeatThreadHandler.removeCallbacks(heartbeatAckTimeoutRunnable);
                mHeartbeatThreadHandler.removeCallbacks(heartbeatTimeoutRunnable);
                mHeartbeatThreadHandler = null;
            } else {
            }

            if (mHeartbeatThreadLooper != null) {
                mHeartbeatThreadLooper.quit();
                mHeartbeatThreadLooper = null;
            } else {
            }
        }
    }

    @Override
    public int getInterval() {
        return mHeartBeatInterval;
    }

    @Override
    public void setInterval(int value) {
        mHeartBeatInterval = value;
    }

    @Override
    public IHeartbeatMonitorListener getListener() {
        return mListener;
    }

    @Override
    public void setListener(IHeartbeatMonitorListener value) {
        mListener = value;
    }

    @Override
    public void notifyTransportActivity() {
        if (mHeartbeatThreadHandler == null) {
            return;
        }
        synchronized (heartbeatThreadHandlerLock) {
            if (mHeartbeatThreadHandler == null) {
                return;
            }
            mHeartbeatThreadHandler.removeCallbacks(heartbeatAckTimeoutRunnable);
            if (!mHeartbeatThreadHandler.postDelayed(heartbeatAckTimeoutRunnable, mHeartBeatInterval)) {
            }
        }
    }

    @Override
    public synchronized void heartbeatACKReceived() {
        synchronized (listenerLock) {
            mIsAckReceived = true;
        }
    }

    @Override
    public void heartbeatReceived() {
        if (mHeartbeatThreadHandler == null) {
            return;
        }
        synchronized (listenerLock) {
            if (mHeartBeatAck) {
                isHeartbeatReceived = true;
                if (!mHeartbeatThreadHandler.post(heartbeatTimeoutRunnable)) {
                }
            }
        }
    }
}


text:
#ifndef __ShapeLayer_h__
#define __ShapeLayer_h__

class ShapeLayer : public CCSprite
{
	public :

		static ShapeLayer*		create ( KDvoid );

	public :

		virtual KDvoid			draw ( KDvoid );
};

#endif	// __ShapeLayer_h__


text:
package ezbake.deployer.publishers.mesos;

public class MarathonLaunchFailureException extends Exception
{
    public MarathonLaunchFailureException(String msg)
    {
        super(msg);
    }
}


text:
package org.opencompare.explorers;

import org.opencompare.explorable.Explorable;
import org.opencompare.explorable.ProcessConfiguration;
import org.opencompare.explore.ExplorationException;
import org.opencompare.explore.ExploringThread;

public interface Explorer {

	/**
	 * Get contents of this object. This method will not be called often, so
	 * there is no need to cache its results in subclasses.
	 *
	 * @throws ExplorationException
	 * @throws InterruptedException
	 */
	void explore(ProcessConfiguration config, ExploringThread thread, Explorable what) throws ExplorationException, InterruptedException;
}


text:
<?php
/**
 * Generated by Protobuf protoc plugin.
 *
 * File descriptor : POGOProtos/Settings/Master/GymBadgeGmtSettings.proto
 */

namespace POGOProtos\Settings\Master;

/**
 * Protobuf message : POGOProtos.Settings.Master.GymBadgeGmtSettings
 */
class GymBadgeGmtSettings extends \Protobuf\AbstractMessage
{

    /**
     * @var \Protobuf\UnknownFieldSet
     */
    protected $unknownFieldSet = null;

    /**
     * @var \Protobuf\Extension\ExtensionFieldMap
     */
    protected $extensions = null;

    /**
     * target repeated int32 = 1
     *
     * @var \Protobuf\Collection
     */
    protected $target = null;

    /**
     * battle_winning_score_per_defender_cp optional float = 2
     *
     * @var float
     */
    protected $battle_winning_score_per_defender_cp = null;

    /**
     * gym_defending_score_per_minute optional float = 3
     *
     * @var float
     */
    protected $gym_defending_score_per_minute = null;

    /**
     * berry_feeding_score optional int32 = 4
     *
     * @var int
     */
    protected $berry_feeding_score = null;

    /**
     * pokemon_deploy_score optional int32 = 5
     *
     * @var int
     */
    protected $pokemon_deploy_score = null;

    /**
     * raid_battle_winning_score optional int32 = 6
     *
     * @var int
     */
    protected $raid_battle_winning_score = null;

    /**
     * lose_all_battles_score optional int32 = 7
     *
     * @var int
     */
    protected $lose_all_battles_score = null;

    /**
     * Check if 'target' has a value
     *
     * @return bool
     */
    public function hasTargetList()
    {
        return $this->target !== null;
    }

    /**
     * Get 'target' value
     *
     * @return \Protobuf\Collection
     */
    public function getTargetList()
    {
        return $this->target;
    }

    /**
     * Set 'target' value
     *
     * @param \Protobuf\Collection $value
     */
    public function setTargetList(\Protobuf\Collection $value = null)
    {
        $this->target = $value;
    }

    /**
     * Add a new element to 'target'
     *
     * @param int $value
     */
    public function addTarget($value)
    {
        if ($this->target === null) {
            $this->target = new \Protobuf\ScalarCollection();
        }

        $this->target->add($value);
    }

    /**
     * Check if 'battle_winning_score_per_defender_cp' has a value
     *
     * @return bool
     */
    public function hasBattleWinningScorePerDefenderCp()
    {
        return $this->battle_winning_score_per_defender_cp !== null;
    }

    /**
     * Get 'battle_winning_score_per_defender_cp' value
     *
     * @return float
     */
    public function getBattleWinningScorePerDefenderCp()
    {
        return $this->battle_winning_score_per_defender_cp;
    }

    /**
     * Set 'battle_winning_score_per_defender_cp' value
     *
     * @param float $value
     */
    public function setBattleWinningScorePerDefenderCp($value = null)
    {
        $this->battle_winning_score_per_defender_cp = $value;
    }

    /**
     * Check if 'gym_defending_score_per_minute' has a value
     *
     * @return bool
     */
    public function hasGymDefendingScorePerMinute()
    {
        return $this->gym_defending_score_per_minute !== null;
    }

    /**
     * Get 'gym_defending_score_per_minute' value
     *
     * @return float
     */
    public function getGymDefendingScorePerMinute()
    {
        return $this->gym_defending_score_per_minute;
    }

    /**
     * Set 'gym_defending_score_per_minute' value
     *
     * @param float $value
     */
    public function setGymDefendingScorePerMinute($value = null)
    {
        $this->gym_defending_score_per_minute = $value;
    }

    /**
     * Check if 'berry_feeding_score' has a value
     *
     * @return bool
     */
    public function hasBerryFeedingScore()
    {
        return $this->berry_feeding_score !== null;
    }

    /**
     * Get 'berry_feeding_score' value
     *
     * @return int
     */
    public function getBerryFeedingScore()
    {
        return $this->berry_feeding_score;
    }

    /**
     * Set 'berry_feeding_score' value
     *
     * @param int $value
     */
    public function setBerryFeedingScore($value = null)
    {
        $this->berry_feeding_score = $value;
    }

    /**
     * Check if 'pokemon_deploy_score' has a value
     *
     * @return bool
     */
    public function hasPokemonDeployScore()
    {
        return $this->pokemon_deploy_score !== null;
    }

    /**
     * Get 'pokemon_deploy_score' value
     *
     * @return int
     */
    public function getPokemonDeployScore()
    {
        return $this->pokemon_deploy_score;
    }

    /**
     * Set 'pokemon_deploy_score' value
     *
     * @param int $value
     */
    public function setPokemonDeployScore($value = null)
    {
        $this->pokemon_deploy_score = $value;
    }

    /**
     * Check if 'raid_battle_winning_score' has a value
     *
     * @return bool
     */
    public function hasRaidBattleWinningScore()
    {
        return $this->raid_battle_winning_score !== null;
    }

    /**
     * Get 'raid_battle_winning_score' value
     *
     * @return int
     */
    public function getRaidBattleWinningScore()
    {
        return $this->raid_battle_winning_score;
    }

    /**
     * Set 'raid_battle_winning_score' value
     *
     * @param int $value
     */
    public function setRaidBattleWinningScore($value = null)
    {
        $this->raid_battle_winning_score = $value;
    }

    /**
     * Check if 'lose_all_battles_score' has a value
     *
     * @return bool
     */
    public function hasLoseAllBattlesScore()
    {
        return $this->lose_all_battles_score !== null;
    }

    /**
     * Get 'lose_all_battles_score' value
     *
     * @return int
     */
    public function getLoseAllBattlesScore()
    {
        return $this->lose_all_battles_score;
    }

    /**
     * Set 'lose_all_battles_score' value
     *
     * @param int $value
     */
    public function setLoseAllBattlesScore($value = null)
    {
        $this->lose_all_battles_score = $value;
    }

    /**
     * {@inheritdoc}
     */
    public function extensions()
    {
        if ( $this->extensions !== null) {
            return $this->extensions;
        }

        return $this->extensions = new \Protobuf\Extension\ExtensionFieldMap(__CLASS__);
    }

    /**
     * {@inheritdoc}
     */
    public function unknownFieldSet()
    {
        return $this->unknownFieldSet;
    }

    /**
     * {@inheritdoc}
     */
    public static function fromStream($stream, \Protobuf\Configuration $configuration = null)
    {
        return new self($stream, $configuration);
    }

    /**
     * {@inheritdoc}
     */
    public static function fromArray(array $values)
    {
        $message = new self();
        $values  = array_merge([
            'target' => [],
            'battle_winning_score_per_defender_cp' => null,
            'gym_defending_score_per_minute' => null,
            'berry_feeding_score' => null,
            'pokemon_deploy_score' => null,
            'raid_battle_winning_score' => null,
            'lose_all_battles_score' => null
        ], $values);

        $message->setBattleWinningScorePerDefenderCp($values['battle_winning_score_per_defender_cp']);
        $message->setGymDefendingScorePerMinute($values['gym_defending_score_per_minute']);
        $message->setBerryFeedingScore($values['berry_feeding_score']);
        $message->setPokemonDeployScore($values['pokemon_deploy_score']);
        $message->setRaidBattleWinningScore($values['raid_battle_winning_score']);
        $message->setLoseAllBattlesScore($values['lose_all_battles_score']);

        foreach ($values['target'] as $item) {
            $message->addTarget($item);
        }

        return $message;
    }

    /**
     * {@inheritdoc}
     */
    public static function descriptor()
    {
        return \google\protobuf\DescriptorProto::fromArray([
            'name'      => 'GymBadgeGmtSettings',
            'field'     => [
                \google\protobuf\FieldDescriptorProto::fromArray([
                    'number' => 1,
                    'name' => 'target',
                    'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_INT32(),
                    'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_REPEATED()
                ]),
                \google\protobuf\FieldDescriptorProto::fromArray([
                    'number' => 2,
                    'name' => 'battle_winning_score_per_defender_cp',
                    'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_FLOAT(),
                    'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()
                ]),
                \google\protobuf\FieldDescriptorProto::fromArray([
                    'number' => 3,
                    'name' => 'gym_defending_score_per_minute',
                    'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_FLOAT(),
                    'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()
                ]),
                \google\protobuf\FieldDescriptorProto::fromArray([
                    'number' => 4,
                    'name' => 'berry_feeding_score',
                    'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_INT32(),
                    'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()
                ]),
                \google\protobuf\FieldDescriptorProto::fromArray([
                    'number' => 5,
                    'name' => 'pokemon_deploy_score',
                    'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_INT32(),
                    'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()
                ]),
                \google\protobuf\FieldDescriptorProto::fromArray([
                    'number' => 6,
                    'name' => 'raid_battle_winning_score',
                    'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_INT32(),
                    'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()
                ]),
                \google\protobuf\FieldDescriptorProto::fromArray([
                    'number' => 7,
                    'name' => 'lose_all_battles_score',
                    'type' => \google\protobuf\FieldDescriptorProto\Type::TYPE_INT32(),
                    'label' => \google\protobuf\FieldDescriptorProto\Label::LABEL_OPTIONAL()
                ]),
            ],
        ]);
    }

    /**
     * {@inheritdoc}
     */
    public function toStream(\Protobuf\Configuration $configuration = null)
    {
        $config  = $configuration ?: \Protobuf\Configuration::getInstance();
        $context = $config->createWriteContext();
        $stream  = $context->getStream();

        $this->writeTo($context);
        $stream->seek(0);

        return $stream;
    }

    /**
     * {@inheritdoc}
     */
    public function writeTo(\Protobuf\WriteContext $context)
    {
        $stream      = $context->getStream();
        $writer      = $context->getWriter();
        $sizeContext = $context->getComputeSizeContext();

        if ($this->target !== null) {
            foreach ($this->target as $val) {
                $writer->writeVarint($stream, 8);
                $writer->writeVarint($stream, $val);
            }
        }

        if ($this->battle_winning_score_per_defender_cp !== null) {
            $writer->writeVarint($stream, 21);
            $writer->writeFloat($stream, $this->battle_winning_score_per_defender_cp);
        }

        if ($this->gym_defending_score_per_minute !== null) {
            $writer->writeVarint($stream, 29);
            $writer->writeFloat($stream, $this->gym_defending_score_per_minute);
        }

        if ($this->berry_feeding_score !== null) {
            $writer->writeVarint($stream, 32);
            $writer->writeVarint($stream, $this->berry_feeding_score);
        }

        if ($this->pokemon_deploy_score !== null) {
            $writer->writeVarint($stream, 40);
            $writer->writeVarint($stream, $this->pokemon_deploy_score);
        }

        if ($this->raid_battle_winning_score !== null) {
            $writer->writeVarint($stream, 48);
            $writer->writeVarint($stream, $this->raid_battle_winning_score);
        }

        if ($this->lose_all_battles_score !== null) {
            $writer->writeVarint($stream, 56);
            $writer->writeVarint($stream, $this->lose_all_battles_score);
        }

        if ($this->extensions !== null) {
            $this->extensions->writeTo($context);
        }

        return $stream;
    }

    /**
     * {@inheritdoc}
     */
    public function readFrom(\Protobuf\ReadContext $context)
    {
        $reader = $context->getReader();
        $length = $context->getLength();
        $stream = $context->getStream();

        $limit = ($length !== null)
            ? ($stream->tell() + $length)
            : null;

        while ($limit === null || $stream->tell() < $limit) {

            if ($stream->eof()) {
                break;
            }

            $key  = $reader->readVarint($stream);
            $wire = \Protobuf\WireFormat::getTagWireType($key);
            $tag  = \Protobuf\WireFormat::getTagFieldNumber($key);

            if ($stream->eof()) {
                break;
            }

            if ($tag === 1) {
                $innerSize  = $reader->readVarint($stream);
                $innerLimit = $stream->tell() + $innerSize;

                if ($this->target === null) {
                    $this->target = new \Protobuf\ScalarCollection();
                }

                while ($stream->tell() < $innerLimit) {
                    $this->target->add($reader->readVarint($stream));
                }

                continue;
            }

            if ($tag === 2) {
                \Protobuf\WireFormat::assertWireType($wire, 2);

                $this->battle_winning_score_per_defender_cp = $reader->readFloat($stream);

                continue;
            }

            if ($tag === 3) {
                \Protobuf\WireFormat::assertWireType($wire, 2);

                $this->gym_defending_score_per_minute = $reader->readFloat($stream);

                continue;
            }

            if ($tag === 4) {
                \Protobuf\WireFormat::assertWireType($wire, 5);

                $this->berry_feeding_score = $reader->readVarint($stream);

                continue;
            }

            if ($tag === 5) {
                \Protobuf\WireFormat::assertWireType($wire, 5);

                $this->pokemon_deploy_score = $reader->readVarint($stream);

                continue;
            }

            if ($tag === 6) {
                \Protobuf\WireFormat::assertWireType($wire, 5);

                $this->raid_battle_winning_score = $reader->readVarint($stream);

                continue;
            }

            if ($tag === 7) {
                \Protobuf\WireFormat::assertWireType($wire, 5);

                $this->lose_all_battles_score = $reader->readVarint($stream);

                continue;
            }

            $extensions = $context->getExtensionRegistry();
            $extension  = $extensions ? $extensions->findByNumber(__CLASS__, $tag) : null;

            if ($extension !== null) {
                $this->extensions()->add($extension, $extension->readFrom($context, $wire));

                continue;
            }

            if ($this->unknownFieldSet === null) {
                $this->unknownFieldSet = new \Protobuf\UnknownFieldSet();
            }

            $data    = $reader->readUnknown($stream, $wire);
            $unknown = new \Protobuf\Unknown($tag, $wire, $data);

            $this->unknownFieldSet->add($unknown);

        }
    }

    /**
     * {@inheritdoc}
     */
    public function serializedSize(\Protobuf\ComputeSizeContext $context)
    {
        $calculator = $context->getSizeCalculator();
        $size       = 0;

        if ($this->target !== null) {
            foreach ($this->target as $val) {
                $size += 1;
                $size += $calculator->computeVarintSize($val);
            }
        }

        if ($this->battle_winning_score_per_defender_cp !== null) {
            $size += 1;
            $size += 4;
        }

        if ($this->gym_defending_score_per_minute !== null) {
            $size += 1;
            $size += 4;
        }

        if ($this->berry_feeding_score !== null) {
            $size += 1;
            $size += $calculator->computeVarintSize($this->berry_feeding_score);
        }

        if ($this->pokemon_deploy_score !== null) {
            $size += 1;
            $size += $calculator->computeVarintSize($this->pokemon_deploy_score);
        }

        if ($this->raid_battle_winning_score !== null) {
            $size += 1;
            $size += $calculator->computeVarintSize($this->raid_battle_winning_score);
        }

        if ($this->lose_all_battles_score !== null) {
            $size += 1;
            $size += $calculator->computeVarintSize($this->lose_all_battles_score);
        }

        if ($this->extensions !== null) {
            $size += $this->extensions->serializedSize($context);
        }

        return $size;
    }

    /**
     * {@inheritdoc}
     */
    public function clear()
    {
        $this->target = null;
        $this->battle_winning_score_per_defender_cp = null;
        $this->gym_defending_score_per_minute = null;
        $this->berry_feeding_score = null;
        $this->pokemon_deploy_score = null;
        $this->raid_battle_winning_score = null;
        $this->lose_all_battles_score = null;
    }

    /**
     * {@inheritdoc}
     */
    public function merge(\Protobuf\Message $message)
    {
        if ( ! $message instanceof \POGOProtos\Settings\Master\GymBadgeGmtSettings) {
            throw new \InvalidArgumentException(sprintf('Argument 1 passed to %s must be a %s, %s given', __METHOD__, __CLASS__, get_class($message)));
        }

        $this->target = ($message->target !== null) ? $message->target : $this->target;
        $this->battle_winning_score_per_defender_cp = ($message->battle_winning_score_per_defender_cp !== null) ? $message->battle_winning_score_per_defender_cp : $this->battle_winning_score_per_defender_cp;
        $this->gym_defending_score_per_minute = ($message->gym_defending_score_per_minute !== null) ? $message->gym_defending_score_per_minute : $this->gym_defending_score_per_minute;
        $this->berry_feeding_score = ($message->berry_feeding_score !== null) ? $message->berry_feeding_score : $this->berry_feeding_score;
        $this->pokemon_deploy_score = ($message->pokemon_deploy_score !== null) ? $message->pokemon_deploy_score : $this->pokemon_deploy_score;
        $this->raid_battle_winning_score = ($message->raid_battle_winning_score !== null) ? $message->raid_battle_winning_score : $this->raid_battle_winning_score;
        $this->lose_all_battles_score = ($message->lose_all_battles_score !== null) ? $message->lose_all_battles_score : $this->lose_all_battles_score;
    }

}