grafana -> notification-provider -> mattermost | see https://gitlab.fedy95.com/dev/notification-provider
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

286 lines
8.3 KiB

<?php
declare(strict_types=1);
namespace App\Tests\Unit\Model\Alertmanager;
use App\Model\Alertmanager\AlertmanagerMessage;
use App\Model\Alertmanager\Alert;
use App\Model\Alertmanager\Annotation;
use App\Model\Alertmanager\Label;
use App\Tests\Unit\UnitTester;
use ReflectionException;
final class AlertmanagerMessageTest extends UnitTester
{
/**
* @throws ReflectionException
*/
public function testGetReceiver(): void
{
$alertmanagerMessage = new AlertmanagerMessage();
$value = $this->faker->sha256();
$property = $this->getClassProperty($alertmanagerMessage, 'receiver');
$property->setValue($alertmanagerMessage, $value);
self::assertEquals($value, $alertmanagerMessage->getReceiver());
}
/**
* @throws ReflectionException
*/
public function testSetReceiver(): void
{
$alertmanagerMessage = new AlertmanagerMessage();
$value = $this->faker->sha256();
self::assertEquals($alertmanagerMessage, $alertmanagerMessage->setReceiver($value));
self::assertEquals(
$value,
($this->getClassProperty($alertmanagerMessage, 'receiver'))
->getValue($alertmanagerMessage)
);
}
/**
* @throws ReflectionException
*/
public function testGetStatus(): void
{
$alertmanagerMessage = new AlertmanagerMessage();
$value = $this->faker->sha256();
$property = $this->getClassProperty($alertmanagerMessage, 'status');
$property->setValue($alertmanagerMessage, $value);
self::assertEquals($value, $alertmanagerMessage->getStatus());
}
/**
* @throws ReflectionException
*/
public function testSetStatus(): void
{
$alertmanagerMessage = new AlertmanagerMessage();
$value = $this->faker->sha256();
self::assertEquals($alertmanagerMessage, $alertmanagerMessage->setStatus($value));
self::assertEquals(
$value,
($this->getClassProperty($alertmanagerMessage, 'status'))
->getValue($alertmanagerMessage)
);
}
/**
* @throws ReflectionException
*/
public function testGetAlerts(): void
{
$alertmanagerMessage = new AlertmanagerMessage();
$value = [new Alert()];
$property = $this->getClassProperty($alertmanagerMessage, 'alerts');
$property->setValue($alertmanagerMessage, $value);
self::assertEquals($value, $alertmanagerMessage->getAlerts());
}
/**
* @throws ReflectionException
*/
public function testSetAlerts(): void
{
$alertmanagerMessage = new AlertmanagerMessage();
$value = [new Alert()];
self::assertEquals($alertmanagerMessage, $alertmanagerMessage->setAlerts($value));
self::assertEquals(
$value,
($this->getClassProperty($alertmanagerMessage, 'alerts'))
->getValue($alertmanagerMessage)
);
}
/**
* @throws ReflectionException
*/
public function testGetLabels(): void
{
$alertmanagerMessage = new AlertmanagerMessage();
$value = new Label();
$property = $this->getClassProperty($alertmanagerMessage, 'commonLabels');
$property->setValue($alertmanagerMessage, $value);
self::assertEquals($value, $alertmanagerMessage->getCommonLabels());
}
/**
* @throws ReflectionException
*/
public function testSetLabels(): void
{
$alertmanagerMessage = new AlertmanagerMessage();
$value = new Label();
self::assertEquals($alertmanagerMessage, $alertmanagerMessage->setCommonLabels($value));
self::assertEquals(
$value,
($this->getClassProperty($alertmanagerMessage, 'commonLabels'))
->getValue($alertmanagerMessage)
);
}
/**
* @throws ReflectionException
*/
public function testGetCommonAnnotations(): void
{
$alertmanagerMessage = new AlertmanagerMessage();
$value = new Annotation();
$property = $this->getClassProperty($alertmanagerMessage, 'commonAnnotations');
$property->setValue($alertmanagerMessage, $value);
self::assertEquals($value, $alertmanagerMessage->getCommonAnnotations());
}
/**
* @throws ReflectionException
*/
public function testSetCommonAnnotations(): void
{
$alertmanagerMessage = new AlertmanagerMessage();
$value = new Annotation();
self::assertEquals($alertmanagerMessage, $alertmanagerMessage->setCommonAnnotations($value));
self::assertEquals(
$value,
($this->getClassProperty($alertmanagerMessage, 'commonAnnotations'))
->getValue($alertmanagerMessage)
);
}
/**
* @throws ReflectionException
*/
public function testGetExternalURL(): void
{
$alertmanagerMessage = new AlertmanagerMessage();
$value = $this->faker->sha256();
$property = $this->getClassProperty($alertmanagerMessage, 'externalURL');
$property->setValue($alertmanagerMessage, $value);
self::assertEquals($value, $alertmanagerMessage->getExternalURL());
}
/**
* @throws ReflectionException
*/
public function testSetExternalURL(): void
{
$alertmanagerMessage = new AlertmanagerMessage();
$value = $this->faker->sha256();
self::assertEquals($alertmanagerMessage, $alertmanagerMessage->setExternalURL($value));
self::assertEquals(
$value,
($this->getClassProperty($alertmanagerMessage, 'externalURL'))
->getValue($alertmanagerMessage)
);
}
/**
* @throws ReflectionException
*/
public function testGetVersion(): void
{
$alertmanagerMessage = new AlertmanagerMessage();
$value = $this->faker->sha256();
$property = $this->getClassProperty($alertmanagerMessage, 'version');
$property->setValue($alertmanagerMessage, $value);
self::assertEquals($value, $alertmanagerMessage->getVersion());
}
/**
* @throws ReflectionException
*/
public function testSetVersion(): void
{
$alertmanagerMessage = new AlertmanagerMessage();
$value = $this->faker->sha256();
self::assertEquals($alertmanagerMessage, $alertmanagerMessage->setVersion($value));
self::assertEquals(
$value,
($this->getClassProperty($alertmanagerMessage, 'version'))
->getValue($alertmanagerMessage)
);
}
/**
* @throws ReflectionException
*/
public function testGetGroupKey(): void
{
$alertmanagerMessage = new AlertmanagerMessage();
$value = $this->faker->sha256();
$property = $this->getClassProperty($alertmanagerMessage, 'groupKey');
$property->setValue($alertmanagerMessage, $value);
self::assertEquals($value, $alertmanagerMessage->getGroupKey());
}
/**
* @throws ReflectionException
*/
public function testSetGroupKey(): void
{
$alertmanagerMessage = new AlertmanagerMessage();
$value = $this->faker->sha256();
self::assertEquals($alertmanagerMessage, $alertmanagerMessage->setGroupKey($value));
self::assertEquals(
$value,
($this->getClassProperty($alertmanagerMessage, 'groupKey'))
->getValue($alertmanagerMessage)
);
}
/**
* @throws ReflectionException
*/
public function testGetTruncatedAlerts(): void
{
$alertmanagerMessage = new AlertmanagerMessage();
$value = $this->faker->randomNumber();
$property = $this->getClassProperty($alertmanagerMessage, 'truncatedAlerts');
$property->setValue($alertmanagerMessage, $value);
self::assertEquals($value, $alertmanagerMessage->getTruncatedAlerts());
}
/**
* @throws ReflectionException
*/
public function testSetTruncatedAlerts(): void
{
$alertmanagerMessage = new AlertmanagerMessage();
$value = $this->faker->randomNumber();
self::assertEquals($alertmanagerMessage, $alertmanagerMessage->setTruncatedAlerts($value));
self::assertEquals(
$value,
($this->getClassProperty($alertmanagerMessage, 'truncatedAlerts'))
->getValue($alertmanagerMessage)
);
}
}