From d683ab48fbb47671d792eb361cd23d1328caa1e9 Mon Sep 17 00:00:00 2001 From: TeoV Date: Wed, 29 Apr 2020 17:59:41 +0300 Subject: [PATCH] Update unit tests after renaming --- agents/asterisk_event_test.go | 4 +- agents/fsevent_test.go | 22 +- agents/kamevent_test.go | 20 +- apier/v1/api_interfaces.go | 2 +- apier/v1/api_interfaces_test.go | 6 +- apier/v1/dispatcher.go | 10 +- config/config_json_test.go | 56 ++--- config/config_test.go | 58 ++--- config/configsanity_test.go | 42 ++-- config/routescfg_test.go | 8 +- config/sessionscfg_test.go | 4 +- engine/libroutes_test.go | 398 +++++++++++++++--------------- engine/libtest.go | 4 +- engine/loader_csv_test.go | 40 +-- engine/routes.go | 4 +- engine/routes_test.go | 422 ++++++++++++++++---------------- loaders/loader_test.go | 78 +++--- sessions/sessions_test.go | 274 ++++++++++----------- utils/apitpdata_test.go | 2 +- utils/cgrevent_test.go | 8 +- 20 files changed, 731 insertions(+), 731 deletions(-) diff --git a/agents/asterisk_event_test.go b/agents/asterisk_event_test.go index 8ed116320..deded5748 100644 --- a/agents/asterisk_event_test.go +++ b/agents/asterisk_event_test.go @@ -349,7 +349,7 @@ func TestSMAEventV1AuthorizeArgs(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", exp.GetMaxUsage, rcv.GetMaxUsage) } - stasisStart2 := `{"type":"StasisStart","timestamp":"2018-11-25T05:03:26.464-0500","args":["cgr_reqtype=*prepaid","cgr_supplier=supplier1","cgr_flags=*accounts,*attributes,*resources,*stats,*suppliers,*thresholds"],"channel":{"id":"1543140206.0","dialplan":{"context":"internal","exten":"1002","priority":4},"caller":{"name":"","number":"1001"},"name":"PJSIP/1001-00000000","state":"Ring","connected":{"name":"","number":""},"language":"en","accountcode":"","creationtime":"2018-11-25T05:03:26.463-0500"},"asterisk_id":"08:00:27:b7:b8:1f","application":"cgrates_auth"}` + stasisStart2 := `{"type":"StasisStart","timestamp":"2018-11-25T05:03:26.464-0500","args":["cgr_reqtype=*prepaid","cgr_route=route1","cgr_flags=*accounts,*attributes,*resources,*stats,*routes,*thresholds"],"channel":{"id":"1543140206.0","dialplan":{"context":"internal","exten":"1002","priority":4},"caller":{"name":"","number":"1001"},"name":"PJSIP/1001-00000000","state":"Ring","connected":{"name":"","number":""},"language":"en","accountcode":"","creationtime":"2018-11-25T05:03:26.463-0500"},"asterisk_id":"08:00:27:b7:b8:1f","application":"cgrates_auth"}` var ev2 map[string]interface{} if err := json.Unmarshal([]byte(stasisStart2), &ev2); err != nil { t.Error(err) @@ -367,7 +367,7 @@ func TestSMAEventV1AuthorizeArgs(t *testing.T) { GetMaxUsage: true, ProcessThresholds: true, ProcessStats: true, - GetSuppliers: true, + GetRoutes: true, CGREvent: cgrEv2, } if rcv := smaEv2.V1AuthorizeArgs(); !reflect.DeepEqual(exp2.GetAttributes, rcv.GetAttributes) { diff --git a/agents/fsevent_test.go b/agents/fsevent_test.go index 9684ba45c..d96f84aa4 100644 --- a/agents/fsevent_test.go +++ b/agents/fsevent_test.go @@ -330,7 +330,7 @@ variable_rtp_audio_out_dtmf_packet_count: 0 variable_rtp_audio_out_cng_packet_count: 0 variable_rtp_audio_rtcp_packet_count: 1450 variable_rtp_audio_rtcp_octet_count: 45940 -variable_cgr_flags: *resources,*attributes,*sessions,*suppliers,*suppliers_event_cost,*suppliers_ignore_errors,*accounts` +variable_cgr_flags: *resources,*attributes,*sessions,*routes,*routes_event_cost,*routes_ignore_errors,*accounts` func TestEventCreation(t *testing.T) { body := `Event-Name: RE_SCHEDULE @@ -981,10 +981,10 @@ func TestFsEvV1AuthorizeArgs(t *testing.T) { Time: &sTime, Event: ev.AsMapStringInterface(timezone), }, - GetSuppliers: true, - GetAttributes: true, - SuppliersIgnoreErrors: true, - SuppliersMaxCost: utils.MetaEventCost, + GetRoutes: true, + GetAttributes: true, + RoutesIgnoreErrors: true, + RoutesMaxCost: utils.MetaEventCost, } expected.Event[utils.Usage] = config.CgrConfig().SessionSCfg().MaxCallDuration rcv := ev.V1AuthorizeArgs() @@ -998,14 +998,14 @@ func TestFsEvV1AuthorizeArgs(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", expected.CGREvent.Event, rcv.CGREvent.Event) } else if !reflect.DeepEqual(expected.GetMaxUsage, rcv.GetMaxUsage) { t.Errorf("Expecting: %+v, received: %+v", expected.GetMaxUsage, rcv.GetMaxUsage) - } else if !reflect.DeepEqual(expected.GetSuppliers, rcv.GetSuppliers) { - t.Errorf("Expecting: %+v, received: %+v", expected.GetSuppliers, rcv.GetSuppliers) + } else if !reflect.DeepEqual(expected.GetRoutes, rcv.GetRoutes) { + t.Errorf("Expecting: %+v, received: %+v", expected.GetRoutes, rcv.GetRoutes) } else if !reflect.DeepEqual(expected.GetAttributes, rcv.GetAttributes) { t.Errorf("Expecting: %+v, received: %+v", expected.GetAttributes, rcv.GetAttributes) - } else if !reflect.DeepEqual(expected.SuppliersMaxCost, rcv.SuppliersMaxCost) { - t.Errorf("Expecting: %+v, received: %+v", expected.SuppliersMaxCost, rcv.SuppliersMaxCost) - } else if !reflect.DeepEqual(expected.SuppliersIgnoreErrors, rcv.SuppliersIgnoreErrors) { - t.Errorf("Expecting: %+v, received: %+v", expected.SuppliersIgnoreErrors, rcv.SuppliersIgnoreErrors) + } else if !reflect.DeepEqual(expected.RoutesMaxCost, rcv.RoutesMaxCost) { + t.Errorf("Expecting: %+v, received: %+v", expected.RoutesMaxCost, rcv.RoutesMaxCost) + } else if !reflect.DeepEqual(expected.RoutesIgnoreErrors, rcv.RoutesIgnoreErrors) { + t.Errorf("Expecting: %+v, received: %+v", expected.RoutesIgnoreErrors, rcv.RoutesIgnoreErrors) } } diff --git a/agents/kamevent_test.go b/agents/kamevent_test.go index 9cf8deb18..2b178dd91 100644 --- a/agents/kamevent_test.go +++ b/agents/kamevent_test.go @@ -151,7 +151,7 @@ func TestKamEvV1AuthorizeArgs(t *testing.T) { "cgr_duration": "3", "cgr_pdd": "4", utils.CGR_SUPPLIER: "supplier2", utils.CGR_DISCONNECT_CAUSE: "200", - utils.CGRFlags: "*accounts,*suppliers,*suppliers_event_cost,*suppliers_ignore_errors"} + utils.CGRFlags: "*accounts,*routes,*routes_event_cost,*routes_ignore_errors"} sTime, err := utils.ParseTimeDetectLayout(kamEv[utils.AnswerTime], timezone) if err != nil { return @@ -165,9 +165,9 @@ func TestKamEvV1AuthorizeArgs(t *testing.T) { Time: &sTime, Event: kamEv.AsMapStringInterface(), }, - GetSuppliers: true, - SuppliersIgnoreErrors: true, - SuppliersMaxCost: utils.MetaEventCost, + GetRoutes: true, + RoutesIgnoreErrors: true, + RoutesMaxCost: utils.MetaEventCost, } rcv := kamEv.V1AuthorizeArgs() if !reflect.DeepEqual(expected.CGREvent.Tenant, rcv.CGREvent.Tenant) { @@ -180,14 +180,14 @@ func TestKamEvV1AuthorizeArgs(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", expected.CGREvent.Event, rcv.CGREvent.Event) } else if !reflect.DeepEqual(expected.GetMaxUsage, rcv.GetMaxUsage) { t.Errorf("Expecting: %+v, received: %+v", expected.GetMaxUsage, rcv.GetMaxUsage) - } else if !reflect.DeepEqual(expected.GetSuppliers, rcv.GetSuppliers) { - t.Errorf("Expecting: %+v, received: %+v", expected.GetSuppliers, rcv.GetSuppliers) + } else if !reflect.DeepEqual(expected.GetRoutes, rcv.GetRoutes) { + t.Errorf("Expecting: %+v, received: %+v", expected.GetRoutes, rcv.GetRoutes) } else if !reflect.DeepEqual(expected.GetAttributes, rcv.GetAttributes) { t.Errorf("Expecting: %+v, received: %+v", expected.GetAttributes, rcv.GetAttributes) - } else if !reflect.DeepEqual(expected.SuppliersMaxCost, rcv.SuppliersMaxCost) { - t.Errorf("Expecting: %+v, received: %+v", expected.SuppliersMaxCost, rcv.SuppliersMaxCost) - } else if !reflect.DeepEqual(expected.SuppliersIgnoreErrors, rcv.SuppliersIgnoreErrors) { - t.Errorf("Expecting: %+v, received: %+v", expected.SuppliersIgnoreErrors, rcv.SuppliersIgnoreErrors) + } else if !reflect.DeepEqual(expected.RoutesMaxCost, rcv.RoutesMaxCost) { + t.Errorf("Expecting: %+v, received: %+v", expected.RoutesMaxCost, rcv.RoutesMaxCost) + } else if !reflect.DeepEqual(expected.RoutesIgnoreErrors, rcv.RoutesIgnoreErrors) { + t.Errorf("Expecting: %+v, received: %+v", expected.RoutesIgnoreErrors, rcv.RoutesIgnoreErrors) } } diff --git a/apier/v1/api_interfaces.go b/apier/v1/api_interfaces.go index 6aece4e13..38cf728cc 100644 --- a/apier/v1/api_interfaces.go +++ b/apier/v1/api_interfaces.go @@ -248,7 +248,7 @@ type ReplicatorSv1Interface interface { RemAccountActionPlans(args *engine.RemAccountActionPlansArgsWithArgDispatcher, reply *string) error RemoveRatingPlan(id *utils.StringWithApiKey, reply *string) error RemoveRatingProfile(id *utils.StringWithApiKey, reply *string) error - RemoveSupplierProfile(args *utils.TenantIDWithArgDispatcher, reply *string) error + RemoveRouteProfile(args *utils.TenantIDWithArgDispatcher, reply *string) error RemoveAttributeProfile(args *utils.TenantIDWithArgDispatcher, reply *string) error RemoveChargerProfile(args *utils.TenantIDWithArgDispatcher, reply *string) error RemoveDispatcherProfile(args *utils.TenantIDWithArgDispatcher, reply *string) error diff --git a/apier/v1/api_interfaces_test.go b/apier/v1/api_interfaces_test.go index 40c2b57be..bd0fcd1d4 100644 --- a/apier/v1/api_interfaces_test.go +++ b/apier/v1/api_interfaces_test.go @@ -39,9 +39,9 @@ func TestResourceSv1Interface(t *testing.T) { _ = ResourceSv1Interface(NewResourceSv1(nil)) } -func TestSupplierSv1Interface(t *testing.T) { - _ = SupplierSv1Interface(NewDispatcherSupplierSv1(nil)) - _ = SupplierSv1Interface(NewSupplierSv1(nil)) +func TestRouteSv1Interface(t *testing.T) { + _ = RouteSv1Interface(NewDispatcherRouteSv1(nil)) + _ = RouteSv1Interface(NewRouteSv1(nil)) } func TestAttributeSv1Interface(t *testing.T) { diff --git a/apier/v1/dispatcher.go b/apier/v1/dispatcher.go index e06539127..e0604ac52 100755 --- a/apier/v1/dispatcher.go +++ b/apier/v1/dispatcher.go @@ -331,19 +331,19 @@ type DispatcherRouteSv1 struct { dRoute *dispatchers.DispatcherService } -// Ping implements SupplierSv1Ping +// Ping implements RouteSv1Ping func (dRoute *DispatcherRouteSv1) Ping(args *utils.CGREventWithArgDispatcher, reply *string) error { return dRoute.dRoute.RouteSv1Ping(args, reply) } -// GetSuppliers implements SupplierSv1GetSuppliers -func (dRoute *DispatcherRouteSv1) GetSuppliers(args *engine.ArgsGetRoutes, +// GetRoutes implements RouteSv1GetRoutes +func (dRoute *DispatcherRouteSv1) GetRoutes(args *engine.ArgsGetRoutes, reply *engine.SortedRoutes) error { return dRoute.dRoute.RouteSv1GetRoutes(args, reply) } -// GetSuppliersProfiles returns a list of suppliers profiles that match for Event -func (dRoute *DispatcherRouteSv1) GetSupplierProfilesForEvent(args *utils.CGREventWithArgDispatcher, +// GetRouteProfilesForEvent returns a list of route profiles that match for Event +func (dRoute *DispatcherRouteSv1) GetRouteProfilesForEvent(args *utils.CGREventWithArgDispatcher, reply *[]*engine.RouteProfile) error { return dRoute.dRoute.RouteSv1GetRouteProfilesForEvent(args, reply) } diff --git a/config/config_json_test.go b/config/config_json_test.go index 5e1dee05d..5665bc89c 100755 --- a/config/config_json_test.go +++ b/config/config_json_test.go @@ -127,7 +127,7 @@ func TestCacheJsonCfg(t *testing.T) { utils.CacheFilters: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false), Precache: utils.BoolPointer(false), Replicate: utils.BoolPointer(false)}, - utils.CacheSupplierProfiles: {Limit: utils.IntPointer(-1), + utils.CacheRouteProfiles: &CacheParamJsonCfg{Limit: utils.IntPointer(-1), Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false), Precache: utils.BoolPointer(false), Replicate: utils.BoolPointer(false)}, utils.CacheAttributeProfiles: {Limit: utils.IntPointer(-1), @@ -151,7 +151,7 @@ func TestCacheJsonCfg(t *testing.T) { utils.CacheThresholdFilterIndexes: {Limit: utils.IntPointer(-1), Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false), Replicate: utils.BoolPointer(false)}, - utils.CacheSupplierFilterIndexes: {Limit: utils.IntPointer(-1), + utils.CacheRouteFilterIndexes: &CacheParamJsonCfg{Limit: utils.IntPointer(-1), Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false), Replicate: utils.BoolPointer(false)}, utils.CacheAttributeFilterIndexes: {Limit: utils.IntPointer(-1), @@ -344,7 +344,7 @@ func TestDfDataDbJsonCfg(t *testing.T) { Ttl: utils.StringPointer(utils.EmptyString), Limit: utils.IntPointer(-1), Static_ttl: utils.BoolPointer(false)}, - utils.MetaSupplierProfiles: &ItemOptJson{ + utils.MetaRouteProfiles: &ItemOptJson{ Replicate: utils.BoolPointer(false), Remote: utils.BoolPointer(false), Ttl: utils.StringPointer(utils.EmptyString), @@ -475,7 +475,7 @@ func TestDfStorDBJsonCfg(t *testing.T) { Ttl: utils.StringPointer(utils.EmptyString), Limit: utils.IntPointer(-1), Static_ttl: utils.BoolPointer(false)}, - utils.TBLTPSuppliers: &ItemOptJson{ + utils.TBLTPRoutes: &ItemOptJson{ Ttl: utils.StringPointer(utils.EmptyString), Limit: utils.IntPointer(-1), Static_ttl: utils.BoolPointer(false)}, @@ -683,7 +683,7 @@ func TestSmgJsonCfg(t *testing.T) { Resources_conns: &[]string{}, Thresholds_conns: &[]string{}, Stats_conns: &[]string{}, - Suppliers_conns: &[]string{}, + Routes_conns: &[]string{}, Attributes_conns: &[]string{}, Replication_conns: &[]string{}, Debit_interval: utils.StringPointer("0s"), @@ -1095,7 +1095,7 @@ func TestDfThresholdSJsonCfg(t *testing.T) { } } -func TestDfSupplierSJsonCfg(t *testing.T) { +func TestDfRouteSJsonCfg(t *testing.T) { eCfg := &RouteSJsonCfg{ Enabled: utils.BoolPointer(false), Indexed_selects: utils.BoolPointer(true), @@ -1379,8 +1379,8 @@ func TestDfLoaderJsonCfg(t *testing.T) { }, }, { - Type: utils.StringPointer(utils.MetaSuppliers), - File_name: utils.StringPointer(utils.SuppliersCsv), + Type: utils.StringPointer(utils.MetaRoutes), + File_name: utils.StringPointer(utils.RoutesCsv), Fields: &[]*FcTemplateJsonCfg{ {Tag: utils.StringPointer(utils.Tenant), Path: utils.StringPointer(utils.Tenant), @@ -1404,44 +1404,44 @@ func TestDfLoaderJsonCfg(t *testing.T) { Path: utils.StringPointer("Sorting"), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~4")}, - {Tag: utils.StringPointer("SortingParamameters"), - Path: utils.StringPointer("SortingParamameters"), + {Tag: utils.StringPointer("SortingParameters"), + Path: utils.StringPointer("SortingParameters"), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~5")}, - {Tag: utils.StringPointer("SupplierID"), - Path: utils.StringPointer("SupplierID"), + {Tag: utils.StringPointer("RouteID"), + Path: utils.StringPointer("RouteID"), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~6")}, - {Tag: utils.StringPointer("SupplierFilterIDs"), - Path: utils.StringPointer("SupplierFilterIDs"), + {Tag: utils.StringPointer("RouteFilterIDs"), + Path: utils.StringPointer("RouteFilterIDs"), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~7")}, - {Tag: utils.StringPointer("SupplierAccountIDs"), - Path: utils.StringPointer("SupplierAccountIDs"), + {Tag: utils.StringPointer("RouteAccountIDs"), + Path: utils.StringPointer("RouteAccountIDs"), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~8")}, - {Tag: utils.StringPointer("SupplierRatingPlanIDs"), - Path: utils.StringPointer("SupplierRatingPlanIDs"), + {Tag: utils.StringPointer("RouteRatingPlanIDs"), + Path: utils.StringPointer("RouteRatingPlanIDs"), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~9")}, - {Tag: utils.StringPointer("SupplierResourceIDs"), - Path: utils.StringPointer("SupplierResourceIDs"), + {Tag: utils.StringPointer("RouteResourceIDs"), + Path: utils.StringPointer("RouteResourceIDs"), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~10")}, - {Tag: utils.StringPointer("SupplierStatIDs"), - Path: utils.StringPointer("SupplierStatIDs"), + {Tag: utils.StringPointer("RouteStatIDs"), + Path: utils.StringPointer("RouteStatIDs"), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~11")}, - {Tag: utils.StringPointer("SupplierWeight"), - Path: utils.StringPointer("SupplierWeight"), + {Tag: utils.StringPointer("RouteWeight"), + Path: utils.StringPointer("RouteWeight"), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~12")}, - {Tag: utils.StringPointer("SupplierBlocker"), - Path: utils.StringPointer("SupplierBlocker"), + {Tag: utils.StringPointer("RouteBlocker"), + Path: utils.StringPointer("RouteBlocker"), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~13")}, - {Tag: utils.StringPointer("SupplierParameters"), - Path: utils.StringPointer("SupplierParameters"), + {Tag: utils.StringPointer("RouteParameters"), + Path: utils.StringPointer("RouteParameters"), Type: utils.StringPointer(utils.MetaVariable), Value: utils.StringPointer("~14")}, {Tag: utils.StringPointer("Weight"), diff --git a/config/config_test.go b/config/config_test.go index 0bc353a4b..b4ff2db50 100755 --- a/config/config_test.go +++ b/config/config_test.go @@ -590,7 +590,7 @@ func TestCgrCfgJSONDefaultsSMGenericCfg(t *testing.T) { ResSConns: []string{}, ThreshSConns: []string{}, StatSConns: []string{}, - SupplSConns: []string{}, + RouteSConns: []string{}, AttrSConns: []string{}, ReplicationConns: []string{}, DebitInterval: 0 * time.Second, @@ -655,7 +655,7 @@ func TestCgrCfgJSONDefaultsCacheCFG(t *testing.T) { TTL: time.Duration(0), StaticTTL: false, Precache: false}, utils.CacheFilters: &CacheParamCfg{Limit: -1, TTL: time.Duration(0), StaticTTL: false, Precache: false}, - utils.CacheSupplierProfiles: &CacheParamCfg{Limit: -1, + utils.CacheRouteProfiles: &CacheParamCfg{Limit: -1, TTL: time.Duration(0), StaticTTL: false, Precache: false}, utils.CacheAttributeProfiles: &CacheParamCfg{Limit: -1, TTL: time.Duration(0), StaticTTL: false, Precache: false}, @@ -671,7 +671,7 @@ func TestCgrCfgJSONDefaultsCacheCFG(t *testing.T) { TTL: time.Duration(0), StaticTTL: false, Precache: false}, utils.CacheThresholdFilterIndexes: &CacheParamCfg{Limit: -1, TTL: time.Duration(0), StaticTTL: false, Precache: false}, - utils.CacheSupplierFilterIndexes: &CacheParamCfg{Limit: -1, + utils.CacheRouteFilterIndexes: &CacheParamCfg{Limit: -1, TTL: time.Duration(0), StaticTTL: false, Precache: false}, utils.CacheAttributeFilterIndexes: &CacheParamCfg{Limit: -1, TTL: time.Duration(0), StaticTTL: false, Precache: false}, @@ -832,8 +832,8 @@ func TestCgrCfgJSONDefaultThresholdSCfg(t *testing.T) { } } -func TestCgrCfgJSONDefaultSupplierSCfg(t *testing.T) { - eSupplSCfg := &SupplierSCfg{ +func TestCgrCfgJSONDefaultRouteSCfg(t *testing.T) { + eSupplSCfg := &RouteSCfg{ Enabled: false, IndexedSelects: true, StringIndexedFields: nil, @@ -844,8 +844,8 @@ func TestCgrCfgJSONDefaultSupplierSCfg(t *testing.T) { ResponderSConns: []string{}, DefaultRatio: 1, } - if !reflect.DeepEqual(eSupplSCfg, cgrCfg.supplierSCfg) { - t.Errorf("received: %+v, expecting: %+v", eSupplSCfg, cgrCfg.supplierSCfg) + if !reflect.DeepEqual(eSupplSCfg, cgrCfg.routeSCfg) { + t.Errorf("received: %+v, expecting: %+v", eSupplSCfg, cgrCfg.routeSCfg) } } @@ -1344,8 +1344,8 @@ func TestCgrLoaderCfgITDefaults(t *testing.T) { }, }, { - Type: utils.MetaSuppliers, - Filename: utils.SuppliersCsv, + Type: utils.MetaRoutes, + Filename: utils.RoutesCsv, Fields: []*FCTemplate{ {Tag: "Tenant", Path: "Tenant", @@ -1374,53 +1374,53 @@ func TestCgrLoaderCfgITDefaults(t *testing.T) { Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~4", true, utils.INFIELD_SEP), Layout: time.RFC3339}, - {Tag: "SortingParamameters", - Path: "SortingParamameters", + {Tag: "SortingParameters", + Path: "SortingParameters", Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~5", true, utils.INFIELD_SEP), Layout: time.RFC3339}, - {Tag: "SupplierID", - Path: "SupplierID", + {Tag: "RouteID", + Path: "RouteID", Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~6", true, utils.INFIELD_SEP), Layout: time.RFC3339}, - {Tag: "SupplierFilterIDs", - Path: "SupplierFilterIDs", + {Tag: "RouteFilterIDs", + Path: "RouteFilterIDs", Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~7", true, utils.INFIELD_SEP), Layout: time.RFC3339}, - {Tag: "SupplierAccountIDs", - Path: "SupplierAccountIDs", + {Tag: "RouteAccountIDs", + Path: "RouteAccountIDs", Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~8", true, utils.INFIELD_SEP), Layout: time.RFC3339}, - {Tag: "SupplierRatingPlanIDs", - Path: "SupplierRatingPlanIDs", + {Tag: "RouteRatingPlanIDs", + Path: "RouteRatingPlanIDs", Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~9", true, utils.INFIELD_SEP), Layout: time.RFC3339}, - {Tag: "SupplierResourceIDs", - Path: "SupplierResourceIDs", + {Tag: "RouteResourceIDs", + Path: "RouteResourceIDs", Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~10", true, utils.INFIELD_SEP), Layout: time.RFC3339}, - {Tag: "SupplierStatIDs", - Path: "SupplierStatIDs", + {Tag: "RouteStatIDs", + Path: "RouteStatIDs", Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~11", true, utils.INFIELD_SEP), Layout: time.RFC3339}, - {Tag: "SupplierWeight", - Path: "SupplierWeight", + {Tag: "RouteWeight", + Path: "RouteWeight", Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~12", true, utils.INFIELD_SEP), Layout: time.RFC3339}, - {Tag: "SupplierBlocker", - Path: "SupplierBlocker", + {Tag: "RouteBlocker", + Path: "RouteBlocker", Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~13", true, utils.INFIELD_SEP), Layout: time.RFC3339}, - {Tag: "SupplierParameters", - Path: "SupplierParameters", + {Tag: "RouteParameters", + Path: "RouteParameters", Type: utils.MetaVariable, Value: NewRSRParsersMustCompile("~14", true, utils.INFIELD_SEP), Layout: time.RFC3339}, diff --git a/config/configsanity_test.go b/config/configsanity_test.go index 661cae382..62ba04514 100644 --- a/config/configsanity_test.go +++ b/config/configsanity_test.go @@ -263,18 +263,18 @@ func TestConfigSanitySessionS(t *testing.T) { cfg.sessionSCfg.StatSConns = []string{} cfg.statsCfg.Enabled = true - cfg.sessionSCfg.SupplSConns = []string{utils.MetaInternal} - expected = " not enabled but requested by component." + cfg.sessionSCfg.RouteSConns = []string{utils.MetaInternal} + expected = " not enabled but requested by component." if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected { t.Errorf("Expecting: %+q received: %+q", expected, err) } - cfg.sessionSCfg.SupplSConns = []string{"test"} + cfg.sessionSCfg.RouteSConns = []string{"test"} expected = " connection with id: not defined" if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected { t.Errorf("Expecting: %+q received: %+q", expected, err) } - cfg.sessionSCfg.SupplSConns = []string{} - cfg.supplierSCfg.Enabled = true + cfg.sessionSCfg.RouteSConns = []string{} + cfg.routeSCfg.Enabled = true cfg.sessionSCfg.AttrSConns = []string{utils.MetaInternal} expected = " not enabled but requested by component." @@ -561,44 +561,44 @@ func TestConfigSanityStatS(t *testing.T) { } } -func TestConfigSanitySupplierS(t *testing.T) { +func TestConfigSanityRouteS(t *testing.T) { cfg, _ = NewDefaultCGRConfig() - cfg.supplierSCfg.Enabled = true + cfg.routeSCfg.Enabled = true - cfg.supplierSCfg.ResourceSConns = []string{utils.MetaInternal} + cfg.routeSCfg.ResourceSConns = []string{utils.MetaInternal} - expected := " not enabled but requested by component." + expected := " not enabled but requested by component." if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected { t.Errorf("Expecting: %+q received: %+q", expected, err) } - cfg.supplierSCfg.ResourceSConns = []string{"test"} - expected = " connection with id: not defined" + cfg.routeSCfg.ResourceSConns = []string{"test"} + expected = " connection with id: not defined" if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected { t.Errorf("Expecting: %+q received: %+q", expected, err) } - cfg.supplierSCfg.ResourceSConns = []string{utils.MetaInternal} + cfg.routeSCfg.ResourceSConns = []string{utils.MetaInternal} cfg.resourceSCfg.Enabled = true - cfg.supplierSCfg.StatSConns = []string{utils.MetaInternal} - expected = " not enabled but requested by component." + cfg.routeSCfg.StatSConns = []string{utils.MetaInternal} + expected = " not enabled but requested by component." if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected { t.Errorf("Expecting: %+q received: %+q", expected, err) } - cfg.supplierSCfg.StatSConns = []string{"test"} - expected = " connection with id: not defined" + cfg.routeSCfg.StatSConns = []string{"test"} + expected = " connection with id: not defined" if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected { t.Errorf("Expecting: %+q received: %+q", expected, err) } - cfg.supplierSCfg.StatSConns = []string{utils.MetaInternal} + cfg.routeSCfg.StatSConns = []string{utils.MetaInternal} cfg.statsCfg.Enabled = true - cfg.supplierSCfg.AttributeSConns = []string{utils.MetaInternal} - expected = " not enabled but requested by component." + cfg.routeSCfg.AttributeSConns = []string{utils.MetaInternal} + expected = " not enabled but requested by component." if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected { t.Errorf("Expecting: %+q received: %+q", expected, err) } - cfg.supplierSCfg.AttributeSConns = []string{"test"} - expected = " connection with id: not defined" + cfg.routeSCfg.AttributeSConns = []string{"test"} + expected = " connection with id: not defined" if err := cfg.checkConfigSanity(); err == nil || err.Error() != expected { t.Errorf("Expecting: %+q received: %+q", expected, err) } diff --git a/config/routescfg_test.go b/config/routescfg_test.go index 4cde501b7..9ee006a3d 100644 --- a/config/routescfg_test.go +++ b/config/routescfg_test.go @@ -25,7 +25,7 @@ import ( ) func TestSupplierSCfgloadFromJsonCfg(t *testing.T) { - var supscfg, expected SupplierSCfg + var supscfg, expected RouteSCfg if err := supscfg.loadFromJsonCfg(nil); err != nil { t.Error(err) } else if !reflect.DeepEqual(supscfg, expected) { @@ -37,8 +37,8 @@ func TestSupplierSCfgloadFromJsonCfg(t *testing.T) { t.Errorf("Expected: %+v ,recived: %+v", expected, supscfg) } cfgJSONStr := `{ -"suppliers": { // Supplier service (*new) - "enabled": false, // starts SupplierS service: . +"routes": { // Route service + "enabled": false, // starts RouteS service: . //"string_indexed_fields": [], // query indexes based on these fields for faster processing "prefix_indexed_fields": ["index1", "index2"], // query indexes based on these fields for faster processing "attributes_conns": [], // address where to reach the AttributeS <""|127.0.0.1:2013> @@ -47,7 +47,7 @@ func TestSupplierSCfgloadFromJsonCfg(t *testing.T) { "default_ratio":1, }, }` - expected = SupplierSCfg{ + expected = RouteSCfg{ PrefixIndexedFields: &[]string{"index1", "index2"}, AttributeSConns: []string{}, ResourceSConns: []string{}, diff --git a/config/sessionscfg_test.go b/config/sessionscfg_test.go index a13299a0a..a820e08c3 100644 --- a/config/sessionscfg_test.go +++ b/config/sessionscfg_test.go @@ -82,7 +82,7 @@ func TestSessionSCfgloadFromJsonCfg(t *testing.T) { "resources_conns": [], // address where to reach the ResourceS <""|*internal|127.0.0.1:2013> "thresholds_conns": [], // address where to reach the ThresholdS <""|*internal|127.0.0.1:2013> "stats_conns": [], // address where to reach the StatS <""|*internal|127.0.0.1:2013> - "suppliers_conns": [], // address where to reach the SupplierS <""|*internal|127.0.0.1:2013> + "routes_conns": [], // address where to reach the RouteS <""|*internal|127.0.0.1:2013> "attributes_conns": [], // address where to reach the AttributeS <""|*internal|127.0.0.1:2013> "replication_conns": [], // replicate sessions towards these session services "debit_interval": "0s", // interval to perform debits on. @@ -104,7 +104,7 @@ func TestSessionSCfgloadFromJsonCfg(t *testing.T) { ResSConns: []string{}, ThreshSConns: []string{}, StatSConns: []string{}, - SupplSConns: []string{}, + RouteSConns: []string{}, AttrSConns: []string{}, CDRsConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaCDRs)}, ReplicationConns: []string{}, diff --git a/engine/libroutes_test.go b/engine/libroutes_test.go index 55366a2d4..1019f5cde 100644 --- a/engine/libroutes_test.go +++ b/engine/libroutes_test.go @@ -25,60 +25,60 @@ import ( ) func TestLibSuppliersSortCost(t *testing.T) { - sSpls := &SortedSuppliers{ - SortedSuppliers: []*SortedSupplier{ - &SortedSupplier{ - SupplierID: "supplier1", + sSpls := &SortedRoutes{ + SortedRoutes: []*SortedRoute{ + &SortedRoute{ + RouteID: "supplier1", SortingData: map[string]interface{}{ utils.Cost: 0.1, utils.Weight: 10.0, }, - SupplierParameters: "param1", + RouteParameters: "param1", }, - &SortedSupplier{ - SupplierID: "supplier2", + &SortedRoute{ + RouteID: "supplier2", SortingData: map[string]interface{}{ utils.Cost: 0.1, utils.Weight: 20.0, }, - SupplierParameters: "param2", + RouteParameters: "param2", }, - &SortedSupplier{ - SupplierID: "supplier3", + &SortedRoute{ + RouteID: "supplier3", SortingData: map[string]interface{}{ utils.Cost: 0.05, utils.Weight: 10.0, }, - SupplierParameters: "param3", + RouteParameters: "param3", }, }, } sSpls.SortLeastCost() - eOrderedSpls := &SortedSuppliers{ - SortedSuppliers: []*SortedSupplier{ - &SortedSupplier{ - SupplierID: "supplier3", + eOrderedSpls := &SortedRoutes{ + SortedRoutes: []*SortedRoute{ + &SortedRoute{ + RouteID: "supplier3", SortingData: map[string]interface{}{ utils.Cost: 0.05, utils.Weight: 10.0, }, - SupplierParameters: "param3", + RouteParameters: "param3", }, - &SortedSupplier{ - SupplierID: "supplier2", + &SortedRoute{ + RouteID: "supplier2", SortingData: map[string]interface{}{ utils.Cost: 0.1, utils.Weight: 20.0, }, - SupplierParameters: "param2", + RouteParameters: "param2", }, - &SortedSupplier{ - SupplierID: "supplier1", + &SortedRoute{ + RouteID: "supplier1", SortingData: map[string]interface{}{ utils.Cost: 0.1, utils.Weight: 10.0, }, - SupplierParameters: "param1", + RouteParameters: "param1", }, }, } @@ -88,55 +88,55 @@ func TestLibSuppliersSortCost(t *testing.T) { } } -func TestLibSuppliersSortWeight(t *testing.T) { - sSpls := &SortedSuppliers{ - SortedSuppliers: []*SortedSupplier{ - &SortedSupplier{ - SupplierID: "supplier1", +func TestLibRoutesSortWeight(t *testing.T) { + sSpls := &SortedRoutes{ + SortedRoutes: []*SortedRoute{ + &SortedRoute{ + RouteID: "supplier1", SortingData: map[string]interface{}{ utils.Weight: 10.0, }, - SupplierParameters: "param1", + RouteParameters: "param1", }, - &SortedSupplier{ - SupplierID: "supplier2", + &SortedRoute{ + RouteID: "supplier2", SortingData: map[string]interface{}{ utils.Weight: 20.0, }, - SupplierParameters: "param2", + RouteParameters: "param2", }, - &SortedSupplier{ - SupplierID: "supplier3", + &SortedRoute{ + RouteID: "supplier3", SortingData: map[string]interface{}{ utils.Weight: 10.5, }, - SupplierParameters: "param3", + RouteParameters: "param3", }, }, } sSpls.SortWeight() - eOrderedSpls := &SortedSuppliers{ - SortedSuppliers: []*SortedSupplier{ - &SortedSupplier{ - SupplierID: "supplier2", + eOrderedSpls := &SortedRoutes{ + SortedRoutes: []*SortedRoute{ + &SortedRoute{ + RouteID: "supplier2", SortingData: map[string]interface{}{ utils.Weight: 20.0, }, - SupplierParameters: "param2", + RouteParameters: "param2", }, - &SortedSupplier{ - SupplierID: "supplier3", + &SortedRoute{ + RouteID: "supplier3", SortingData: map[string]interface{}{ utils.Weight: 10.5, }, - SupplierParameters: "param3", + RouteParameters: "param3", }, - &SortedSupplier{ - SupplierID: "supplier1", + &SortedRoute{ + RouteID: "supplier1", SortingData: map[string]interface{}{ utils.Weight: 10.0, }, - SupplierParameters: "param1", + RouteParameters: "param1", }, }, } @@ -146,24 +146,24 @@ func TestLibSuppliersSortWeight(t *testing.T) { } } -func TestSortedSuppliersDigest(t *testing.T) { - eSpls := SortedSuppliers{ +func TestSortedRoutesDigest(t *testing.T) { + eSpls := SortedRoutes{ ProfileID: "SPL_WEIGHT_1", Sorting: utils.MetaWeight, - SortedSuppliers: []*SortedSupplier{ - &SortedSupplier{ - SupplierID: "supplier2", + SortedRoutes: []*SortedRoute{ + &SortedRoute{ + RouteID: "supplier2", SortingData: map[string]interface{}{ "Weight": 20.0, }, - SupplierParameters: "param2", + RouteParameters: "param2", }, - &SortedSupplier{ - SupplierID: "supplier1", + &SortedRoute{ + RouteID: "supplier1", SortingData: map[string]interface{}{ "Weight": 10.0, }, - SupplierParameters: "param1", + RouteParameters: "param1", }, }, } @@ -174,24 +174,24 @@ func TestSortedSuppliersDigest(t *testing.T) { } } -func TestSortedSuppliersDigest2(t *testing.T) { - eSpls := SortedSuppliers{ +func TestSortedRoutesDigest2(t *testing.T) { + eSpls := SortedRoutes{ ProfileID: "SPL_WEIGHT_1", Sorting: utils.MetaWeight, - SortedSuppliers: []*SortedSupplier{ - &SortedSupplier{ - SupplierID: "supplier1", + SortedRoutes: []*SortedRoute{ + &SortedRoute{ + RouteID: "supplier1", SortingData: map[string]interface{}{ "Weight": 30.0, }, - SupplierParameters: "param1", + RouteParameters: "param1", }, - &SortedSupplier{ - SupplierID: "supplier2", + &SortedRoute{ + RouteID: "supplier2", SortingData: map[string]interface{}{ "Weight": 20.0, }, - SupplierParameters: "param2", + RouteParameters: "param2", }, }, } @@ -202,11 +202,11 @@ func TestSortedSuppliersDigest2(t *testing.T) { } } -func TestSortedSuppliersDigest3(t *testing.T) { - eSpls := SortedSuppliers{ - ProfileID: "SPL_WEIGHT_1", - Sorting: utils.MetaWeight, - SortedSuppliers: []*SortedSupplier{}, +func TestSortedRoutesDigest3(t *testing.T) { + eSpls := SortedRoutes{ + ProfileID: "SPL_WEIGHT_1", + Sorting: utils.MetaWeight, + SortedRoutes: []*SortedRoute{}, } exp := "" rcv := eSpls.Digest() @@ -215,61 +215,61 @@ func TestSortedSuppliersDigest3(t *testing.T) { } } -func TestLibSuppliersSortHighestCost(t *testing.T) { - sSpls := &SortedSuppliers{ - SortedSuppliers: []*SortedSupplier{ - &SortedSupplier{ - SupplierID: "supplier1", +func TestLibRoutesSortHighestCost(t *testing.T) { + sSpls := &SortedRoutes{ + SortedRoutes: []*SortedRoute{ + &SortedRoute{ + RouteID: "supplier1", SortingData: map[string]interface{}{ utils.Cost: 0.1, utils.Weight: 15.0, }, - SupplierParameters: "param1", + RouteParameters: "param1", }, - &SortedSupplier{ - SupplierID: "supplier2", + &SortedRoute{ + RouteID: "supplier2", SortingData: map[string]interface{}{ utils.Cost: 0.2, utils.Weight: 20.0, }, - SupplierParameters: "param2", + RouteParameters: "param2", }, - &SortedSupplier{ - SupplierID: "supplier3", + &SortedRoute{ + RouteID: "supplier3", SortingData: map[string]interface{}{ utils.Cost: 0.05, utils.Weight: 10.0, }, - SupplierParameters: "param3", + RouteParameters: "param3", }, }, } sSpls.SortHighestCost() - eOrderedSpls := &SortedSuppliers{ - SortedSuppliers: []*SortedSupplier{ - &SortedSupplier{ - SupplierID: "supplier2", + eOrderedSpls := &SortedRoutes{ + SortedRoutes: []*SortedRoute{ + &SortedRoute{ + RouteID: "supplier2", SortingData: map[string]interface{}{ utils.Cost: 0.2, utils.Weight: 20.0, }, - SupplierParameters: "param2", + RouteParameters: "param2", }, - &SortedSupplier{ - SupplierID: "supplier1", + &SortedRoute{ + RouteID: "supplier1", SortingData: map[string]interface{}{ utils.Cost: 0.1, utils.Weight: 15.0, }, - SupplierParameters: "param1", + RouteParameters: "param1", }, - &SortedSupplier{ - SupplierID: "supplier3", + &SortedRoute{ + RouteID: "supplier3", SortingData: map[string]interface{}{ utils.Cost: 0.05, utils.Weight: 10.0, }, - SupplierParameters: "param3", + RouteParameters: "param3", }, }, } @@ -280,12 +280,12 @@ func TestLibSuppliersSortHighestCost(t *testing.T) { } //sort based on *acd and *tcd -func TestLibSuppliersSortQOS(t *testing.T) { - sSpls := &SortedSuppliers{ - SortedSuppliers: []*SortedSupplier{ - &SortedSupplier{ +func TestLibRoutesSortQOS(t *testing.T) { + sSpls := &SortedRoutes{ + SortedRoutes: []*SortedRoute{ + &SortedRoute{ //the average value for supplier1 for *acd is 0.5 , *tcd 1.1 - SupplierID: "supplier1", + RouteID: "supplier1", SortingData: map[string]interface{}{ utils.Cost: 0.5, utils.Weight: 10.0, @@ -293,9 +293,9 @@ func TestLibSuppliersSortQOS(t *testing.T) { utils.MetaTCD: 1.1, }, }, - &SortedSupplier{ + &SortedRoute{ //the average value for supplier2 for *acd is 0.5 , *tcd 4.1 - SupplierID: "supplier2", + RouteID: "supplier2", SortingData: map[string]interface{}{ utils.Cost: 0.1, utils.Weight: 15.0, @@ -303,9 +303,9 @@ func TestLibSuppliersSortQOS(t *testing.T) { utils.MetaTCD: 4.1, }, }, - &SortedSupplier{ + &SortedRoute{ //the average value for supplier3 for *acd is 0.4 , *tcd 5.1 - SupplierID: "supplier3", + RouteID: "supplier3", SortingData: map[string]interface{}{ utils.Cost: 1.1, utils.Weight: 17.8, @@ -318,10 +318,10 @@ func TestLibSuppliersSortQOS(t *testing.T) { //sort base on *acd and *tcd sSpls.SortQOS([]string{utils.MetaACD, utils.MetaTCD}) - rcv := make([]string, len(sSpls.SortedSuppliers)) + rcv := make([]string, len(sSpls.SortedRoutes)) eIds := []string{"supplier2", "supplier1", "supplier3"} - for i, spl := range sSpls.SortedSuppliers { - rcv[i] = spl.SupplierID + for i, spl := range sSpls.SortedRoutes { + rcv[i] = spl.RouteID } if !reflect.DeepEqual(eIds, rcv) { @@ -331,32 +331,32 @@ func TestLibSuppliersSortQOS(t *testing.T) { } //sort based on *acd and *tcd -func TestLibSuppliersSortQOS2(t *testing.T) { - sSpls := &SortedSuppliers{ - SortedSuppliers: []*SortedSupplier{ - &SortedSupplier{ +func TestLibRoutesSortQOS2(t *testing.T) { + sSpls := &SortedRoutes{ + SortedRoutes: []*SortedRoute{ + &SortedRoute{ //the average value for supplier1 for *acd is 0.5 , *tcd 1.1 - SupplierID: "supplier1", + RouteID: "supplier1", SortingData: map[string]interface{}{ utils.Weight: 10.0, utils.MetaACD: 0.5, utils.MetaTCD: 1.1, }, }, - &SortedSupplier{ + &SortedRoute{ //the worst value for supplier1 for *acd is 0.5 , *tcd 1.1 //supplier1 and supplier2 have the same value for *acd and *tcd //will be sorted based on weight - SupplierID: "supplier2", + RouteID: "supplier2", SortingData: map[string]interface{}{ utils.Weight: 17.0, utils.MetaACD: 0.5, utils.MetaTCD: 1.1, }, }, - &SortedSupplier{ + &SortedRoute{ - SupplierID: "supplier3", + RouteID: "supplier3", SortingData: map[string]interface{}{ utils.Cost: 0.5, utils.Weight: 10.0, @@ -367,10 +367,10 @@ func TestLibSuppliersSortQOS2(t *testing.T) { }, } sSpls.SortQOS([]string{utils.MetaACD, utils.MetaTCD}) - rcv := make([]string, len(sSpls.SortedSuppliers)) + rcv := make([]string, len(sSpls.SortedRoutes)) eIds := []string{"supplier3", "supplier2", "supplier1"} - for i, spl := range sSpls.SortedSuppliers { - rcv[i] = spl.SupplierID + for i, spl := range sSpls.SortedRoutes { + rcv[i] = spl.RouteID } if !reflect.DeepEqual(eIds, rcv) { @@ -380,32 +380,32 @@ func TestLibSuppliersSortQOS2(t *testing.T) { } //sort based on *pdd -func TestLibSuppliersSortQOS3(t *testing.T) { - sSpls := &SortedSuppliers{ - SortedSuppliers: []*SortedSupplier{ - &SortedSupplier{ +func TestLibRoutesSortQOS3(t *testing.T) { + sSpls := &SortedRoutes{ + SortedRoutes: []*SortedRoute{ + &SortedRoute{ //the worst value for supplier1 for *pdd is 0.7 , *tcd 1.1 //supplier1 and supplier3 have the same value for *pdd //will be sorted based on weight - SupplierID: "supplier1", + RouteID: "supplier1", SortingData: map[string]interface{}{ utils.Weight: 15.0, utils.MetaPDD: 0.7, utils.MetaTCD: 1.1, }, }, - &SortedSupplier{ + &SortedRoute{ //the worst value for supplier2 for *pdd is 1.2, *tcd 1.1 - SupplierID: "supplier2", + RouteID: "supplier2", SortingData: map[string]interface{}{ utils.Weight: 10.0, utils.MetaPDD: 1.2, utils.MetaTCD: 1.1, }, }, - &SortedSupplier{ + &SortedRoute{ //the worst value for supplier3 for *pdd is 0.7, *tcd 10.1 - SupplierID: "supplier3", + RouteID: "supplier3", SortingData: map[string]interface{}{ utils.Weight: 10.0, utils.MetaPDD: 0.7, @@ -415,10 +415,10 @@ func TestLibSuppliersSortQOS3(t *testing.T) { }, } sSpls.SortQOS([]string{utils.MetaPDD}) - rcv := make([]string, len(sSpls.SortedSuppliers)) + rcv := make([]string, len(sSpls.SortedRoutes)) eIds := []string{"supplier1", "supplier3", "supplier2"} - for i, spl := range sSpls.SortedSuppliers { - rcv[i] = spl.SupplierID + for i, spl := range sSpls.SortedRoutes { + rcv[i] = spl.RouteID } if !reflect.DeepEqual(eIds, rcv) { @@ -427,27 +427,27 @@ func TestLibSuppliersSortQOS3(t *testing.T) { } } -func TestLibSuppliersSortQOS4(t *testing.T) { - sSpls := &SortedSuppliers{ - SortedSuppliers: []*SortedSupplier{ - &SortedSupplier{ - SupplierID: "supplier1", +func TestLibRoutesSortQOS4(t *testing.T) { + sSpls := &SortedRoutes{ + SortedRoutes: []*SortedRoute{ + &SortedRoute{ + RouteID: "supplier1", SortingData: map[string]interface{}{ utils.MetaACD: 0.2, utils.MetaTCD: 15.0, utils.MetaASR: 1.2, }, }, - &SortedSupplier{ - SupplierID: "supplier2", + &SortedRoute{ + RouteID: "supplier2", SortingData: map[string]interface{}{ utils.MetaACD: 0.2, utils.MetaTCD: 20.0, utils.MetaASR: -1.0, }, }, - &SortedSupplier{ - SupplierID: "supplier3", + &SortedRoute{ + RouteID: "supplier3", SortingData: map[string]interface{}{ utils.MetaACD: 0.1, utils.MetaTCD: 10.0, @@ -457,10 +457,10 @@ func TestLibSuppliersSortQOS4(t *testing.T) { }, } sSpls.SortQOS([]string{utils.MetaASR, utils.MetaACD, utils.MetaTCD}) - rcv := make([]string, len(sSpls.SortedSuppliers)) + rcv := make([]string, len(sSpls.SortedRoutes)) eIds := []string{"supplier1", "supplier3", "supplier2"} - for i, spl := range sSpls.SortedSuppliers { - rcv[i] = spl.SupplierID + for i, spl := range sSpls.SortedRoutes { + rcv[i] = spl.RouteID } if !reflect.DeepEqual(eIds, rcv) { @@ -469,11 +469,11 @@ func TestLibSuppliersSortQOS4(t *testing.T) { } } -func TestLibSuppliersSortQOS5(t *testing.T) { - sSpls := &SortedSuppliers{ - SortedSuppliers: []*SortedSupplier{ - &SortedSupplier{ - SupplierID: "supplier1", +func TestLibRoutesSortQOS5(t *testing.T) { + sSpls := &SortedRoutes{ + SortedRoutes: []*SortedRoute{ + &SortedRoute{ + RouteID: "supplier1", SortingData: map[string]interface{}{ utils.MetaACD: 0.2, utils.MetaTCD: 15.0, @@ -481,8 +481,8 @@ func TestLibSuppliersSortQOS5(t *testing.T) { utils.MetaTCC: 10.1, }, }, - &SortedSupplier{ - SupplierID: "supplier2", + &SortedRoute{ + RouteID: "supplier2", SortingData: map[string]interface{}{ utils.MetaACD: 0.2, utils.MetaTCD: 20.0, @@ -490,8 +490,8 @@ func TestLibSuppliersSortQOS5(t *testing.T) { utils.MetaTCC: 10.1, }, }, - &SortedSupplier{ - SupplierID: "supplier3", + &SortedRoute{ + RouteID: "supplier3", SortingData: map[string]interface{}{ utils.MetaACD: 0.1, utils.MetaTCD: 10.0, @@ -502,10 +502,10 @@ func TestLibSuppliersSortQOS5(t *testing.T) { }, } sSpls.SortQOS([]string{utils.MetaTCC, utils.MetaASR, utils.MetaACD, utils.MetaTCD}) - rcv := make([]string, len(sSpls.SortedSuppliers)) + rcv := make([]string, len(sSpls.SortedRoutes)) eIds := []string{"supplier2", "supplier3", "supplier1"} - for i, spl := range sSpls.SortedSuppliers { - rcv[i] = spl.SupplierID + for i, spl := range sSpls.SortedRoutes { + rcv[i] = spl.RouteID } if !reflect.DeepEqual(eIds, rcv) { @@ -514,25 +514,25 @@ func TestLibSuppliersSortQOS5(t *testing.T) { } } -func TestLibSuppliersSortQOS6(t *testing.T) { - sSpls := &SortedSuppliers{ - SortedSuppliers: []*SortedSupplier{ - &SortedSupplier{ - SupplierID: "supplier1", +func TestLibRoutesSortQOS6(t *testing.T) { + sSpls := &SortedRoutes{ + SortedRoutes: []*SortedRoute{ + &SortedRoute{ + RouteID: "supplier1", SortingData: map[string]interface{}{ utils.Weight: 15.0, utils.MetaACD: 0.2, }, }, - &SortedSupplier{ - SupplierID: "supplier2", + &SortedRoute{ + RouteID: "supplier2", SortingData: map[string]interface{}{ utils.Weight: 25.0, utils.MetaACD: 0.2, }, }, - &SortedSupplier{ - SupplierID: "supplier3", + &SortedRoute{ + RouteID: "supplier3", SortingData: map[string]interface{}{ utils.Weight: 20.0, utils.MetaACD: 0.1, @@ -541,10 +541,10 @@ func TestLibSuppliersSortQOS6(t *testing.T) { }, } sSpls.SortQOS([]string{utils.MetaACD}) - rcv := make([]string, len(sSpls.SortedSuppliers)) + rcv := make([]string, len(sSpls.SortedRoutes)) eIds := []string{"supplier2", "supplier1", "supplier3"} - for i, spl := range sSpls.SortedSuppliers { - rcv[i] = spl.SupplierID + for i, spl := range sSpls.SortedRoutes { + rcv[i] = spl.RouteID } if !reflect.DeepEqual(eIds, rcv) { @@ -553,25 +553,25 @@ func TestLibSuppliersSortQOS6(t *testing.T) { } } -func TestLibSuppliersSortQOS7(t *testing.T) { - sSpls := &SortedSuppliers{ - SortedSuppliers: []*SortedSupplier{ - &SortedSupplier{ - SupplierID: "supplier1", +func TestLibRoutesSortQOS7(t *testing.T) { + sSpls := &SortedRoutes{ + SortedRoutes: []*SortedRoute{ + &SortedRoute{ + RouteID: "supplier1", SortingData: map[string]interface{}{ utils.Weight: 15.0, utils.MetaACD: -1.0, }, }, - &SortedSupplier{ - SupplierID: "supplier2", + &SortedRoute{ + RouteID: "supplier2", SortingData: map[string]interface{}{ utils.Weight: 25.0, utils.MetaACD: -1.0, }, }, - &SortedSupplier{ - SupplierID: "supplier3", + &SortedRoute{ + RouteID: "supplier3", SortingData: map[string]interface{}{ utils.Weight: 20.0, utils.MetaACD: -1.0, @@ -580,10 +580,10 @@ func TestLibSuppliersSortQOS7(t *testing.T) { }, } sSpls.SortQOS([]string{utils.MetaACD}) - rcv := make([]string, len(sSpls.SortedSuppliers)) + rcv := make([]string, len(sSpls.SortedRoutes)) eIds := []string{"supplier2", "supplier3", "supplier1"} - for i, spl := range sSpls.SortedSuppliers { - rcv[i] = spl.SupplierID + for i, spl := range sSpls.SortedRoutes { + rcv[i] = spl.RouteID } if !reflect.DeepEqual(eIds, rcv) { @@ -592,25 +592,25 @@ func TestLibSuppliersSortQOS7(t *testing.T) { } } -func TestLibSuppliersSortQOS8(t *testing.T) { - sSpls := &SortedSuppliers{ - SortedSuppliers: []*SortedSupplier{ - &SortedSupplier{ - SupplierID: "supplier1", +func TestLibRoutesSortQOS8(t *testing.T) { + sSpls := &SortedRoutes{ + SortedRoutes: []*SortedRoute{ + &SortedRoute{ + RouteID: "supplier1", SortingData: map[string]interface{}{ utils.Weight: 15.0, utils.MetaACD: -1.0, }, }, - &SortedSupplier{ - SupplierID: "supplier2", + &SortedRoute{ + RouteID: "supplier2", SortingData: map[string]interface{}{ utils.Weight: 25.0, utils.MetaACD: -1.0, }, }, - &SortedSupplier{ - SupplierID: "supplier3", + &SortedRoute{ + RouteID: "supplier3", SortingData: map[string]interface{}{ utils.Weight: 20.0, utils.MetaACD: 10.0, @@ -619,10 +619,10 @@ func TestLibSuppliersSortQOS8(t *testing.T) { }, } sSpls.SortQOS([]string{utils.MetaACD}) - rcv := make([]string, len(sSpls.SortedSuppliers)) + rcv := make([]string, len(sSpls.SortedRoutes)) eIds := []string{"supplier3", "supplier2", "supplier1"} - for i, spl := range sSpls.SortedSuppliers { - rcv[i] = spl.SupplierID + for i, spl := range sSpls.SortedRoutes { + rcv[i] = spl.RouteID } if !reflect.DeepEqual(eIds, rcv) { @@ -631,27 +631,27 @@ func TestLibSuppliersSortQOS8(t *testing.T) { } } -func TestLibSuppliersSortLoadDistribution(t *testing.T) { - sSpls := &SortedSuppliers{ - SortedSuppliers: []*SortedSupplier{ - &SortedSupplier{ - SupplierID: "supplier1", +func TestLibRoutesSortLoadDistribution(t *testing.T) { + sSpls := &SortedRoutes{ + SortedRoutes: []*SortedRoute{ + &SortedRoute{ + RouteID: "supplier1", SortingData: map[string]interface{}{ utils.Weight: 25.0, utils.Ratio: 4.0, utils.Load: 3.0, }, }, - &SortedSupplier{ - SupplierID: "supplier2", + &SortedRoute{ + RouteID: "supplier2", SortingData: map[string]interface{}{ utils.Weight: 15.0, utils.Ratio: 10.0, utils.Load: 5.0, }, }, - &SortedSupplier{ - SupplierID: "supplier3", + &SortedRoute{ + RouteID: "supplier3", SortingData: map[string]interface{}{ utils.Weight: 25.0, utils.Ratio: 1.0, @@ -661,10 +661,10 @@ func TestLibSuppliersSortLoadDistribution(t *testing.T) { }, } sSpls.SortLoadDistribution() - rcv := make([]string, len(sSpls.SortedSuppliers)) + rcv := make([]string, len(sSpls.SortedRoutes)) eIds := []string{"supplier2", "supplier1", "supplier3"} - for i, spl := range sSpls.SortedSuppliers { - rcv[i] = spl.SupplierID + for i, spl := range sSpls.SortedRoutes { + rcv[i] = spl.RouteID } if !reflect.DeepEqual(eIds, rcv) { t.Errorf("Expecting: %+v, \n received: %+v", diff --git a/engine/libtest.go b/engine/libtest.go index 55ea24c5c..4ec318ced 100644 --- a/engine/libtest.go +++ b/engine/libtest.go @@ -254,8 +254,8 @@ cgrates.org,FLTR_ACNT_dan,*string,~*req.Account,dan,2014-07-29T15:00:00Z cgrates.org,FLTR_DST_DE,*destinations,~*req.Destination,DST_DE,2014-07-29T15:00:00Z cgrates.org,FLTR_DST_NL,*destinations,~*req.Destination,DST_NL,2014-07-29T15:00:00Z ` - SuppliersCSVContent = ` -#Tenant[0],ID[1],FilterIDs[2],ActivationInterval[3],Sorting[4],SortingParameters[5],SupplierID[6],SupplierFilterIDs[7],SupplierAccountIDs[8],SupplierRatingPlanIDs[9],SupplierResourceIDs[10],SupplierStatIDs[11],SupplierWeight[12],SupplierBlocker[13],SupplierParameters[14],Weight[15] + RoutesCSVContent = ` +#Tenant[0],ID[1],FilterIDs[2],ActivationInterval[3],Sorting[4],SortingParameters[5],RouteID[6],RouteFilterIDs[7],RouteAccountIDs[8],RouteRatingPlanIDs[9],RouteResourceIDs[10],RouteStatIDs[11],RouteWeight[12],RouteBlocker[13],RouteParameters[14],Weight[15] cgrates.org,SPP_1,*string:~*req.Account:dan,2014-07-29T15:00:00Z,*least_cost,,supplier1,FLTR_ACNT_dan,Account1;Account1_1,RPL_1,ResGroup1,Stat1,10,true,param1,20 cgrates.org,SPP_1,,,,,supplier1,,,RPL_2,ResGroup2,,10,,, cgrates.org,SPP_1,,,,,supplier1,FLTR_DST_DE,Account2,RPL_3,ResGroup3,Stat2,10,,, diff --git a/engine/loader_csv_test.go b/engine/loader_csv_test.go index e6d6b6416..01bb06d49 100644 --- a/engine/loader_csv_test.go +++ b/engine/loader_csv_test.go @@ -41,7 +41,7 @@ func init() { RatingPlansCSVContent, RatingProfilesCSVContent, SharedGroupsCSVContent, ActionsCSVContent, ActionPlansCSVContent, ActionTriggersCSVContent, AccountActionsCSVContent, ResourcesCSVContent, StatsCSVContent, ThresholdsCSVContent, FiltersCSVContent, - SuppliersCSVContent, AttributesCSVContent, ChargersCSVContent, DispatcherCSVContent, + RoutesCSVContent, AttributesCSVContent, ChargersCSVContent, DispatcherCSVContent, DispatcherHostCSVContent), testTPID, "", nil, nil) if err != nil { log.Print("error when creating TpReader:", err) @@ -91,7 +91,7 @@ func init() { if err := csvr.LoadThresholds(); err != nil { log.Print("error in LoadThresholds:", err) } - if err := csvr.LoadSupplierProfiles(); err != nil { + if err := csvr.LoadRouteProfiles(); err != nil { log.Print("error in LoadSupplierProfiles:", err) } if err := csvr.LoadAttributeProfiles(); err != nil { @@ -1224,9 +1224,9 @@ func TestLoadFilters(t *testing.T) { } } -func TestLoadSupplierProfiles(t *testing.T) { - eSppProfiles := map[utils.TenantID]*utils.TPSupplierProfile{ - utils.TenantID{Tenant: "cgrates.org", ID: "SPP_1"}: &utils.TPSupplierProfile{ +func TestLoadRouteProfiles(t *testing.T) { + eSppProfiles := map[utils.TenantID]*utils.TPRouteProfile{ + utils.TenantID{Tenant: "cgrates.org", ID: "SPP_1"}: &utils.TPRouteProfile{ TPid: testTPID, Tenant: "cgrates.org", ID: "SPP_1", @@ -1236,27 +1236,27 @@ func TestLoadSupplierProfiles(t *testing.T) { }, Sorting: "*least_cost", SortingParameters: []string{}, - Suppliers: []*utils.TPSupplier{ - &utils.TPSupplier{ - ID: "supplier1", - FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE"}, - AccountIDs: []string{"Account1", "Account1_1", "Account2"}, - RatingPlanIDs: []string{"RPL_1", "RPL_2", "RPL_3"}, - ResourceIDs: []string{"ResGroup1", "ResGroup2", "ResGroup3", "ResGroup4"}, - StatIDs: []string{"Stat1", "Stat2", "Stat3"}, - Weight: 10, - Blocker: true, - SupplierParameters: "param1", + Routes: []*utils.TPRoute{ + &utils.TPRoute{ + ID: "supplier1", + FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE"}, + AccountIDs: []string{"Account1", "Account1_1", "Account2"}, + RatingPlanIDs: []string{"RPL_1", "RPL_2", "RPL_3"}, + ResourceIDs: []string{"ResGroup1", "ResGroup2", "ResGroup3", "ResGroup4"}, + StatIDs: []string{"Stat1", "Stat2", "Stat3"}, + Weight: 10, + Blocker: true, + RouteParameters: "param1", }, }, Weight: 20, }, } resKey := utils.TenantID{Tenant: "cgrates.org", ID: "SPP_1"} - if len(csvr.sppProfiles) != len(eSppProfiles) { - t.Errorf("Failed to load SupplierProfiles: %s", utils.ToIJSON(csvr.sppProfiles)) - } else if !reflect.DeepEqual(eSppProfiles[resKey], csvr.sppProfiles[resKey]) { - t.Errorf("Expecting: %+v, received: %+v", eSppProfiles[resKey], csvr.sppProfiles[resKey]) + if len(csvr.routeProfiles) != len(eSppProfiles) { + t.Errorf("Failed to load SupplierProfiles: %s", utils.ToIJSON(csvr.routeProfiles)) + } else if !reflect.DeepEqual(eSppProfiles[resKey], csvr.routeProfiles[resKey]) { + t.Errorf("Expecting: %+v, received: %+v", eSppProfiles[resKey], csvr.routeProfiles[resKey]) } } diff --git a/engine/routes.go b/engine/routes.go index 81d711378..5104885b2 100644 --- a/engine/routes.go +++ b/engine/routes.go @@ -487,7 +487,7 @@ func (rpS *RouteService) sortedRoutesForEvent(args *ArgsGetRoutes) (sortedRoutes return } rPrfl := rPrfs[0] - extraOpts, err := args.asOptsGetSuppliers() // convert suppliers arguments into internal options used to limit data + extraOpts, err := args.asOptsGetRoutes() // convert suppliers arguments into internal options used to limit data if err != nil { return nil, err } @@ -541,7 +541,7 @@ type ArgsGetRoutes struct { *utils.ArgDispatcher } -func (args *ArgsGetRoutes) asOptsGetSuppliers() (opts *optsGetRoutes, err error) { +func (args *ArgsGetRoutes) asOptsGetRoutes() (opts *optsGetRoutes, err error) { opts = &optsGetRoutes{ignoreErrors: args.IgnoreErrors} if args.MaxCost == utils.MetaEventCost { // dynamic cost needs to be calculated from event if err = args.CGREvent.CheckMandatoryFields([]string{utils.Account, diff --git a/engine/routes_test.go b/engine/routes_test.go index 9603f1456..b6caa734a 100644 --- a/engine/routes_test.go +++ b/engine/routes_test.go @@ -27,113 +27,113 @@ import ( ) var ( - expTimeSuppliers = time.Now().Add(time.Duration(20 * time.Minute)) - splService *SupplierService - dmSPP *DataManager - sppTest = SupplierProfiles{ - &SupplierProfile{ + expTimeRoutes = time.Now().Add(time.Duration(20 * time.Minute)) + splService *RouteService + dmSPP *DataManager + sppTest = RouteProfiles{ + &RouteProfile{ Tenant: "cgrates.org", - ID: "SupplierProfile1", + ID: "RouteProfile1", FilterIDs: []string{"FLTR_SUPP_1"}, ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - ExpiryTime: expTimeSuppliers, + ExpiryTime: expTimeRoutes, }, Sorting: utils.MetaWeight, SortingParameters: []string{}, - Suppliers: []*Supplier{ + Routes: []*Route{ { - ID: "supplier1", - FilterIDs: []string{}, - AccountIDs: []string{}, - RatingPlanIDs: []string{}, - ResourceIDs: []string{}, - StatIDs: []string{}, - Weight: 10.0, - Blocker: false, - SupplierParameters: "param1", + ID: "supplier1", + FilterIDs: []string{}, + AccountIDs: []string{}, + RatingPlanIDs: []string{}, + ResourceIDs: []string{}, + StatIDs: []string{}, + Weight: 10.0, + Blocker: false, + RouteParameters: "param1", }, }, Weight: 10, }, - &SupplierProfile{ + &RouteProfile{ Tenant: "cgrates.org", - ID: "SupplierProfile2", + ID: "RouteProfile2", FilterIDs: []string{"FLTR_SUPP_2"}, ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - ExpiryTime: expTimeSuppliers, + ExpiryTime: expTimeRoutes, }, Sorting: utils.MetaWeight, SortingParameters: []string{}, - Suppliers: []*Supplier{ + Routes: []*Route{ { - ID: "supplier2", - FilterIDs: []string{}, - AccountIDs: []string{}, - RatingPlanIDs: []string{}, - ResourceIDs: []string{}, - StatIDs: []string{}, - Weight: 20.0, - SupplierParameters: "param2", + ID: "supplier2", + FilterIDs: []string{}, + AccountIDs: []string{}, + RatingPlanIDs: []string{}, + ResourceIDs: []string{}, + StatIDs: []string{}, + Weight: 20.0, + RouteParameters: "param2", }, { - ID: "supplier3", - FilterIDs: []string{}, - AccountIDs: []string{}, - RatingPlanIDs: []string{}, - ResourceIDs: []string{}, - StatIDs: []string{}, - Weight: 10.0, - SupplierParameters: "param3", + ID: "supplier3", + FilterIDs: []string{}, + AccountIDs: []string{}, + RatingPlanIDs: []string{}, + ResourceIDs: []string{}, + StatIDs: []string{}, + Weight: 10.0, + RouteParameters: "param3", }, { - ID: "supplier1", - FilterIDs: []string{}, - AccountIDs: []string{}, - RatingPlanIDs: []string{}, - ResourceIDs: []string{}, - StatIDs: []string{}, - Weight: 30.0, - Blocker: false, - SupplierParameters: "param1", + ID: "supplier1", + FilterIDs: []string{}, + AccountIDs: []string{}, + RatingPlanIDs: []string{}, + ResourceIDs: []string{}, + StatIDs: []string{}, + Weight: 30.0, + Blocker: false, + RouteParameters: "param1", }, }, Weight: 20.0, }, - &SupplierProfile{ + &RouteProfile{ Tenant: "cgrates.org", - ID: "SupplierProfilePrefix", + ID: "RouteProfilePrefix", FilterIDs: []string{"FLTR_SUPP_3"}, ActivationInterval: &utils.ActivationInterval{ ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC), - ExpiryTime: expTimeSuppliers, + ExpiryTime: expTimeRoutes, }, Sorting: utils.MetaWeight, SortingParameters: []string{}, - Suppliers: []*Supplier{ + Routes: []*Route{ { - ID: "supplier1", - FilterIDs: []string{}, - AccountIDs: []string{}, - RatingPlanIDs: []string{}, - ResourceIDs: []string{}, - StatIDs: []string{}, - Weight: 10.0, - Blocker: false, - SupplierParameters: "param1", + ID: "supplier1", + FilterIDs: []string{}, + AccountIDs: []string{}, + RatingPlanIDs: []string{}, + ResourceIDs: []string{}, + StatIDs: []string{}, + Weight: 10.0, + Blocker: false, + RouteParameters: "param1", }, }, Weight: 10, }, } - argsGetSuppliers = []*ArgsGetSuppliers{ - { //matching SupplierProfile1 + argsGetRoutes = []*ArgsGetRoutes{ + { //matching RouteProfile1 CGREvent: &utils.CGREvent{ Tenant: "cgrates.org", ID: "utils.CGREvent1", Event: map[string]interface{}{ - "Supplier": "SupplierProfile1", + "Route": "RouteProfile1", utils.AnswerTime: time.Date(2014, 7, 14, 14, 30, 0, 0, time.UTC), "UsageInterval": "1s", "PddInterval": "1s", @@ -141,12 +141,12 @@ var ( }, }, }, - { //matching SupplierProfile2 + { //matching RouteProfile2 CGREvent: &utils.CGREvent{ Tenant: "cgrates.org", ID: "utils.CGREvent1", Event: map[string]interface{}{ - "Supplier": "SupplierProfile2", + "Route": "RouteProfile2", utils.AnswerTime: time.Date(2014, 7, 14, 14, 30, 0, 0, time.UTC), "UsageInterval": "1s", "PddInterval": "1s", @@ -154,12 +154,12 @@ var ( }, }, }, - { //matching SupplierProfilePrefix + { //matching RouteProfilePrefix CGREvent: &utils.CGREvent{ Tenant: "cgrates.org", ID: "utils.CGREvent1", Event: map[string]interface{}{ - "Supplier": "SupplierProfilePrefix", + "Route": "RouteProfilePrefix", }, }, }, @@ -176,9 +176,9 @@ var ( } ) -func TestSuppliersSort(t *testing.T) { - sprs := SupplierProfiles{ - &SupplierProfile{ +func TestRoutesSort(t *testing.T) { + sprs := RouteProfiles{ + &RouteProfile{ Tenant: "cgrates.org", ID: "supplierprofile1", FilterIDs: []string{}, @@ -188,22 +188,22 @@ func TestSuppliersSort(t *testing.T) { }, Sorting: "", SortingParameters: []string{}, - Suppliers: []*Supplier{ + Routes: []*Route{ { - ID: "supplier1", - FilterIDs: []string{}, - AccountIDs: []string{}, - RatingPlanIDs: []string{}, - ResourceIDs: []string{}, - StatIDs: []string{}, - Weight: 10.0, - Blocker: false, - SupplierParameters: "param1", + ID: "supplier1", + FilterIDs: []string{}, + AccountIDs: []string{}, + RatingPlanIDs: []string{}, + ResourceIDs: []string{}, + StatIDs: []string{}, + Weight: 10.0, + Blocker: false, + RouteParameters: "param1", }, }, Weight: 10, }, - &SupplierProfile{ + &RouteProfile{ Tenant: "cgrates.org", ID: "supplierprofile2", FilterIDs: []string{}, @@ -213,24 +213,24 @@ func TestSuppliersSort(t *testing.T) { }, Sorting: "", SortingParameters: []string{}, - Suppliers: []*Supplier{ + Routes: []*Route{ { - ID: "supplier1", - FilterIDs: []string{}, - AccountIDs: []string{}, - RatingPlanIDs: []string{}, - ResourceIDs: []string{}, - StatIDs: []string{}, - Weight: 20.0, - Blocker: false, - SupplierParameters: "param1", + ID: "supplier1", + FilterIDs: []string{}, + AccountIDs: []string{}, + RatingPlanIDs: []string{}, + ResourceIDs: []string{}, + StatIDs: []string{}, + Weight: 20.0, + Blocker: false, + RouteParameters: "param1", }, }, Weight: 20.0, }, } - eSupplierProfile := SupplierProfiles{ - &SupplierProfile{ + eRouteProfile := RouteProfiles{ + &RouteProfile{ Tenant: "cgrates.org", ID: "supplierprofile2", FilterIDs: []string{}, @@ -240,22 +240,22 @@ func TestSuppliersSort(t *testing.T) { }, Sorting: "", SortingParameters: []string{}, - Suppliers: []*Supplier{ + Routes: []*Route{ { - ID: "supplier1", - FilterIDs: []string{}, - AccountIDs: []string{}, - RatingPlanIDs: []string{}, - ResourceIDs: []string{}, - StatIDs: []string{}, - Weight: 20.0, - Blocker: false, - SupplierParameters: "param1", + ID: "supplier1", + FilterIDs: []string{}, + AccountIDs: []string{}, + RatingPlanIDs: []string{}, + ResourceIDs: []string{}, + StatIDs: []string{}, + Weight: 20.0, + Blocker: false, + RouteParameters: "param1", }, }, Weight: 20.0, }, - &SupplierProfile{ + &RouteProfile{ Tenant: "cgrates.org", ID: "supplierprofile1", FilterIDs: []string{}, @@ -265,50 +265,50 @@ func TestSuppliersSort(t *testing.T) { }, Sorting: "", SortingParameters: []string{}, - Suppliers: []*Supplier{ + Routes: []*Route{ { - ID: "supplier1", - FilterIDs: []string{}, - AccountIDs: []string{}, - RatingPlanIDs: []string{}, - ResourceIDs: []string{}, - StatIDs: []string{}, - Weight: 10.0, - Blocker: false, - SupplierParameters: "param1", + ID: "supplier1", + FilterIDs: []string{}, + AccountIDs: []string{}, + RatingPlanIDs: []string{}, + ResourceIDs: []string{}, + StatIDs: []string{}, + Weight: 10.0, + Blocker: false, + RouteParameters: "param1", }, }, Weight: 10.0, }, } sprs.Sort() - if !reflect.DeepEqual(eSupplierProfile, sprs) { - t.Errorf("Expecting: %+v, received: %+v", eSupplierProfile, sprs) + if !reflect.DeepEqual(eRouteProfile, sprs) { + t.Errorf("Expecting: %+v, received: %+v", eRouteProfile, sprs) } } -func TestSuppliersPopulateSupplierService(t *testing.T) { +func TestRoutesPopulateRouteService(t *testing.T) { defaultCfg, _ := config.NewDefaultCGRConfig() data := NewInternalDB(nil, nil, true, defaultCfg.DataDbCfg().Items) dmSPP = NewDataManager(data, config.CgrConfig().CacheCfg(), nil) - defaultCfg.SupplierSCfg().StringIndexedFields = nil - defaultCfg.SupplierSCfg().PrefixIndexedFields = nil - splService, err = NewSupplierService(dmSPP, &FilterS{ + defaultCfg.RouteCfg().StringIndexedFields = nil + defaultCfg.RouteCfg().PrefixIndexedFields = nil + splService, err = NewRouteService(dmSPP, &FilterS{ dm: dmSPP, cfg: defaultCfg}, defaultCfg, nil) if err != nil { t.Errorf("Error: %+v", err) } } -func TestSuppliersAddFilters(t *testing.T) { +func TestRoutesAddFilters(t *testing.T) { fltrSupp1 := &Filter{ Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, ID: "FLTR_SUPP_1", Rules: []*FilterRule{ { Type: utils.MetaString, - Element: "~*req.Supplier", - Values: []string{"SupplierProfile1"}, + Element: "~*req.Route", + Values: []string{"RouteProfile1"}, }, { Type: utils.MetaGreaterOrEqual, @@ -329,8 +329,8 @@ func TestSuppliersAddFilters(t *testing.T) { Rules: []*FilterRule{ { Type: utils.MetaString, - Element: "~*req.Supplier", - Values: []string{"SupplierProfile2"}, + Element: "~*req.Route", + Values: []string{"RouteProfile2"}, }, { Type: utils.MetaGreaterOrEqual, @@ -351,23 +351,23 @@ func TestSuppliersAddFilters(t *testing.T) { Rules: []*FilterRule{ { Type: utils.MetaPrefix, - Element: "~*req.Supplier", - Values: []string{"SupplierProfilePrefix"}, + Element: "~*req.Route", + Values: []string{"RouteProfilePrefix"}, }, }, } dmSPP.SetFilter(fltrSupp3) } -func TestSuppliersCache(t *testing.T) { +func TestRoutesCache(t *testing.T) { for _, spp := range sppTest { - if err = dmSPP.SetSupplierProfile(spp, true); err != nil { + if err = dmSPP.SetRouteProfile(spp, true); err != nil { t.Errorf("Error: %+v", err) } } //Test each supplier profile from cache for _, spp := range sppTest { - if tempSpp, err := dmSPP.GetSupplierProfile(spp.Tenant, + if tempSpp, err := dmSPP.GetRouteProfile(spp.Tenant, spp.ID, true, true, utils.NonTransactional); err != nil { t.Errorf("Error: %+v", err) } else if !reflect.DeepEqual(spp, tempSpp) { @@ -376,8 +376,8 @@ func TestSuppliersCache(t *testing.T) { } } -func TestSuppliersmatchingRouteProfilesForEvent(t *testing.T) { - sprf, err := splService.matchingRouteProfilesForEvent(argsGetSuppliers[0].CGREvent, true) +func TestRoutesmatchingRouteProfilesForEvent(t *testing.T) { + sprf, err := splService.matchingRouteProfilesForEvent(argsGetRoutes[0].CGREvent, true) if err != nil { t.Errorf("Error: %+v", err) } @@ -385,7 +385,7 @@ func TestSuppliersmatchingRouteProfilesForEvent(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", sppTest[0], sprf[0]) } - sprf, err = splService.matchingRouteProfilesForEvent(argsGetSuppliers[1].CGREvent, true) + sprf, err = splService.matchingRouteProfilesForEvent(argsGetRoutes[1].CGREvent, true) if err != nil { t.Errorf("Error: %+v", err) } @@ -393,7 +393,7 @@ func TestSuppliersmatchingRouteProfilesForEvent(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", sppTest[1], sprf[0]) } - sprf, err = splService.matchingRouteProfilesForEvent(argsGetSuppliers[2].CGREvent, true) + sprf, err = splService.matchingRouteProfilesForEvent(argsGetRoutes[2].CGREvent, true) if err != nil { t.Errorf("Error: %+v", err) } @@ -402,189 +402,189 @@ func TestSuppliersmatchingRouteProfilesForEvent(t *testing.T) { } } -func TestSuppliersSortedForEvent(t *testing.T) { - eFirstSupplierProfile := &SortedSuppliers{ - ProfileID: "SupplierProfile1", +func TestRoutesSortedForEvent(t *testing.T) { + eFirstRouteProfile := &SortedRoutes{ + ProfileID: "RouteProfile1", Sorting: utils.MetaWeight, Count: 1, - SortedSuppliers: []*SortedSupplier{ + SortedRoutes: []*SortedRoute{ { - SupplierID: "supplier1", + RouteID: "supplier1", SortingData: map[string]interface{}{ "Weight": 10.0, }, - SupplierParameters: "param1", + RouteParameters: "param1", }, }, } - sprf, err := splService.sortedSuppliersForEvent(argsGetSuppliers[0]) + sprf, err := splService.sortedRoutesForEvent(argsGetRoutes[0]) if err != nil { t.Errorf("Error: %+v", err) } - if !reflect.DeepEqual(eFirstSupplierProfile, sprf) { - t.Errorf("Expecting: %+v, received: %+v", eFirstSupplierProfile, sprf) + if !reflect.DeepEqual(eFirstRouteProfile, sprf) { + t.Errorf("Expecting: %+v, received: %+v", eFirstRouteProfile, sprf) } - eFirstSupplierProfile = &SortedSuppliers{ - ProfileID: "SupplierProfile2", + eFirstRouteProfile = &SortedRoutes{ + ProfileID: "RouteProfile2", Sorting: utils.MetaWeight, Count: 3, - SortedSuppliers: []*SortedSupplier{ + SortedRoutes: []*SortedRoute{ { - SupplierID: "supplier1", + RouteID: "supplier1", SortingData: map[string]interface{}{ "Weight": 30.0, }, - SupplierParameters: "param1", + RouteParameters: "param1", }, { - SupplierID: "supplier2", + RouteID: "supplier2", SortingData: map[string]interface{}{ "Weight": 20.0, }, - SupplierParameters: "param2", + RouteParameters: "param2", }, { - SupplierID: "supplier3", + RouteID: "supplier3", SortingData: map[string]interface{}{ "Weight": 10.0, }, - SupplierParameters: "param3", + RouteParameters: "param3", }, }, } - sprf, err = splService.sortedSuppliersForEvent(argsGetSuppliers[1]) + sprf, err = splService.sortedRoutesForEvent(argsGetRoutes[1]) if err != nil { t.Errorf("Error: %+v", err) } - if !reflect.DeepEqual(eFirstSupplierProfile, sprf) { - t.Errorf("Expecting: %+v, received: %+v", eFirstSupplierProfile, sprf) + if !reflect.DeepEqual(eFirstRouteProfile, sprf) { + t.Errorf("Expecting: %+v, received: %+v", eFirstRouteProfile, sprf) } - eFirstSupplierProfile = &SortedSuppliers{ - ProfileID: "SupplierProfilePrefix", + eFirstRouteProfile = &SortedRoutes{ + ProfileID: "RouteProfilePrefix", Sorting: utils.MetaWeight, Count: 1, - SortedSuppliers: []*SortedSupplier{ + SortedRoutes: []*SortedRoute{ { - SupplierID: "supplier1", + RouteID: "supplier1", SortingData: map[string]interface{}{ "Weight": 10.0, }, - SupplierParameters: "param1", + RouteParameters: "param1", }, }, } - sprf, err = splService.sortedSuppliersForEvent(argsGetSuppliers[2]) + sprf, err = splService.sortedRoutesForEvent(argsGetRoutes[2]) if err != nil { t.Errorf("Error: %+v", err) } - if !reflect.DeepEqual(eFirstSupplierProfile, sprf) { - t.Errorf("Expecting: %+v, received: %+v", eFirstSupplierProfile, sprf) + if !reflect.DeepEqual(eFirstRouteProfile, sprf) { + t.Errorf("Expecting: %+v, received: %+v", eFirstRouteProfile, sprf) } } -func TestSuppliersSortedForEventWithLimit(t *testing.T) { - eFirstSupplierProfile := &SortedSuppliers{ - ProfileID: "SupplierProfile2", +func TestRoutesSortedForEventWithLimit(t *testing.T) { + eFirstRouteProfile := &SortedRoutes{ + ProfileID: "RouteProfile2", Sorting: utils.MetaWeight, Count: 2, - SortedSuppliers: []*SortedSupplier{ + SortedRoutes: []*SortedRoute{ { - SupplierID: "supplier1", + RouteID: "supplier1", SortingData: map[string]interface{}{ "Weight": 30.0, }, - SupplierParameters: "param1", + RouteParameters: "param1", }, { - SupplierID: "supplier2", + RouteID: "supplier2", SortingData: map[string]interface{}{ "Weight": 20.0, }, - SupplierParameters: "param2", + RouteParameters: "param2", }, }, } - argsGetSuppliers[1].Paginator = utils.Paginator{ + argsGetRoutes[1].Paginator = utils.Paginator{ Limit: utils.IntPointer(2), } - sprf, err := splService.sortedSuppliersForEvent(argsGetSuppliers[1]) + sprf, err := splService.sortedRoutesForEvent(argsGetRoutes[1]) if err != nil { t.Errorf("Error: %+v", err) } - if !reflect.DeepEqual(eFirstSupplierProfile, sprf) { - t.Errorf("Expecting: %+v, received: %+v", eFirstSupplierProfile, sprf) + if !reflect.DeepEqual(eFirstRouteProfile, sprf) { + t.Errorf("Expecting: %+v, received: %+v", eFirstRouteProfile, sprf) } } -func TestSuppliersSortedForEventWithOffset(t *testing.T) { - eFirstSupplierProfile := &SortedSuppliers{ - ProfileID: "SupplierProfile2", +func TestRoutesSortedForEventWithOffset(t *testing.T) { + eFirstRouteProfile := &SortedRoutes{ + ProfileID: "RouteProfile2", Sorting: utils.MetaWeight, Count: 1, - SortedSuppliers: []*SortedSupplier{ + SortedRoutes: []*SortedRoute{ { - SupplierID: "supplier3", + RouteID: "supplier3", SortingData: map[string]interface{}{ "Weight": 10.0, }, - SupplierParameters: "param3", + RouteParameters: "param3", }, }, } - argsGetSuppliers[1].Paginator = utils.Paginator{ + argsGetRoutes[1].Paginator = utils.Paginator{ Offset: utils.IntPointer(2), } - sprf, err := splService.sortedSuppliersForEvent(argsGetSuppliers[1]) + sprf, err := splService.sortedRoutesForEvent(argsGetRoutes[1]) if err != nil { t.Errorf("Error: %+v", err) } - if !reflect.DeepEqual(eFirstSupplierProfile, sprf) { - t.Errorf("Expecting: %+v,received: %+v", utils.ToJSON(eFirstSupplierProfile), utils.ToJSON(sprf)) + if !reflect.DeepEqual(eFirstRouteProfile, sprf) { + t.Errorf("Expecting: %+v,received: %+v", utils.ToJSON(eFirstRouteProfile), utils.ToJSON(sprf)) } } -func TestSuppliersSortedForEventWithLimitAndOffset(t *testing.T) { - eFirstSupplierProfile := &SortedSuppliers{ - ProfileID: "SupplierProfile2", +func TestRoutesSortedForEventWithLimitAndOffset(t *testing.T) { + eFirstRouteProfile := &SortedRoutes{ + ProfileID: "RouteProfile2", Sorting: utils.MetaWeight, Count: 1, - SortedSuppliers: []*SortedSupplier{ + SortedRoutes: []*SortedRoute{ { - SupplierID: "supplier2", + RouteID: "supplier2", SortingData: map[string]interface{}{ "Weight": 20.0, }, - SupplierParameters: "param2", + RouteParameters: "param2", }, }, } - argsGetSuppliers[1].Paginator = utils.Paginator{ + argsGetRoutes[1].Paginator = utils.Paginator{ Limit: utils.IntPointer(1), Offset: utils.IntPointer(1), } - sprf, err := splService.sortedSuppliersForEvent(argsGetSuppliers[1]) + sprf, err := splService.sortedRoutesForEvent(argsGetRoutes[1]) if err != nil { t.Errorf("Error: %+v", err) } - if !reflect.DeepEqual(eFirstSupplierProfile, sprf) { - t.Errorf("Expecting: %+v,received: %+v", utils.ToJSON(eFirstSupplierProfile), utils.ToJSON(sprf)) + if !reflect.DeepEqual(eFirstRouteProfile, sprf) { + t.Errorf("Expecting: %+v,received: %+v", utils.ToJSON(eFirstRouteProfile), utils.ToJSON(sprf)) } } -func TestSuppliersAsOptsGetSuppliers(t *testing.T) { - s := &ArgsGetSuppliers{ +func TestRoutesAsOptsGetRoutes(t *testing.T) { + s := &ArgsGetRoutes{ IgnoreErrors: true, MaxCost: "10.0", } - spl := &optsGetSuppliers{ + spl := &optsGetRoutes{ ignoreErrors: true, maxCost: 10.0, } - sprf, err := s.asOptsGetSuppliers() + sprf, err := s.asOptsGetRoutes() if err != nil { t.Errorf("Error: %+v", err) } @@ -593,14 +593,14 @@ func TestSuppliersAsOptsGetSuppliers(t *testing.T) { } } -func TestSuppliersAsOptsGetSuppliersIgnoreErrors(t *testing.T) { - s := &ArgsGetSuppliers{ +func TestRoutesAsOptsGetRoutesIgnoreErrors(t *testing.T) { + s := &ArgsGetRoutes{ IgnoreErrors: true, } - spl := &optsGetSuppliers{ + spl := &optsGetRoutes{ ignoreErrors: true, } - sprf, err := s.asOptsGetSuppliers() + sprf, err := s.asOptsGetRoutes() if err != nil { t.Errorf("Error: %+v", err) } @@ -609,14 +609,14 @@ func TestSuppliersAsOptsGetSuppliersIgnoreErrors(t *testing.T) { } } -func TestSuppliersAsOptsGetSuppliersMaxCost(t *testing.T) { - s := &ArgsGetSuppliers{ +func TestRoutesAsOptsGetRoutesMaxCost(t *testing.T) { + s := &ArgsGetRoutes{ MaxCost: "10.0", } - spl := &optsGetSuppliers{ + spl := &optsGetRoutes{ maxCost: 10.0, } - sprf, err := s.asOptsGetSuppliers() + sprf, err := s.asOptsGetRoutes() if err != nil { t.Errorf("Error: %+v", err) } @@ -625,9 +625,9 @@ func TestSuppliersAsOptsGetSuppliersMaxCost(t *testing.T) { } } -func TestSuppliersMatchWithIndexFalse(t *testing.T) { - splService.cgrcfg.SupplierSCfg().IndexedSelects = false - sprf, err := splService.matchingRouteProfilesForEvent(argsGetSuppliers[0].CGREvent, true) +func TestRoutesMatchWithIndexFalse(t *testing.T) { + splService.cgrcfg.RouteCfg().IndexedSelects = false + sprf, err := splService.matchingRouteProfilesForEvent(argsGetRoutes[0].CGREvent, true) if err != nil { t.Errorf("Error: %+v", err) } @@ -635,7 +635,7 @@ func TestSuppliersMatchWithIndexFalse(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", sppTest[0], sprf[0]) } - sprf, err = splService.matchingRouteProfilesForEvent(argsGetSuppliers[1].CGREvent, true) + sprf, err = splService.matchingRouteProfilesForEvent(argsGetRoutes[1].CGREvent, true) if err != nil { t.Errorf("Error: %+v", err) } @@ -643,7 +643,7 @@ func TestSuppliersMatchWithIndexFalse(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", sppTest[1], sprf[0]) } - sprf, err = splService.matchingRouteProfilesForEvent(argsGetSuppliers[2].CGREvent, true) + sprf, err = splService.matchingRouteProfilesForEvent(argsGetRoutes[2].CGREvent, true) if err != nil { t.Errorf("Error: %+v", err) } diff --git a/loaders/loader_test.go b/loaders/loader_test.go index 2ed60b130..d68657bc9 100644 --- a/loaders/loader_test.go +++ b/loaders/loader_test.go @@ -665,7 +665,7 @@ func TestLoaderProcessStats(t *testing.T) { } } -func TestLoaderProcessSuppliers(t *testing.T) { +func TestLoaderProcessRoutes(t *testing.T) { data := engine.NewInternalDB(nil, nil, true, config.CgrConfig().DataDbCfg().Items) ldr := &Loader{ ldrID: "TestLoaderProcessContent", @@ -674,7 +674,7 @@ func TestLoaderProcessSuppliers(t *testing.T) { timezone: "UTC", } ldr.dataTpls = map[string][]*config.FCTemplate{ - utils.MetaSuppliers: []*config.FCTemplate{ + utils.MetaRoutes: []*config.FCTemplate{ &config.FCTemplate{Tag: "TenantID", Path: "Tenant", Type: utils.META_COMPOSED, @@ -697,44 +697,44 @@ func TestLoaderProcessSuppliers(t *testing.T) { Path: "Sorting", Type: utils.META_COMPOSED, Value: config.NewRSRParsersMustCompile("~4", true, utils.INFIELD_SEP)}, - &config.FCTemplate{Tag: "SortingParamameters", - Path: "SortingParamameters", + &config.FCTemplate{Tag: "SortingParameters", + Path: "SortingParameters", Type: utils.META_COMPOSED, Value: config.NewRSRParsersMustCompile("~5", true, utils.INFIELD_SEP)}, - &config.FCTemplate{Tag: "SupplierID", - Path: "SupplierID", + &config.FCTemplate{Tag: "RouteID", + Path: "RouteID", Type: utils.META_COMPOSED, Value: config.NewRSRParsersMustCompile("~6", true, utils.INFIELD_SEP)}, - &config.FCTemplate{Tag: "SupplierFilterIDs", - Path: "SupplierFilterIDs", + &config.FCTemplate{Tag: "RouteFilterIDs", + Path: "RouteFilterIDs", Type: utils.META_COMPOSED, Value: config.NewRSRParsersMustCompile("~7", true, utils.INFIELD_SEP)}, - &config.FCTemplate{Tag: "SupplierAccountIDs", - Path: "SupplierAccountIDs", + &config.FCTemplate{Tag: "RouteAccountIDs", + Path: "RouteAccountIDs", Type: utils.META_COMPOSED, Value: config.NewRSRParsersMustCompile("~8", true, utils.INFIELD_SEP)}, - &config.FCTemplate{Tag: "SupplierRatingPlanIDs", - Path: "SupplierRatingplanIDs", + &config.FCTemplate{Tag: "RouteRatingPlanIDs", + Path: "RouteRatingplanIDs", Type: utils.META_COMPOSED, Value: config.NewRSRParsersMustCompile("~9", true, utils.INFIELD_SEP)}, - &config.FCTemplate{Tag: "SupplierResourceIDs", - Path: "SupplierResourceIDs", + &config.FCTemplate{Tag: "RouteResourceIDs", + Path: "RouteResourceIDs", Type: utils.META_COMPOSED, Value: config.NewRSRParsersMustCompile("~10", true, utils.INFIELD_SEP)}, - &config.FCTemplate{Tag: "SupplierStatIDs", - Path: "SupplierStatIDs", + &config.FCTemplate{Tag: "RouteStatIDs", + Path: "RouteStatIDs", Type: utils.META_COMPOSED, Value: config.NewRSRParsersMustCompile("~11", true, utils.INFIELD_SEP)}, - &config.FCTemplate{Tag: "SupplierWeight", - Path: "SupplierWeight", + &config.FCTemplate{Tag: "RouteWeight", + Path: "RouteWeight", Type: utils.META_COMPOSED, Value: config.NewRSRParsersMustCompile("~12", true, utils.INFIELD_SEP)}, - &config.FCTemplate{Tag: "SupplierBlocker", - Path: "SupplierBlocker", + &config.FCTemplate{Tag: "RouteBlocker", + Path: "RouteBlocker", Type: utils.META_COMPOSED, Value: config.NewRSRParsersMustCompile("~13", true, utils.INFIELD_SEP)}, - &config.FCTemplate{Tag: "SupplierParameters", - Path: "SupplierParameters", + &config.FCTemplate{Tag: "RouteParameters", + Path: "RouteParameters", Type: utils.META_COMPOSED, Value: config.NewRSRParsersMustCompile("~14", true, utils.INFIELD_SEP)}, &config.FCTemplate{Tag: "Weight", @@ -743,22 +743,22 @@ func TestLoaderProcessSuppliers(t *testing.T) { Value: config.NewRSRParsersMustCompile("~15", true, utils.INFIELD_SEP)}, }, } - rdr := ioutil.NopCloser(strings.NewReader(engine.SuppliersCSVContent)) + rdr := ioutil.NopCloser(strings.NewReader(engine.RoutesCSVContent)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ - utils.MetaSuppliers: map[string]*openedCSVFile{ - "Suppliers.csv": &openedCSVFile{fileName: "Suppliers.csv", + utils.MetaRoutes: map[string]*openedCSVFile{ + utils.RoutesCsv: &openedCSVFile{fileName: utils.RoutesCsv, rdr: rdr, csvRdr: csvRdr}}, } - if err := ldr.processContent(utils.MetaSuppliers, utils.EmptyString); err != nil { + if err := ldr.processContent(utils.MetaRoutes, utils.EmptyString); err != nil { t.Error(err) } if len(ldr.bufLoaderData) != 0 { t.Errorf("wrong buffer content: %+v", ldr.bufLoaderData) } - eSp3 := &engine.SupplierProfile{ + eSp3 := &engine.RouteProfile{ Tenant: "cgrates.org", ID: "SPP_1", FilterIDs: []string{"*string:~*req.Account:dan"}, @@ -767,23 +767,23 @@ func TestLoaderProcessSuppliers(t *testing.T) { }, Sorting: "*least_cost", SortingParameters: []string{}, - Suppliers: []*engine.Supplier{ - &engine.Supplier{ - ID: "supplier1", - FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE"}, - AccountIDs: []string{"Account1", "Account1_1", "Account2"}, - RatingPlanIDs: []string{"RPL_1", "RPL_2", "RPL_3"}, - ResourceIDs: []string{"ResGroup1", "ResGroup2", "ResGroup3", "ResGroup4"}, - StatIDs: []string{"Stat1", "Stat2", "Stat3"}, - Weight: 10, - Blocker: true, - SupplierParameters: "param1", + Routes: []*engine.Route{ + &engine.Route{ + ID: "supplier1", + FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE"}, + AccountIDs: []string{"Account1", "Account1_1", "Account2"}, + RatingPlanIDs: []string{"RPL_1", "RPL_2", "RPL_3"}, + ResourceIDs: []string{"ResGroup1", "ResGroup2", "ResGroup3", "ResGroup4"}, + StatIDs: []string{"Stat1", "Stat2", "Stat3"}, + Weight: 10, + Blocker: true, + RouteParameters: "param1", }, }, Weight: 20, } - if aps, err := ldr.dm.GetSupplierProfile("cgrates.org", "SPP_1", + if aps, err := ldr.dm.GetRouteProfile("cgrates.org", "SPP_1", true, false, utils.NonTransactional); err != nil { t.Error(err) } else if !reflect.DeepEqual(eSp3, aps) { diff --git a/sessions/sessions_test.go b/sessions/sessions_test.go index 33ea760df..0fc1adb97 100644 --- a/sessions/sessions_test.go +++ b/sessions/sessions_test.go @@ -863,16 +863,16 @@ func TestSessionSNewV1AuthorizeArgs(t *testing.T) { t.Errorf("Expecting %+v, received: %+v", expected, rply) } expected = &V1AuthorizeArgs{ - GetAttributes: true, - AuthorizeResources: false, - GetMaxUsage: true, - ProcessThresholds: false, - ProcessStats: true, - GetSuppliers: false, - SuppliersIgnoreErrors: true, - SuppliersMaxCost: utils.MetaSuppliersEventCost, - CGREvent: cgrEv, - ForceDuration: true, + GetAttributes: true, + AuthorizeResources: false, + GetMaxUsage: true, + ProcessThresholds: false, + ProcessStats: true, + GetRoutes: false, + RoutesIgnoreErrors: true, + RoutesMaxCost: utils.MetaRoutesEventCost, + CGREvent: cgrEv, + ForceDuration: true, } rply = NewV1AuthorizeArgs(true, nil, false, nil, true, nil, false, true, false, true, true, cgrEv, nil, utils.Paginator{}, true, nil) if !reflect.DeepEqual(expected, rply) { @@ -883,18 +883,18 @@ func TestSessionSNewV1AuthorizeArgs(t *testing.T) { thresholdIDs := []string{"ID1", "ID2"} statIDs := []string{"test3", "test4"} expected = &V1AuthorizeArgs{ - GetAttributes: true, - AuthorizeResources: false, - GetMaxUsage: true, - ProcessThresholds: false, - ProcessStats: true, - GetSuppliers: false, - SuppliersIgnoreErrors: true, - SuppliersMaxCost: utils.MetaSuppliersEventCost, - CGREvent: cgrEv, - AttributeIDs: []string{"ATTR1", "ATTR2"}, - ThresholdIDs: []string{"ID1", "ID2"}, - StatIDs: []string{"test3", "test4"}, + GetAttributes: true, + AuthorizeResources: false, + GetMaxUsage: true, + ProcessThresholds: false, + ProcessStats: true, + GetRoutes: false, + RoutesIgnoreErrors: true, + RoutesMaxCost: utils.MetaRoutesEventCost, + CGREvent: cgrEv, + AttributeIDs: []string{"ATTR1", "ATTR2"}, + ThresholdIDs: []string{"ID1", "ID2"}, + StatIDs: []string{"test3", "test4"}, } rply = NewV1AuthorizeArgs(true, attributeIDs, false, thresholdIDs, true, statIDs, false, true, false, true, true, cgrEv, nil, utils.Paginator{}, false, nil) @@ -915,23 +915,23 @@ func TestV1AuthorizeArgsParseFlags(t *testing.T) { //normal check -> without *dispatchers cgrArgs, _ := utils.ExtractArgsFromOpts(v1authArgs.Opts, false, true) eOut = &V1AuthorizeArgs{ - GetMaxUsage: true, - AuthorizeResources: true, - GetSuppliers: true, - SuppliersIgnoreErrors: true, - SuppliersMaxCost: utils.MetaEventCost, - GetAttributes: true, - AttributeIDs: []string{"Attr1", "Attr2"}, - ProcessThresholds: true, - ThresholdIDs: []string{"tr1", "tr2", "tr3"}, - ProcessStats: true, - StatIDs: []string{"st1", "st2", "st3"}, - ArgDispatcher: cgrArgs.ArgDispatcher, - Paginator: *cgrArgs.SupplierPaginator, - ForceDuration: true, + GetMaxUsage: true, + AuthorizeResources: true, + GetRoutes: true, + RoutesIgnoreErrors: true, + RoutesMaxCost: utils.MetaEventCost, + GetAttributes: true, + AttributeIDs: []string{"Attr1", "Attr2"}, + ProcessThresholds: true, + ThresholdIDs: []string{"tr1", "tr2", "tr3"}, + ProcessStats: true, + StatIDs: []string{"st1", "st2", "st3"}, + ArgDispatcher: cgrArgs.ArgDispatcher, + Paginator: *cgrArgs.RoutePaginator, + ForceDuration: true, } - strArg = "*accounts,*fd,*resources,*suppliers,*suppliers_ignore_errors,*suppliers_event_cost,*attributes:Attr1;Attr2,*thresholds:tr1;tr2;tr3,*stats:st1;st2;st3" + strArg = "*accounts,*fd,*resources,*routes,*routes_ignore_errors,*routes_event_cost,*attributes:Attr1;Attr2,*thresholds:tr1;tr2;tr3,*stats:st1;st2;st3" v1authArgs.ParseFlags(strArg) if !reflect.DeepEqual(eOut, v1authArgs) { t.Errorf("Expecting %+v,\n received: %+v\n", utils.ToJSON(eOut), utils.ToJSON(v1authArgs)) @@ -939,23 +939,23 @@ func TestV1AuthorizeArgsParseFlags(t *testing.T) { // //normal check -> with *dispatchers cgrArgs, _ = utils.ExtractArgsFromOpts(v1authArgs.Opts, true, true) eOut = &V1AuthorizeArgs{ - GetMaxUsage: true, - AuthorizeResources: true, - GetSuppliers: true, - SuppliersIgnoreErrors: true, - SuppliersMaxCost: utils.MetaEventCost, - GetAttributes: true, - AttributeIDs: []string{"Attr1", "Attr2"}, - ProcessThresholds: true, - ThresholdIDs: []string{"tr1", "tr2", "tr3"}, - ProcessStats: true, - StatIDs: []string{"st1", "st2", "st3"}, - ArgDispatcher: cgrArgs.ArgDispatcher, - Paginator: *cgrArgs.SupplierPaginator, - ForceDuration: true, + GetMaxUsage: true, + AuthorizeResources: true, + GetRoutes: true, + RoutesIgnoreErrors: true, + RoutesMaxCost: utils.MetaEventCost, + GetAttributes: true, + AttributeIDs: []string{"Attr1", "Attr2"}, + ProcessThresholds: true, + ThresholdIDs: []string{"tr1", "tr2", "tr3"}, + ProcessStats: true, + StatIDs: []string{"st1", "st2", "st3"}, + ArgDispatcher: cgrArgs.ArgDispatcher, + Paginator: *cgrArgs.RoutePaginator, + ForceDuration: true, } - strArg = "*accounts,*fd,*resources,,*dispatchers,*suppliers,*suppliers_ignore_errors,*suppliers_event_cost,*attributes:Attr1;Attr2,*thresholds:tr1;tr2;tr3,*stats:st1;st2;st3" + strArg = "*accounts,*fd,*resources,,*dispatchers,*routes,*routes_ignore_errors,*routes_event_cost,*attributes:Attr1;Attr2,*thresholds:tr1;tr2;tr3,*stats:st1;st2;st3" v1authArgs.ParseFlags(strArg) if !reflect.DeepEqual(eOut, v1authArgs) { t.Errorf("Expecting %+v,\n received: %+v\n", utils.ToJSON(eOut), utils.ToJSON(v1authArgs)) @@ -1057,7 +1057,7 @@ func TestSessionSNewV1ProcessMessageArgs(t *testing.T) { Debit: true, GetAttributes: true, CGREvent: cgrEv, - GetSuppliers: true, + GetRoutes: true, ForceDuration: true, } rply := NewV1ProcessMessageArgs(true, nil, false, nil, false, @@ -1066,13 +1066,13 @@ func TestSessionSNewV1ProcessMessageArgs(t *testing.T) { t.Errorf("Expecting %+v, received: %+v", expected, rply) } expected = &V1ProcessMessageArgs{ - AllocateResources: true, - GetAttributes: true, - CGREvent: cgrEv, - GetSuppliers: true, - SuppliersMaxCost: utils.MetaSuppliersEventCost, - SuppliersIgnoreErrors: true, - ForceDuration: true, + AllocateResources: true, + GetAttributes: true, + CGREvent: cgrEv, + GetRoutes: true, + RoutesMaxCost: utils.MetaRoutesEventCost, + RoutesIgnoreErrors: true, + ForceDuration: true, } rply = NewV1ProcessMessageArgs(true, nil, false, nil, false, nil, true, false, true, true, true, cgrEv, nil, utils.Paginator{}, true, nil) @@ -1085,16 +1085,16 @@ func TestSessionSNewV1ProcessMessageArgs(t *testing.T) { statIDs := []string{"test3", "test4"} expected = &V1ProcessMessageArgs{ - AllocateResources: true, - GetAttributes: true, - CGREvent: cgrEv, - GetSuppliers: true, - SuppliersMaxCost: utils.MetaSuppliersEventCost, - SuppliersIgnoreErrors: true, - AttributeIDs: []string{"ATTR1", "ATTR2"}, - ThresholdIDs: []string{"ID1", "ID2"}, - StatIDs: []string{"test3", "test4"}, - ForceDuration: true, + AllocateResources: true, + GetAttributes: true, + CGREvent: cgrEv, + GetRoutes: true, + RoutesMaxCost: utils.MetaRoutesEventCost, + RoutesIgnoreErrors: true, + AttributeIDs: []string{"ATTR1", "ATTR2"}, + ThresholdIDs: []string{"ID1", "ID2"}, + StatIDs: []string{"test3", "test4"}, + ForceDuration: true, } rply = NewV1ProcessMessageArgs(true, attributeIDs, false, thresholdIDs, false, statIDs, true, false, true, true, true, cgrEv, nil, utils.Paginator{}, true, nil) @@ -1172,18 +1172,18 @@ func TestSessionSNewV1InitSessionArgs(t *testing.T) { } func TestSessionSV1AuthorizeReplyAsNavigableMap(t *testing.T) { - splrs := &engine.SortedSuppliers{ + splrs := &engine.SortedRoutes{ ProfileID: "SPL_ACNT_1001", Sorting: utils.MetaWeight, - SortedSuppliers: []*engine.SortedSupplier{ + SortedRoutes: []*engine.SortedRoute{ { - SupplierID: "supplier1", + RouteID: "supplier1", SortingData: map[string]interface{}{ "Weight": 20.0, }, }, { - SupplierID: "supplier2", + RouteID: "supplier2", SortingData: map[string]interface{}{ "Weight": 10.0, }, @@ -1214,7 +1214,7 @@ func TestSessionSV1AuthorizeReplyAsNavigableMap(t *testing.T) { Attributes: attrs, ResourceAllocation: utils.StringPointer("ResGr1"), MaxUsage: utils.DurationPointer(5 * time.Minute), - Suppliers: splrs, + Routes: splrs, ThresholdIDs: thIDs, StatQueueIDs: statIDs, } @@ -1222,7 +1222,7 @@ func TestSessionSV1AuthorizeReplyAsNavigableMap(t *testing.T) { utils.CapAttributes: map[string]interface{}{"OfficeGroup": "Marketing"}, utils.CapResourceAllocation: "ResGr1", utils.CapMaxUsage: 5 * time.Minute, - utils.CapSuppliers: splrs.AsNavigableMap(), + utils.CapRoutes: splrs.AsNavigableMap(), utils.CapThresholds: *thIDs, utils.CapStatQueues: *statIDs, }) @@ -1317,18 +1317,18 @@ func TestSessionSV1ProcessMessageReplyAsNavigableMap(t *testing.T) { t.Errorf("Expecting \n%+v\n, received: \n%+v", expected, rply) } - //test with Suppliers, ThresholdIDs, StatQueueIDs != nil + //test with Routes, ThresholdIDs, StatQueueIDs != nil tmpTresholdIDs := []string{"ID1", "ID2"} tmpStatQueueIDs := []string{"Que1", "Que2"} - tmpSuppliers := &engine.SortedSuppliers{ - ProfileID: "Supplier1", + tmpRoutes := &engine.SortedRoutes{ + ProfileID: "Route1", Count: 1, } - v1PrcEvRpl.Suppliers = tmpSuppliers + v1PrcEvRpl.Routes = tmpRoutes v1PrcEvRpl.ThresholdIDs = &tmpTresholdIDs v1PrcEvRpl.StatQueueIDs = &tmpStatQueueIDs expected.Set([]string{utils.CapResourceAllocation}, "ResGr1", false, false) - expected.Set([]string{utils.CapSuppliers}, tmpSuppliers.AsNavigableMap(), false, false) + expected.Set([]string{utils.CapRoutes}, tmpRoutes.AsNavigableMap(), false, false) expected.Set([]string{utils.CapThresholds}, tmpTresholdIDs, false, false) expected.Set([]string{utils.CapStatQueues}, tmpStatQueueIDs, false, false) if rply, _ := v1PrcEvRpl.AsNavigableMap(nil); !reflect.DeepEqual(expected, rply) { @@ -1361,13 +1361,13 @@ func TestV1ProcessEventReplyAsNavigableMap(t *testing.T) { if rply, _ := v1per.AsNavigableMap(nil); !reflect.DeepEqual(expected, rply) { t.Errorf("Expecting \n%+v\n, received: \n%+v", expected, rply) } - //suppliers check - tmpSuppliers := &engine.SortedSuppliers{ - ProfileID: "Supplier1", + //routes check + tmpRoutes := &engine.SortedRoutes{ + ProfileID: "Route1", Count: 1, } - v1per.Suppliers = tmpSuppliers - expected.Set([]string{utils.CapSuppliers}, tmpSuppliers.AsNavigableMap(), false, false) + v1per.Routes = tmpRoutes + expected.Set([]string{utils.CapRoutes}, tmpRoutes.AsNavigableMap(), false, false) if rply, _ := v1per.AsNavigableMap(nil); !reflect.DeepEqual(expected, rply) { t.Errorf("Expecting \n%+v\n, received: \n%+v", expected, rply) } @@ -1511,20 +1511,20 @@ func TestSessionSNewV1AuthorizeArgsWithArgDispatcher(t *testing.T) { } cgrArgs, _ := utils.ExtractArgsFromOpts(opts, true, true) rply := NewV1AuthorizeArgs(true, nil, false, nil, false, nil, true, false, - false, false, false, cgrEv, cgrArgs.ArgDispatcher, *cgrArgs.SupplierPaginator, true, opts) + false, false, false, cgrEv, cgrArgs.ArgDispatcher, *cgrArgs.RoutePaginator, true, opts) if !reflect.DeepEqual(expected, rply) { t.Errorf("Expecting %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(rply)) } expected = &V1AuthorizeArgs{ - GetAttributes: true, - AuthorizeResources: false, - GetMaxUsage: true, - ProcessThresholds: false, - ProcessStats: true, - GetSuppliers: false, - SuppliersIgnoreErrors: true, - SuppliersMaxCost: utils.MetaSuppliersEventCost, - CGREvent: cgrEv, + GetAttributes: true, + AuthorizeResources: false, + GetMaxUsage: true, + ProcessThresholds: false, + ProcessStats: true, + GetRoutes: false, + RoutesIgnoreErrors: true, + RoutesMaxCost: utils.MetaRoutesEventCost, + CGREvent: cgrEv, ArgDispatcher: &utils.ArgDispatcher{ APIKey: utils.StringPointer("testkey"), RouteID: utils.StringPointer("testrouteid"), @@ -1533,7 +1533,7 @@ func TestSessionSNewV1AuthorizeArgsWithArgDispatcher(t *testing.T) { Opts: opts, } rply = NewV1AuthorizeArgs(true, nil, false, nil, true, nil, false, true, - false, true, true, cgrEv, cgrArgs.ArgDispatcher, *cgrArgs.SupplierPaginator, true, opts) + false, true, true, cgrEv, cgrArgs.ArgDispatcher, *cgrArgs.RoutePaginator, true, opts) if !reflect.DeepEqual(expected, rply) { t.Errorf("Expecting %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(rply)) } @@ -1563,20 +1563,20 @@ func TestSessionSNewV1AuthorizeArgsWithArgDispatcher2(t *testing.T) { } cgrArgs, _ := utils.ExtractArgsFromOpts(opts, true, true) rply := NewV1AuthorizeArgs(true, nil, false, nil, false, nil, true, false, false, - false, false, cgrEv, cgrArgs.ArgDispatcher, *cgrArgs.SupplierPaginator, true, opts) + false, false, cgrEv, cgrArgs.ArgDispatcher, *cgrArgs.RoutePaginator, true, opts) if !reflect.DeepEqual(expected, rply) { t.Errorf("Expecting %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(rply)) } expected = &V1AuthorizeArgs{ - GetAttributes: true, - AuthorizeResources: false, - GetMaxUsage: true, - ProcessThresholds: false, - ProcessStats: true, - GetSuppliers: false, - SuppliersIgnoreErrors: true, - SuppliersMaxCost: utils.MetaSuppliersEventCost, - CGREvent: cgrEv, + GetAttributes: true, + AuthorizeResources: false, + GetMaxUsage: true, + ProcessThresholds: false, + ProcessStats: true, + GetRoutes: false, + RoutesIgnoreErrors: true, + RoutesMaxCost: utils.MetaRoutesEventCost, + CGREvent: cgrEv, ArgDispatcher: &utils.ArgDispatcher{ RouteID: utils.StringPointer("testrouteid"), }, @@ -1584,7 +1584,7 @@ func TestSessionSNewV1AuthorizeArgsWithArgDispatcher2(t *testing.T) { Opts: opts, } rply = NewV1AuthorizeArgs(true, nil, false, nil, true, nil, false, true, false, - true, true, cgrEv, cgrArgs.ArgDispatcher, *cgrArgs.SupplierPaginator, true, opts) + true, true, cgrEv, cgrArgs.ArgDispatcher, *cgrArgs.RoutePaginator, true, opts) if !reflect.DeepEqual(expected, rply) { t.Errorf("Expecting %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(rply)) } @@ -1845,7 +1845,7 @@ func TestV1TerminateSessionArgsParseFlags(t *testing.T) { ArgDispatcher: cgrArgs.ArgDispatcher, } - strArg = "*accounts,*resources,*suppliers,*thresholds:tr1;tr2;tr3,*stats:st1;st2;st3" + strArg = "*accounts,*resources,*routes,*thresholds:tr1;tr2;tr3,*stats:st1;st2;st3" v1TerminateSsArgs.ParseFlags(strArg) if !reflect.DeepEqual(eOut, v1TerminateSsArgs) { t.Errorf("Expecting %+v,\n received: %+v\n", utils.ToJSON(eOut), utils.ToJSON(v1TerminateSsArgs)) @@ -1882,21 +1882,21 @@ func TestV1ProcessMessageArgsParseFlags(t *testing.T) { //normal check -> without *dispatchers cgrArgs, _ := utils.ExtractArgsFromOpts(v1ProcessMsgArgs.Opts, false, true) eOut = &V1ProcessMessageArgs{ - Debit: true, - AllocateResources: true, - GetSuppliers: true, - SuppliersIgnoreErrors: true, - SuppliersMaxCost: utils.MetaEventCost, - GetAttributes: true, - AttributeIDs: []string{"Attr1", "Attr2"}, - ProcessThresholds: true, - ThresholdIDs: []string{"tr1", "tr2", "tr3"}, - ProcessStats: true, - StatIDs: []string{"st1", "st2", "st3"}, - ArgDispatcher: cgrArgs.ArgDispatcher, + Debit: true, + AllocateResources: true, + GetRoutes: true, + RoutesIgnoreErrors: true, + RoutesMaxCost: utils.MetaEventCost, + GetAttributes: true, + AttributeIDs: []string{"Attr1", "Attr2"}, + ProcessThresholds: true, + ThresholdIDs: []string{"tr1", "tr2", "tr3"}, + ProcessStats: true, + StatIDs: []string{"st1", "st2", "st3"}, + ArgDispatcher: cgrArgs.ArgDispatcher, } - strArg = "*accounts,*resources,*suppliers,*suppliers_ignore_errors,*suppliers_event_cost,*attributes:Attr1;Attr2,*thresholds:tr1;tr2;tr3,*stats:st1;st2;st3" + strArg = "*accounts,*resources,*routes,*routes_ignore_errors,*routes_event_cost,*attributes:Attr1;Attr2,*thresholds:tr1;tr2;tr3,*stats:st1;st2;st3" v1ProcessMsgArgs.ParseFlags(strArg) if !reflect.DeepEqual(eOut, v1ProcessMsgArgs) { t.Errorf("Expecting %+v,\n received: %+v\n", utils.ToJSON(eOut), utils.ToJSON(v1ProcessMsgArgs)) @@ -1905,21 +1905,21 @@ func TestV1ProcessMessageArgsParseFlags(t *testing.T) { //normal check -> with *dispatchers cgrArgs, _ = utils.ExtractArgsFromOpts(v1ProcessMsgArgs.Opts, true, true) eOut = &V1ProcessMessageArgs{ - Debit: true, - AllocateResources: true, - GetSuppliers: true, - SuppliersIgnoreErrors: true, - SuppliersMaxCost: utils.MetaEventCost, - GetAttributes: true, - AttributeIDs: []string{"Attr1", "Attr2"}, - ProcessThresholds: true, - ThresholdIDs: []string{"tr1", "tr2", "tr3"}, - ProcessStats: true, - StatIDs: []string{"st1", "st2", "st3"}, - ArgDispatcher: cgrArgs.ArgDispatcher, + Debit: true, + AllocateResources: true, + GetRoutes: true, + RoutesIgnoreErrors: true, + RoutesMaxCost: utils.MetaEventCost, + GetAttributes: true, + AttributeIDs: []string{"Attr1", "Attr2"}, + ProcessThresholds: true, + ThresholdIDs: []string{"tr1", "tr2", "tr3"}, + ProcessStats: true, + StatIDs: []string{"st1", "st2", "st3"}, + ArgDispatcher: cgrArgs.ArgDispatcher, } - strArg = "*accounts,*resources,*dispatchers,*suppliers,*suppliers_ignore_errors,*suppliers_event_cost,*attributes:Attr1;Attr2,*thresholds:tr1;tr2;tr3,*stats:st1;st2;st3" + strArg = "*accounts,*resources,*dispatchers,*routes,*routes_ignore_errors,*routes_event_cost,*attributes:Attr1;Attr2,*thresholds:tr1;tr2;tr3,*stats:st1;st2;st3" v1ProcessMsgArgs.ParseFlags(strArg) if !reflect.DeepEqual(eOut, v1ProcessMsgArgs) { t.Errorf("Expecting %+v,\n received: %+v\n", utils.ToJSON(eOut), utils.ToJSON(v1ProcessMsgArgs)) @@ -2052,7 +2052,7 @@ func TestSessionSfilterSessions(t *testing.T) { "Extra3": "", "LastUsed": "21s", "PDD": "300ms", - "Supplier": "supplier1", + utils.SUPPLIER: "supplier1", }, NodeID: sSCfg.GeneralCfg().NodeID, } @@ -2077,7 +2077,7 @@ func TestSessionSfilterSessions(t *testing.T) { "Extra3": "", "LastUsed": "21s", "PDD": "300ms", - "Supplier": "supplier1", + utils.SUPPLIER: "supplier1", }, NodeID: sSCfg.GeneralCfg().NodeID, } diff --git a/utils/apitpdata_test.go b/utils/apitpdata_test.go index 0828267eb..3ffb5b8a8 100644 --- a/utils/apitpdata_test.go +++ b/utils/apitpdata_test.go @@ -992,7 +992,7 @@ func TestInitAttrReloadCache(t *testing.T) { expected.ThresholdIDs = &[]string{} expected.ThresholdProfileIDs = &[]string{} expected.FilterIDs = &[]string{} - expected.SupplierProfileIDs = &[]string{} + expected.RouteProfileIDs = &[]string{} expected.AttributeProfileIDs = &[]string{} expected.ChargerProfileIDs = &[]string{} expected.DispatcherProfileIDs = &[]string{} diff --git a/utils/cgrevent_test.go b/utils/cgrevent_test.go index ef663f6c9..29aa88522 100644 --- a/utils/cgrevent_test.go +++ b/utils/cgrevent_test.go @@ -101,7 +101,7 @@ func TestCGREventFielAsString(t *testing.T) { } -func TestLibSuppliersUsage(t *testing.T) { +func TestLibRoutesUsage(t *testing.T) { se := &CGREvent{ Tenant: "cgrates.org", ID: "supplierEvent1", @@ -328,7 +328,7 @@ func TestCGREventconsumeArgDispatcher(t *testing.T) { } } -func TestCGREventconsumeSupplierPaginator(t *testing.T) { +func TestCGREventconsumeRoutePaginator(t *testing.T) { //empty check var opts map[string]interface{} rcv, err := getSupplierPaginatorFromOpts(opts) @@ -440,8 +440,8 @@ func TestCGREventConsumeArgs(t *testing.T) { } //true false eOut = ExtractedArgs{ - ArgDispatcher: new(ArgDispatcher), - SupplierPaginator: nil, + ArgDispatcher: new(ArgDispatcher), + RoutePaginator: nil, } rcv, err = ExtractArgsFromOpts(opts, true, false) if err != nil {