mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-17 22:29:55 +05:00
Improve dynamicDP for AttributeS and create libphonenumberDP
This commit is contained in:
committed by
Dan Christian Bogos
parent
39ca3307c1
commit
83a0a6ef1b
@@ -60,6 +60,7 @@ func (objDP *ObjectDP) FieldAsInterface(fldPath []string) (data interface{}, err
|
||||
if data, has = objDP.getCache(strings.Join(fldPath, utils.NestingSep)); has {
|
||||
return
|
||||
}
|
||||
data = obj // in case the fldPath is empty we need to return the whole object
|
||||
var prevFld string
|
||||
for _, fld := range fldPath {
|
||||
var slctrStr string
|
||||
|
||||
@@ -205,7 +205,7 @@ func (attr *AttrArgsProcessEvent) Clone() *AttrArgsProcessEvent {
|
||||
}
|
||||
|
||||
// processEvent will match event with attribute profile and do the necessary replacements
|
||||
func (alS *AttributeService) processEvent(args *AttrArgsProcessEvent, evNm utils.MapStorage, lastID string) (
|
||||
func (alS *AttributeService) processEvent(args *AttrArgsProcessEvent, evNm utils.MapStorage, dynDP utils.DataProvider, lastID string) (
|
||||
rply *AttrSProcessEventReply, err error) {
|
||||
var attrPrf *AttributeProfile
|
||||
if attrPrf, err = alS.attributeProfileForEvent(args, evNm, lastID); err != nil {
|
||||
@@ -235,21 +235,18 @@ func (alS *AttributeService) processEvent(args *AttrArgsProcessEvent, evNm utils
|
||||
case utils.META_CONSTANT:
|
||||
substitute, err = attribute.Value.ParseValue(utils.EmptyString)
|
||||
case utils.MetaVariable, utils.META_COMPOSED:
|
||||
substitute, err = attribute.Value.ParseDataProvider(newDynamicDP(alS.cgrcfg.AttributeSCfg().ResourceSConns,
|
||||
alS.cgrcfg.AttributeSCfg().StatSConns, alS.cgrcfg.AttributeSCfg().ApierSConns, args.Tenant, evNm))
|
||||
substitute, err = attribute.Value.ParseDataProvider(dynDP)
|
||||
case utils.META_USAGE_DIFFERENCE:
|
||||
if len(attribute.Value) != 2 {
|
||||
return nil, fmt.Errorf("invalid arguments <%s>", utils.ToJSON(attribute.Value))
|
||||
}
|
||||
var strVal1 string
|
||||
if strVal1, err = attribute.Value[0].ParseDataProvider(newDynamicDP(alS.cgrcfg.AttributeSCfg().ResourceSConns,
|
||||
alS.cgrcfg.AttributeSCfg().StatSConns, alS.cgrcfg.AttributeSCfg().ApierSConns, args.Tenant, evNm)); err != nil {
|
||||
if strVal1, err = attribute.Value[0].ParseDataProvider(dynDP); err != nil {
|
||||
rply = nil
|
||||
return
|
||||
}
|
||||
var strVal2 string
|
||||
if strVal2, err = attribute.Value[1].ParseDataProvider(newDynamicDP(alS.cgrcfg.AttributeSCfg().ResourceSConns,
|
||||
alS.cgrcfg.AttributeSCfg().StatSConns, alS.cgrcfg.AttributeSCfg().ApierSConns, args.Tenant, evNm)); err != nil {
|
||||
if strVal2, err = attribute.Value[1].ParseDataProvider(dynDP); err != nil {
|
||||
rply = nil
|
||||
return
|
||||
}
|
||||
@@ -266,8 +263,7 @@ func (alS *AttributeService) processEvent(args *AttrArgsProcessEvent, evNm utils
|
||||
substitute = tEnd.Sub(tStart).String()
|
||||
case utils.MetaSum:
|
||||
var ifaceVals []interface{}
|
||||
if ifaceVals, err = attribute.Value.GetIfaceFromValues(newDynamicDP(alS.cgrcfg.AttributeSCfg().ResourceSConns,
|
||||
alS.cgrcfg.AttributeSCfg().StatSConns, alS.cgrcfg.AttributeSCfg().ApierSConns, args.Tenant, evNm)); err != nil {
|
||||
if ifaceVals, err = attribute.Value.GetIfaceFromValues(dynDP); err != nil {
|
||||
rply = nil
|
||||
return
|
||||
}
|
||||
@@ -279,8 +275,7 @@ func (alS *AttributeService) processEvent(args *AttrArgsProcessEvent, evNm utils
|
||||
substitute = utils.IfaceAsString(ifaceSum)
|
||||
case utils.MetaDifference:
|
||||
var ifaceVals []interface{}
|
||||
if ifaceVals, err = attribute.Value.GetIfaceFromValues(newDynamicDP(alS.cgrcfg.AttributeSCfg().ResourceSConns,
|
||||
alS.cgrcfg.AttributeSCfg().StatSConns, alS.cgrcfg.AttributeSCfg().ApierSConns, args.Tenant, evNm)); err != nil {
|
||||
if ifaceVals, err = attribute.Value.GetIfaceFromValues(dynDP); err != nil {
|
||||
rply = nil
|
||||
return
|
||||
}
|
||||
@@ -292,8 +287,7 @@ func (alS *AttributeService) processEvent(args *AttrArgsProcessEvent, evNm utils
|
||||
substitute = utils.IfaceAsString(ifaceSum)
|
||||
case utils.MetaMultiply:
|
||||
var ifaceVals []interface{}
|
||||
if ifaceVals, err = attribute.Value.GetIfaceFromValues(newDynamicDP(alS.cgrcfg.AttributeSCfg().ResourceSConns,
|
||||
alS.cgrcfg.AttributeSCfg().StatSConns, alS.cgrcfg.AttributeSCfg().ApierSConns, args.Tenant, evNm)); err != nil {
|
||||
if ifaceVals, err = attribute.Value.GetIfaceFromValues(dynDP); err != nil {
|
||||
rply = nil
|
||||
return
|
||||
}
|
||||
@@ -305,8 +299,7 @@ func (alS *AttributeService) processEvent(args *AttrArgsProcessEvent, evNm utils
|
||||
substitute = utils.IfaceAsString(ifaceSum)
|
||||
case utils.MetaDivide:
|
||||
var ifaceVals []interface{}
|
||||
if ifaceVals, err = attribute.Value.GetIfaceFromValues(newDynamicDP(alS.cgrcfg.AttributeSCfg().ResourceSConns,
|
||||
alS.cgrcfg.AttributeSCfg().StatSConns, alS.cgrcfg.AttributeSCfg().ApierSConns, args.Tenant, evNm)); err != nil {
|
||||
if ifaceVals, err = attribute.Value.GetIfaceFromValues(dynDP); err != nil {
|
||||
rply = nil
|
||||
return
|
||||
}
|
||||
@@ -322,8 +315,7 @@ func (alS *AttributeService) processEvent(args *AttrArgsProcessEvent, evNm utils
|
||||
utils.ToJSON(attribute.Value), utils.MetaValueExponent)
|
||||
}
|
||||
var strVal1 string
|
||||
if strVal1, err = attribute.Value[0].ParseDataProvider(newDynamicDP(alS.cgrcfg.AttributeSCfg().ResourceSConns,
|
||||
alS.cgrcfg.AttributeSCfg().StatSConns, alS.cgrcfg.AttributeSCfg().ApierSConns, args.Tenant, evNm)); err != nil {
|
||||
if strVal1, err = attribute.Value[0].ParseDataProvider(dynDP); err != nil {
|
||||
rply = nil
|
||||
return
|
||||
}
|
||||
@@ -333,8 +325,7 @@ func (alS *AttributeService) processEvent(args *AttrArgsProcessEvent, evNm utils
|
||||
strVal1, utils.MetaValueExponent)
|
||||
}
|
||||
var strVal2 string
|
||||
if strVal2, err = attribute.Value[1].ParseDataProvider(newDynamicDP(alS.cgrcfg.AttributeSCfg().ResourceSConns,
|
||||
alS.cgrcfg.AttributeSCfg().StatSConns, alS.cgrcfg.AttributeSCfg().ApierSConns, args.Tenant, evNm)); err != nil {
|
||||
if strVal2, err = attribute.Value[1].ParseDataProvider(dynDP); err != nil {
|
||||
rply = nil
|
||||
return
|
||||
}
|
||||
@@ -347,8 +338,7 @@ func (alS *AttributeService) processEvent(args *AttrArgsProcessEvent, evNm utils
|
||||
alS.cgrcfg.GeneralCfg().RoundingDecimals, utils.ROUNDING_MIDDLE), 'f', -1, 64)
|
||||
case utils.MetaUnixTimestamp:
|
||||
var val string
|
||||
if val, err = attribute.Value.ParseDataProvider(newDynamicDP(alS.cgrcfg.AttributeSCfg().ResourceSConns,
|
||||
alS.cgrcfg.AttributeSCfg().StatSConns, alS.cgrcfg.AttributeSCfg().ApierSConns, args.Tenant, evNm)); err != nil {
|
||||
if val, err = attribute.Value.ParseDataProvider(dynDP); err != nil {
|
||||
rply = nil
|
||||
return
|
||||
}
|
||||
@@ -359,8 +349,7 @@ func (alS *AttributeService) processEvent(args *AttrArgsProcessEvent, evNm utils
|
||||
}
|
||||
substitute = strconv.Itoa(int(t.Unix()))
|
||||
default: // backwards compatible in case that Type is empty
|
||||
substitute, err = attribute.Value.ParseDataProvider(newDynamicDP(alS.cgrcfg.AttributeSCfg().ResourceSConns,
|
||||
alS.cgrcfg.AttributeSCfg().StatSConns, alS.cgrcfg.AttributeSCfg().ApierSConns, args.Tenant, evNm))
|
||||
substitute, err = attribute.Value.ParseDataProvider(dynDP)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@@ -446,10 +435,12 @@ func (alS *AttributeService) V1ProcessEvent(args *AttrArgsProcessEvent,
|
||||
var lastID string
|
||||
matchedIDs := make([]string, 0, processRuns)
|
||||
alteredFields := make(utils.StringSet)
|
||||
dynDP := newDynamicDP(alS.cgrcfg.AttributeSCfg().ResourceSConns,
|
||||
alS.cgrcfg.AttributeSCfg().StatSConns, alS.cgrcfg.AttributeSCfg().ApierSConns, args.Tenant, eNV)
|
||||
for i := 0; i < processRuns; i++ {
|
||||
(eNV[utils.MetaVars].(utils.MapStorage))[utils.ProcessRuns] = utils.NewNMData(i + 1)
|
||||
var evRply *AttrSProcessEventReply
|
||||
evRply, err = alS.processEvent(args, eNV, lastID)
|
||||
evRply, err = alS.processEvent(args, eNV, dynDP, lastID)
|
||||
if err != nil {
|
||||
if err != utils.ErrNotFound {
|
||||
err = utils.NewErrServerError(err)
|
||||
|
||||
@@ -122,41 +122,115 @@ func (dDP *dynamicDP) fieldAsInterface(fldPath []string) (val interface{}, err e
|
||||
}
|
||||
return dDP.cache.FieldAsInterface(fldPath)
|
||||
case utils.MetaLibPhoneNumber:
|
||||
if len(fldPath) < 3 {
|
||||
return nil, fmt.Errorf("invalid fieldname <%s> for libphonenumber", fldPath)
|
||||
}
|
||||
// sample of fieldName ~*libphonenumber.*req.Destination
|
||||
// or ~*libphonenumber.*req.Destination.Carrier
|
||||
fieldFromDP, err := dDP.initialDP.FieldAsString(fldPath[1:3])
|
||||
if err != nil {
|
||||
utils.Logger.Warning(fmt.Sprintf("Received error: <%+v> when getting Destination for libphonenumber", err))
|
||||
return nil, err
|
||||
}
|
||||
num, err := phonenumbers.Parse(fieldFromDP, utils.EmptyString)
|
||||
// sample of fieldName ~*libphonenumber.<~*req.Destination>
|
||||
// or ~*libphonenumber.<~*req.Destination>.Carrier
|
||||
dp, err := newLibPhoneNumberDP(fldPath[1])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// add the fields from libphonenumber
|
||||
dDP.cache.Set([]string{utils.MetaLibPhoneNumber, fieldFromDP, "CountryCode"}, num.CountryCode)
|
||||
dDP.cache.Set([]string{utils.MetaLibPhoneNumber, fieldFromDP, "NationalNumber"}, num.GetNationalNumber())
|
||||
dDP.cache.Set([]string{utils.MetaLibPhoneNumber, fieldFromDP, "Region"}, phonenumbers.GetRegionCodeForNumber(num))
|
||||
dDP.cache.Set([]string{utils.MetaLibPhoneNumber, fieldFromDP, "NumberType"}, phonenumbers.GetNumberType(num))
|
||||
geoLocation, err := phonenumbers.GetGeocodingForNumber(num, phonenumbers.GetRegionCodeForNumber(num))
|
||||
if err != nil {
|
||||
utils.Logger.Warning(fmt.Sprintf("Received error: <%+v> when getting GeoLocation for number %+v", err, num))
|
||||
}
|
||||
dDP.cache.Set([]string{utils.MetaLibPhoneNumber, fieldFromDP, "GeoLocation"}, geoLocation)
|
||||
carrier, err := phonenumbers.GetCarrierForNumber(num, phonenumbers.GetRegionCodeForNumber(num))
|
||||
if err != nil {
|
||||
utils.Logger.Warning(fmt.Sprintf("Received error: <%+v> when getting Carrier for number %+v", err, num))
|
||||
}
|
||||
dDP.cache.Set([]string{utils.MetaLibPhoneNumber, fieldFromDP, "Carrier"}, carrier)
|
||||
path := []string{utils.MetaLibPhoneNumber, fieldFromDP}
|
||||
if len(fldPath) == 4 {
|
||||
path = append(path, fldPath[3])
|
||||
}
|
||||
return dDP.cache.FieldAsInterface(path)
|
||||
dDP.cache.Set(fldPath[:2], dp)
|
||||
return dp.FieldAsInterface(fldPath[2:])
|
||||
default: // in case of constant we give an empty DataProvider ( empty navigable map )
|
||||
}
|
||||
return nil, utils.ErrNotFound
|
||||
}
|
||||
|
||||
func newLibPhoneNumberDP(number string) (dp utils.DataProvider, err error) {
|
||||
num, err := phonenumbers.Parse(number, utils.EmptyString)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &libphonenumberDP{pNumber: num, cache: make(utils.MapStorage)}, nil
|
||||
|
||||
}
|
||||
|
||||
type libphonenumberDP struct {
|
||||
pNumber *phonenumbers.PhoneNumber
|
||||
cache utils.MapStorage
|
||||
}
|
||||
|
||||
func (dDP *libphonenumberDP) String() string { return dDP.pNumber.String() }
|
||||
|
||||
func (dDP *libphonenumberDP) FieldAsString(fldPath []string) (string, error) {
|
||||
val, err := dDP.FieldAsInterface(fldPath)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return utils.IfaceAsString(val), nil
|
||||
}
|
||||
|
||||
func (dDP *libphonenumberDP) RemoteHost() net.Addr {
|
||||
return utils.LocalAddr()
|
||||
}
|
||||
|
||||
func (dDP *libphonenumberDP) FieldAsInterface(fldPath []string) (val interface{}, err error) {
|
||||
if len(fldPath) == 0 {
|
||||
dDP.initCache()
|
||||
val = dDP.cache
|
||||
return
|
||||
}
|
||||
val, err = dDP.cache.FieldAsInterface(fldPath)
|
||||
if err == utils.ErrNotFound { // in case not found in cache try to populate it
|
||||
return dDP.fieldAsInterface(fldPath)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (dDP *libphonenumberDP) fieldAsInterface(fldPath []string) (val interface{}, err error) {
|
||||
if len(fldPath) != 1 {
|
||||
return nil, fmt.Errorf("invalid field path <%+v> for libphonenumberDP", fldPath)
|
||||
}
|
||||
switch fldPath[0] {
|
||||
case "CountryCode":
|
||||
val = dDP.pNumber.CountryCode
|
||||
case "NationalNumber":
|
||||
val = dDP.pNumber.GetNationalNumber()
|
||||
case "Region":
|
||||
val = phonenumbers.GetRegionCodeForNumber(dDP.pNumber)
|
||||
case "NumberType":
|
||||
val = phonenumbers.GetNumberType(dDP.pNumber)
|
||||
case "GeoLocation":
|
||||
geoLocation, err := phonenumbers.GetGeocodingForNumber(dDP.pNumber, phonenumbers.GetRegionCodeForNumber(dDP.pNumber))
|
||||
if err != nil {
|
||||
utils.Logger.Warning(fmt.Sprintf("Received error: <%+v> when getting GeoLocation for number %+v", err, dDP.pNumber))
|
||||
}
|
||||
val = geoLocation
|
||||
case "Carrier":
|
||||
carrier, err := phonenumbers.GetCarrierForNumber(dDP.pNumber, phonenumbers.GetRegionCodeForNumber(dDP.pNumber))
|
||||
if err != nil {
|
||||
utils.Logger.Warning(fmt.Sprintf("Received error: <%+v> when getting Carrier for number %+v", err, dDP.pNumber))
|
||||
}
|
||||
val = carrier
|
||||
}
|
||||
dDP.cache[fldPath[0]] = val
|
||||
return
|
||||
}
|
||||
|
||||
func (dDP *libphonenumberDP) initCache() {
|
||||
if _, has := dDP.cache["CountryCode"]; !has {
|
||||
dDP.cache["CountryCode"] = dDP.pNumber.CountryCode
|
||||
}
|
||||
if _, has := dDP.cache["NationalNumber"]; !has {
|
||||
dDP.cache["NationalNumber"] = dDP.pNumber.GetNationalNumber()
|
||||
}
|
||||
if _, has := dDP.cache["Region"]; !has {
|
||||
dDP.cache["Region"] = phonenumbers.GetRegionCodeForNumber(dDP.pNumber)
|
||||
}
|
||||
if _, has := dDP.cache["NumberType"]; !has {
|
||||
dDP.cache["NumberType"] = phonenumbers.GetNumberType(dDP.pNumber)
|
||||
}
|
||||
if _, has := dDP.cache["GeoLocation"]; !has {
|
||||
geoLocation, err := phonenumbers.GetGeocodingForNumber(dDP.pNumber, phonenumbers.GetRegionCodeForNumber(dDP.pNumber))
|
||||
if err != nil {
|
||||
utils.Logger.Warning(fmt.Sprintf("Received error: <%+v> when getting GeoLocation for number %+v", err, dDP.pNumber))
|
||||
}
|
||||
dDP.cache["GeoLocation"] = geoLocation
|
||||
}
|
||||
if _, has := dDP.cache["Carrier"]; !has {
|
||||
carrier, err := phonenumbers.GetCarrierForNumber(dDP.pNumber, phonenumbers.GetRegionCodeForNumber(dDP.pNumber))
|
||||
if err != nil {
|
||||
utils.Logger.Warning(fmt.Sprintf("Received error: <%+v> when getting Carrier for number %+v", err, dDP.pNumber))
|
||||
}
|
||||
dDP.cache["Carrier"] = carrier
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,13 +297,14 @@ func TestAttributeProcessEvent(t *testing.T) {
|
||||
AlteredFields: []string{utils.MetaReq + utils.NestingSep + "Account"},
|
||||
CGREventWithOpts: attrEvs[0].CGREventWithOpts,
|
||||
}
|
||||
atrp, err := attrService.processEvent(attrEvs[0], utils.MapStorage{
|
||||
eNM := utils.MapStorage{
|
||||
utils.MetaReq: attrEvs[0].CGREvent.Event,
|
||||
utils.MetaOpts: attrEvs[0].Opts,
|
||||
utils.MetaVars: utils.MapStorage{
|
||||
utils.ProcessRuns: utils.NewNMData(0),
|
||||
},
|
||||
}, utils.EmptyString)
|
||||
}
|
||||
atrp, err := attrService.processEvent(attrEvs[0], eNM, newDynamicDP(nil, nil, nil, "cgrates.org", eNM), utils.EmptyString)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -314,13 +315,15 @@ func TestAttributeProcessEvent(t *testing.T) {
|
||||
|
||||
func TestAttributeProcessEventWithNotFound(t *testing.T) {
|
||||
attrEvs[3].CGREvent.Event["Account"] = "1010" //Field added in event after process
|
||||
if _, err := attrService.processEvent(attrEvs[3], utils.MapStorage{
|
||||
eNM := utils.MapStorage{
|
||||
utils.MetaReq: attrEvs[3].CGREvent.Event,
|
||||
utils.MetaOpts: attrEvs[3].Opts,
|
||||
utils.MetaVars: utils.MapStorage{
|
||||
utils.ProcessRuns: utils.NewNMData(0),
|
||||
},
|
||||
}, utils.EmptyString); err == nil || err != utils.ErrNotFound {
|
||||
}
|
||||
if _, err := attrService.processEvent(attrEvs[3], eNM,
|
||||
newDynamicDP(nil, nil, nil, "cgrates.org", eNM), utils.EmptyString); err == nil || err != utils.ErrNotFound {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
}
|
||||
@@ -333,13 +336,14 @@ func TestAttributeProcessEventWithIDs(t *testing.T) {
|
||||
AlteredFields: []string{utils.MetaReq + utils.NestingSep + "Account"},
|
||||
CGREventWithOpts: attrEvs[3].CGREventWithOpts,
|
||||
}
|
||||
if atrp, err := attrService.processEvent(attrEvs[3], utils.MapStorage{
|
||||
eNM := utils.MapStorage{
|
||||
utils.MetaReq: attrEvs[3].CGREvent.Event,
|
||||
utils.MetaOpts: attrEvs[3].Opts,
|
||||
utils.MetaVars: utils.MapStorage{
|
||||
utils.ProcessRuns: utils.NewNMData(0),
|
||||
},
|
||||
}, utils.EmptyString); err != nil {
|
||||
}
|
||||
if atrp, err := attrService.processEvent(attrEvs[3], eNM, newDynamicDP(nil, nil, nil, "cgrates.org", eNM), utils.EmptyString); err != nil {
|
||||
} else if !reflect.DeepEqual(eRply, atrp) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(eRply), utils.ToJSON(atrp))
|
||||
}
|
||||
@@ -2003,13 +2007,14 @@ func TestProcessAttributeConstant(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
rcv, err := attrService.processEvent(ev, utils.MapStorage{
|
||||
eNM := utils.MapStorage{
|
||||
utils.MetaReq: ev.CGREvent.Event,
|
||||
utils.MetaOpts: ev.Opts,
|
||||
utils.MetaVars: utils.MapStorage{
|
||||
utils.ProcessRuns: utils.NewNMData(0),
|
||||
},
|
||||
}, utils.EmptyString)
|
||||
}
|
||||
rcv, err := attrService.processEvent(ev, eNM, newDynamicDP(nil, nil, nil, "cgrates.org", eNM), utils.EmptyString)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -2065,13 +2070,14 @@ func TestProcessAttributeVariable(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
rcv, err := attrService.processEvent(ev, utils.MapStorage{
|
||||
eNM := utils.MapStorage{
|
||||
utils.MetaReq: ev.CGREvent.Event,
|
||||
utils.MetaOpts: ev.Opts,
|
||||
utils.MetaVars: utils.MapStorage{
|
||||
utils.ProcessRuns: utils.NewNMData(0),
|
||||
},
|
||||
}, utils.EmptyString)
|
||||
}
|
||||
rcv, err := attrService.processEvent(ev, eNM, newDynamicDP(nil, nil, nil, "cgrates.org", eNM), utils.EmptyString)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -2134,13 +2140,14 @@ func TestProcessAttributeComposed(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
rcv, err := attrService.processEvent(ev, utils.MapStorage{
|
||||
eNM := utils.MapStorage{
|
||||
utils.MetaReq: ev.CGREvent.Event,
|
||||
utils.MetaOpts: ev.Opts,
|
||||
utils.MetaVars: utils.MapStorage{
|
||||
utils.ProcessRuns: utils.NewNMData(0),
|
||||
},
|
||||
}, utils.EmptyString)
|
||||
}
|
||||
rcv, err := attrService.processEvent(ev, eNM, newDynamicDP(nil, nil, nil, "cgrates.org", eNM), utils.EmptyString)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -2198,13 +2205,14 @@ func TestProcessAttributeUsageDifference(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
rcv, err := attrService.processEvent(ev, utils.MapStorage{
|
||||
eNM := utils.MapStorage{
|
||||
utils.MetaReq: ev.CGREvent.Event,
|
||||
utils.MetaOpts: ev.Opts,
|
||||
utils.MetaVars: utils.MapStorage{
|
||||
utils.ProcessRuns: utils.NewNMData(0),
|
||||
},
|
||||
}, utils.EmptyString)
|
||||
}
|
||||
rcv, err := attrService.processEvent(ev, eNM, newDynamicDP(nil, nil, nil, "cgrates.org", eNM), utils.EmptyString)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -2262,13 +2270,14 @@ func TestProcessAttributeSum(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
rcv, err := attrService.processEvent(ev, utils.MapStorage{
|
||||
eNM := utils.MapStorage{
|
||||
utils.MetaReq: ev.CGREvent.Event,
|
||||
utils.MetaOpts: ev.Opts,
|
||||
utils.MetaVars: utils.MapStorage{
|
||||
utils.ProcessRuns: utils.NewNMData(0),
|
||||
},
|
||||
}, utils.EmptyString)
|
||||
}
|
||||
rcv, err := attrService.processEvent(ev, eNM, newDynamicDP(nil, nil, nil, "cgrates.org", eNM), utils.EmptyString)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -2326,13 +2335,14 @@ func TestProcessAttributeDiff(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
rcv, err := attrService.processEvent(ev, utils.MapStorage{
|
||||
eNM := utils.MapStorage{
|
||||
utils.MetaReq: ev.CGREvent.Event,
|
||||
utils.MetaOpts: ev.Opts,
|
||||
utils.MetaVars: utils.MapStorage{
|
||||
utils.ProcessRuns: utils.NewNMData(0),
|
||||
},
|
||||
}, utils.EmptyString)
|
||||
}
|
||||
rcv, err := attrService.processEvent(ev, eNM, newDynamicDP(nil, nil, nil, "cgrates.org", eNM), utils.EmptyString)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -2390,13 +2400,14 @@ func TestProcessAttributeMultiply(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
rcv, err := attrService.processEvent(ev, utils.MapStorage{
|
||||
eNM := utils.MapStorage{
|
||||
utils.MetaReq: ev.CGREvent.Event,
|
||||
utils.MetaOpts: ev.Opts,
|
||||
utils.MetaVars: utils.MapStorage{
|
||||
utils.ProcessRuns: utils.NewNMData(0),
|
||||
},
|
||||
}, utils.EmptyString)
|
||||
}
|
||||
rcv, err := attrService.processEvent(ev, eNM, newDynamicDP(nil, nil, nil, "cgrates.org", eNM), utils.EmptyString)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -2454,13 +2465,14 @@ func TestProcessAttributeDivide(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
rcv, err := attrService.processEvent(ev, utils.MapStorage{
|
||||
eNM := utils.MapStorage{
|
||||
utils.MetaReq: ev.CGREvent.Event,
|
||||
utils.MetaOpts: ev.Opts,
|
||||
utils.MetaVars: utils.MapStorage{
|
||||
utils.ProcessRuns: utils.NewNMData(0),
|
||||
},
|
||||
}, utils.EmptyString)
|
||||
}
|
||||
rcv, err := attrService.processEvent(ev, eNM, newDynamicDP(nil, nil, nil, "cgrates.org", eNM), utils.EmptyString)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -2518,13 +2530,14 @@ func TestProcessAttributeValueExponent(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
rcv, err := attrService.processEvent(ev, utils.MapStorage{
|
||||
eNM := utils.MapStorage{
|
||||
utils.MetaReq: ev.CGREvent.Event,
|
||||
utils.MetaOpts: ev.Opts,
|
||||
utils.MetaVars: utils.MapStorage{
|
||||
utils.ProcessRuns: utils.NewNMData(0),
|
||||
},
|
||||
}, utils.EmptyString)
|
||||
}
|
||||
rcv, err := attrService.processEvent(ev, eNM, newDynamicDP(nil, nil, nil, "cgrates.org", eNM), utils.EmptyString)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -2582,13 +2595,14 @@ func TestProcessAttributeUnixTimeStamp(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
rcv, err := attrService.processEvent(ev, utils.MapStorage{
|
||||
eNM := utils.MapStorage{
|
||||
utils.MetaReq: ev.CGREvent.Event,
|
||||
utils.MetaOpts: ev.Opts,
|
||||
utils.MetaVars: utils.MapStorage{
|
||||
utils.ProcessRuns: utils.NewNMData(0),
|
||||
},
|
||||
}, utils.EmptyString)
|
||||
}
|
||||
rcv, err := attrService.processEvent(ev, eNM, newDynamicDP(nil, nil, nil, "cgrates.org", eNM), utils.EmptyString)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
|
||||
@@ -538,7 +538,7 @@ func testAttributeSProcessEventWithLibPhoneNumber(t *testing.T) {
|
||||
Type: utils.MetaVariable,
|
||||
Value: config.RSRParsers{
|
||||
&config.RSRParser{
|
||||
Rules: "~*libphonenumber.*req.Destination",
|
||||
Rules: "~*libphonenumber.<~*req.Destination>",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user