From c4f22e2015fe6bcd0d12dcad1f06ee6b1a4837cb Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Tue, 26 Mar 2019 11:56:42 +0100 Subject: [PATCH] Visual Console Refactor: added linked visual console capabilities to the group item Former-commit-id: 4f314c53781cd478078198b99b4ea02943579fd0 --- .../models/VisualConsole/items/Group.php | 8 ++ .../Models/VisualConsole/items/GroupTest.php | 98 ++++++++++++++++++- 2 files changed, 105 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/rest-api/models/VisualConsole/items/Group.php b/pandora_console/include/rest-api/models/VisualConsole/items/Group.php index 8e798f7215..c48c26df0a 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/items/Group.php +++ b/pandora_console/include/rest-api/models/VisualConsole/items/Group.php @@ -11,6 +11,14 @@ use Models\VisualConsole\Item; final class Group extends Item { + /** + * Used to enable the fetching, validation and extraction of information + * about the linked visual console. + * + * @var boolean + */ + protected static $useLinkedVisualConsole = true; + /** * Returns a valid representation of the model. diff --git a/pandora_console/tests/Functional/Models/VisualConsole/items/GroupTest.php b/pandora_console/tests/Functional/Models/VisualConsole/items/GroupTest.php index 33106b1aab..97fdb1a206 100644 --- a/pandora_console/tests/Functional/Models/VisualConsole/items/GroupTest.php +++ b/pandora_console/tests/Functional/Models/VisualConsole/items/GroupTest.php @@ -149,7 +149,7 @@ class GroupTest extends TestCase public function testContainerIsRepresentedAsJson(): void { $this->assertEquals( - '{"aclGroupId":null,"groupId":12,"height":0,"id":7,"imageSrc":"image.jpg","isLinkEnabled":true,"isOnTop":false,"label":null,"labelPosition":"up","parentId":null,"type":11,"width":0,"x":-666,"y":76}', + '{"aclGroupId":null,"groupId":12,"height":0,"id":7,"imageSrc":"image.jpg","isLinkEnabled":true,"isOnTop":false,"label":null,"labelPosition":"up","linkedLayoutAgentId":null,"linkedLayoutId":null,"linkedLayoutStatusType":"default","parentId":null,"type":11,"width":0,"x":-666,"y":76}', (string) Group::fromArray( [ 'id' => 7, @@ -168,6 +168,102 @@ class GroupTest extends TestCase ] ) ); + + // With a linked layout. + $this->assertEquals( + '{"aclGroupId":null,"groupId":12,"height":0,"id":7,"imageSrc":"image.jpg","isLinkEnabled":true,"isOnTop":false,"label":null,"labelPosition":"up","linkedLayoutAgentId":null,"linkedLayoutId":1,"linkedLayoutStatusType":"default","parentId":null,"type":11,"width":0,"x":-666,"y":76}', + (string) Group::fromArray( + [ + 'id' => 7, + 'type' => GROUP_ITEM, + 'label' => null, + 'labelPosition' => 'up', + 'isLinkEnabled' => true, + 'isOnTop' => false, + 'parentId' => null, + 'width' => '0', + 'height' => '0', + 'x' => -666, + 'y' => 76, + 'imageSrc' => 'image.jpg', + 'groupId' => 12, + 'id_layout_linked' => 1, + ] + ) + ); + + $this->assertEquals( + '{"aclGroupId":null,"groupId":12,"height":0,"id":7,"imageSrc":"image.jpg","isLinkEnabled":true,"isOnTop":false,"label":null,"labelPosition":"up","linkedLayoutAgentId":3,"linkedLayoutId":2,"linkedLayoutStatusType":"default","metaconsoleId":5,"parentId":null,"type":11,"width":0,"x":-666,"y":76}', + (string) Group::fromArray( + [ + 'id' => 7, + 'type' => GROUP_ITEM, + 'label' => null, + 'labelPosition' => 'up', + 'isLinkEnabled' => true, + 'isOnTop' => false, + 'parentId' => null, + 'width' => '0', + 'height' => '0', + 'x' => -666, + 'y' => 76, + 'imageSrc' => 'image.jpg', + 'groupId' => 12, + 'id_metaconsole' => 5, + 'linked_layout_node_id' => 3, + 'linkedLayoutId' => 2, + ] + ) + ); + $this->assertEquals( + '{"aclGroupId":null,"groupId":12,"height":0,"id":7,"imageSrc":"image.jpg","isLinkEnabled":true,"isOnTop":false,"label":null,"labelPosition":"up","linkedLayoutAgentId":3,"linkedLayoutId":2,"linkedLayoutStatusType":"weight","linkedLayoutStatusTypeWeight":80,"metaconsoleId":5,"parentId":null,"type":11,"width":0,"x":-666,"y":76}', + (string) Group::fromArray( + [ + 'id' => 7, + 'type' => GROUP_ITEM, + 'label' => null, + 'labelPosition' => 'up', + 'isLinkEnabled' => true, + 'isOnTop' => false, + 'parentId' => null, + 'width' => '0', + 'height' => '0', + 'x' => -666, + 'y' => 76, + 'imageSrc' => 'image.jpg', + 'groupId' => 12, + 'id_metaconsole' => 5, + 'linked_layout_node_id' => 3, + 'linkedLayoutId' => 2, + 'linkedLayoutStatusType' => 'weight', + 'linkedLayoutStatusTypeWeight' => 80, + ] + ) + ); + $this->assertEquals( + '{"aclGroupId":null,"groupId":12,"height":0,"id":7,"imageSrc":"image.jpg","isLinkEnabled":true,"isOnTop":false,"label":null,"labelPosition":"up","linkedLayoutAgentId":null,"linkedLayoutId":2,"linkedLayoutStatusType":"service","linkedLayoutStatusTypeCriticalThreshold":80,"linkedLayoutStatusTypeWarningThreshold":50,"parentId":null,"type":11,"width":0,"x":-666,"y":76}', + (string) Group::fromArray( + [ + 'id' => 7, + 'type' => GROUP_ITEM, + 'label' => null, + 'labelPosition' => 'up', + 'isLinkEnabled' => true, + 'isOnTop' => false, + 'parentId' => null, + 'width' => '0', + 'height' => '0', + 'x' => -666, + 'y' => 76, + 'imageSrc' => 'image.jpg', + 'groupId' => 12, + 'linkedLayoutId' => 2, + 'linked_layout_status_type' => 'service', + 'linkedLayoutStatusTypeWarningThreshold' => 50, + 'linked_layout_status_as_service_critical' => 80, + ] + ) + ); }