From aca89ee8a928eedbee75de102a3e0bf8aa0c0de7 Mon Sep 17 00:00:00 2001 From: nickolasdaniel Date: Fri, 10 Sep 2021 17:08:35 +0300 Subject: [PATCH] Testing V1ProcessEvent API --- apis/ees_test.go | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 apis/ees_test.go diff --git a/apis/ees_test.go b/apis/ees_test.go new file mode 100644 index 000000000..1273357b4 --- /dev/null +++ b/apis/ees_test.go @@ -0,0 +1,70 @@ +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +package apis + +import ( + "fmt" + "testing" + "time" + + "github.com/cgrates/birpc/context" + "github.com/cgrates/cgrates/config" + "github.com/cgrates/cgrates/ees" + "github.com/cgrates/cgrates/engine" + "github.com/cgrates/cgrates/utils" +) + +func TestEeSProcessEvent(t *testing.T) { + cfg := config.NewDefaultCGRConfig() + filterS := new(engine.FilterS) + connMgr := engine.NewConnManager(cfg, nil) + eeS := ees.NewEventExporterS(cfg, filterS, connMgr) + cS := NewEeSv1(eeS) + + ///create logger and see the event in log + //define non default cgrconfig, define exporters + cgrEv := &utils.CGREventWithEeIDs{ + EeIDs: []string{"*default"}, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "voiceEvent", + Event: map[string]interface{}{ + utils.CGRID: utils.Sha1("dsafdsaf", time.Unix(1383813745, 0).UTC().String()), + utils.ToR: utils.MetaVoice, + utils.OriginID: "dsafdsaf", + utils.OriginHost: "192.168.1.1", + utils.RequestType: utils.MetaRated, + utils.Tenant: "cgrates.org", + utils.Category: "call", + utils.AccountField: "1001", + utils.Subject: "1001", + utils.Destination: "1002", + utils.SetupTime: time.Unix(1383813745, 0).UTC(), + utils.AnswerTime: time.Unix(1383813746, 0).UTC(), + utils.Usage: 10 * time.Second, + utils.RunID: utils.MetaDefault, + utils.Cost: 1.01, + "ExtraFields": map[string]string{"extra1": "val_extra1", + "extra2": "val_extra2", "extra3": "val_extra3"}, + }, + }, + } + var reply map[string]map[string]interface{} + if err := cS.ProcessEvent(context.Background(), cgrEv, &reply); err != nil { + t.Error(err) + } + fmt.Println(utils.IfaceAsString(reply)) +}