From 0e8dadaf69a5a9b68f86dee6101a38d4dca2a961 Mon Sep 17 00:00:00 2001 From: TeoV Date: Thu, 14 Jan 2021 11:09:54 +0200 Subject: [PATCH] Clone function for CGREvent initialize the Opts map --- apier/v1/accountprofiles_it_test.go | 2 +- apier/v1/actions_it_test.go | 2 +- apier/v1/apier2_it_test.go | 24 +- apier/v1/attributes_it_test.go | 314 +++++------ apier/v1/cache_replication_it_test.go | 38 +- apier/v1/caches_it_test.go | 2 +- apier/v1/cdrs_it_test.go | 238 ++++----- apier/v1/chargers_it_test.go | 106 ++-- apier/v1/cost_bench_it_test.go | 28 +- apier/v1/dispatchersv1_it_test.go | 32 +- apier/v1/filterindexecache_it_test.go | 536 +++++++++---------- apier/v1/rateprofiles_it_test.go | 124 ++--- apier/v1/remote_it_test.go | 36 +- apier/v1/replicate_it_test.go | 20 +- apier/v1/resourcesv1_it_test.go | 344 ++++++------ apier/v1/routes_it_test.go | 512 ++++++++---------- apier/v1/routes_with_rates_it_test.go | 110 ++-- apier/v1/sessions_process_event_it_test.go | 455 ++++++++-------- apier/v1/sessions_thresholds_it_test.go | 268 +++++----- apier/v1/sessionsv1_it_test.go | 574 ++++++++++----------- apier/v1/stats_it_test.go | 176 +++---- apier/v1/thresholds_it_test.go | 260 +++++----- engine/actions_test.go | 1 + engine/cdr.go | 1 + engine/chargers.go | 6 +- engine/z_attributes_test.go | 11 + utils/cgrevent.go | 2 +- 27 files changed, 1899 insertions(+), 2323 deletions(-) diff --git a/apier/v1/accountprofiles_it_test.go b/apier/v1/accountprofiles_it_test.go index 6fa72c32b..2fe136196 100644 --- a/apier/v1/accountprofiles_it_test.go +++ b/apier/v1/accountprofiles_it_test.go @@ -190,7 +190,7 @@ func testAccountSGetAccountProfile(t *testing.T) { func testAccountSPing(t *testing.T) { var resp string - if err := accSRPC.Call(utils.AccountSv1Ping, new(utils.CGREventWithOpts), &resp); err != nil { + if err := accSRPC.Call(utils.AccountSv1Ping, new(utils.CGREvent), &resp); err != nil { t.Error(err) } else if resp != utils.Pong { t.Error("Unexpected reply returned", resp) diff --git a/apier/v1/actions_it_test.go b/apier/v1/actions_it_test.go index 0e4c3374c..d60e48560 100644 --- a/apier/v1/actions_it_test.go +++ b/apier/v1/actions_it_test.go @@ -194,7 +194,7 @@ func testActionSGetActionProfile(t *testing.T) { func testActionSPing(t *testing.T) { var resp string - if err := actSRPC.Call(utils.ActionSv1Ping, new(utils.CGREventWithOpts), &resp); err != nil { + if err := actSRPC.Call(utils.ActionSv1Ping, new(utils.CGREvent), &resp); err != nil { t.Error(err) } else if resp != utils.Pong { t.Error("Unexpected reply returned", resp) diff --git a/apier/v1/apier2_it_test.go b/apier/v1/apier2_it_test.go index 2c5602329..f2c68bc66 100644 --- a/apier/v1/apier2_it_test.go +++ b/apier/v1/apier2_it_test.go @@ -138,13 +138,11 @@ func testAPIerLoadFromFolder(t *testing.T) { func testAPIerVerifyAttributesAfterLoad(t *testing.T) { ev := &engine.AttrArgsProcessEvent{ Context: utils.StringPointer("simpleauth"), - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testAPIerAfterDelete", - Event: map[string]interface{}{ - utils.AccountField: "1001", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAPIerAfterDelete", + Event: map[string]interface{}{ + utils.AccountField: "1001", }, }, } @@ -216,13 +214,11 @@ func testAPIerAfterDelete(t *testing.T) { func testAPIerVerifyAttributesAfterDelete(t *testing.T) { ev := &engine.AttrArgsProcessEvent{ Context: utils.StringPointer("simpleauth"), - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testAPIerAfterDelete", - Event: map[string]interface{}{ - utils.AccountField: "1001", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAPIerAfterDelete", + Event: map[string]interface{}{ + utils.AccountField: "1001", }, }, } diff --git a/apier/v1/attributes_it_test.go b/apier/v1/attributes_it_test.go index e7a8fa5cc..5a3a0167e 100644 --- a/apier/v1/attributes_it_test.go +++ b/apier/v1/attributes_it_test.go @@ -172,14 +172,12 @@ func testAttributeSLoadFromFolder(t *testing.T) { func testAttributeSGetAttributeForEvent(t *testing.T) { ev := &engine.AttrArgsProcessEvent{ Context: utils.StringPointer(utils.MetaSessionS), - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testAttributeSGetAttributeForEvent", - Event: map[string]interface{}{ - utils.AccountField: "1007", - utils.Destination: "+491511231234", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAttributeSGetAttributeForEvent", + Event: map[string]interface{}{ + utils.AccountField: "1007", + utils.Destination: "+491511231234", }, }, } @@ -239,14 +237,12 @@ func testAttributeSGetAttributeForEvent(t *testing.T) { func testAttributeSGetAttributeForEventNotFound(t *testing.T) { ev := &engine.AttrArgsProcessEvent{ Context: utils.StringPointer(utils.MetaCDRs), - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testAttributeSGetAttributeForEventWihMetaAnyContext", - Event: map[string]interface{}{ - utils.AccountField: "dan", - utils.Destination: "+491511231234", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAttributeSGetAttributeForEventWihMetaAnyContext", + Event: map[string]interface{}{ + utils.AccountField: "dan", + utils.Destination: "+491511231234", }, }, } @@ -293,14 +289,12 @@ func testAttributeSGetAttributeForEventNotFound(t *testing.T) { func testAttributeSGetAttributeForEventWithMetaAnyContext(t *testing.T) { ev := &engine.AttrArgsProcessEvent{ Context: utils.StringPointer(utils.MetaCDRs), - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testAttributeSGetAttributeForEventWihMetaAnyContext", - Event: map[string]interface{}{ - utils.AccountField: "dan", - utils.Destination: "+491511231234", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAttributeSGetAttributeForEventWihMetaAnyContext", + Event: map[string]interface{}{ + utils.AccountField: "dan", + utils.Destination: "+491511231234", }, }, } @@ -351,14 +345,12 @@ func testAttributeSGetAttributeForEventWithMetaAnyContext(t *testing.T) { func testAttributeSProcessEvent(t *testing.T) { ev := &engine.AttrArgsProcessEvent{ Context: utils.StringPointer(utils.MetaSessionS), - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testAttributeSProcessEvent", - Event: map[string]interface{}{ - utils.AccountField: "1007", - utils.Destination: "+491511231234", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAttributeSProcessEvent", + Event: map[string]interface{}{ + utils.AccountField: "1007", + utils.Destination: "+491511231234", }, }, } @@ -366,15 +358,13 @@ func testAttributeSProcessEvent(t *testing.T) { MatchedProfiles: []string{"ATTR_1"}, AlteredFields: []string{utils.MetaReq + utils.NestingSep + utils.AccountField, utils.MetaReq + utils.NestingSep + utils.Subject}, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testAttributeSProcessEvent", - Event: map[string]interface{}{ - utils.AccountField: "1001", - utils.Subject: "1001", - utils.Destination: "+491511231234", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAttributeSProcessEvent", + Event: map[string]interface{}{ + utils.AccountField: "1001", + utils.Subject: "1001", + utils.Destination: "+491511231234", }, }, } @@ -410,14 +400,12 @@ func testAttributeSProcessEvent(t *testing.T) { func testAttributeSProcessEventNotFound(t *testing.T) { ev := &engine.AttrArgsProcessEvent{ Context: utils.StringPointer(utils.MetaSessionS), - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testAttributeSProcessEventNotFound", - Event: map[string]interface{}{ - utils.AccountField: "Inexistent", - utils.Destination: "+491511231234", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAttributeSProcessEventNotFound", + Event: map[string]interface{}{ + utils.AccountField: "Inexistent", + utils.Destination: "+491511231234", }, }, } @@ -432,15 +420,13 @@ func testAttributeSProcessEventNotFound(t *testing.T) { func testAttributeSProcessEventMissing(t *testing.T) { ev := &engine.AttrArgsProcessEvent{ Context: utils.StringPointer(utils.MetaSessionS), - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testAttributeSProcessEvent", - Event: map[string]interface{}{ - utils.AccountField: "NonExist", - utils.Category: "*attributes", - utils.Destination: "+491511231234", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAttributeSProcessEvent", + Event: map[string]interface{}{ + utils.AccountField: "NonExist", + utils.Category: "*attributes", + utils.Destination: "+491511231234", }, }, } @@ -455,14 +441,12 @@ func testAttributeSProcessEventMissing(t *testing.T) { func testAttributeSProcessEventWithNoneSubstitute(t *testing.T) { ev := &engine.AttrArgsProcessEvent{ Context: utils.StringPointer(utils.MetaSessionS), - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testAttributeSWithNoneSubstitute", - Event: map[string]interface{}{ - utils.AccountField: "1008", - utils.Destination: "+491511231234", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAttributeSWithNoneSubstitute", + Event: map[string]interface{}{ + utils.AccountField: "1008", + utils.Destination: "+491511231234", }, }, } @@ -501,14 +485,12 @@ func testAttributeSProcessEventWithNoneSubstitute(t *testing.T) { MatchedProfiles: []string{"AttributeWithNonSubstitute"}, AlteredFields: []string{utils.MetaReq + utils.NestingSep + utils.AccountField, utils.MetaReq + utils.NestingSep + utils.Subject}, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testAttributeSWithNoneSubstitute", - Event: map[string]interface{}{ - utils.AccountField: "1001", - utils.Destination: "+491511231234", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAttributeSWithNoneSubstitute", + Event: map[string]interface{}{ + utils.AccountField: "1001", + utils.Destination: "+491511231234", }, }, } @@ -528,15 +510,13 @@ func testAttributeSProcessEventWithNoneSubstitute(t *testing.T) { func testAttributeSProcessEventWithNoneSubstitute2(t *testing.T) { ev := &engine.AttrArgsProcessEvent{ Context: utils.StringPointer(utils.MetaSessionS), - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testAttributeSWithNoneSubstitute", - Event: map[string]interface{}{ - utils.AccountField: "1008", - utils.Subject: "1008", - utils.Destination: "+491511231234", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAttributeSWithNoneSubstitute", + Event: map[string]interface{}{ + utils.AccountField: "1008", + utils.Subject: "1008", + utils.Destination: "+491511231234", }, }, } @@ -573,14 +553,12 @@ func testAttributeSProcessEventWithNoneSubstitute2(t *testing.T) { eRply := &engine.AttrSProcessEventReply{ MatchedProfiles: []string{"AttributeWithNonSubstitute"}, AlteredFields: []string{"*req.Account", "*req.Subject"}, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testAttributeSWithNoneSubstitute", - Event: map[string]interface{}{ - utils.AccountField: "1001", - utils.Destination: "+491511231234", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAttributeSWithNoneSubstitute", + Event: map[string]interface{}{ + utils.AccountField: "1001", + utils.Destination: "+491511231234", }, }, } @@ -588,14 +566,12 @@ func testAttributeSProcessEventWithNoneSubstitute2(t *testing.T) { MatchedProfiles: []string{"AttributeWithNonSubstitute"}, AlteredFields: []string{utils.MetaReq + utils.NestingSep + utils.Subject, utils.MetaReq + utils.NestingSep + utils.AccountField}, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testAttributeSWithNoneSubstitute", - Event: map[string]interface{}{ - utils.AccountField: "1001", - utils.Destination: "+491511231234", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAttributeSWithNoneSubstitute", + Event: map[string]interface{}{ + utils.AccountField: "1001", + utils.Destination: "+491511231234", }, }, } @@ -613,15 +589,13 @@ func testAttributeSProcessEventWithNoneSubstitute2(t *testing.T) { func testAttributeSProcessEventWithNoneSubstitute3(t *testing.T) { ev := &engine.AttrArgsProcessEvent{ Context: utils.StringPointer(utils.MetaSessionS), - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testAttributeSWithNoneSubstitute", - Event: map[string]interface{}{ - utils.AccountField: "1008", - utils.Subject: "1001", - utils.Destination: "+491511231234", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAttributeSWithNoneSubstitute", + Event: map[string]interface{}{ + utils.AccountField: "1008", + utils.Subject: "1001", + utils.Destination: "+491511231234", }, }, } @@ -659,15 +633,13 @@ func testAttributeSProcessEventWithNoneSubstitute3(t *testing.T) { eRply := &engine.AttrSProcessEventReply{ MatchedProfiles: []string{"AttributeWithNonSubstitute"}, AlteredFields: []string{"*req.Account"}, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testAttributeSWithNoneSubstitute", - Event: map[string]interface{}{ - utils.AccountField: "1001", - utils.Subject: "1001", - utils.Destination: "+491511231234", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAttributeSWithNoneSubstitute", + Event: map[string]interface{}{ + utils.AccountField: "1001", + utils.Subject: "1001", + utils.Destination: "+491511231234", }, }, } @@ -710,27 +682,23 @@ func testAttributeSProcessEventWithHeader(t *testing.T) { attrArgs := &engine.AttrArgsProcessEvent{ ProcessRuns: utils.IntPointer(1), Context: utils.StringPointer(utils.MetaSessionS), - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, - ID: "HeaderEventForAttribute", - Event: map[string]interface{}{ - "Field1": "Value1", - }, + CGREvent: &utils.CGREvent{ + Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, + ID: "HeaderEventForAttribute", + Event: map[string]interface{}{ + "Field1": "Value1", }, }, } eRply := &engine.AttrSProcessEventReply{ MatchedProfiles: []string{"ATTR_Header"}, AlteredFields: []string{"*req.Field2"}, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, - ID: "HeaderEventForAttribute", - Event: map[string]interface{}{ - "Field1": "Value1", - "Field2": "Value1", - }, + CGREvent: &utils.CGREvent{ + Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, + ID: "HeaderEventForAttribute", + Event: map[string]interface{}{ + "Field1": "Value1", + "Field2": "Value1", }, }, } @@ -1037,26 +1005,22 @@ func testAttributeSProcessEventWithSearchAndReplace(t *testing.T) { attrArgs := &engine.AttrArgsProcessEvent{ ProcessRuns: utils.IntPointer(1), Context: utils.StringPointer(utils.MetaSessionS), - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, - ID: "HeaderEventForAttribute", - Event: map[string]interface{}{ - "Category": "call", - }, + CGREvent: &utils.CGREvent{ + Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, + ID: "HeaderEventForAttribute", + Event: map[string]interface{}{ + "Category": "call", }, }, } eRply := &engine.AttrSProcessEventReply{ MatchedProfiles: []string{"ATTR_Search_and_replace"}, AlteredFields: []string{"*req.Category"}, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, - ID: "HeaderEventForAttribute", - Event: map[string]interface{}{ - "Category": "call_suffix", - }, + CGREvent: &utils.CGREvent{ + Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, + ID: "HeaderEventForAttribute", + Event: map[string]interface{}{ + "Category": "call_suffix", }, }, } @@ -1145,28 +1109,24 @@ func testAttributeSProcessWithMultipleRuns(t *testing.T) { attrArgs := &engine.AttrArgsProcessEvent{ Context: utils.StringPointer(utils.MetaSessionS), ProcessRuns: utils.IntPointer(4), - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, - ID: utils.GenUUID(), - Event: map[string]interface{}{ - "InitialField": "InitialValue", - }, + CGREvent: &utils.CGREvent{ + Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, + ID: utils.GenUUID(), + Event: map[string]interface{}{ + "InitialField": "InitialValue", }, }, } eRply := &engine.AttrSProcessEventReply{ MatchedProfiles: []string{"ATTR_1", "ATTR_2", "ATTR_1", "ATTR_2"}, AlteredFields: []string{"*req.Field1", "*req.Field2"}, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, - ID: utils.GenUUID(), - Event: map[string]interface{}{ - "InitialField": "InitialValue", - "Field1": "Value1", - "Field2": "Value2", - }, + CGREvent: &utils.CGREvent{ + Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, + ID: utils.GenUUID(), + Event: map[string]interface{}{ + "InitialField": "InitialValue", + "Field1": "Value1", + "Field2": "Value2", }, }, } @@ -1261,29 +1221,25 @@ func testAttributeSProcessWithMultipleRuns2(t *testing.T) { attrArgs := &engine.AttrArgsProcessEvent{ Context: utils.StringPointer(utils.MetaSessionS), ProcessRuns: utils.IntPointer(4), - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, - ID: utils.GenUUID(), - Event: map[string]interface{}{ - "InitialField": "InitialValue", - }, + CGREvent: &utils.CGREvent{ + Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, + ID: utils.GenUUID(), + Event: map[string]interface{}{ + "InitialField": "InitialValue", }, }, } eRply := &engine.AttrSProcessEventReply{ MatchedProfiles: []string{"ATTR_1", "ATTR_2", "ATTR_3", "ATTR_2"}, AlteredFields: []string{"*req.Field1", "*req.Field2", "*req.Field3"}, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, - ID: utils.GenUUID(), - Event: map[string]interface{}{ - "InitialField": "InitialValue", - "Field1": "Value1", - "Field2": "Value2", - "Field3": "Value3", - }, + CGREvent: &utils.CGREvent{ + Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, + ID: utils.GenUUID(), + Event: map[string]interface{}{ + "InitialField": "InitialValue", + "Field1": "Value1", + "Field2": "Value2", + "Field3": "Value3", }, }, } diff --git a/apier/v1/cache_replication_it_test.go b/apier/v1/cache_replication_it_test.go index a66873b47..0ac6f18bb 100644 --- a/apier/v1/cache_replication_it_test.go +++ b/apier/v1/cache_replication_it_test.go @@ -126,27 +126,23 @@ func testCacheSReplicateLoadTariffPlanFromFolder(t *testing.T) { func testCacheSReplicateProcessAttributes(t *testing.T) { ev := &engine.AttrArgsProcessEvent{ Context: utils.StringPointer(utils.MetaSessionS), - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testCacheSReplicateProcessAttributes", - Event: map[string]interface{}{ - utils.AccountField: "1001", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testCacheSReplicateProcessAttributes", + Event: map[string]interface{}{ + utils.AccountField: "1001", }, }, } eRply := &engine.AttrSProcessEventReply{ MatchedProfiles: []string{"ATTR_ACNT_1001"}, AlteredFields: []string{utils.MetaReq + utils.NestingSep + "OfficeGroup"}, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testCacheSReplicateProcessAttributes", - Event: map[string]interface{}{ - utils.AccountField: "1001", - "OfficeGroup": "Marketing", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testCacheSReplicateProcessAttributes", + Event: map[string]interface{}{ + utils.AccountField: "1001", + "OfficeGroup": "Marketing", }, }, } @@ -178,13 +174,11 @@ func testCacheSReplicateProcessAttributes(t *testing.T) { func testCacheSReplicateProcessRateProfile(t *testing.T) { var rply *engine.RateProfileCost argsRt := &utils.ArgsCostForEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - utils.AccountField: "1002", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + utils.AccountField: "1002", }, }, } diff --git a/apier/v1/caches_it_test.go b/apier/v1/caches_it_test.go index 7e8b2be49..659b7dd62 100644 --- a/apier/v1/caches_it_test.go +++ b/apier/v1/caches_it_test.go @@ -455,7 +455,7 @@ func testCacheSPrecacheStatus(t *testing.T) { func testCacheSPing(t *testing.T) { var reply string expected := utils.Pong - if err := chcRPC.Call(utils.CacheSv1Ping, &utils.CGREventWithOpts{}, &reply); err != nil { + if err := chcRPC.Call(utils.CacheSv1Ping, &utils.CGREvent{}, &reply); err != nil { t.Error(err) } else if !reflect.DeepEqual(expected, reply) { t.Errorf("Expected: %v , received:%v", utils.ToJSON(expected), utils.ToJSON(reply)) diff --git a/apier/v1/cdrs_it_test.go b/apier/v1/cdrs_it_test.go index 06c68b7aa..8145fc44a 100644 --- a/apier/v1/cdrs_it_test.go +++ b/apier/v1/cdrs_it_test.go @@ -168,18 +168,16 @@ func testV1CDRsProcessEventWithRefund(t *testing.T) { } argsEv := &engine.ArgV1ProcessEvent{ Flags: []string{utils.MetaRALs}, - CGREventWithOpts: utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - Event: map[string]interface{}{ - utils.RunID: "testv1", - utils.OriginID: "testV1CDRsProcessEventWithRefund", - utils.RequestType: utils.MetaPseudoPrepaid, - utils.AccountField: "testV1CDRsProcessEventWithRefund", - utils.Destination: "+4986517174963", - utils.AnswerTime: time.Date(2019, 11, 27, 12, 21, 26, 0, time.UTC), - utils.Usage: 3 * time.Minute, - }, + CGREvent: utils.CGREvent{ + Tenant: "cgrates.org", + Event: map[string]interface{}{ + utils.RunID: "testv1", + utils.OriginID: "testV1CDRsProcessEventWithRefund", + utils.RequestType: utils.MetaPseudoPrepaid, + utils.AccountField: "testV1CDRsProcessEventWithRefund", + utils.Destination: "+4986517174963", + utils.AnswerTime: time.Date(2019, 11, 27, 12, 21, 26, 0, time.UTC), + utils.Usage: 3 * time.Minute, }, }, } @@ -218,18 +216,16 @@ func testV1CDRsProcessEventWithRefund(t *testing.T) { } argsEv = &engine.ArgV1ProcessEvent{ Flags: []string{utils.MetaRALs, utils.MetaRerate}, - CGREventWithOpts: utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - Event: map[string]interface{}{ - utils.RunID: "testv1", - utils.OriginID: "testV1CDRsProcessEventWithRefund", - utils.RequestType: utils.MetaPseudoPrepaid, - utils.AccountField: "testV1CDRsProcessEventWithRefund", - utils.Destination: "+4986517174963", - utils.AnswerTime: time.Date(2019, 11, 27, 12, 21, 26, 0, time.UTC), - utils.Usage: time.Minute, - }, + CGREvent: utils.CGREvent{ + Tenant: "cgrates.org", + Event: map[string]interface{}{ + utils.RunID: "testv1", + utils.OriginID: "testV1CDRsProcessEventWithRefund", + utils.RequestType: utils.MetaPseudoPrepaid, + utils.AccountField: "testV1CDRsProcessEventWithRefund", + utils.Destination: "+4986517174963", + utils.AnswerTime: time.Date(2019, 11, 27, 12, 21, 26, 0, time.UTC), + utils.Usage: time.Minute, }, }, } @@ -367,19 +363,17 @@ func testV1CDRsRefundOutOfSessionCost(t *testing.T) { argsEv := &engine.ArgV1ProcessEvent{ Flags: []string{utils.MetaRALs}, - CGREventWithOpts: utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - Event: map[string]interface{}{ - utils.CGRID: "test1", - utils.RunID: utils.MetaDefault, - utils.OriginID: "testV1CDRsRefundOutOfSessionCost", - utils.RequestType: utils.MetaPrepaid, - utils.AccountField: "testV1CDRsRefundOutOfSessionCost", - utils.Destination: "+4986517174963", - utils.AnswerTime: time.Date(2019, 11, 27, 12, 21, 26, 0, time.UTC), - utils.Usage: 123 * time.Minute, - }, + CGREvent: utils.CGREvent{ + Tenant: "cgrates.org", + Event: map[string]interface{}{ + utils.CGRID: "test1", + utils.RunID: utils.MetaDefault, + utils.OriginID: "testV1CDRsRefundOutOfSessionCost", + utils.RequestType: utils.MetaPrepaid, + utils.AccountField: "testV1CDRsRefundOutOfSessionCost", + utils.Destination: "+4986517174963", + utils.AnswerTime: time.Date(2019, 11, 27, 12, 21, 26, 0, time.UTC), + utils.Usage: 123 * time.Minute, }, }, } @@ -433,85 +427,83 @@ func testV1CDRsRefundCDR(t *testing.T) { argsEv := &engine.ArgV1ProcessEvent{ Flags: []string{utils.MetaRefund}, - CGREventWithOpts: utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - Event: map[string]interface{}{ - utils.RunID: utils.MetaDefault, - utils.OriginID: "testV1CDRsRefundCDR", - utils.RequestType: utils.MetaPseudoPrepaid, - utils.AccountField: "testV1CDRsRefundCDR", - utils.Destination: "+4986517174963", - utils.AnswerTime: time.Date(2019, 11, 27, 12, 21, 26, 0, time.UTC), - utils.Usage: 10 * time.Minute, - utils.CostDetails: &engine.EventCost{ - CGRID: "test1", - RunID: utils.MetaDefault, - StartTime: time.Date(2017, 1, 9, 16, 18, 21, 0, time.UTC), - Usage: utils.DurationPointer(3 * time.Minute), - Cost: utils.Float64Pointer(2.3), - Charges: []*engine.ChargingInterval{ - { - RatingID: "c1a5ab9", - Increments: []*engine.ChargingIncrement{ - { - Usage: 2 * time.Minute, - Cost: 2.0, - AccountingID: "a012888", - CompressFactor: 1, - }, - { - Usage: time.Second, - Cost: 0.005, - AccountingID: "44d6c02", - CompressFactor: 60, - }, - }, - CompressFactor: 1, - }, - }, - AccountSummary: &engine.AccountSummary{ - Tenant: "cgrates.org", - ID: "testV1CDRsRefundCDR", - BalanceSummaries: []*engine.BalanceSummary{ + CGREvent: utils.CGREvent{ + Tenant: "cgrates.org", + Event: map[string]interface{}{ + utils.RunID: utils.MetaDefault, + utils.OriginID: "testV1CDRsRefundCDR", + utils.RequestType: utils.MetaPseudoPrepaid, + utils.AccountField: "testV1CDRsRefundCDR", + utils.Destination: "+4986517174963", + utils.AnswerTime: time.Date(2019, 11, 27, 12, 21, 26, 0, time.UTC), + utils.Usage: 10 * time.Minute, + utils.CostDetails: &engine.EventCost{ + CGRID: "test1", + RunID: utils.MetaDefault, + StartTime: time.Date(2017, 1, 9, 16, 18, 21, 0, time.UTC), + Usage: utils.DurationPointer(3 * time.Minute), + Cost: utils.Float64Pointer(2.3), + Charges: []*engine.ChargingInterval{ + { + RatingID: "c1a5ab9", + Increments: []*engine.ChargingIncrement{ { - UUID: balanceUuid, - Type: utils.MetaMonetary, - Value: 50, + Usage: 2 * time.Minute, + Cost: 2.0, + AccountingID: "a012888", + CompressFactor: 1, + }, + { + Usage: time.Second, + Cost: 0.005, + AccountingID: "44d6c02", + CompressFactor: 60, }, }, - AllowNegative: false, - Disabled: false, + CompressFactor: 1, }, - Rating: engine.Rating{ - "c1a5ab9": &engine.RatingUnit{ - ConnectFee: 0.1, - RoundingMethod: "*up", - RoundingDecimals: 5, - RatesID: "ec1a177", - RatingFiltersID: "43e77dc", + }, + AccountSummary: &engine.AccountSummary{ + Tenant: "cgrates.org", + ID: "testV1CDRsRefundCDR", + BalanceSummaries: []*engine.BalanceSummary{ + { + UUID: balanceUuid, + Type: utils.MetaMonetary, + Value: 50, }, }, - Accounting: engine.Accounting{ - "a012888": &engine.BalanceCharge{ - AccountID: "cgrates.org:testV1CDRsRefundCDR", - BalanceUUID: balanceUuid, - Units: 120.7, - }, - "44d6c02": &engine.BalanceCharge{ - AccountID: "cgrates.org:testV1CDRsRefundCDR", - BalanceUUID: balanceUuid, - Units: 120.7, - }, + AllowNegative: false, + Disabled: false, + }, + Rating: engine.Rating{ + "c1a5ab9": &engine.RatingUnit{ + ConnectFee: 0.1, + RoundingMethod: "*up", + RoundingDecimals: 5, + RatesID: "ec1a177", + RatingFiltersID: "43e77dc", }, - Rates: engine.ChargedRates{ - "ec1a177": engine.RateGroups{ - &engine.RGRate{ - GroupIntervalStart: 0, - Value: 0.01, - RateIncrement: time.Minute, - RateUnit: time.Second}, - }, + }, + Accounting: engine.Accounting{ + "a012888": &engine.BalanceCharge{ + AccountID: "cgrates.org:testV1CDRsRefundCDR", + BalanceUUID: balanceUuid, + Units: 120.7, + }, + "44d6c02": &engine.BalanceCharge{ + AccountID: "cgrates.org:testV1CDRsRefundCDR", + BalanceUUID: balanceUuid, + Units: 120.7, + }, + }, + Rates: engine.ChargedRates{ + "ec1a177": engine.RateGroups{ + &engine.RGRate{ + GroupIntervalStart: 0, + Value: 0.01, + RateIncrement: time.Minute, + RateUnit: time.Second}, }, }, }, @@ -590,21 +582,19 @@ func testV1CDRsAddBalanceForSMS(t *testing.T) { argsEv := &engine.ArgV1ProcessEvent{ Flags: []string{utils.MetaRALs}, - CGREventWithOpts: utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - Event: map[string]interface{}{ - utils.CGRID: "asdfas", - utils.ToR: utils.MetaSMS, - utils.Category: "sms", - utils.RunID: utils.MetaDefault, - utils.OriginID: "testV1CDRsAddBalanceForSMS", - utils.RequestType: utils.MetaPrepaid, - utils.AccountField: "testV1CDRsAddBalanceForSMS", - utils.Destination: "+4986517174963", - utils.AnswerTime: time.Date(2019, 11, 27, 12, 21, 26, 0, time.UTC), - utils.Usage: 1, - }, + CGREvent: utils.CGREvent{ + Tenant: "cgrates.org", + Event: map[string]interface{}{ + utils.CGRID: "asdfas", + utils.ToR: utils.MetaSMS, + utils.Category: "sms", + utils.RunID: utils.MetaDefault, + utils.OriginID: "testV1CDRsAddBalanceForSMS", + utils.RequestType: utils.MetaPrepaid, + utils.AccountField: "testV1CDRsAddBalanceForSMS", + utils.Destination: "+4986517174963", + utils.AnswerTime: time.Date(2019, 11, 27, 12, 21, 26, 0, time.UTC), + utils.Usage: 1, }, }, } diff --git a/apier/v1/chargers_it_test.go b/apier/v1/chargers_it_test.go index 7f42f9860..8bafdcdc0 100755 --- a/apier/v1/chargers_it_test.go +++ b/apier/v1/chargers_it_test.go @@ -40,34 +40,29 @@ var ( chargerProfile *ChargerWithCache chargerConfigDIR string //run tests for specific configuration - chargerEvent = []*utils.CGREventWithOpts{ + chargerEvent = []*utils.CGREvent{ { - CGREvent: &utils.CGREvent{ // matching Charger1 - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - utils.AccountField: "1001", - }, + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + utils.AccountField: "1001", }, Opts: map[string]interface{}{utils.OptsContext: "simpleauth"}, }, + { - CGREvent: &utils.CGREvent{ // no matching - Tenant: "cgrates.org", - ID: "event2", - Event: map[string]interface{}{ - utils.AccountField: "1010", - "DistinctMatch": "cgrates", - }, + Tenant: "cgrates.org", + ID: "event2", + Event: map[string]interface{}{ + utils.AccountField: "1010", + "DistinctMatch": "cgrates", }, }, { - CGREvent: &utils.CGREvent{ // matching Charger1 - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - utils.AccountField: "1007", - }, + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + utils.AccountField: "1007", }, Opts: map[string]interface{}{utils.OptsContext: "simpleauth"}, }, @@ -256,18 +251,12 @@ func testChargerSGetChargersForEvent(t *testing.T) { } var result *engine.ChargerProfiles if err := chargerRPC.Call(utils.ChargerSv1GetChargersForEvent, - &utils.CGREventWithOpts{ - CGREvent: chargerEvent[1].CGREvent, - Opts: chargerEvent[1].Opts, - }, &result); err == nil || + chargerEvent[1], &result); err == nil || err.Error() != utils.ErrNotFound.Error() { t.Error(err) } if err := chargerRPC.Call(utils.ChargerSv1GetChargersForEvent, - &utils.CGREventWithOpts{ - CGREvent: chargerEvent[0].CGREvent, - Opts: chargerEvent[0].Opts, - }, &result); err != nil { + chargerEvent[0], &result); err != nil { t.Error(err) } else if !reflect.DeepEqual(result, chargerProfiles) { t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(chargerProfiles), utils.ToJSON(result)) @@ -286,12 +275,9 @@ func testChargerSGetChargersForEvent(t *testing.T) { Weight: 20, }, } - chargerEvent[0].CGREvent.Tenant = utils.EmptyString + chargerEvent[0].Tenant = utils.EmptyString if err := chargerRPC.Call(utils.ChargerSv1GetChargersForEvent, - &utils.CGREventWithOpts{ - CGREvent: chargerEvent[0].CGREvent, - Opts: chargerEvent[0].Opts, - }, &result); err != nil { + chargerEvent[0], &result); err != nil { t.Error(err) } else if !reflect.DeepEqual(result, chargerProfiles) { t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(chargerProfiles), utils.ToJSON(result)) @@ -301,14 +287,12 @@ func testChargerSGetChargersForEvent(t *testing.T) { func testChargerSGetChargersForEvent2(t *testing.T) { var result *engine.ChargerProfiles if err := chargerRPC.Call(utils.ChargerSv1GetChargersForEvent, - &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ // matching Charger1 - Tenant: utils.EmptyString, - ID: "event1", - Event: map[string]interface{}{ - utils.AccountField: "1015", - utils.Usage: 1, - }, + &utils.CGREvent{ // matching Charger1 + Tenant: utils.EmptyString, + ID: "event1", + Event: map[string]interface{}{ + utils.AccountField: "1015", + utils.Usage: 1, }, }, &result); err == nil || err.Error() != utils.ErrNotFound.Error() { @@ -323,7 +307,6 @@ func testChargerSProcessEvent(t *testing.T) { ChargerSProfile: "Charger1", AttributeSProfiles: []string{"ATTR_1001_SIMPLEAUTH"}, AlteredFields: []string{utils.MetaReqRunID, "*req.Password"}, - Opts: map[string]interface{}{utils.OptsContext: "simpleauth", utils.Subsys: utils.MetaChargers}, CGREvent: &utils.CGREvent{ // matching Charger1 Tenant: "cgrates.org", ID: "event1", @@ -332,6 +315,7 @@ func testChargerSProcessEvent(t *testing.T) { "Password": "CGRateS.org", "RunID": utils.MetaDefault, }, + Opts: map[string]interface{}{utils.OptsContext: "simpleauth", utils.Subsys: utils.MetaChargers}, }, }, } @@ -351,7 +335,6 @@ func testChargerSProcessEvent(t *testing.T) { ChargerSProfile: "Charger2", AttributeSProfiles: []string{"*constant:*req.RequestType:*rated;*constant:*req.Category:call"}, AlteredFields: []string{"*req.Category", "*req.RequestType", utils.MetaReqRunID}, - Opts: map[string]interface{}{utils.OptsContext: "simpleauth", utils.Subsys: utils.MetaChargers}, CGREvent: &utils.CGREvent{ // matching Charger1 Tenant: "cgrates.org", ID: "event1", @@ -361,6 +344,7 @@ func testChargerSProcessEvent(t *testing.T) { utils.Category: "call", utils.RunID: utils.MetaDefault, }, + Opts: map[string]interface{}{utils.OptsContext: "simpleauth", utils.Subsys: utils.MetaChargers}, }, }, } @@ -513,19 +497,16 @@ func testChargerSProcessWithNotFoundAttribute(t *testing.T) { t.Error("Unexpected reply returned", result) } - ev := &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "CustomEvent", - Event: map[string]interface{}{ - utils.AccountField: "Random", - "CustomField": "WithoutAttributes", - }, + ev := &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "CustomEvent", + Event: map[string]interface{}{ + utils.AccountField: "Random", + "CustomField": "WithoutAttributes", }, } processedEv := []*engine.ChrgSProcessEventReply{ { - Opts: map[string]interface{}{utils.Subsys: utils.MetaChargers}, ChargerSProfile: "ChargerWithoutAttribute", AttributeSProfiles: []string{}, AlteredFields: []string{utils.MetaReqRunID}, @@ -537,6 +518,7 @@ func testChargerSProcessWithNotFoundAttribute(t *testing.T) { "CustomField": "WithoutAttributes", "RunID": "CustomRun", }, + Opts: map[string]interface{}{utils.Subsys: utils.MetaChargers}, }, }, } @@ -591,10 +573,6 @@ func testChargerSProccessEventWithProcceSRunS(t *testing.T) { ChargerSProfile: "ApierTest", AttributeSProfiles: []string{"*constant:*req.Account:1002"}, AlteredFields: []string{utils.MetaReqRunID, "*req.Account"}, - Opts: map[string]interface{}{ - utils.Subsys: utils.MetaChargers, - utils.OptsAttributesProcessRuns: 1., - }, CGREvent: &utils.CGREvent{ // matching Charger1 Tenant: "cgrates.org", ID: "event1", @@ -602,16 +580,18 @@ func testChargerSProccessEventWithProcceSRunS(t *testing.T) { utils.AccountField: "1002", utils.RunID: "*default", }, + Opts: map[string]interface{}{ + utils.Subsys: utils.MetaChargers, + utils.OptsAttributesProcessRuns: 1., + }, }, }, } - cgrEv := &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ // matching Charger1 - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - utils.AccountField: "1010", - }, + cgrEv := &utils.CGREvent{ // matching Charger1 + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + utils.AccountField: "1010", }, Opts: map[string]interface{}{utils.OptsAttributesProcessRuns: 1.}, } diff --git a/apier/v1/cost_bench_it_test.go b/apier/v1/cost_bench_it_test.go index c22fea139..50ad0f373 100644 --- a/apier/v1/cost_bench_it_test.go +++ b/apier/v1/cost_bench_it_test.go @@ -265,17 +265,15 @@ func BenchmarkCostWithRateS(b *testing.B) { testCostBenchSetRateProfile(b) var rply *engine.RateProfileCost argsRt := &utils.ArgsCostForEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + utils.Subject: "1001", + }, Opts: map[string]interface{}{ utils.OptsRatesUsage: "2m", }, - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - utils.Subject: "1001", - }, - }, }, } b.ResetTimer() @@ -299,18 +297,16 @@ func BenchmarkCostDiffPeriodWithRateS(b *testing.B) { testCostBenchSetRateProfile2(b) var rply *engine.RateProfileCost argsRt := &utils.ArgsCostForEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + utils.Subject: "1010", + }, Opts: map[string]interface{}{ utils.OptsRatesStartTime: time.Date(2020, 12, 23, 59, 0, 0, 0, time.UTC), utils.OptsRatesUsage: "2h", }, - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - utils.Subject: "1010", - }, - }, }, } b.ResetTimer() diff --git a/apier/v1/dispatchersv1_it_test.go b/apier/v1/dispatchersv1_it_test.go index 62a9fcdd0..68ccf6557 100644 --- a/apier/v1/dispatchersv1_it_test.go +++ b/apier/v1/dispatchersv1_it_test.go @@ -132,13 +132,11 @@ func testDspITLoadData(t *testing.T) { } func testDspDspv1GetProfileForEvent(t *testing.T) { - arg := utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testDspv1", - Event: map[string]interface{}{ - utils.EventName: "Event1", - }, + arg := &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testDspv1", + Event: map[string]interface{}{ + utils.EventName: "Event1", }, Opts: map[string]interface{}{ utils.Subsys: utils.MetaAny, @@ -181,12 +179,10 @@ func testDspDspv1GetProfileForEvent(t *testing.T) { t.Errorf("expected: %s ,\n received: %s", utils.ToJSON(expected), utils.ToJSON(reply)) } - arg2 := utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - ID: "testDspvWithoutTenant", - Event: map[string]interface{}{ - utils.EventName: "Event1", - }, + arg2 := &utils.CGREvent{ + ID: "testDspvWithoutTenant", + Event: map[string]interface{}{ + utils.EventName: "Event1", }, Opts: map[string]interface{}{ utils.Subsys: utils.MetaAny, @@ -203,12 +199,10 @@ func testDspDspv1GetProfileForEvent(t *testing.T) { } func testDspDspv1GetProfileForEventWithMethod(t *testing.T) { - arg := utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testDspv2", - Event: map[string]interface{}{}, - }, + arg := &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testDspv2", + Event: map[string]interface{}{}, Opts: map[string]interface{}{ utils.Subsys: utils.MetaAny, utils.OptsDispatcherMethod: utils.DispatcherSv1GetProfileForEvent, diff --git a/apier/v1/filterindexecache_it_test.go b/apier/v1/filterindexecache_it_test.go index b74a577ca..ab13fc9fe 100644 --- a/apier/v1/filterindexecache_it_test.go +++ b/apier/v1/filterindexecache_it_test.go @@ -144,14 +144,12 @@ func testV1FIdxCaFromFolder(t *testing.T) { //ThresholdProfile func testV1FIdxCaProcessEventWithNotFound(t *testing.T) { tEv := &engine.ThresholdsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - utils.EventType: utils.BalanceUpdate, - utils.AccountField: "1001", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + utils.EventType: utils.BalanceUpdate, + utils.AccountField: "1001", }, Opts: map[string]interface{}{ utils.MetaEventType: utils.BalanceUpdate, @@ -217,14 +215,12 @@ func testV1FIdxCaSetThresholdProfile(t *testing.T) { //matches TEST_PROFILE1 tEv := &engine.ThresholdsArgsProcessEvent{ ThresholdIDs: []string{"TEST_PROFILE1"}, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - utils.EventType: utils.BalanceUpdate, - utils.AccountField: "1001", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + utils.EventType: utils.BalanceUpdate, + utils.AccountField: "1001", }, Opts: map[string]interface{}{ utils.MetaEventType: utils.BalanceUpdate, @@ -246,16 +242,14 @@ func testV1FIdxCaGetThresholdFromTP(t *testing.T) { //matches THD_ACNT_BALANCE_1 tEv := &engine.ThresholdsArgsProcessEvent{ ThresholdIDs: []string{"THD_ACNT_BALANCE_1"}, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - utils.EventType: utils.BalanceUpdate, - utils.AccountField: "1001", - utils.BalanceID: utils.MetaDefault, - utils.Units: 12.3, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + utils.EventType: utils.BalanceUpdate, + utils.AccountField: "1001", + utils.BalanceID: utils.MetaDefault, + utils.Units: 12.3, }, Opts: map[string]interface{}{ utils.MetaEventType: utils.BalanceUpdate, @@ -323,14 +317,12 @@ func testV1FIdxCaUpdateThresholdProfile(t *testing.T) { } //make sure doesn't match the thresholdprofile after update tEv := &engine.ThresholdsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - utils.EventType: utils.AccountUpdate, - utils.AccountField: "1001", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + utils.EventType: utils.AccountUpdate, + utils.AccountField: "1001", }, Opts: map[string]interface{}{ utils.MetaEventType: utils.AccountUpdate, @@ -346,14 +338,12 @@ func testV1FIdxCaUpdateThresholdProfile(t *testing.T) { } //matches thresholdprofile after update tEv2 := &engine.ThresholdsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - utils.EventType: utils.AccountUpdate, - utils.AccountField: "1002", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + utils.EventType: utils.AccountUpdate, + utils.AccountField: "1002", }, Opts: map[string]interface{}{ utils.MetaEventType: utils.AccountUpdate, @@ -418,14 +408,12 @@ func testV1FIdxCaUpdateThresholdProfileFromTP(t *testing.T) { t.Error("Unexpected reply returned", result) } tEv := &engine.ThresholdsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - utils.AccountField: "1002", - utils.EventType: utils.BalanceUpdate, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + utils.AccountField: "1002", + utils.EventType: utils.BalanceUpdate, }, Opts: map[string]interface{}{ utils.MetaEventType: utils.BalanceUpdate, @@ -439,14 +427,12 @@ func testV1FIdxCaUpdateThresholdProfileFromTP(t *testing.T) { t.Error(err) } tEv2 := &engine.ThresholdsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event3", - Event: map[string]interface{}{ - utils.AccountField: "1003", - utils.EventType: utils.BalanceUpdate, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event3", + Event: map[string]interface{}{ + utils.AccountField: "1003", + utils.EventType: utils.BalanceUpdate, }, Opts: map[string]interface{}{ utils.MetaEventType: utils.BalanceUpdate, @@ -465,14 +451,12 @@ func testV1FIdxCaUpdateThresholdProfileFromTP(t *testing.T) { func testV1FIdxCaRemoveThresholdProfile(t *testing.T) { var resp string tEv := &engine.ThresholdsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event8", - Event: map[string]interface{}{ - utils.AccountField: "1002", - utils.EventType: utils.AccountUpdate, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event8", + Event: map[string]interface{}{ + utils.AccountField: "1002", + utils.EventType: utils.AccountUpdate, }, Opts: map[string]interface{}{ utils.MetaEventType: utils.AccountUpdate, @@ -488,14 +472,12 @@ func testV1FIdxCaRemoveThresholdProfile(t *testing.T) { } tEv2 := &engine.ThresholdsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event9", - Event: map[string]interface{}{ - utils.AccountField: "1003", - utils.EventType: utils.BalanceUpdate, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event9", + Event: map[string]interface{}{ + utils.AccountField: "1003", + utils.EventType: utils.BalanceUpdate, }, Opts: map[string]interface{}{ utils.MetaEventType: utils.BalanceUpdate, @@ -549,14 +531,12 @@ func testV1FIdxCaRemoveThresholdProfile(t *testing.T) { func testV1FIdxCaGetStatQueuesWithNotFound(t *testing.T) { var reply *[]string tEv := &engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - utils.EventType: utils.AccountUpdate, - utils.AccountField: "1001", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + utils.EventType: utils.AccountUpdate, + utils.AccountField: "1001", }, Opts: map[string]interface{}{ utils.MetaEventType: utils.AccountUpdate, @@ -568,7 +548,7 @@ func testV1FIdxCaGetStatQueuesWithNotFound(t *testing.T) { t.Error(err) } - tEv.CGREventWithOpts.CGREvent.Tenant = utils.EmptyString + tEv.CGREvent.Tenant = utils.EmptyString if err := tFIdxCaRpc.Call(utils.StatSv1ProcessEvent, tEv, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() { t.Error(err) @@ -634,15 +614,13 @@ func testV1FIdxCaSetStatQueueProfile(t *testing.T) { } tEv := &engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - utils.EventType: utils.AccountUpdate, - utils.AccountField: "1001", - "Val": 10, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + utils.EventType: utils.AccountUpdate, + utils.AccountField: "1001", + "Val": 10, }, Opts: map[string]interface{}{ utils.MetaEventType: utils.AccountUpdate, @@ -663,16 +641,14 @@ func testV1FIdxCaGetStatQueuesFromTP(t *testing.T) { var reply []string expected := []string{"Stats1"} ev2 := &engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event2", - Event: map[string]interface{}{ - utils.AccountField: "1002", - utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: 45 * time.Second, - utils.Cost: 12.1, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event2", + Event: map[string]interface{}{ + utils.AccountField: "1002", + utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), + utils.Usage: 45 * time.Second, + utils.Cost: 12.1, }, }, } @@ -682,16 +658,14 @@ func testV1FIdxCaGetStatQueuesFromTP(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", expected, reply) } ev3 := &engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event3", - Event: map[string]interface{}{ - utils.AccountField: "1002", - utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: 45 * time.Second, - utils.Cost: 12.1, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event3", + Event: map[string]interface{}{ + utils.AccountField: "1002", + utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), + utils.Usage: 45 * time.Second, + utils.Cost: 12.1, }, }, } @@ -702,17 +676,15 @@ func testV1FIdxCaGetStatQueuesFromTP(t *testing.T) { } tEv := &engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - utils.EventType: utils.AccountUpdate, - utils.AccountField: "1001", - utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: 45 * time.Second, - utils.Cost: 12.1, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + utils.EventType: utils.AccountUpdate, + utils.AccountField: "1001", + utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), + utils.Usage: 45 * time.Second, + utils.Cost: 12.1, }, Opts: map[string]interface{}{ utils.MetaEventType: utils.AccountUpdate, @@ -725,17 +697,15 @@ func testV1FIdxCaGetStatQueuesFromTP(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", expected, reply) } tEv2 := &engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - utils.EventType: utils.AccountUpdate, - utils.AccountField: "1001", - utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: 45 * time.Second, - utils.Cost: 12.1, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + utils.EventType: utils.AccountUpdate, + utils.AccountField: "1001", + utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), + utils.Usage: 45 * time.Second, + utils.Cost: 12.1, }, Opts: map[string]interface{}{ utils.MetaEventType: utils.AccountUpdate, @@ -807,15 +777,13 @@ func testV1FIdxCaUpdateStatQueueProfile(t *testing.T) { var reply []string expected := []string{"TEST_PROFILE1"} tEv := &engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - utils.EventType: utils.BalanceUpdate, - utils.AccountField: "1003", - "Val": 10, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + utils.EventType: utils.BalanceUpdate, + utils.AccountField: "1003", + "Val": 10, }, Opts: map[string]interface{}{ utils.MetaEventType: utils.BalanceUpdate, @@ -871,17 +839,15 @@ func testV1FIdxCaUpdateStatQueueProfileFromTP(t *testing.T) { t.Error("Unexpected reply returned", result) } tEv := &engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - utils.EventType: utils.AccountUpdate, - utils.AccountField: "1003", - utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: 45 * time.Second, - utils.Cost: 12.1, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + utils.EventType: utils.AccountUpdate, + utils.AccountField: "1003", + utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), + utils.Usage: 45 * time.Second, + utils.Cost: 12.1, }, Opts: map[string]interface{}{ utils.MetaEventType: utils.AccountUpdate, @@ -902,15 +868,13 @@ func testV1FIdxCaRemoveStatQueueProfile(t *testing.T) { var reply []string expected := []string{"TEST_PROFILE1"} tEv := &engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - utils.EventType: utils.BalanceUpdate, - utils.AccountField: "1003", - "Val": 10, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + utils.EventType: utils.BalanceUpdate, + utils.AccountField: "1003", + "Val": 10, }, Opts: map[string]interface{}{ utils.MetaEventType: utils.BalanceUpdate, @@ -924,17 +888,15 @@ func testV1FIdxCaRemoveStatQueueProfile(t *testing.T) { } expected = []string{"Stats1"} tEv2 := &engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - utils.EventType: utils.AccountUpdate, - utils.AccountField: "1003", - utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: 45 * time.Second, - utils.Cost: 12.1, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + utils.EventType: utils.AccountUpdate, + utils.AccountField: "1003", + utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), + utils.Usage: 45 * time.Second, + utils.Cost: 12.1, }, Opts: map[string]interface{}{ utils.MetaEventType: utils.AccountUpdate, @@ -989,14 +951,12 @@ func testV1FIdxCaRemoveStatQueueProfile(t *testing.T) { func testV1FIdxCaProcessAttributeProfileEventWithNotFound(t *testing.T) { ev := &engine.AttrArgsProcessEvent{ Context: utils.StringPointer(utils.MetaSessionS), - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testAttributeSProcessEvent", - Event: map[string]interface{}{ - utils.AccountField: "3009", - utils.Destination: "+492511231234", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAttributeSProcessEvent", + Event: map[string]interface{}{ + utils.AccountField: "3009", + utils.Destination: "+492511231234", }, }, } @@ -1065,14 +1025,12 @@ func testV1FIdxCaSetAttributeProfile(t *testing.T) { //matches TEST_PROFILE1 ev := &engine.AttrArgsProcessEvent{ Context: utils.StringPointer(utils.MetaSessionS), - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testAttributeSProcessEvent", - Event: map[string]interface{}{ - utils.AccountField: "1009", - utils.Destination: "+491511231234", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAttributeSProcessEvent", + Event: map[string]interface{}{ + utils.AccountField: "1009", + utils.Destination: "+491511231234", }, }, } @@ -1087,14 +1045,12 @@ func testV1FIdxCaGetAttributeProfileFromTP(t *testing.T) { //matches ATTR_1 ev := &engine.AttrArgsProcessEvent{ Context: utils.StringPointer(utils.MetaSessionS), - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testAttributeSProcessEvent", - Event: map[string]interface{}{ - utils.AccountField: "1007", - utils.Destination: "+491511231234", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAttributeSProcessEvent", + Event: map[string]interface{}{ + utils.AccountField: "1007", + utils.Destination: "+491511231234", }, }, } @@ -1162,14 +1118,12 @@ func testV1FIdxCaUpdateAttributeProfile(t *testing.T) { //matches TEST_PROFILE1 ev := &engine.AttrArgsProcessEvent{ Context: utils.StringPointer(utils.MetaSessionS), - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testAttributeSProcessEvent", - Event: map[string]interface{}{ - utils.AccountField: "2009", - utils.Destination: "+492511231234", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAttributeSProcessEvent", + Event: map[string]interface{}{ + utils.AccountField: "2009", + utils.Destination: "+492511231234", }, }, } @@ -1222,14 +1176,12 @@ func testV1FIdxCaUpdateAttributeProfileFromTP(t *testing.T) { //matches TEST_PROFILE1 ev := &engine.AttrArgsProcessEvent{ Context: utils.StringPointer(utils.MetaSessionS), - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testAttributeSProcessEvent", - Event: map[string]interface{}{ - utils.AccountField: "3009", - utils.Destination: "+492511231234", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAttributeSProcessEvent", + Event: map[string]interface{}{ + utils.AccountField: "3009", + utils.Destination: "+492511231234", }, }, } @@ -1243,14 +1195,12 @@ func testV1FIdxCaRemoveAttributeProfile(t *testing.T) { var resp string ev := &engine.AttrArgsProcessEvent{ Context: utils.StringPointer(utils.MetaSessionS), - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testAttributeSProcessEvent", - Event: map[string]interface{}{ - utils.AccountField: "3009", - utils.Destination: "+492511231234", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAttributeSProcessEvent", + Event: map[string]interface{}{ + utils.AccountField: "3009", + utils.Destination: "+492511231234", }, }, } @@ -1261,14 +1211,12 @@ func testV1FIdxCaRemoveAttributeProfile(t *testing.T) { ev2 := &engine.AttrArgsProcessEvent{ Context: utils.StringPointer(utils.MetaSessionS), - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testAttributeSProcessEvent", - Event: map[string]interface{}{ - utils.AccountField: "2009", - utils.Destination: "+492511231234", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testAttributeSProcessEvent", + Event: map[string]interface{}{ + utils.AccountField: "2009", + utils.Destination: "+492511231234", }, }, } @@ -1319,15 +1267,13 @@ func testV1FIdxCaGetResourceProfileWithNotFound(t *testing.T) { var reply string argsRU := utils.ArgRSv1ResourceUsage{ UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e61", - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - utils.AccountField: "1002", - utils.Subject: "1001", - utils.Destination: "1002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + utils.AccountField: "1002", + utils.Subject: "1001", + utils.Destination: "1002"}, }, Units: 6, } @@ -1408,15 +1354,13 @@ func testV1FIdxCaSetResourceProfile(t *testing.T) { } argsRU := utils.ArgRSv1ResourceUsage{ UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e61", - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - utils.AccountField: "1001", - utils.Subject: "1002", - utils.Destination: "1001"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + utils.AccountField: "1001", + utils.Subject: "1002", + utils.Destination: "1001"}, }, Units: 6, } @@ -1439,15 +1383,13 @@ func testV1FIdxCaGetResourceProfileFromTP(t *testing.T) { var reply string argsRU := utils.ArgRSv1ResourceUsage{ UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e63", - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - utils.AccountField: "1001", - utils.Subject: "1002", - utils.Destination: "1001"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + utils.AccountField: "1001", + utils.Subject: "1002", + utils.Destination: "1001"}, }, Units: 6, } @@ -1466,15 +1408,13 @@ func testV1FIdxCaGetResourceProfileFromTP(t *testing.T) { argsReU := utils.ArgRSv1ResourceUsage{ UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e61", - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - utils.AccountField: "1002", - utils.Subject: "1001", - utils.Destination: "1002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + utils.AccountField: "1002", + utils.Subject: "1001", + utils.Destination: "1002"}, }, Units: 6, } @@ -1544,15 +1484,13 @@ func testV1FIdxCaUpdateResourceProfile(t *testing.T) { } argsReU := utils.ArgRSv1ResourceUsage{ UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e61", - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - utils.AccountField: "2002", - utils.Subject: "2001", - utils.Destination: "2002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + utils.AccountField: "2002", + utils.Subject: "2001", + utils.Destination: "2002"}, }, Units: 6, } @@ -1612,15 +1550,13 @@ func testV1FIdxCaUpdateResourceProfileFromTP(t *testing.T) { } argsReU := utils.ArgRSv1ResourceUsage{ UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e65", - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - utils.AccountField: "1002", - utils.Subject: "1001", - utils.Destination: "1002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + utils.AccountField: "1002", + utils.Subject: "1001", + utils.Destination: "1002"}, }, Units: 6, } @@ -1635,15 +1571,13 @@ func testV1FIdxCaRemoveResourceProfile(t *testing.T) { var resp string argsReU := utils.ArgRSv1ResourceUsage{ UsageID: "653a8db2-4f67-4cf8-b622-169e8a482e61", - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - utils.AccountField: "2002", - utils.Subject: "2001", - utils.Destination: "2002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + utils.AccountField: "2002", + utils.Subject: "2001", + utils.Destination: "2002"}, }, Units: 6, } @@ -1659,15 +1593,13 @@ func testV1FIdxCaRemoveResourceProfile(t *testing.T) { } argsRU := utils.ArgRSv1ResourceUsage{ UsageID: "654a8db2-4f67-4cf8-b622-169e8a482e61", - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - utils.AccountField: "1002", - utils.Subject: "1001", - utils.Destination: "1002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + utils.AccountField: "1002", + utils.Subject: "1001", + utils.Destination: "1002"}, }, Units: 6, } diff --git a/apier/v1/rateprofiles_it_test.go b/apier/v1/rateprofiles_it_test.go index ecfd71df6..933e10f7b 100644 --- a/apier/v1/rateprofiles_it_test.go +++ b/apier/v1/rateprofiles_it_test.go @@ -823,13 +823,11 @@ func testV1RateCostForEventWithDefault(t *testing.T) { var rply *engine.RateProfileCost argsRt := &utils.ArgsCostForEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - utils.Subject: "1001", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + utils.Subject: "1001", }, }, } @@ -867,17 +865,15 @@ func testV1RateCostForEventWithUsage(t *testing.T) { } var rply *engine.RateProfileCost argsRt := &utils.ArgsCostForEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + utils.Subject: "1001", + }, Opts: map[string]interface{}{ utils.OptsRatesUsage: "2m10s", }, - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - utils.Subject: "1001", - }, - }, }, } rate1 := &engine.Rate{ @@ -933,17 +929,15 @@ func testV1RateCostForEventWithUsage(t *testing.T) { } argsRt2 := &utils.ArgsCostForEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + utils.Subject: "1001", + }, Opts: map[string]interface{}{ utils.OptsRatesUsage: "4h10m15s", }, - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - utils.Subject: "1001", - }, - }, }, } exp2 := &engine.RateProfileCost{ @@ -982,17 +976,15 @@ func testV1RateCostForEventWithUsage(t *testing.T) { func testV1RateCostForEventWithWrongUsage(t *testing.T) { var rply *engine.RateProfileCost argsRt := &utils.ArgsCostForEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + utils.Subject: "1001", + }, Opts: map[string]interface{}{ utils.OptsRatesUsage: "wrongUsage", }, - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - utils.Subject: "1001", - }, - }, }, } if err := ratePrfRpc.Call(utils.RateSv1CostForEvent, &argsRt, &rply); err == nil || @@ -1032,17 +1024,15 @@ func testV1RateCostForEventWithStartTime(t *testing.T) { var rply *engine.RateProfileCost argsRt := &utils.ArgsCostForEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + utils.Subject: "1001", + }, Opts: map[string]interface{}{ utils.OptsRatesStartTime: time.Date(2018, 8, 24, 16, 00, 26, 0, time.UTC), }, - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - utils.Subject: "1001", - }, - }, }, } exp := &engine.RateProfileCost{ @@ -1071,17 +1061,15 @@ func testV1RateCostForEventWithStartTime(t *testing.T) { } argsRt2 := &utils.ArgsCostForEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + utils.Subject: "1001", + }, Opts: map[string]interface{}{ utils.OptsRatesStartTime: time.Date(2018, 8, 24, 16, 00, 26, 0, time.UTC).String(), }, - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - utils.Subject: "1001", - }, - }, }, } if err := ratePrfRpc.Call(utils.RateSv1CostForEvent, &argsRt2, &rply); err != nil { @@ -1094,17 +1082,15 @@ func testV1RateCostForEventWithStartTime(t *testing.T) { func testV1RateCostForEventWithWrongStartTime(t *testing.T) { var rply *engine.RateProfileCost argsRt := &utils.ArgsCostForEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + utils.Subject: "1001", + }, Opts: map[string]interface{}{ utils.OptsRatesStartTime: "wrongTime", }, - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - utils.Subject: "1001", - }, - }, }, } if err := ratePrfRpc.Call(utils.RateSv1CostForEvent, &argsRt, &rply); err == nil || @@ -1124,18 +1110,16 @@ func testV1RateCostForEventWithOpts(t *testing.T) { } var rply *engine.RateProfileCost argsRt := &utils.ArgsCostForEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + utils.Subject: "1001", + }, Opts: map[string]interface{}{ utils.OptsRatesStartTime: time.Date(2018, 8, 24, 16, 00, 26, 0, time.UTC), utils.OptsRatesUsage: "2m10s", }, - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - utils.Subject: "1001", - }, - }, }, } rate1 := &engine.Rate{ @@ -1191,18 +1175,16 @@ func testV1RateCostForEventWithOpts(t *testing.T) { } argsRt2 := &utils.ArgsCostForEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + utils.Subject: "1001", + }, Opts: map[string]interface{}{ utils.OptsRatesStartTime: time.Date(2018, 8, 24, 16, 00, 26, 0, time.UTC), utils.OptsRatesUsage: "4h10m15s", }, - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - utils.Subject: "1001", - }, - }, }, } exp2 := &engine.RateProfileCost{ diff --git a/apier/v1/remote_it_test.go b/apier/v1/remote_it_test.go index 65d6838b8..e89373418 100644 --- a/apier/v1/remote_it_test.go +++ b/apier/v1/remote_it_test.go @@ -882,13 +882,11 @@ func testInternalReplicationSetThreshold(t *testing.T) { func testInternalMatchThreshold(t *testing.T) { ev := &engine.ThresholdsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event2", - Event: map[string]interface{}{ - utils.AccountField: "1002", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event2", + Event: map[string]interface{}{ + utils.AccountField: "1002", }, }, } @@ -900,13 +898,11 @@ func testInternalMatchThreshold(t *testing.T) { t.Errorf("Expecting ids: %s, received: %s", eIDs, ids) } ev = &engine.ThresholdsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event2", - Event: map[string]interface{}{ - utils.AccountField: "1001", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event2", + Event: map[string]interface{}{ + utils.AccountField: "1001", }, }, } @@ -917,13 +913,11 @@ func testInternalMatchThreshold(t *testing.T) { t.Errorf("Expecting ids: %s, received: %s", eIDs, ids) } ev2 := &engine.ThresholdsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event3", - Event: map[string]interface{}{ - utils.AccountField: "1001", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event3", + Event: map[string]interface{}{ + utils.AccountField: "1001", }, }, } diff --git a/apier/v1/replicate_it_test.go b/apier/v1/replicate_it_test.go index 4127b0515..df07c2a21 100644 --- a/apier/v1/replicate_it_test.go +++ b/apier/v1/replicate_it_test.go @@ -1207,17 +1207,15 @@ func testInternalReplicateITThreshold(t *testing.T) { t.Error(err) } tEvs := engine.ThresholdsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - utils.EventType: utils.AccountUpdate, - utils.AccountField: "1005", - utils.AllowNegative: true, - utils.Disabled: false, - utils.Units: 12.3}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + utils.EventType: utils.AccountUpdate, + utils.AccountField: "1005", + utils.AllowNegative: true, + utils.Disabled: false, + utils.Units: 12.3}, Opts: map[string]interface{}{ utils.MetaEventType: utils.AccountUpdate, }, diff --git a/apier/v1/resourcesv1_it_test.go b/apier/v1/resourcesv1_it_test.go index 94c51d83a..d7180adf6 100644 --- a/apier/v1/resourcesv1_it_test.go +++ b/apier/v1/resourcesv1_it_test.go @@ -138,12 +138,10 @@ func testV1RsFromFolder(t *testing.T) { func testV1RsGetResourcesForEvent(t *testing.T) { var reply *engine.Resources args := &utils.ArgRSv1ResourceUsage{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "Event1", - Event: map[string]interface{}{"Unknown": "unknown"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "Event1", + Event: map[string]interface{}{"Unknown": "unknown"}, }, UsageID: "RandomUsageID", } @@ -216,14 +214,12 @@ func testV1RsGetResourcesForEvent(t *testing.T) { func testV1RsTTL0(t *testing.T) { // only matching Resource3 argsRU := utils.ArgRSv1ResourceUsage{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - "Account": "3001", - "Destination": "3002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + "Account": "3001", + "Destination": "3002"}, }, UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e21", Units: 1, @@ -235,14 +231,12 @@ func testV1RsTTL0(t *testing.T) { } // overwrite the first allocation argsRU = utils.ArgRSv1ResourceUsage{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - "Account": "3001", - "Destination": "3002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + "Account": "3001", + "Destination": "3002"}, }, UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e21", Units: 2, @@ -252,14 +246,12 @@ func testV1RsTTL0(t *testing.T) { } // too many units should be rejected argsRU = utils.ArgRSv1ResourceUsage{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - "Account": "3001", - "Destination": "3002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + "Account": "3001", + "Destination": "3002"}, }, UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e22", Units: 4, @@ -271,14 +263,12 @@ func testV1RsTTL0(t *testing.T) { // check the record var rs *engine.Resources args := &utils.ArgRSv1ResourceUsage{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - "Account": "3001", - "Destination": "3002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + "Account": "3001", + "Destination": "3002"}, }, UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e21", } @@ -317,14 +307,12 @@ func testV1RsTTL0(t *testing.T) { var releaseReply string argsRU = utils.ArgRSv1ResourceUsage{ UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e25", // same ID should be accepted by first group since the previous resource should be expired - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - "Account": "3001", - "Destination": "3002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + "Account": "3001", + "Destination": "3002"}, }, } if err := rlsV1Rpc.Call(utils.ResourceSv1ReleaseResources, @@ -344,15 +332,13 @@ func testV1RsAllocateResource(t *testing.T) { var reply string argsRU := utils.ArgRSv1ResourceUsage{ UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e51", - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - "Account": "1002", - "Subject": "1001", - "Destination": "1002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + "Account": "1002", + "Subject": "1001", + "Destination": "1002"}, }, Units: 3, } @@ -367,15 +353,13 @@ func testV1RsAllocateResource(t *testing.T) { // Second event to test matching of exact limit of first resource argsRU = utils.ArgRSv1ResourceUsage{ UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e52", - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - "Account": "1002", - "Subject": "1001", - "Destination": "1002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + "Account": "1002", + "Subject": "1001", + "Destination": "1002"}, }, Units: 4, } @@ -390,15 +374,13 @@ func testV1RsAllocateResource(t *testing.T) { // Third event testing overflow to second resource which still has one resource available argsRU = utils.ArgRSv1ResourceUsage{ UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e53", - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - "Account": "dan", - "Subject": "dan", - "Destination": "1002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + "Account": "dan", + "Subject": "dan", + "Destination": "1002"}, }, Units: 1, } @@ -413,15 +395,13 @@ func testV1RsAllocateResource(t *testing.T) { // Test resource unavailable argsRU = utils.ArgRSv1ResourceUsage{ UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e54", // same ID should be accepted by first group since the previous resource should be expired - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - "Account": "1002", - "Subject": "1001", - "Destination": "1002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + "Account": "1002", + "Subject": "1001", + "Destination": "1002"}, }, Units: 1, } @@ -434,15 +414,13 @@ func testV1RsAllocateResource(t *testing.T) { argsRU = utils.ArgRSv1ResourceUsage{ UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e55", // same ID should be accepted by first group since the previous resource should be expired - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - "Account": "1002", - "Subject": "1001", - "Destination": "1002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + "Account": "1002", + "Subject": "1001", + "Destination": "1002"}, }, Units: 1, } @@ -460,15 +438,13 @@ func testV1RsAuthorizeResources(t *testing.T) { var reply string argsRU := utils.ArgRSv1ResourceUsage{ UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e61", - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - "Account": "1002", - "Subject": "1001", - "Destination": "1002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + "Account": "1002", + "Subject": "1001", + "Destination": "1002"}, }, Units: 6, } @@ -479,15 +455,13 @@ func testV1RsAuthorizeResources(t *testing.T) { } argsRU = utils.ArgRSv1ResourceUsage{ UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e61", - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - "Account": "1002", - "Subject": "1001", - "Destination": "1002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + "Account": "1002", + "Subject": "1001", + "Destination": "1002"}, }, Units: 7, } @@ -502,15 +476,13 @@ func testV1RsReleaseResource(t *testing.T) { var reply string argsRU := utils.ArgRSv1ResourceUsage{ UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e55", // same ID should be accepted by first group since the previous resource should be expired - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - "Account": "1002", - "Subject": "1001", - "Destination": "1002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + "Account": "1002", + "Subject": "1001", + "Destination": "1002"}, }, } if err := rlsV1Rpc.Call(utils.ResourceSv1ReleaseResources, @@ -521,15 +493,13 @@ func testV1RsReleaseResource(t *testing.T) { // only match Resource1 since we don't want for storing of the resource2 bellow argsRU = utils.ArgRSv1ResourceUsage{ UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e61", - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - "Account": "1002", - "Subject": "1001", - "Destination": "1002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + "Account": "1002", + "Subject": "1001", + "Destination": "1002"}, }, Units: 7, } @@ -540,15 +510,13 @@ func testV1RsReleaseResource(t *testing.T) { } var rs *engine.Resources args := &utils.ArgRSv1ResourceUsage{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "Event5", - Event: map[string]interface{}{ - "Account": "1002", - "Subject": "1001", - "Destination": "1002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "Event5", + Event: map[string]interface{}{ + "Account": "1002", + "Subject": "1001", + "Destination": "1002"}, }, UsageID: utils.UUIDSha1Prefix(), } @@ -570,15 +538,13 @@ func testV1RsReleaseResource(t *testing.T) { // release an empty resource should return error argsRU = utils.ArgRSv1ResourceUsage{ UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e55", // same ID should be accepted by first group since the previous resource should be expired - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - "Account": "1002", - "Subject": "1001", - "Destination": "1002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + "Account": "1002", + "Subject": "1001", + "Destination": "1002"}, }, } if err := rlsV1Rpc.Call(utils.ResourceSv1ReleaseResources, @@ -593,15 +559,13 @@ func testV1RsDBStore(t *testing.T) { } argsRU := utils.ArgRSv1ResourceUsage{ UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e71", - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - "Account": "1002", - "Subject": "1001", - "Destination": "1002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + "Account": "1002", + "Subject": "1001", + "Destination": "1002"}, }, Units: 1, } @@ -614,15 +578,13 @@ func testV1RsDBStore(t *testing.T) { } var rs *engine.Resources args := &utils.ArgRSv1ResourceUsage{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "Event3", - Event: map[string]interface{}{ - "Account": "1002", - "Subject": "1001", - "Destination": "1002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "Event3", + Event: map[string]interface{}{ + "Account": "1002", + "Subject": "1001", + "Destination": "1002"}, }, UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e71", } @@ -657,15 +619,13 @@ func testV1RsDBStore(t *testing.T) { } rs = new(engine.Resources) args = &utils.ArgRSv1ResourceUsage{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "Event4", - Event: map[string]interface{}{ - "Account": "1002", - "Subject": "1001", - "Destination": "1002"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "Event4", + Event: map[string]interface{}{ + "Account": "1002", + "Subject": "1001", + "Destination": "1002"}, }, UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e71", } @@ -838,14 +798,12 @@ func testV1RsMatchNotFound(t *testing.T) { } argsRU := utils.ArgRSv1ResourceUsage{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - "Account": "CustomTest", - "Custom": ""}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + "Account": "CustomTest", + "Custom": ""}, }, UsageID: "test", Units: 1, @@ -884,13 +842,11 @@ func testV1RsAllocateUnlimited(t *testing.T) { var reply string argsRU := utils.ArgRSv1ResourceUsage{ UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e51", - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: utils.UUIDSha1Prefix(), - Event: map[string]interface{}{ - "CustomField": "UnlimitedEvent"}, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: utils.UUIDSha1Prefix(), + Event: map[string]interface{}{ + "CustomField": "UnlimitedEvent"}, }, Units: 1, } @@ -1015,14 +971,12 @@ func testV1RsAuthorizeResourcesWithOpts(t *testing.T) { var reply string argsRU := utils.ArgRSv1ResourceUsage{ UsageID: "651a8db2-4f67-4cf8-b622-169e8a482e45", - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TEST_WITH_OPTS", - Event: map[string]interface{}{ - "Subject": "1001", - "Destination": "1002", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TEST_WITH_OPTS", + Event: map[string]interface{}{ + "Subject": "1001", + "Destination": "1002", }, Opts: map[string]interface{}{ "CustomField": "1007", diff --git a/apier/v1/routes_it_test.go b/apier/v1/routes_it_test.go index ed2c455bb..e65b29e49 100644 --- a/apier/v1/routes_it_test.go +++ b/apier/v1/routes_it_test.go @@ -156,14 +156,12 @@ func testV1RouteFromFolder(t *testing.T) { func testV1RouteGetWeightRoutes(t *testing.T) { ev := &engine.ArgsGetRoutes{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testV1RouteGetWeightRoutes", - Event: map[string]interface{}{ - utils.AccountField: "1007", - utils.Destination: "+491511231234", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testV1RouteGetWeightRoutes", + Event: map[string]interface{}{ + utils.AccountField: "1007", + utils.Destination: "+491511231234", }, }, } @@ -207,17 +205,15 @@ func testV1RouteGetWeightRoutes(t *testing.T) { func testV1RouteGetLeastCostRoutes(t *testing.T) { ev := &engine.ArgsGetRoutes{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testV1RouteGetLeastCostRoutes", - Event: map[string]interface{}{ - utils.AccountField: "1003", - utils.Subject: "1003", - utils.Destination: "1002", - utils.SetupTime: time.Date(2017, 12, 1, 14, 25, 0, 0, time.UTC), - utils.Usage: "1m20s", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testV1RouteGetLeastCostRoutes", + Event: map[string]interface{}{ + utils.AccountField: "1003", + utils.Subject: "1003", + utils.Destination: "1002", + utils.SetupTime: time.Date(2017, 12, 1, 14, 25, 0, 0, time.UTC), + utils.Usage: "1m20s", }, }, } @@ -264,16 +260,14 @@ func testV1RouteGetLeastCostRoutes(t *testing.T) { func testV1RouteGetLeastCostRoutesWithoutUsage(t *testing.T) { ev := &engine.ArgsGetRoutes{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testV1RouteGetLeastCostRoutes", - Event: map[string]interface{}{ - utils.AccountField: "1003", - utils.Subject: "1003", - utils.Destination: "1002", - utils.SetupTime: time.Date(2017, 12, 1, 14, 25, 0, 0, time.UTC), - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testV1RouteGetLeastCostRoutes", + Event: map[string]interface{}{ + utils.AccountField: "1003", + utils.Subject: "1003", + utils.Destination: "1002", + utils.SetupTime: time.Date(2017, 12, 1, 14, 25, 0, 0, time.UTC), }, }, } @@ -321,17 +315,15 @@ func testV1RouteGetLeastCostRoutesWithoutUsage(t *testing.T) { func testV1RouteGetLeastCostRoutesWithMaxCost(t *testing.T) { ev := &engine.ArgsGetRoutes{ MaxCost: "0.30", - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testV1RouteGetLeastCostRoutes", - Event: map[string]interface{}{ - utils.AccountField: "1003", - utils.Subject: "1001", - utils.Destination: "1002", - utils.SetupTime: time.Date(2017, 12, 1, 14, 25, 0, 0, time.UTC), - utils.Usage: "1m20s", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testV1RouteGetLeastCostRoutes", + Event: map[string]interface{}{ + utils.AccountField: "1003", + utils.Subject: "1001", + utils.Destination: "1002", + utils.SetupTime: time.Date(2017, 12, 1, 14, 25, 0, 0, time.UTC), + utils.Usage: "1m20s", }, }, } @@ -371,17 +363,15 @@ func testV1RouteGetLeastCostRoutesWithMaxCost(t *testing.T) { func testV1RouteGetLeastCostRoutesWithMaxCostNotFound(t *testing.T) { ev := &engine.ArgsGetRoutes{ MaxCost: "0.001", - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testV1RouteGetLeastCostRoutes", - Event: map[string]interface{}{ - utils.AccountField: "1003", - utils.Subject: "1001", - utils.Destination: "1002", - utils.SetupTime: time.Date(2017, 12, 1, 14, 25, 0, 0, time.UTC), - utils.Usage: "1m20s", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testV1RouteGetLeastCostRoutes", + Event: map[string]interface{}{ + utils.AccountField: "1003", + utils.Subject: "1001", + utils.Destination: "1002", + utils.SetupTime: time.Date(2017, 12, 1, 14, 25, 0, 0, time.UTC), + utils.Usage: "1m20s", }, }, } @@ -395,18 +385,16 @@ func testV1RouteGetLeastCostRoutesWithMaxCostNotFound(t *testing.T) { func testV1RouteGetLeastCostRoutesWithMaxCost2(t *testing.T) { ev := &engine.ArgsGetRoutes{ MaxCost: utils.MetaEventCost, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testV1RouteGetLeastCostRoutes", - Event: map[string]interface{}{ - utils.AccountField: "1003", - utils.Subject: "SPECIAL_1002", - utils.Destination: "1002", - utils.SetupTime: time.Date(2014, 01, 14, 0, 0, 0, 0, time.UTC), - utils.Usage: "10m20s", - utils.Category: "call", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testV1RouteGetLeastCostRoutes", + Event: map[string]interface{}{ + utils.AccountField: "1003", + utils.Subject: "SPECIAL_1002", + utils.Destination: "1002", + utils.SetupTime: time.Date(2014, 01, 14, 0, 0, 0, 0, time.UTC), + utils.Usage: "10m20s", + utils.Category: "call", }, }, } @@ -445,17 +433,15 @@ func testV1RouteGetLeastCostRoutesWithMaxCost2(t *testing.T) { func testV1RouteGetHighestCostRoutes(t *testing.T) { ev := &engine.ArgsGetRoutes{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testV1RouteGetHighestCostRoutes", - Event: map[string]interface{}{ - utils.AccountField: "1003", - utils.Destination: "1002", - utils.SetupTime: time.Date(2017, 12, 1, 14, 25, 0, 0, time.UTC), - utils.Usage: "1m20s", - "DistinctMatch": "*highest_cost", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testV1RouteGetHighestCostRoutes", + Event: map[string]interface{}{ + utils.AccountField: "1003", + utils.Destination: "1002", + utils.SetupTime: time.Date(2017, 12, 1, 14, 25, 0, 0, time.UTC), + utils.Usage: "1m20s", + "DistinctMatch": "*highest_cost", }, }, } @@ -503,16 +489,14 @@ func testV1RouteGetHighestCostRoutes(t *testing.T) { func testV1RouteGetLeastCostRoutesErr(t *testing.T) { ev := &engine.ArgsGetRoutes{ IgnoreErrors: true, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testV1RouteGetHighestCostRoutes", - Event: map[string]interface{}{ - utils.AccountField: "1000", - utils.Destination: "1001", - utils.SetupTime: "*now", - "Subject": "TEST", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testV1RouteGetHighestCostRoutes", + Event: map[string]interface{}{ + utils.AccountField: "1000", + utils.Destination: "1001", + utils.SetupTime: "*now", + "Subject": "TEST", }, }, } @@ -527,16 +511,14 @@ func testV1RoutePolulateStatsForQOS(t *testing.T) { var reply []string expected := []string{"Stat_1"} ev1 := &engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - utils.AccountField: "1001", - utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: 11 * time.Second, - utils.Cost: 10.0, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + utils.AccountField: "1001", + utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), + utils.Usage: 11 * time.Second, + utils.Cost: 10.0, }, }, } @@ -548,16 +530,14 @@ func testV1RoutePolulateStatsForQOS(t *testing.T) { expected = []string{"Stat_1"} ev1 = &engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event2", - Event: map[string]interface{}{ - utils.AccountField: "1001", - utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: 11 * time.Second, - utils.Cost: 10.5, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event2", + Event: map[string]interface{}{ + utils.AccountField: "1001", + utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), + utils.Usage: 11 * time.Second, + utils.Cost: 10.5, }, }, } @@ -569,16 +549,14 @@ func testV1RoutePolulateStatsForQOS(t *testing.T) { expected = []string{"Stat_2"} ev1 = &engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event2", - Event: map[string]interface{}{ - utils.AccountField: "1002", - utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: 5 * time.Second, - utils.Cost: 12.5, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event2", + Event: map[string]interface{}{ + utils.AccountField: "1002", + utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), + utils.Usage: 5 * time.Second, + utils.Cost: 12.5, }, }, } @@ -590,16 +568,14 @@ func testV1RoutePolulateStatsForQOS(t *testing.T) { expected = []string{"Stat_2"} ev1 = &engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event2", - Event: map[string]interface{}{ - utils.AccountField: "1002", - utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: 6 * time.Second, - utils.Cost: 17.5, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event2", + Event: map[string]interface{}{ + utils.AccountField: "1002", + utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), + utils.Usage: 6 * time.Second, + utils.Cost: 17.5, }, }, } @@ -611,16 +587,14 @@ func testV1RoutePolulateStatsForQOS(t *testing.T) { expected = []string{"Stat_3"} ev1 = &engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event3", - Event: map[string]interface{}{ - utils.AccountField: "1003", - utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: 11 * time.Second, - utils.Cost: 12.5, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event3", + Event: map[string]interface{}{ + utils.AccountField: "1003", + utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), + utils.Usage: 11 * time.Second, + utils.Cost: 12.5, }, }, } @@ -632,17 +606,15 @@ func testV1RoutePolulateStatsForQOS(t *testing.T) { expected = []string{"Stat_1_1"} ev1 = &engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event3", - Event: map[string]interface{}{ - "Stat": "Stat1_1", - utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: 11 * time.Second, - utils.Cost: 12.5, - utils.PDD: 12 * time.Second, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event3", + Event: map[string]interface{}{ + "Stat": "Stat1_1", + utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), + utils.Usage: 11 * time.Second, + utils.Cost: 12.5, + utils.PDD: 12 * time.Second, }, }, } @@ -654,17 +626,15 @@ func testV1RoutePolulateStatsForQOS(t *testing.T) { expected = []string{"Stat_1_1"} ev1 = &engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event3", - Event: map[string]interface{}{ - "Stat": "Stat1_1", - utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: 15 * time.Second, - utils.Cost: 15.5, - utils.PDD: 15 * time.Second, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event3", + Event: map[string]interface{}{ + "Stat": "Stat1_1", + utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), + utils.Usage: 15 * time.Second, + utils.Cost: 15.5, + utils.PDD: 15 * time.Second, }, }, } @@ -677,13 +647,11 @@ func testV1RoutePolulateStatsForQOS(t *testing.T) { func testV1RouteGetQOSRoutes(t *testing.T) { ev := &engine.ArgsGetRoutes{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testV1RouteGetQOSRoutes", - Event: map[string]interface{}{ - "DistinctMatch": "*qos", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testV1RouteGetQOSRoutes", + Event: map[string]interface{}{ + "DistinctMatch": "*qos", }, }, } @@ -710,13 +678,11 @@ func testV1RouteGetQOSRoutes(t *testing.T) { func testV1RouteGetQOSRoutes2(t *testing.T) { ev := &engine.ArgsGetRoutes{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testV1RouteGetQOSRoutes", - Event: map[string]interface{}{ - "DistinctMatch": "*qos2", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testV1RouteGetQOSRoutes", + Event: map[string]interface{}{ + "DistinctMatch": "*qos2", }, }, } @@ -743,13 +709,11 @@ func testV1RouteGetQOSRoutes2(t *testing.T) { func testV1RouteGetQOSRoutes3(t *testing.T) { ev := &engine.ArgsGetRoutes{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testV1RouteGetQOSRoutes", - Event: map[string]interface{}{ - "DistinctMatch": "*qos3", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testV1RouteGetQOSRoutes", + Event: map[string]interface{}{ + "DistinctMatch": "*qos3", }, }, } @@ -776,13 +740,11 @@ func testV1RouteGetQOSRoutes3(t *testing.T) { func testV1RouteGetQOSRoutesFiltred(t *testing.T) { ev := &engine.ArgsGetRoutes{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testV1RouteGetQOSRoutes", - Event: map[string]interface{}{ - "DistinctMatch": "*qos_filtred", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testV1RouteGetQOSRoutes", + Event: map[string]interface{}{ + "DistinctMatch": "*qos_filtred", }, }, } @@ -809,17 +771,15 @@ func testV1RouteGetQOSRoutesFiltred(t *testing.T) { func testV1RouteGetQOSRoutesFiltred2(t *testing.T) { ev := &engine.ArgsGetRoutes{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testV1RouteGetQOSRoutes", - Event: map[string]interface{}{ - "DistinctMatch": "*qos_filtred2", - utils.AccountField: "1003", - utils.Destination: "1002", - utils.SetupTime: time.Date(2017, 12, 1, 14, 25, 0, 0, time.UTC), - utils.Usage: "1m20s", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testV1RouteGetQOSRoutes", + Event: map[string]interface{}{ + "DistinctMatch": "*qos_filtred2", + utils.AccountField: "1003", + utils.Destination: "1002", + utils.SetupTime: time.Date(2017, 12, 1, 14, 25, 0, 0, time.UTC), + utils.Usage: "1m20s", }, }, } @@ -846,14 +806,12 @@ func testV1RouteGetQOSRoutesFiltred2(t *testing.T) { func testV1RouteGetRouteWithoutFilter(t *testing.T) { ev := &engine.ArgsGetRoutes{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testV1RouteGetRouteWithoutFilter", - Event: map[string]interface{}{ - utils.AccountField: "1008", - utils.Destination: "+49", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testV1RouteGetRouteWithoutFilter", + Event: map[string]interface{}{ + utils.AccountField: "1008", + utils.Destination: "+49", }, }, } @@ -1045,16 +1003,14 @@ func testV1RouteRoutePing(t *testing.T) { } func testV1RouteGetRouteForEvent(t *testing.T) { - ev := &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testV1RouteGetHighestCostRoutes", - Event: map[string]interface{}{ - utils.AccountField: "1000", - utils.Destination: "1001", - utils.SetupTime: "*now", - utils.Subject: "TEST", - }, + ev := &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testV1RouteGetHighestCostRoutes", + Event: map[string]interface{}{ + utils.AccountField: "1000", + utils.Destination: "1001", + utils.SetupTime: "*now", + utils.Subject: "TEST", }, } expected := engine.RouteProfile{ @@ -1111,7 +1067,7 @@ func testV1RouteGetRouteForEvent(t *testing.T) { } supProf = nil - ev.CGREvent.Tenant = utils.EmptyString + ev.Tenant = utils.EmptyString if err := routeSv1Rpc.Call(utils.RouteSv1GetRouteProfilesForEvent, ev, &supProf); err != nil { t.Fatal(err) @@ -1176,16 +1132,14 @@ func testV1RoutesOneRouteWithoutDestination(t *testing.T) { } ev := &engine.ArgsGetRoutes{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testV1RoutesOneRouteWithoutDestination", - Event: map[string]interface{}{ - utils.AccountField: "SpecialCase", - utils.Destination: "+24680", - utils.SetupTime: utils.MetaNow, - utils.Usage: "2m", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testV1RoutesOneRouteWithoutDestination", + Event: map[string]interface{}{ + utils.AccountField: "SpecialCase", + utils.Destination: "+24680", + utils.SetupTime: utils.MetaNow, + utils.Usage: "2m", }, }, } @@ -1253,18 +1207,16 @@ func testV1RouteMultipleRouteSameID(t *testing.T) { } tNow := time.Now() ev := &engine.ArgsGetRoutes{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - Time: &tNow, - ID: "testV1RouteMultipleRouteSameID", - Event: map[string]interface{}{ - utils.AccountField: "SpecialCase2", - utils.Destination: "+135876", - utils.SetupTime: utils.MetaNow, - utils.Usage: "2m", - "Month": "April", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + Time: &tNow, + ID: "testV1RouteMultipleRouteSameID", + Event: map[string]interface{}{ + utils.AccountField: "SpecialCase2", + utils.Destination: "+135876", + utils.SetupTime: utils.MetaNow, + utils.Usage: "2m", + "Month": "April", }, }, } @@ -1293,18 +1245,16 @@ func testV1RouteMultipleRouteSameID(t *testing.T) { } ev = &engine.ArgsGetRoutes{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - Time: &tNow, - ID: "testV1RouteMultipleRouteSameID", - Event: map[string]interface{}{ - utils.AccountField: "SpecialCase2", - utils.Destination: "+135876", - utils.SetupTime: utils.MetaNow, - utils.Usage: "2m", - "Month": "May", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + Time: &tNow, + ID: "testV1RouteMultipleRouteSameID", + Event: map[string]interface{}{ + utils.AccountField: "SpecialCase2", + utils.Destination: "+135876", + utils.SetupTime: utils.MetaNow, + utils.Usage: "2m", + "Month": "May", }, }, } @@ -1393,18 +1343,16 @@ func testV1RouteAccountWithRatingPlan(t *testing.T) { // we expect that the route with account to have cost 0 tNow := time.Now() ev := &engine.ArgsGetRoutes{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - Time: &tNow, - ID: "testV1RouteAccountWithRatingPlan", - Event: map[string]interface{}{ - utils.AccountField: "RandomAccount", - utils.Destination: "+135876", - utils.SetupTime: utils.MetaNow, - utils.Usage: "30s", - "EventType": "testV1RouteAccountWithRatingPlan", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + Time: &tNow, + ID: "testV1RouteAccountWithRatingPlan", + Event: map[string]interface{}{ + utils.AccountField: "RandomAccount", + utils.Destination: "+135876", + utils.SetupTime: utils.MetaNow, + utils.Usage: "30s", + "EventType": "testV1RouteAccountWithRatingPlan", }, }, } @@ -1465,18 +1413,16 @@ func testV1RouteAccountWithRatingPlan(t *testing.T) { // test for 60 seconds usage // 30 seconds are covered by account and the remaining will be calculated ev = &engine.ArgsGetRoutes{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - Time: &tNow, - ID: "testV1RouteAccountWithRatingPlan", - Event: map[string]interface{}{ - utils.AccountField: "RandomAccount", - utils.Destination: "+135876", - utils.SetupTime: utils.MetaNow, - utils.Usage: "60s", - "EventType": "testV1RouteAccountWithRatingPlan", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + Time: &tNow, + ID: "testV1RouteAccountWithRatingPlan", + Event: map[string]interface{}{ + utils.AccountField: "RandomAccount", + utils.Destination: "+135876", + utils.SetupTime: utils.MetaNow, + utils.Usage: "60s", + "EventType": "testV1RouteAccountWithRatingPlan", }, }, } @@ -1539,18 +1485,16 @@ func testV1RouteAccountWithRatingPlan(t *testing.T) { // test for 61 seconds usage // 30 seconds are covered by account and the remaining will be calculated ev = &engine.ArgsGetRoutes{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - Time: &tNow, - ID: "testV1RouteAccountWithRatingPlan", - Event: map[string]interface{}{ - utils.AccountField: "RandomAccount", - utils.Destination: "+135876", - utils.SetupTime: utils.MetaNow, - utils.Usage: "1m1s", - "EventType": "testV1RouteAccountWithRatingPlan", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + Time: &tNow, + ID: "testV1RouteAccountWithRatingPlan", + Event: map[string]interface{}{ + utils.AccountField: "RandomAccount", + utils.Destination: "+135876", + utils.SetupTime: utils.MetaNow, + utils.Usage: "1m1s", + "EventType": "testV1RouteAccountWithRatingPlan", }, }, } diff --git a/apier/v1/routes_with_rates_it_test.go b/apier/v1/routes_with_rates_it_test.go index da0999c08..6d94c0a58 100644 --- a/apier/v1/routes_with_rates_it_test.go +++ b/apier/v1/routes_with_rates_it_test.go @@ -110,18 +110,16 @@ func testV1RouteSWithRateSFromFolder(t *testing.T) { func testV1RouteSWithRateSGetRoutes(t *testing.T) { ev := &engine.ArgsGetRoutes{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testV1RouteSWithRateSGetRoutes", - Event: map[string]interface{}{ - utils.AccountField: "1003", - utils.Subject: "1003", - utils.Destination: "1002", - utils.SetupTime: time.Date(2017, 12, 1, 14, 25, 0, 0, time.UTC), - utils.Usage: "1m20s", - "EventName": "RouteWithRateS", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testV1RouteSWithRateSGetRoutes", + Event: map[string]interface{}{ + utils.AccountField: "1003", + utils.Subject: "1003", + utils.Destination: "1002", + utils.SetupTime: time.Date(2017, 12, 1, 14, 25, 0, 0, time.UTC), + utils.Usage: "1m20s", + "EventName": "RouteWithRateS", }, }, } @@ -227,18 +225,16 @@ func testV1RouteSWithRateSAccountWithRateProfile(t *testing.T) { // we expect that the route with account to have cost 0 tNow := time.Now() ev := &engine.ArgsGetRoutes{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - Time: &tNow, - ID: "testV1RouteAccountWithRatingPlan", - Event: map[string]interface{}{ - utils.AccountField: "RandomAccount", - utils.Destination: "+135876", - utils.SetupTime: utils.MetaNow, - utils.Usage: "30s", - "EventType": "testV1RouteSWithRateSAccountWithRateProfile", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + Time: &tNow, + ID: "testV1RouteAccountWithRatingPlan", + Event: map[string]interface{}{ + utils.AccountField: "RandomAccount", + utils.Destination: "+135876", + utils.SetupTime: utils.MetaNow, + utils.Usage: "30s", + "EventType": "testV1RouteSWithRateSAccountWithRateProfile", }, }, } @@ -281,18 +277,16 @@ func testV1RouteSWithRateSAccountWithRateProfile(t *testing.T) { // test for 60 seconds usage // 30 seconds are covered by account and the remaining will be calculated ev = &engine.ArgsGetRoutes{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - Time: &tNow, - ID: "testV1RouteAccountWithRatingPlan", - Event: map[string]interface{}{ - utils.AccountField: "RandomAccount", - utils.Destination: "+135876", - utils.SetupTime: utils.MetaNow, - utils.Usage: "60s", - "EventType": "testV1RouteSWithRateSAccountWithRateProfile", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + Time: &tNow, + ID: "testV1RouteAccountWithRatingPlan", + Event: map[string]interface{}{ + utils.AccountField: "RandomAccount", + utils.Destination: "+135876", + utils.SetupTime: utils.MetaNow, + utils.Usage: "60s", + "EventType": "testV1RouteSWithRateSAccountWithRateProfile", }, }, } @@ -336,18 +330,16 @@ func testV1RouteSWithRateSAccountWithRateProfile(t *testing.T) { // test for 61 seconds usage // 30 seconds are covered by account and the remaining will be calculated ev = &engine.ArgsGetRoutes{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - Time: &tNow, - ID: "testV1RouteAccountWithRatingPlan", - Event: map[string]interface{}{ - utils.AccountField: "RandomAccount", - utils.Destination: "+135876", - utils.SetupTime: utils.MetaNow, - utils.Usage: "1m1s", - "EventType": "testV1RouteSWithRateSAccountWithRateProfile", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + Time: &tNow, + ID: "testV1RouteAccountWithRatingPlan", + Event: map[string]interface{}{ + utils.AccountField: "RandomAccount", + utils.Destination: "+135876", + utils.SetupTime: utils.MetaNow, + utils.Usage: "1m1s", + "EventType": "testV1RouteSWithRateSAccountWithRateProfile", }, }, } @@ -421,18 +413,16 @@ func testV1RouteSWithRateSWithEmptyRateProfileIDs(t *testing.T) { } ev := &engine.ArgsGetRoutes{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testV1RouteSWithRateSGetRoutes", - Event: map[string]interface{}{ - utils.AccountField: "1003", - utils.Subject: "1003", - utils.Destination: "1002", - utils.SetupTime: time.Date(2017, 12, 1, 14, 25, 0, 0, time.UTC), - utils.Usage: "1m20s", - "EventName": "testV1RouteSWithRateSWithEmptyRateProfileIDs", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testV1RouteSWithRateSGetRoutes", + Event: map[string]interface{}{ + utils.AccountField: "1003", + utils.Subject: "1003", + utils.Destination: "1002", + utils.SetupTime: time.Date(2017, 12, 1, 14, 25, 0, 0, time.UTC), + utils.Usage: "1m20s", + "EventName": "testV1RouteSWithRateSWithEmptyRateProfileIDs", }, }, } diff --git a/apier/v1/sessions_process_event_it_test.go b/apier/v1/sessions_process_event_it_test.go index 793aa6f4b..d2ab57f39 100644 --- a/apier/v1/sessions_process_event_it_test.go +++ b/apier/v1/sessions_process_event_it_test.go @@ -163,21 +163,19 @@ func testSSv1ItProcessEventAuth(t *testing.T) { utils.ConcatenatedKey(utils.MetaRALs, utils.MetaAuthorize), utils.ConcatenatedKey(utils.MetaRALs, utils.MetaDerivedReply), utils.MetaRoutes, utils.MetaAttributes, utils.MetaChargers}, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testSSv1ItProcessEventAuth", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaVoice, - utils.OriginID: "testSSv1ItProcessEvent", - utils.RequestType: sSV1RequestType, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.Usage: authUsage, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testSSv1ItProcessEventAuth", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaVoice, + utils.OriginID: "testSSv1ItProcessEvent", + utils.RequestType: sSV1RequestType, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.Usage: authUsage, }, }, } @@ -222,25 +220,24 @@ func testSSv1ItProcessEventAuth(t *testing.T) { eAttrs := &engine.AttrSProcessEventReply{ MatchedProfiles: []string{"ATTR_ACNT_1001"}, AlteredFields: []string{"*req.OfficeGroup"}, - CGREventWithOpts: &utils.CGREventWithOpts{ - Opts: map[string]interface{}{utils.Subsys: utils.MetaSessionS}, - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testSSv1ItProcessEventAuth", - Event: map[string]interface{}{ - utils.CGRID: "4be779c004d9f784e836db9ffd41b50319d71fe8", - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaVoice, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - "OfficeGroup": "Marketing", - utils.OriginID: "testSSv1ItProcessEvent", - utils.RequestType: sSV1RequestType, - utils.SetupTime: "2018-01-07T17:00:00Z", - utils.Usage: 300000000000.0, - }, + + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testSSv1ItProcessEventAuth", + Event: map[string]interface{}{ + utils.CGRID: "4be779c004d9f784e836db9ffd41b50319d71fe8", + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaVoice, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + "OfficeGroup": "Marketing", + utils.OriginID: "testSSv1ItProcessEvent", + utils.RequestType: sSV1RequestType, + utils.SetupTime: "2018-01-07T17:00:00Z", + utils.Usage: 300000000000.0, }, + Opts: map[string]interface{}{utils.Subsys: utils.MetaSessionS}, }, } if !reflect.DeepEqual(eAttrs, rply.Attributes[utils.MetaRaw]) { @@ -257,22 +254,20 @@ func testSSv1ItProcessEventInitiateSession(t *testing.T) { utils.ConcatenatedKey(utils.MetaResources, utils.MetaAllocate), utils.ConcatenatedKey(utils.MetaResources, utils.MetaDerivedReply), utils.MetaAttributes, utils.MetaChargers}, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testSSv1ItProcessEventInitiateSession", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaVoice, - utils.OriginID: "testSSv1ItProcessEvent", - utils.RequestType: sSV1RequestType, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: initUsage, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testSSv1ItProcessEventInitiateSession", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaVoice, + utils.OriginID: "testSSv1ItProcessEvent", + utils.RequestType: sSV1RequestType, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: initUsage, }, }, } @@ -299,26 +294,24 @@ func testSSv1ItProcessEventInitiateSession(t *testing.T) { eAttrs := &engine.AttrSProcessEventReply{ MatchedProfiles: []string{"ATTR_ACNT_1001"}, AlteredFields: []string{"*req.OfficeGroup"}, - CGREventWithOpts: &utils.CGREventWithOpts{ - Opts: map[string]interface{}{utils.Subsys: utils.MetaSessionS}, - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testSSv1ItProcessEventInitiateSession", - Event: map[string]interface{}{ - utils.CGRID: "4be779c004d9f784e836db9ffd41b50319d71fe8", - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaVoice, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - "OfficeGroup": "Marketing", - utils.OriginID: "testSSv1ItProcessEvent", - utils.RequestType: sSV1RequestType, - utils.SetupTime: "2018-01-07T17:00:00Z", - utils.AnswerTime: "2018-01-07T17:00:10Z", - utils.Usage: 300000000000.0, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testSSv1ItProcessEventInitiateSession", + Event: map[string]interface{}{ + utils.CGRID: "4be779c004d9f784e836db9ffd41b50319d71fe8", + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaVoice, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + "OfficeGroup": "Marketing", + utils.OriginID: "testSSv1ItProcessEvent", + utils.RequestType: sSV1RequestType, + utils.SetupTime: "2018-01-07T17:00:00Z", + utils.AnswerTime: "2018-01-07T17:00:10Z", + utils.Usage: 300000000000.0, }, + Opts: map[string]interface{}{utils.Subsys: utils.MetaSessionS}, }, } if !reflect.DeepEqual(eAttrs, rply.Attributes[utils.MetaRaw]) { @@ -339,22 +332,20 @@ func testSSv1ItProcessEventUpdateSession(t *testing.T) { Flags: []string{utils.ConcatenatedKey(utils.MetaRALs, utils.MetaUpdate), utils.ConcatenatedKey(utils.MetaRALs, utils.MetaDerivedReply), utils.MetaAttributes}, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testSSv1ItProcessEventUpdateSession", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaVoice, - utils.OriginID: "testSSv1ItProcessEvent", - utils.RequestType: sSV1RequestType, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: reqUsage, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testSSv1ItProcessEventUpdateSession", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaVoice, + utils.OriginID: "testSSv1ItProcessEvent", + utils.RequestType: sSV1RequestType, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: reqUsage, }, }, } @@ -366,26 +357,24 @@ func testSSv1ItProcessEventUpdateSession(t *testing.T) { eAttrs := &engine.AttrSProcessEventReply{ MatchedProfiles: []string{"ATTR_ACNT_1001"}, AlteredFields: []string{"*req.OfficeGroup"}, - CGREventWithOpts: &utils.CGREventWithOpts{ - Opts: map[string]interface{}{utils.Subsys: utils.MetaSessionS}, - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testSSv1ItProcessEventUpdateSession", - Event: map[string]interface{}{ - utils.CGRID: "4be779c004d9f784e836db9ffd41b50319d71fe8", - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaVoice, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - "OfficeGroup": "Marketing", - utils.OriginID: "testSSv1ItProcessEvent", - utils.RequestType: sSV1RequestType, - utils.SetupTime: "2018-01-07T17:00:00Z", - utils.AnswerTime: "2018-01-07T17:00:10Z", - utils.Usage: 300000000000.0, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testSSv1ItProcessEventUpdateSession", + Event: map[string]interface{}{ + utils.CGRID: "4be779c004d9f784e836db9ffd41b50319d71fe8", + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaVoice, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + "OfficeGroup": "Marketing", + utils.OriginID: "testSSv1ItProcessEvent", + utils.RequestType: sSV1RequestType, + utils.SetupTime: "2018-01-07T17:00:00Z", + utils.AnswerTime: "2018-01-07T17:00:10Z", + utils.Usage: 300000000000.0, }, + Opts: map[string]interface{}{utils.Subsys: utils.MetaSessionS}, }, } if !reflect.DeepEqual(eAttrs, rply.Attributes[utils.MetaRaw]) { @@ -416,22 +405,20 @@ func testSSv1ItProcessEventTerminateSession(t *testing.T) { args := &sessions.V1ProcessEventArgs{ Flags: []string{utils.ConcatenatedKey(utils.MetaRALs, utils.MetaTerminate), utils.ConcatenatedKey(utils.MetaResources, utils.MetaRelease)}, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testSSv1ItProcessEventTerminateSession", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaVoice, - utils.OriginID: "testSSv1ItProcessEvent", - utils.RequestType: sSV1RequestType, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: 10 * time.Minute, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testSSv1ItProcessEventTerminateSession", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaVoice, + utils.OriginID: "testSSv1ItProcessEvent", + utils.RequestType: sSV1RequestType, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: 10 * time.Minute, }, }, } @@ -522,21 +509,19 @@ func testSSv1ItProcessEventWithGetCost(t *testing.T) { // GetCost for ANY2CNT Subject args := &sessions.V1ProcessEventArgs{ Flags: []string{utils.MetaAttributes, utils.ConcatenatedKey(utils.MetaRALs, utils.MetaCost)}, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testSSv1ItProcessEventWithGetCost", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaMonetary, - utils.OriginID: "testSSv1ItProcessEventWithGetCost", - utils.RequestType: sSV1RequestType, - utils.Subject: "*attributes", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: 10 * time.Minute, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testSSv1ItProcessEventWithGetCost", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaMonetary, + utils.OriginID: "testSSv1ItProcessEventWithGetCost", + utils.RequestType: sSV1RequestType, + utils.Subject: "*attributes", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: 10 * time.Minute, }, }, } @@ -563,21 +548,19 @@ func testSSv1ItProcessEventWithGetCost2(t *testing.T) { // GetCost for SPECIAL_1002 Subject args := &sessions.V1ProcessEventArgs{ Flags: []string{utils.MetaAttributes, utils.ConcatenatedKey(utils.MetaRALs, utils.MetaCost)}, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testSSv1ItProcessEventWithGetCost2", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaMonetary, - utils.OriginID: "testSSv1ItProcessEventWithGetCost2", - utils.RequestType: sSV1RequestType, - utils.Subject: "*attributes", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: 10 * time.Minute, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testSSv1ItProcessEventWithGetCost2", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaMonetary, + utils.OriginID: "testSSv1ItProcessEventWithGetCost2", + utils.RequestType: sSV1RequestType, + utils.Subject: "*attributes", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: 10 * time.Minute, }, }, } @@ -606,21 +589,19 @@ func testSSv1ItProcessEventWithGetCost3(t *testing.T) { // for the 9 minutes remaining apply args := &sessions.V1ProcessEventArgs{ Flags: []string{utils.MetaAttributes, utils.ConcatenatedKey(utils.MetaRALs, utils.MetaCost)}, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testSSv1ItProcessEventWithGetCost3", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaMonetary, - utils.OriginID: "testSSv1ItProcessEventWithGetCost3", - utils.RequestType: sSV1RequestType, - utils.Subject: "*attributes", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: 10 * time.Minute, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testSSv1ItProcessEventWithGetCost3", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaMonetary, + utils.OriginID: "testSSv1ItProcessEventWithGetCost3", + utils.RequestType: sSV1RequestType, + utils.Subject: "*attributes", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: 10 * time.Minute, }, }, } @@ -646,21 +627,19 @@ func testSSv1ItProcessEventWithGetCost3(t *testing.T) { func testSSv1ItProcessEventWithGetCost4(t *testing.T) { args := &sessions.V1ProcessEventArgs{ Flags: []string{utils.MetaAttributes, utils.ConcatenatedKey(utils.MetaRALs, utils.MetaCost)}, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testSSv1ItProcessEventWithGetCost4", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaMonetary, - utils.OriginID: "testSSv1ItProcessEventWithGetCost4", - utils.RequestType: sSV1RequestType, - utils.Subject: "*attributes", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: 10 * time.Minute, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testSSv1ItProcessEventWithGetCost4", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaMonetary, + utils.OriginID: "testSSv1ItProcessEventWithGetCost4", + utils.RequestType: sSV1RequestType, + utils.Subject: "*attributes", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: 10 * time.Minute, }, }, } @@ -676,21 +655,19 @@ func testSSv1ItGetCost(t *testing.T) { // GetCost for ANY2CNT Subject args := &sessions.V1ProcessEventArgs{ Flags: []string{utils.MetaAttributes}, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testSSv1ItGetCost", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaMonetary, - utils.OriginID: "testSSv1ItProcessEventWithGetCost", - utils.RequestType: sSV1RequestType, - utils.Subject: "*attributes", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: 10 * time.Minute, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testSSv1ItGetCost", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaMonetary, + utils.OriginID: "testSSv1ItProcessEventWithGetCost", + utils.RequestType: sSV1RequestType, + utils.Subject: "*attributes", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: 10 * time.Minute, }, }, } @@ -718,22 +695,20 @@ func testSSv1ItGetCost(t *testing.T) { func testSSv1ItProcessEventWithCDR(t *testing.T) { args := &sessions.V1ProcessEventArgs{ Flags: []string{utils.MetaCDRs + utils.InInFieldSep + utils.MetaRALs}, // *cdrs:*rals - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testSSv1ItProcessEventWithCDR", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaVoice, - utils.OriginID: "testSSv1ItProcessEventWithCDR", - utils.RequestType: sSV1RequestType, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: 10 * time.Minute, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testSSv1ItProcessEventWithCDR", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaVoice, + utils.OriginID: "testSSv1ItProcessEventWithCDR", + utils.RequestType: sSV1RequestType, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: 10 * time.Minute, }, }, } @@ -797,22 +772,20 @@ func testSSv1ItProcessEventWithCDRResourceError(t *testing.T) { args := &sessions.V1ProcessEventArgs{ Flags: []string{utils.MetaCDRs + utils.InInFieldSep + utils.MetaRALs, utils.ConcatenatedKey(utils.MetaResources, utils.MetaRelease)}, // force a resource error and expect that the cdr to be written - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testSSv1ItProcessEventWithCDRResourceError", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaVoice, - utils.OriginID: "testSSv1ItProcessEventWithCDRResourceError", - utils.RequestType: sSV1RequestType, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: 10 * time.Minute, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testSSv1ItProcessEventWithCDRResourceError", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaVoice, + utils.OriginID: "testSSv1ItProcessEventWithCDRResourceError", + utils.RequestType: sSV1RequestType, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: 10 * time.Minute, }, }, } @@ -877,22 +850,20 @@ func testSSv1ItProcessEventWithCDRResourceErrorBlockError(t *testing.T) { Flags: []string{utils.MetaCDRs + utils.InInFieldSep + utils.MetaRALs, utils.ConcatenatedKey(utils.MetaResources, utils.MetaRelease), utils.MetaBlockerError}, // expended to stop the processing because we have error at resource - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "testSSv1ItProcessEventWithCDRResourceErrorBlockError", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaVoice, - utils.OriginID: "testSSv1ItProcessEventWithCDRResourceErrorBlockError", - utils.RequestType: sSV1RequestType, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: 10 * time.Minute, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "testSSv1ItProcessEventWithCDRResourceErrorBlockError", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaVoice, + utils.OriginID: "testSSv1ItProcessEventWithCDRResourceErrorBlockError", + utils.RequestType: sSV1RequestType, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: 10 * time.Minute, }, }, } diff --git a/apier/v1/sessions_thresholds_it_test.go b/apier/v1/sessions_thresholds_it_test.go index f71ac3dad..a11195ddc 100755 --- a/apier/v1/sessions_thresholds_it_test.go +++ b/apier/v1/sessions_thresholds_it_test.go @@ -206,18 +206,16 @@ func testSessionSv1ItAuth(t *testing.T) { args := &sessions.V1AuthorizeArgs{ AuthorizeResources: true, ProcessThresholds: true, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSSv1ItAuth", - Event: map[string]interface{}{ - utils.OriginID: "TestSSv1It1", - utils.RequestType: utils.MetaPrepaid, - utils.AccountField: "1001", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, - time.January, 7, 16, 60, 0, 0, time.UTC), - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSSv1ItAuth", + Event: map[string]interface{}{ + utils.OriginID: "TestSSv1It1", + utils.RequestType: utils.MetaPrepaid, + utils.AccountField: "1001", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, + time.January, 7, 16, 60, 0, 0, time.UTC), }, }, } @@ -269,24 +267,22 @@ func testSessionSv1ItInitiateSession(t *testing.T) { InitSession: true, AllocateResources: true, ProcessThresholds: true, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSSv1ItInitiateSession", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.Category: "call", - utils.ToR: utils.MetaVoice, - utils.OriginID: "TestSSv1It1", - utils.RequestType: utils.MetaPrepaid, - utils.AccountField: "1001", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, - time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, - time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: initUsage, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSSv1ItInitiateSession", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.Category: "call", + utils.ToR: utils.MetaVoice, + utils.OriginID: "TestSSv1It1", + utils.RequestType: utils.MetaPrepaid, + utils.AccountField: "1001", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, + time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, + time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: initUsage, }, }, } @@ -333,19 +329,17 @@ func testSessionSv1ItTerminateSession(t *testing.T) { TerminateSession: true, ReleaseResources: true, ProcessThresholds: true, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSSv1ItTerminateSession", - Event: map[string]interface{}{ - utils.OriginID: "TestSSv1It1", - utils.RequestType: utils.MetaPrepaid, - utils.AccountField: "1001", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: 10 * time.Minute, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSSv1ItTerminateSession", + Event: map[string]interface{}{ + utils.OriginID: "TestSSv1It1", + utils.RequestType: utils.MetaPrepaid, + utils.AccountField: "1001", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: 10 * time.Minute, }, }, } @@ -392,18 +386,16 @@ func testSessionSv1ItAuthNotFoundThreshold(t *testing.T) { ProcessStats: true, GetMaxUsage: true, ProcessThresholds: true, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSesssonSv1ItNotFoundThreshold", - Event: map[string]interface{}{ - utils.OriginID: "TestSesssonSv1ItNotFoundThreshold", - utils.RequestType: utils.MetaPrepaid, - utils.AccountField: "1002", - utils.Destination: "1001", - utils.SetupTime: time.Date(2018, - time.January, 7, 16, 60, 0, 0, time.UTC), - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSesssonSv1ItNotFoundThreshold", + Event: map[string]interface{}{ + utils.OriginID: "TestSesssonSv1ItNotFoundThreshold", + utils.RequestType: utils.MetaPrepaid, + utils.AccountField: "1002", + utils.Destination: "1001", + utils.SetupTime: time.Date(2018, + time.January, 7, 16, 60, 0, 0, time.UTC), }, }, } @@ -427,25 +419,23 @@ func testSessionSv1ItInitNotFoundThreshold(t *testing.T) { ProcessStats: true, InitSession: true, ProcessThresholds: true, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSessionSv1ItInitNotFoundThreshold", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.Category: "call", - utils.ToR: utils.MetaData, - utils.OriginID: "TestSessionSv1ItInitNotFoundThreshold", - utils.RequestType: utils.MetaPrepaid, - utils.AccountField: "1002", - utils.Subject: "RP_ANY2CNT", - utils.Destination: "1001", - utils.SetupTime: time.Date(2018, - time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, - time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: initUsage, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSessionSv1ItInitNotFoundThreshold", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.Category: "call", + utils.ToR: utils.MetaData, + utils.OriginID: "TestSessionSv1ItInitNotFoundThreshold", + utils.RequestType: utils.MetaPrepaid, + utils.AccountField: "1002", + utils.Subject: "RP_ANY2CNT", + utils.Destination: "1001", + utils.SetupTime: time.Date(2018, + time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, + time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: initUsage, }, }, } @@ -480,25 +470,23 @@ func testSessionSv1ItTerminateNotFoundThreshold(t *testing.T) { ProcessStats: true, TerminateSession: true, ProcessThresholds: true, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSessionSv1ItTerminateNotFoundThreshold", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.Category: "call", - utils.ToR: utils.MetaData, - utils.OriginID: "TestSessionSv1ItInitNotFoundThreshold", - utils.RequestType: utils.MetaPrepaid, - utils.AccountField: "1002", - utils.Subject: "RP_ANY2CNT", - utils.Destination: "1001", - utils.SetupTime: time.Date(2018, - time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, - time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: initUsage, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSessionSv1ItTerminateNotFoundThreshold", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.Category: "call", + utils.ToR: utils.MetaData, + utils.OriginID: "TestSessionSv1ItInitNotFoundThreshold", + utils.RequestType: utils.MetaPrepaid, + utils.AccountField: "1002", + utils.Subject: "RP_ANY2CNT", + utils.Destination: "1001", + utils.SetupTime: time.Date(2018, + time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, + time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: initUsage, }, }, } @@ -530,18 +518,16 @@ func testSessionSv1ItAuthNotFoundThresholdAndStats(t *testing.T) { ProcessStats: true, GetMaxUsage: true, ProcessThresholds: true, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSesssonSv1ItNotFoundThreshold", - Event: map[string]interface{}{ - utils.OriginID: "TestSesssonSv1ItNotFoundThreshold", - utils.RequestType: utils.MetaPrepaid, - utils.AccountField: "1002", - utils.Destination: "1001", - utils.SetupTime: time.Date(2018, - time.January, 7, 16, 60, 0, 0, time.UTC), - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSesssonSv1ItNotFoundThreshold", + Event: map[string]interface{}{ + utils.OriginID: "TestSesssonSv1ItNotFoundThreshold", + utils.RequestType: utils.MetaPrepaid, + utils.AccountField: "1002", + utils.Destination: "1001", + utils.SetupTime: time.Date(2018, + time.January, 7, 16, 60, 0, 0, time.UTC), }, }, } @@ -566,25 +552,23 @@ func testSessionSv1ItInitNotFoundThresholdAndStats(t *testing.T) { ProcessStats: true, InitSession: true, ProcessThresholds: true, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSessionSv1ItInitNotFoundThreshold", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.Category: "call", - utils.ToR: utils.MetaData, - utils.OriginID: "TestSessionSv1ItInitNotFoundThreshold", - utils.RequestType: utils.MetaPrepaid, - utils.AccountField: "1002", - utils.Subject: "RP_ANY2CNT", - utils.Destination: "1001", - utils.SetupTime: time.Date(2018, - time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, - time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: initUsage, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSessionSv1ItInitNotFoundThreshold", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.Category: "call", + utils.ToR: utils.MetaData, + utils.OriginID: "TestSessionSv1ItInitNotFoundThreshold", + utils.RequestType: utils.MetaPrepaid, + utils.AccountField: "1002", + utils.Subject: "RP_ANY2CNT", + utils.Destination: "1001", + utils.SetupTime: time.Date(2018, + time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, + time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: initUsage, }, }, } @@ -620,25 +604,23 @@ func testSessionSv1ItTerminateNotFoundThresholdAndStats(t *testing.T) { ProcessStats: true, TerminateSession: true, ProcessThresholds: true, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSessionSv1ItTerminateNotFoundThreshold", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.Category: "call", - utils.ToR: utils.MetaData, - utils.OriginID: "TestSessionSv1ItInitNotFoundThreshold", - utils.RequestType: utils.MetaPrepaid, - utils.AccountField: "1002", - utils.Subject: "RP_ANY2CNT", - utils.Destination: "1001", - utils.SetupTime: time.Date(2018, - time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, - time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: initUsage, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSessionSv1ItTerminateNotFoundThreshold", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.Category: "call", + utils.ToR: utils.MetaData, + utils.OriginID: "TestSessionSv1ItInitNotFoundThreshold", + utils.RequestType: utils.MetaPrepaid, + utils.AccountField: "1002", + utils.Subject: "RP_ANY2CNT", + utils.Destination: "1001", + utils.SetupTime: time.Date(2018, + time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, + time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: initUsage, }, }, } diff --git a/apier/v1/sessionsv1_it_test.go b/apier/v1/sessionsv1_it_test.go index 3be195846..9d5c40f05 100644 --- a/apier/v1/sessionsv1_it_test.go +++ b/apier/v1/sessionsv1_it_test.go @@ -206,21 +206,19 @@ func testSSv1ItAuth(t *testing.T) { AuthorizeResources: true, GetRoutes: true, GetAttributes: true, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSSv1ItAuth", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaVoice, - utils.OriginID: "TestSSv1It1", - utils.RequestType: sSV1RequestType, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.Usage: authUsage, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSSv1ItAuth", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaVoice, + utils.OriginID: "TestSSv1It1", + utils.RequestType: sSV1RequestType, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.Usage: authUsage, }, }, } @@ -259,25 +257,23 @@ func testSSv1ItAuth(t *testing.T) { eAttrs := &engine.AttrSProcessEventReply{ MatchedProfiles: []string{"ATTR_ACNT_1001"}, AlteredFields: []string{"*req.OfficeGroup"}, - CGREventWithOpts: &utils.CGREventWithOpts{ - Opts: map[string]interface{}{utils.Subsys: utils.MetaSessionS}, - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSSv1ItAuth", - Event: map[string]interface{}{ - utils.CGRID: "5668666d6b8e44eb949042f25ce0796ec3592ff9", - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaVoice, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - "OfficeGroup": "Marketing", - utils.OriginID: "TestSSv1It1", - utils.RequestType: sSV1RequestType, - utils.SetupTime: "2018-01-07T17:00:00Z", - utils.Usage: 300000000000.0, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSSv1ItAuth", + Event: map[string]interface{}{ + utils.CGRID: "5668666d6b8e44eb949042f25ce0796ec3592ff9", + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaVoice, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + "OfficeGroup": "Marketing", + utils.OriginID: "TestSSv1It1", + utils.RequestType: sSV1RequestType, + utils.SetupTime: "2018-01-07T17:00:00Z", + utils.Usage: 300000000000.0, }, + Opts: map[string]interface{}{utils.Subsys: utils.MetaSessionS}, }, } if !reflect.DeepEqual(eAttrs, rply.Attributes) { @@ -293,21 +289,19 @@ func testSSv1ItAuthWithDigest(t *testing.T) { AuthorizeResources: true, GetRoutes: true, GetAttributes: true, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSSv1ItAuth", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaVoice, - utils.OriginID: "TestSSv1It1", - utils.RequestType: sSV1RequestType, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.Usage: authUsage, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSSv1ItAuth", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaVoice, + utils.OriginID: "TestSSv1It1", + utils.RequestType: sSV1RequestType, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.Usage: authUsage, }, }, } @@ -339,22 +333,20 @@ func testSSv1ItInitiateSession(t *testing.T) { InitSession: true, AllocateResources: true, GetAttributes: true, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSSv1ItInitiateSession", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaVoice, - utils.OriginID: "TestSSv1It1", - utils.RequestType: sSV1RequestType, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: initUsage, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSSv1ItInitiateSession", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaVoice, + utils.OriginID: "TestSSv1It1", + utils.RequestType: sSV1RequestType, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: initUsage, }, }, } @@ -375,26 +367,24 @@ func testSSv1ItInitiateSession(t *testing.T) { eAttrs := &engine.AttrSProcessEventReply{ MatchedProfiles: []string{"ATTR_ACNT_1001"}, AlteredFields: []string{"*req.OfficeGroup"}, - CGREventWithOpts: &utils.CGREventWithOpts{ - Opts: map[string]interface{}{utils.Subsys: utils.MetaSessionS}, - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSSv1ItInitiateSession", - Event: map[string]interface{}{ - utils.CGRID: "5668666d6b8e44eb949042f25ce0796ec3592ff9", - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaVoice, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - "OfficeGroup": "Marketing", - utils.OriginID: "TestSSv1It1", - utils.RequestType: sSV1RequestType, - utils.SetupTime: "2018-01-07T17:00:00Z", - utils.AnswerTime: "2018-01-07T17:00:10Z", - utils.Usage: 300000000000.0, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSSv1ItInitiateSession", + Event: map[string]interface{}{ + utils.CGRID: "5668666d6b8e44eb949042f25ce0796ec3592ff9", + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaVoice, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + "OfficeGroup": "Marketing", + utils.OriginID: "TestSSv1It1", + utils.RequestType: sSV1RequestType, + utils.SetupTime: "2018-01-07T17:00:00Z", + utils.AnswerTime: "2018-01-07T17:00:10Z", + utils.Usage: 300000000000.0, }, + Opts: map[string]interface{}{utils.Subsys: utils.MetaSessionS}, }, } if !reflect.DeepEqual(eAttrs, rply.Attributes) { @@ -415,22 +405,20 @@ func testSSv1ItInitiateSessionWithDigest(t *testing.T) { InitSession: true, AllocateResources: true, GetAttributes: true, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSSv1ItInitiateSession", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaVoice, - utils.OriginID: "TestSSv1It2", - utils.RequestType: sSV1RequestType, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: initUsage, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSSv1ItInitiateSession", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaVoice, + utils.OriginID: "TestSSv1It2", + utils.RequestType: sSV1RequestType, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: initUsage, }, }, } @@ -466,22 +454,20 @@ func testSSv1ItUpdateSession(t *testing.T) { args := &sessions.V1UpdateSessionArgs{ GetAttributes: true, UpdateSession: true, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSSv1ItUpdateSession", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaVoice, - utils.OriginID: "TestSSv1It1", - utils.RequestType: sSV1RequestType, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: reqUsage, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSSv1ItUpdateSession", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaVoice, + utils.OriginID: "TestSSv1It1", + utils.RequestType: sSV1RequestType, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: reqUsage, }, }, } @@ -493,26 +479,24 @@ func testSSv1ItUpdateSession(t *testing.T) { eAttrs := &engine.AttrSProcessEventReply{ MatchedProfiles: []string{"ATTR_ACNT_1001"}, AlteredFields: []string{"*req.OfficeGroup"}, - CGREventWithOpts: &utils.CGREventWithOpts{ - Opts: map[string]interface{}{utils.Subsys: utils.MetaSessionS}, - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSSv1ItUpdateSession", - Event: map[string]interface{}{ - utils.CGRID: "5668666d6b8e44eb949042f25ce0796ec3592ff9", - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaVoice, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - "OfficeGroup": "Marketing", - utils.OriginID: "TestSSv1It1", - utils.RequestType: sSV1RequestType, - utils.SetupTime: "2018-01-07T17:00:00Z", - utils.AnswerTime: "2018-01-07T17:00:10Z", - utils.Usage: 300000000000.0, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSSv1ItUpdateSession", + Event: map[string]interface{}{ + utils.CGRID: "5668666d6b8e44eb949042f25ce0796ec3592ff9", + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaVoice, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + "OfficeGroup": "Marketing", + utils.OriginID: "TestSSv1It1", + utils.RequestType: sSV1RequestType, + utils.SetupTime: "2018-01-07T17:00:00Z", + utils.AnswerTime: "2018-01-07T17:00:10Z", + utils.Usage: 300000000000.0, }, + Opts: map[string]interface{}{utils.Subsys: utils.MetaSessionS}, }, } if !reflect.DeepEqual(eAttrs, rply.Attributes) { @@ -537,22 +521,20 @@ func testSSv1ItTerminateSession(t *testing.T) { args := &sessions.V1TerminateSessionArgs{ TerminateSession: true, ReleaseResources: true, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSSv1ItUpdateSession", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaVoice, - utils.OriginID: "TestSSv1It1", - utils.RequestType: sSV1RequestType, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: 10 * time.Minute, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSSv1ItUpdateSession", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaVoice, + utils.OriginID: "TestSSv1It1", + utils.RequestType: sSV1RequestType, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: 10 * time.Minute, }, }, } @@ -572,22 +554,20 @@ func testSSv1ItTerminateSession(t *testing.T) { } func testSSv1ItProcessCDR(t *testing.T) { - args := &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSSv1ItProcessCDR", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaVoice, - utils.OriginID: "TestSSv1It1", - utils.RequestType: sSV1RequestType, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: 10 * time.Minute, - }, + args := &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSSv1ItProcessCDR", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaVoice, + utils.OriginID: "TestSSv1It1", + utils.RequestType: sSV1RequestType, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: 10 * time.Minute, }, } var rply string @@ -607,23 +587,21 @@ func testSSv1ItProcessEvent(t *testing.T) { AllocateResources: true, Debit: true, GetAttributes: true, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSSv1ItProcessEvent", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaVoice, - utils.OriginID: "TestSSv1It2", - utils.OriginHost: "TestSSv1It3", - utils.RequestType: sSV1RequestType, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: initUsage, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSSv1ItProcessEvent", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaVoice, + utils.OriginID: "TestSSv1It2", + utils.OriginHost: "TestSSv1It3", + utils.RequestType: sSV1RequestType, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: initUsage, }, }, } @@ -644,27 +622,25 @@ func testSSv1ItProcessEvent(t *testing.T) { eAttrs := &engine.AttrSProcessEventReply{ MatchedProfiles: []string{"ATTR_ACNT_1001"}, AlteredFields: []string{"*req.OfficeGroup"}, - CGREventWithOpts: &utils.CGREventWithOpts{ - Opts: map[string]interface{}{utils.Subsys: utils.MetaSessionS}, - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSSv1ItProcessEvent", - Event: map[string]interface{}{ - utils.CGRID: "f7f5cf1029905f9b98be1a608e4bd975b8e51413", - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaVoice, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - "OfficeGroup": "Marketing", - utils.OriginID: "TestSSv1It2", - utils.OriginHost: "TestSSv1It3", - utils.RequestType: sSV1RequestType, - utils.SetupTime: "2018-01-07T17:00:00Z", - utils.AnswerTime: "2018-01-07T17:00:10Z", - utils.Usage: 300000000000.0, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSSv1ItProcessEvent", + Event: map[string]interface{}{ + utils.CGRID: "f7f5cf1029905f9b98be1a608e4bd975b8e51413", + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaVoice, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + "OfficeGroup": "Marketing", + utils.OriginID: "TestSSv1It2", + utils.OriginHost: "TestSSv1It3", + utils.RequestType: sSV1RequestType, + utils.SetupTime: "2018-01-07T17:00:00Z", + utils.AnswerTime: "2018-01-07T17:00:10Z", + utils.Usage: 300000000000.0, }, + Opts: map[string]interface{}{utils.Subsys: utils.MetaSessionS}, }, } if !reflect.DeepEqual(eAttrs, rply.Attributes) { @@ -799,23 +775,21 @@ func testSSv1ItForceUpdateSession(t *testing.T) { args := &sessions.V1UpdateSessionArgs{ GetAttributes: true, UpdateSession: true, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSSv1ItUpdateSession", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.Category: "call", - utils.ToR: utils.MetaVoice, - utils.OriginID: "TestSSv1It", - utils.RequestType: sSV1RequestType, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: reqUsage, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSSv1ItUpdateSession", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.Category: "call", + utils.ToR: utils.MetaVoice, + utils.OriginID: "TestSSv1It", + utils.RequestType: sSV1RequestType, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: reqUsage, }, }, } @@ -827,27 +801,25 @@ func testSSv1ItForceUpdateSession(t *testing.T) { eAttrs := &engine.AttrSProcessEventReply{ MatchedProfiles: []string{"ATTR_ACNT_1001"}, AlteredFields: []string{"*req.OfficeGroup"}, - CGREventWithOpts: &utils.CGREventWithOpts{ - Opts: map[string]interface{}{utils.Subsys: utils.MetaSessionS}, - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSSv1ItUpdateSession", - Event: map[string]interface{}{ - utils.CGRID: "70876773b294f0e1476065f8d18bb9ec6bcb3d5f", - utils.Tenant: "cgrates.org", - utils.Category: "call", - utils.ToR: utils.MetaVoice, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - "OfficeGroup": "Marketing", - utils.OriginID: "TestSSv1It", - utils.RequestType: sSV1RequestType, - utils.SetupTime: "2018-01-07T17:00:00Z", - utils.AnswerTime: "2018-01-07T17:00:10Z", - utils.Usage: 300000000000.0, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSSv1ItUpdateSession", + Event: map[string]interface{}{ + utils.CGRID: "70876773b294f0e1476065f8d18bb9ec6bcb3d5f", + utils.Tenant: "cgrates.org", + utils.Category: "call", + utils.ToR: utils.MetaVoice, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + "OfficeGroup": "Marketing", + utils.OriginID: "TestSSv1It", + utils.RequestType: sSV1RequestType, + utils.SetupTime: "2018-01-07T17:00:00Z", + utils.AnswerTime: "2018-01-07T17:00:10Z", + utils.Usage: 300000000000.0, }, + Opts: map[string]interface{}{utils.Subsys: utils.MetaSessionS}, }, } if !reflect.DeepEqual(eAttrs, rply.Attributes) { @@ -957,27 +929,25 @@ func testSSv1ItDynamicDebit(t *testing.T) { args1 := &sessions.V1InitSessionArgs{ InitSession: true, GetAttributes: true, - CGREventWithOpts: &utils.CGREventWithOpts{ + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSSv1ItInitiateSession2", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.Category: "call", + utils.ToR: utils.MetaVoice, + utils.OriginID: "TestDynamicTDebit", + utils.RequestType: sSV1RequestType, + utils.AccountField: "TestDynamicDebit", + utils.Subject: "TEST", + utils.Destination: "TEST", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: 0, + }, Opts: map[string]interface{}{ utils.OptsDebitInterval: 30 * time.Millisecond, }, - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSSv1ItInitiateSession2", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.Category: "call", - utils.ToR: utils.MetaVoice, - utils.OriginID: "TestDynamicTDebit", - utils.RequestType: sSV1RequestType, - utils.AccountField: "TestDynamicDebit", - utils.Subject: "TEST", - utils.Destination: "TEST", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: 0, - }, - }, }, } var rply1 sessions.V1InitSessionReply @@ -1056,22 +1026,20 @@ func testSSv1ItDeactivateSessions(t *testing.T) { args := &sessions.V1InitSessionArgs{ InitSession: true, GetAttributes: true, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "TestSSv1ItInitiateSession", - Event: map[string]interface{}{ - utils.Tenant: "cgrates.org", - utils.ToR: utils.MetaVoice, - utils.OriginID: "TestSSv1It1", - utils.RequestType: sSV1RequestType, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: initUsage, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestSSv1ItInitiateSession", + Event: map[string]interface{}{ + utils.Tenant: "cgrates.org", + utils.ToR: utils.MetaVoice, + utils.OriginID: "TestSSv1It1", + utils.RequestType: sSV1RequestType, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: initUsage, }, }, } @@ -1108,21 +1076,19 @@ func testSSv1ItAuthNotFoundCharger(t *testing.T) { authUsage := 5 * time.Minute args := &sessions.V1AuthorizeArgs{ GetMaxUsage: true, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "Unexist", - ID: "testSSv1ItAuthNotFoundCharger", - Event: map[string]interface{}{ - utils.Tenant: "Unexist", - utils.ToR: utils.MetaVoice, - utils.OriginID: "testSSv1ItAuthNotFoundCharger", - utils.RequestType: sSV1RequestType, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.Usage: authUsage, - }, + CGREvent: &utils.CGREvent{ + Tenant: "Unexist", + ID: "testSSv1ItAuthNotFoundCharger", + Event: map[string]interface{}{ + utils.Tenant: "Unexist", + utils.ToR: utils.MetaVoice, + utils.OriginID: "testSSv1ItAuthNotFoundCharger", + utils.RequestType: sSV1RequestType, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.Usage: authUsage, }, }, } @@ -1137,22 +1103,20 @@ func testSSv1ItInitiateSessionNotFoundCharger(t *testing.T) { initUsage := 5 * time.Minute args := &sessions.V1InitSessionArgs{ InitSession: true, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "Unexist", - ID: "testSSv1ItInitiateSessionNotFoundCharger", - Event: map[string]interface{}{ - utils.Tenant: "Unexist", - utils.ToR: utils.MetaVoice, - utils.OriginID: "testSSv1ItInitiateSessionNotFoundCharger", - utils.RequestType: sSV1RequestType, - utils.AccountField: "1001", - utils.Subject: "ANY2CNT", - utils.Destination: "1002", - utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), - utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), - utils.Usage: initUsage, - }, + CGREvent: &utils.CGREvent{ + Tenant: "Unexist", + ID: "testSSv1ItInitiateSessionNotFoundCharger", + Event: map[string]interface{}{ + utils.Tenant: "Unexist", + utils.ToR: utils.MetaVoice, + utils.OriginID: "testSSv1ItInitiateSessionNotFoundCharger", + utils.RequestType: sSV1RequestType, + utils.AccountField: "1001", + utils.Subject: "ANY2CNT", + utils.Destination: "1002", + utils.SetupTime: time.Date(2018, time.January, 7, 16, 60, 0, 0, time.UTC), + utils.AnswerTime: time.Date(2018, time.January, 7, 16, 60, 10, 0, time.UTC), + utils.Usage: initUsage, }, }, } diff --git a/apier/v1/stats_it_test.go b/apier/v1/stats_it_test.go index 466aa0a1a..b618d4990 100644 --- a/apier/v1/stats_it_test.go +++ b/apier/v1/stats_it_test.go @@ -246,17 +246,15 @@ func testV1STSProcessEvent(t *testing.T) { var reply []string expected := []string{"Stats1"} args := engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - utils.AccountField: "1001", - utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: 135 * time.Second, - utils.Cost: 123.0, - utils.PDD: 12 * time.Second, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + utils.AccountField: "1001", + utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), + utils.Usage: 135 * time.Second, + utils.Cost: 123.0, + utils.PDD: 12 * time.Second, }, }, } @@ -304,16 +302,14 @@ func testV1STSProcessEvent(t *testing.T) { } args2 := engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event2", - Event: map[string]interface{}{ - utils.AccountField: "1002", - utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: 45 * time.Second, - utils.Cost: 12.1, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event2", + Event: map[string]interface{}{ + utils.AccountField: "1002", + utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), + utils.Usage: 45 * time.Second, + utils.Cost: 12.1, }, }, } @@ -323,16 +319,14 @@ func testV1STSProcessEvent(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", expected, reply) } args3 := engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event3", - Event: map[string]interface{}{ - utils.AccountField: "1002", - utils.SetupTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: 0, - utils.Cost: 0, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event3", + Event: map[string]interface{}{ + utils.AccountField: "1002", + utils.SetupTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), + utils.Usage: 0, + utils.Cost: 0, }, }, } @@ -640,15 +634,13 @@ func testV1STSProcessMetricsWithFilter(t *testing.T) { var reply2 []string expected := []string{"CustomStatProfile"} args := engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - "DistinctVal": "RandomVal", - utils.Usage: 6 * time.Second, - "CustomValue": 7.0, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + "DistinctVal": "RandomVal", + utils.Usage: 6 * time.Second, + "CustomValue": 7.0, }, }, } @@ -672,15 +664,13 @@ func testV1STSProcessMetricsWithFilter(t *testing.T) { } //second process args = engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event2", - Event: map[string]interface{}{ - "DistinctVal": "RandomVal", - utils.Usage: 12 * time.Second, - "CustomValue": 10.0, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event2", + Event: map[string]interface{}{ + "DistinctVal": "RandomVal", + utils.Usage: 12 * time.Second, + "CustomValue": 10.0, }, }, } @@ -755,13 +745,11 @@ func testV1STSProcessStaticMetrics(t *testing.T) { var reply2 []string expected := []string{"StaticStatQueue"} args := engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - "StaticMetrics": "StaticMetrics", - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + "StaticMetrics": "StaticMetrics", }, }, } @@ -884,14 +872,12 @@ func testV1STSProcessStatWithThreshold(t *testing.T) { var reply2 []string expected := []string{"StatWithThreshold"} args := engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - "CustomEvent": "CustomEvent", - utils.Usage: 45 * time.Second, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + "CustomEvent": "CustomEvent", + utils.Usage: 45 * time.Second, }, }, } @@ -1010,9 +996,7 @@ func testV1STSProcessCDRStat(t *testing.T) { var reply2 []string expected := []string{"StatForCDR"} args := engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: cdr.AsCGREvent(), - }, + CGREvent: cdr.AsCGREvent(), } if err := stsV1Rpc.Call(utils.StatSv1ProcessEvent, &args, &reply2); err != nil { t.Error(err) @@ -1195,14 +1179,12 @@ func testV1STSProcessStatWithThreshold2(t *testing.T) { var reply2 []string expected := []string{"StatWithThreshold2"} args := engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - "CustomEvent2": "CustomEvent2", - utils.Usage: 45 * time.Second, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + "CustomEvent2": "CustomEvent2", + utils.Usage: 45 * time.Second, }, }, } @@ -1355,17 +1337,15 @@ func testV1STSV1GetStatQueuesForEventWithoutTenant(t *testing.T) { estats := []string{"Stats1"} if err := stsV1Rpc.Call(utils.StatSv1GetStatQueuesForEvent, &engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - ID: "GetStats", - Event: map[string]interface{}{ - utils.AccountField: "1002", - utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - utils.Usage: 45 * time.Second, - utils.RunID: utils.MetaDefault, - utils.Cost: 10.0, - utils.Destination: "1001", - }, + CGREvent: &utils.CGREvent{ + ID: "GetStats", + Event: map[string]interface{}{ + utils.AccountField: "1002", + utils.AnswerTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), + utils.Usage: 45 * time.Second, + utils.RunID: utils.MetaDefault, + utils.Cost: 10.0, + utils.Destination: "1001", }, Opts: map[string]interface{}{ utils.OptsAPIKey: "stat12345", @@ -1453,12 +1433,10 @@ func testV1STSSimulateAccountUpdate(t *testing.T) { } acntUpdateEv := &engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ // hitting TH_ACNT_UPDATE_EV - Tenant: "cgrates.org", - ID: "SIMULATE_ACNT_UPDATE_EV", - Event: acnt.AsAccountSummary().AsMapInterface(), - }, + CGREvent: &utils.CGREvent{ // hitting TH_ACNT_UPDATE_EV + Tenant: "cgrates.org", + ID: "SIMULATE_ACNT_UPDATE_EV", + Event: acnt.AsAccountSummary().AsMapInterface(), Opts: map[string]interface{}{ utils.MetaEventType: utils.AccountUpdate, }, @@ -1538,14 +1516,12 @@ func testV1STSGetStatQueueWithoutExpired(t *testing.T) { var reply2 []string expected := []string{"Sq1Nanao"} args := engine.StatsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "event1012", - Event: map[string]interface{}{ - "StatQ": "Sq1Nanao", - utils.Usage: 10, - }, + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "event1012", + Event: map[string]interface{}{ + "StatQ": "Sq1Nanao", + utils.Usage: 10, }, }, } diff --git a/apier/v1/thresholds_it_test.go b/apier/v1/thresholds_it_test.go index d2140c8f3..85cf51655 100644 --- a/apier/v1/thresholds_it_test.go +++ b/apier/v1/thresholds_it_test.go @@ -41,34 +41,30 @@ var ( tEvs = []*engine.ThresholdsArgsProcessEvent{ { - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ // hitting THD_ACNT_BALANCE_1 - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - utils.EventType: utils.AccountUpdate, - utils.AccountField: "1002", - utils.AllowNegative: true, - utils.Disabled: false, - utils.Units: 12.3}, - }, + CGREvent: &utils.CGREvent{ // hitting THD_ACNT_BALANCE_1 + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + utils.EventType: utils.AccountUpdate, + utils.AccountField: "1002", + utils.AllowNegative: true, + utils.Disabled: false, + utils.Units: 12.3}, Opts: map[string]interface{}{ utils.MetaEventType: utils.AccountUpdate, }, }, }, { - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ // hitting THD_ACNT_BALANCE_1 - Tenant: "cgrates.org", - ID: "event2", - Event: map[string]interface{}{ - utils.EventType: utils.BalanceUpdate, - utils.AccountField: "1002", - utils.BalanceID: utils.MetaDefault, - utils.Units: 12.3, - utils.ExpiryTime: time.Date(2009, 11, 10, 23, 00, 0, 0, time.UTC), - }, + CGREvent: &utils.CGREvent{ // hitting THD_ACNT_BALANCE_1 + Tenant: "cgrates.org", + ID: "event2", + Event: map[string]interface{}{ + utils.EventType: utils.BalanceUpdate, + utils.AccountField: "1002", + utils.BalanceID: utils.MetaDefault, + utils.Units: 12.3, + utils.ExpiryTime: time.Date(2009, 11, 10, 23, 00, 0, 0, time.UTC), }, Opts: map[string]interface{}{ utils.MetaEventType: utils.BalanceUpdate, @@ -76,21 +72,19 @@ var ( }, }, { - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ // hitting THD_STATS_1 - Tenant: "cgrates.org", - ID: "event3", - Event: map[string]interface{}{ - utils.EventType: utils.StatUpdate, - utils.StatID: "Stats1", - utils.AccountField: "1002", - "ASR": 35.0, - "ACD": "2m45s", - "TCC": 12.7, - "TCD": "12m15s", - "ACC": 0.75, - "PDD": "2s", - }, + CGREvent: &utils.CGREvent{ // hitting THD_STATS_1 + Tenant: "cgrates.org", + ID: "event3", + Event: map[string]interface{}{ + utils.EventType: utils.StatUpdate, + utils.StatID: "Stats1", + utils.AccountField: "1002", + "ASR": 35.0, + "ACD": "2m45s", + "TCC": 12.7, + "TCD": "12m15s", + "ACC": 0.75, + "PDD": "2s", }, Opts: map[string]interface{}{ utils.MetaEventType: utils.StatUpdate, @@ -98,18 +92,16 @@ var ( }, }, { - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ // hitting THD_STATS_1 and THD_STATS_2 - Tenant: "cgrates.org", - ID: "event4", - Event: map[string]interface{}{ - utils.EventType: utils.StatUpdate, - utils.StatID: "STATS_HOURLY_DE", - utils.AccountField: "1002", - "ASR": 35.0, - "ACD": "2m45s", - "TCD": "1h", - }, + CGREvent: &utils.CGREvent{ // hitting THD_STATS_1 and THD_STATS_2 + Tenant: "cgrates.org", + ID: "event4", + Event: map[string]interface{}{ + utils.EventType: utils.StatUpdate, + utils.StatID: "STATS_HOURLY_DE", + utils.AccountField: "1002", + "ASR": 35.0, + "ACD": "2m45s", + "TCD": "1h", }, Opts: map[string]interface{}{ utils.MetaEventType: utils.StatUpdate, @@ -117,17 +109,15 @@ var ( }, }, { - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ // hitting THD_STATS_3 - Tenant: "cgrates.org", - ID: "event5", - Event: map[string]interface{}{ - utils.EventType: utils.StatUpdate, - utils.StatID: "STATS_DAILY_DE", - utils.AccountField: "1002", - "ACD": "2m45s", - "TCD": "3h1s", - }, + CGREvent: &utils.CGREvent{ // hitting THD_STATS_3 + Tenant: "cgrates.org", + ID: "event5", + Event: map[string]interface{}{ + utils.EventType: utils.StatUpdate, + utils.StatID: "STATS_DAILY_DE", + utils.AccountField: "1002", + "ACD": "2m45s", + "TCD": "3h1s", }, Opts: map[string]interface{}{ utils.MetaEventType: utils.StatUpdate, @@ -135,16 +125,14 @@ var ( }, }, { - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ // hitting THD_RES_1 - Tenant: "cgrates.org", - ID: "event6", - Event: map[string]interface{}{ - utils.EventType: utils.ResourceUpdate, - utils.AccountField: "1002", - utils.ResourceID: "RES_GRP_1", - utils.Usage: 10.0, - }, + CGREvent: &utils.CGREvent{ // hitting THD_RES_1 + Tenant: "cgrates.org", + ID: "event6", + Event: map[string]interface{}{ + utils.EventType: utils.ResourceUpdate, + utils.AccountField: "1002", + utils.ResourceID: "RES_GRP_1", + utils.Usage: 10.0, }, Opts: map[string]interface{}{ utils.MetaEventType: utils.ResourceUpdate, @@ -152,16 +140,14 @@ var ( }, }, { - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ // hitting THD_RES_1 - Tenant: "cgrates.org", - ID: "event6", - Event: map[string]interface{}{ - utils.EventType: utils.ResourceUpdate, - utils.AccountField: "1002", - utils.ResourceID: "RES_GRP_1", - utils.Usage: 10.0, - }, + CGREvent: &utils.CGREvent{ // hitting THD_RES_1 + Tenant: "cgrates.org", + ID: "event6", + Event: map[string]interface{}{ + utils.EventType: utils.ResourceUpdate, + utils.AccountField: "1002", + utils.ResourceID: "RES_GRP_1", + utils.Usage: 10.0, }, Opts: map[string]interface{}{ utils.MetaEventType: utils.ResourceUpdate, @@ -169,16 +155,14 @@ var ( }, }, { - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ // hitting THD_RES_1 - Tenant: "cgrates.org", - ID: "event6", - Event: map[string]interface{}{ - utils.EventType: utils.ResourceUpdate, - utils.AccountField: "1002", - utils.ResourceID: "RES_GRP_1", - utils.Usage: 10.0, - }, + CGREvent: &utils.CGREvent{ // hitting THD_RES_1 + Tenant: "cgrates.org", + ID: "event6", + Event: map[string]interface{}{ + utils.EventType: utils.ResourceUpdate, + utils.AccountField: "1002", + utils.ResourceID: "RES_GRP_1", + utils.Usage: 10.0, }, Opts: map[string]interface{}{ utils.MetaEventType: utils.ResourceUpdate, @@ -186,33 +170,31 @@ var ( }, }, { - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ // hitting THD_CDRS_1 - Tenant: "cgrates.org", - ID: "cdrev1", - Event: map[string]interface{}{ - "field_extr1": "val_extr1", - "fieldextr2": "valextr2", - utils.CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), - utils.RunID: utils.MetaRaw, - utils.OrderID: 123, - utils.OriginHost: "192.168.1.1", - utils.Source: utils.UnitTest, - utils.OriginID: "dsafdsaf", - utils.ToR: utils.MetaVoice, - utils.RequestType: utils.MetaRated, - utils.Tenant: "cgrates.org", - utils.Category: "call", - utils.AccountField: "1007", - utils.Subject: "1007", - utils.Destination: "+4986517174963", - utils.SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), - utils.PDD: 0 * time.Second, - utils.AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), - utils.Usage: 10 * time.Second, - utils.Route: "SUPPL1", - utils.Cost: -1.0, - }, + CGREvent: &utils.CGREvent{ // hitting THD_CDRS_1 + Tenant: "cgrates.org", + ID: "cdrev1", + Event: map[string]interface{}{ + "field_extr1": "val_extr1", + "fieldextr2": "valextr2", + utils.CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), + utils.RunID: utils.MetaRaw, + utils.OrderID: 123, + utils.OriginHost: "192.168.1.1", + utils.Source: utils.UnitTest, + utils.OriginID: "dsafdsaf", + utils.ToR: utils.MetaVoice, + utils.RequestType: utils.MetaRated, + utils.Tenant: "cgrates.org", + utils.Category: "call", + utils.AccountField: "1007", + utils.Subject: "1007", + utils.Destination: "+4986517174963", + utils.SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), + utils.PDD: 0 * time.Second, + utils.AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), + utils.Usage: 10 * time.Second, + utils.Route: "SUPPL1", + utils.Cost: -1.0, }, Opts: map[string]interface{}{ utils.MetaEventType: utils.CDR, @@ -586,13 +568,11 @@ func testV1TSMaxHits(t *testing.T) { var ids []string eIDs := []string{"TH3"} thEvent := &engine.ThresholdsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ // hitting TH3 - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - utils.AccountField: "1002", - }, + CGREvent: &utils.CGREvent{ // hitting TH3 + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + utils.AccountField: "1002", }, }, } @@ -696,13 +676,11 @@ func testV1TSUpdateSnooze(t *testing.T) { eIDs := []string{"TH4"} thEvent := &engine.ThresholdsArgsProcessEvent{ ThresholdIDs: []string{"TH4"}, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ // hitting TH4 - Tenant: "cgrates.org", - ID: "event1", - Event: map[string]interface{}{ - "CustomEv": "SnoozeEv", - }, + CGREvent: &utils.CGREvent{ // hitting TH4 + Tenant: "cgrates.org", + ID: "event1", + Event: map[string]interface{}{ + "CustomEv": "SnoozeEv", }, }, } @@ -832,12 +810,10 @@ func testV1TSProcessEventWithoutTenant(t *testing.T) { eIDs := []string{"TH4"} thEvent := &engine.ThresholdsArgsProcessEvent{ ThresholdIDs: []string{"TH4"}, - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ // hitting TH4 - ID: "event1", - Event: map[string]interface{}{ - "CustomEv": "SnoozeEv", - }, + CGREvent: &utils.CGREvent{ // hitting TH4 + ID: "event1", + Event: map[string]interface{}{ + "CustomEv": "SnoozeEv", }, }, } @@ -924,12 +900,10 @@ func testV1TSProcessAccountUpdateEvent(t *testing.T) { } acntUpdateEv := &engine.ThresholdsArgsProcessEvent{ - CGREventWithOpts: &utils.CGREventWithOpts{ - CGREvent: &utils.CGREvent{ // hitting TH_ACNT_UPDATE_EV - Tenant: "cgrates.org", - ID: "SIMULATE_ACNT_UPDATE_EV", - Event: acnt.AsAccountSummary().AsMapInterface(), - }, + CGREvent: &utils.CGREvent{ // hitting TH_ACNT_UPDATE_EV + Tenant: "cgrates.org", + ID: "SIMULATE_ACNT_UPDATE_EV", + Event: acnt.AsAccountSummary().AsMapInterface(), Opts: map[string]interface{}{ utils.MetaEventType: utils.AccountUpdate, }, diff --git a/engine/actions_test.go b/engine/actions_test.go index a1993f7d7..01882381b 100644 --- a/engine/actions_test.go +++ b/engine/actions_test.go @@ -2698,6 +2698,7 @@ func TestCdrLogAction(t *testing.T) { "ToR": "*monetary", "Usage": mock.args.CGREvent.Event["Usage"], }, + Opts: map[string]interface{}{}, } if !reflect.DeepEqual(expCgrEv, mock.args.CGREvent) { t.Errorf("Expected: %+v \n,received: %+v", expCgrEv, mock.args.CGREvent) diff --git a/engine/cdr.go b/engine/cdr.go index e9689beec..a40678812 100644 --- a/engine/cdr.go +++ b/engine/cdr.go @@ -448,6 +448,7 @@ func (cdr *CDR) AsCGREvent() *utils.CGREvent { Tenant: cdr.Tenant, ID: utils.UUIDSha1Prefix(), Event: cdr.AsMapStringIface(), + Opts: map[string]interface{}{}, } } diff --git a/engine/chargers.go b/engine/chargers.go index ee8f59023..1cfef1a69 100644 --- a/engine/chargers.go +++ b/engine/chargers.go @@ -108,11 +108,6 @@ type ChrgSProcessEventReply struct { func (cS *ChargerService) processEvent(tnt string, cgrEv *utils.CGREvent) (rply []*ChrgSProcessEventReply, err error) { var cPs ChargerProfiles - cgrEv.Opts = MapEvent(cgrEv.Opts).Clone() - if cgrEv.Opts == nil { - cgrEv.Opts = make(map[string]interface{}) - } - cgrEv.Opts[utils.Subsys] = utils.MetaChargers var processRuns *int if val, has := cgrEv.Opts[utils.OptsAttributesProcessRuns]; has { if v, err := utils.IfaceAsTInt64(val); err == nil { @@ -127,6 +122,7 @@ func (cS *ChargerService) processEvent(tnt string, cgrEv *utils.CGREvent) (rply clonedEv := cgrEv.Clone() clonedEv.Tenant = tnt clonedEv.Event[utils.RunID] = cP.RunID + clonedEv.Opts[utils.Subsys] = utils.MetaChargers rply[i] = &ChrgSProcessEventReply{ ChargerSProfile: cP.ID, CGREvent: clonedEv, diff --git a/engine/z_attributes_test.go b/engine/z_attributes_test.go index 1415e09d1..cd51c6031 100644 --- a/engine/z_attributes_test.go +++ b/engine/z_attributes_test.go @@ -1989,6 +1989,7 @@ func TestProcessAttributeVariable(t *testing.T) { "RandomField": "Val2", utils.Weight: "20.0", }, + Opts: map[string]interface{}{}, }, } eNM := utils.MapStorage{ @@ -2055,6 +2056,7 @@ func TestProcessAttributeComposed(t *testing.T) { "RandomField2": "Concatenated", utils.Weight: "20.0", }, + Opts: map[string]interface{}{}, }, } eNM := utils.MapStorage{ @@ -2116,6 +2118,7 @@ func TestProcessAttributeUsageDifference(t *testing.T) { "RandomField2": "1514804400", utils.Weight: "20.0", }, + Opts: map[string]interface{}{}, }, } eNM := utils.MapStorage{ @@ -2177,6 +2180,7 @@ func TestProcessAttributeSum(t *testing.T) { "RandomField2": "5", utils.Weight: "20.0", }, + Opts: map[string]interface{}{}, }, } eNM := utils.MapStorage{ @@ -2238,6 +2242,7 @@ func TestProcessAttributeDiff(t *testing.T) { "RandomField2": "5", utils.Weight: "20.0", }, + Opts: map[string]interface{}{}, }, } eNM := utils.MapStorage{ @@ -2299,6 +2304,7 @@ func TestProcessAttributeMultiply(t *testing.T) { "RandomField2": "5", utils.Weight: "20.0", }, + Opts: map[string]interface{}{}, }, } eNM := utils.MapStorage{ @@ -2360,6 +2366,7 @@ func TestProcessAttributeDivide(t *testing.T) { "RandomField2": "5", utils.Weight: "20.0", }, + Opts: map[string]interface{}{}, }, } eNM := utils.MapStorage{ @@ -2421,6 +2428,7 @@ func TestProcessAttributeValueExponent(t *testing.T) { "RandomField2": "5", utils.Weight: "20.0", }, + Opts: map[string]interface{}{}, }, } eNM := utils.MapStorage{ @@ -2482,6 +2490,7 @@ func TestProcessAttributeUnixTimeStamp(t *testing.T) { "RandomField2": "2013-12-30T15:00:01Z", utils.Weight: "20.0", }, + Opts: map[string]interface{}{}, }, } eNM := utils.MapStorage{ @@ -2542,6 +2551,7 @@ func TestProcessAttributePrefix(t *testing.T) { "Field2": "Val2", utils.Weight: "20.0", }, + Opts: map[string]interface{}{}, }, } eNM := utils.MapStorage{ @@ -2602,6 +2612,7 @@ func TestProcessAttributeSuffix(t *testing.T) { "Field2": "Val2", utils.Weight: "20.0", }, + Opts: map[string]interface{}{}, }, } eNM := utils.MapStorage{ diff --git a/utils/cgrevent.go b/utils/cgrevent.go index ffa640a18..928c817e1 100644 --- a/utils/cgrevent.go +++ b/utils/cgrevent.go @@ -131,6 +131,7 @@ func (ev *CGREvent) Clone() (clned *CGREvent) { Tenant: ev.Tenant, ID: ev.ID, Event: make(map[string]interface{}), // a bit forced but safe + Opts: make(map[string]interface{}), } if ev.Time != nil { clned.Time = TimePointer(*ev.Time) @@ -139,7 +140,6 @@ func (ev *CGREvent) Clone() (clned *CGREvent) { clned.Event[k] = v } if ev.Opts != nil { - clned.Opts = make(map[string]interface{}) for opt, val := range ev.Opts { clned.Opts[opt] = val }