converter = new C52AggregateItemKeyConverter(); } public function dataProvider(): array { return [ [ 'grpsum["MySQL Servers","vfs.fs.size[/,total]",last]', 'sum(last_foreach(/*/vfs.fs.size[/,total]?[group="MySQL Servers"]))' ], [ 'grpavg["MySQL Servers","system.cpu.load[,avg1]",last]', 'avg(last_foreach(/*/system.cpu.load[,avg1]?[group="MySQL Servers"]))' ], [ 'grpavg["MySQL Servers",mysql.qps,avg,5m]', 'avg(avg_foreach(/*/mysql.qps?[group="MySQL Servers"],5m))' ], [ 'grpavg[["Servers A","Servers B","Servers C"],system.cpu.load,last]', 'avg(last_foreach(/*/system.cpu.load?[group="Servers A" or group="Servers B" or group="Servers C"]))' ], [ 'grpsum["My, group","trap1",last]', 'sum(last_foreach(/*/trap1?[group="My, group"]))' ], [ 'grpsum["MySQL\\"Servers","vfs.fs.size[/,total]",last]', 'sum(last_foreach(/*/vfs.fs.size[/,total]?[group="MySQL\\"Servers"]))' ], [ 'grpsum["MySQL\\Servers","trap1",last]', 'sum(last_foreach(/*/trap1?[group="MySQL\\\\Servers"]))' ], [ 'grpsum[ "Zabbix servers" , trap1 , last, 30s ]', 'sum(last_foreach(/*/trap1?[group="Zabbix servers"],30s))' ], [ 'grpavg[{$M},trap1,avg,{$M3}s]', 'avg(avg_foreach(/*/trap1?[group="{$M}"],"{$M3}s"))' ], [ 'grpfunc["Host group",item key,func1,timeperiod]', 'func(func1_foreach(/*/item key?[group="Host group"],"timeperiod"))' ], [ 'simplekey', 'simplekey' ], [ 'grpmin[]', 'grpmin[]' ] ]; } /** * @dataProvider dataProvider * * @param $key * @param $expected */ public function testConvert($key, $expected) { $this->assertEquals($expected, $this->converter->convert($key)); } }