CDR and related TOR -> ToR field

This commit is contained in:
DanB
2015-12-28 13:37:43 +01:00
parent b8f90ee94f
commit eadd0cbb79
50 changed files with 203 additions and 203 deletions

View File

@@ -113,7 +113,7 @@ func TestActionsLocalSetCdrlogActions(t *testing.T) {
t.Error("Unexpected error: ", err.Error())
} else if len(rcvedCdrs) != 1 {
t.Error("Unexpected number of CDRs returned: ", len(rcvedCdrs))
} else if rcvedCdrs[0].TOR != utils.MONETARY ||
} else if rcvedCdrs[0].ToR != utils.MONETARY ||
rcvedCdrs[0].OriginHost != "127.0.0.1" ||
rcvedCdrs[0].Source != CDRLOG ||
rcvedCdrs[0].RequestType != utils.META_PREPAID ||

View File

@@ -1212,7 +1212,7 @@ func TestActionCdrLogParamsWithOverload(t *testing.T) {
acnt := &Account{Id: "cgrates.org:dan2904"}
cdrlog := &Action{
ActionType: CDRLOG,
ExtraParameters: `{"Subject":"^rif","Destination":"^1234","TOR":"~action_tag:s/^at(.)$/0$1/","AccountId":"~account_id:s/^\\*(.*)$/$1/"}`,
ExtraParameters: `{"Subject":"^rif","Destination":"^1234","ToR":"~action_tag:s/^at(.)$/0$1/","AccountId":"~account_id:s/^\\*(.*)$/$1/"}`,
}
err := cdrLogAction(acnt, nil, cdrlog, Actions{
&Action{

View File

@@ -33,7 +33,7 @@ import (
func NewCDRFromExternalCDR(extCdr *ExternalCDR, timezone string) (*CDR, error) {
var err error
cdr := &CDR{CGRID: extCdr.CGRID, RunID: extCdr.RunID, OrderID: extCdr.OrderID, TOR: extCdr.TOR, OriginID: extCdr.OriginID, OriginHost: extCdr.OriginHost,
cdr := &CDR{CGRID: extCdr.CGRID, RunID: extCdr.RunID, OrderID: extCdr.OrderID, ToR: extCdr.ToR, OriginID: extCdr.OriginID, OriginHost: extCdr.OriginHost,
Source: extCdr.Source, RequestType: extCdr.RequestType, Direction: extCdr.Direction, Tenant: extCdr.Tenant, Category: extCdr.Category,
Account: extCdr.Account, Subject: extCdr.Subject, Destination: extCdr.Destination, Supplier: extCdr.Supplier,
DisconnectCause: extCdr.DisconnectCause, CostSource: extCdr.CostSource, Cost: extCdr.Cost, Rated: extCdr.Rated}
@@ -67,7 +67,7 @@ func NewCDRFromExternalCDR(extCdr *ExternalCDR, timezone string) (*CDR, error) {
}
func NewCDRWithDefaults(cfg *config.CGRConfig) *CDR {
return &CDR{TOR: utils.VOICE, RequestType: cfg.DefaultReqType, Direction: utils.OUT, Tenant: cfg.DefaultTenant, Category: cfg.DefaultCategory,
return &CDR{ToR: utils.VOICE, RequestType: cfg.DefaultReqType, Direction: utils.OUT, Tenant: cfg.DefaultTenant, Category: cfg.DefaultCategory,
ExtraFields: make(map[string]string), Cost: -1}
}
@@ -78,7 +78,7 @@ type CDR struct {
OriginHost string // represents the IP address of the host generating the CDR (automatically populated by the server)
Source string // formally identifies the source of the CDR (free form field)
OriginID string // represents the unique accounting id given by the telecom switch generating the CDR
TOR string // type of record, meta-field, should map to one of the TORs hardcoded inside the server <*voice|*data|*sms|*generic>
ToR string // type of record, meta-field, should map to one of the TORs hardcoded inside the server <*voice|*data|*sms|*generic>
RequestType string // matching the supported request types by the **CGRateS**, accepted values are hardcoded in the server <prepaid|postpaid|pseudoprepaid|rated>.
Direction string // matching the supported direction identifiers of the CGRateS <*out>
Tenant string // tenant whom this record belongs
@@ -126,7 +126,7 @@ func (cdr *CDR) FormatCost(shiftDecimals, roundDecimals int) string {
// Formats usage on export
func (cdr *CDR) FormatUsage(layout string) string {
if utils.IsSliceMember([]string{utils.DATA, utils.SMS, utils.GENERIC}, cdr.TOR) {
if utils.IsSliceMember([]string{utils.DATA, utils.SMS, utils.GENERIC}, cdr.ToR) {
return strconv.FormatFloat(utils.Round(cdr.Usage.Seconds(), 0, utils.ROUNDING_MIDDLE), 'f', -1, 64)
}
switch layout {
@@ -146,7 +146,7 @@ func (cdr *CDR) FieldAsString(rsrFld *utils.RSRField) string {
case utils.ORDERID:
return rsrFld.ParseValue(strconv.FormatInt(cdr.OrderID, 10))
case utils.TOR:
return rsrFld.ParseValue(cdr.TOR)
return rsrFld.ParseValue(cdr.ToR)
case utils.ACCID:
return rsrFld.ParseValue(cdr.OriginID)
case utils.CDRHOST:
@@ -197,7 +197,7 @@ func (cdr *CDR) ParseFieldValue(fieldId, fieldVal, timezone string) error {
var err error
switch fieldId {
case utils.TOR:
cdr.TOR += fieldVal
cdr.ToR += fieldVal
case utils.ACCID:
cdr.OriginID += fieldVal
case utils.REQTYPE:
@@ -291,7 +291,7 @@ func (cdr *CDR) AsHttpForm() url.Values {
for fld, val := range cdr.ExtraFields {
v.Set(fld, val)
}
v.Set(utils.TOR, cdr.TOR)
v.Set(utils.TOR, cdr.ToR)
v.Set(utils.ACCID, cdr.OriginID)
v.Set(utils.CDRHOST, cdr.OriginHost)
v.Set(utils.CDRSOURCE, cdr.Source)
@@ -411,7 +411,7 @@ func (cdr *CDR) ForkCdr(runId string, RequestTypeFld, directionFld, tenantFld, c
var err error
frkStorCdr := new(CDR)
frkStorCdr.CGRID = cdr.CGRID
frkStorCdr.TOR = cdr.TOR
frkStorCdr.ToR = cdr.ToR
frkStorCdr.RunID = runId
frkStorCdr.Cost = -1.0 // Default for non-rated CDR
frkStorCdr.OriginID = cdr.OriginID
@@ -442,7 +442,7 @@ func (cdr *CDR) ForkCdr(runId string, RequestTypeFld, directionFld, tenantFld, c
return nil, utils.NewErrMandatoryIeMissing(utils.SUBJECT, subjectFld.Id)
}
frkStorCdr.Destination = cdr.FieldAsString(destFld)
if primaryMandatory && len(frkStorCdr.Destination) == 0 && frkStorCdr.TOR == utils.VOICE {
if primaryMandatory && len(frkStorCdr.Destination) == 0 && frkStorCdr.ToR == utils.VOICE {
return nil, utils.NewErrMandatoryIeMissing(utils.DESTINATION, destFld.Id)
}
sTimeStr := cdr.FieldAsString(setupTimeFld)
@@ -497,7 +497,7 @@ func (cdr *CDR) AsExternalCDR() *ExternalCDR {
OriginHost: cdr.OriginHost,
Source: cdr.Source,
OriginID: cdr.OriginID,
TOR: cdr.TOR,
ToR: cdr.ToR,
RequestType: cdr.RequestType,
Direction: cdr.Direction,
Tenant: cdr.Tenant,
@@ -705,7 +705,7 @@ type ExternalCDR struct {
OriginHost string
Source string
OriginID string
TOR string
ToR string
RequestType string
Direction string
Tenant string
@@ -729,7 +729,7 @@ type ExternalCDR struct {
// Used when authorizing requests from outside, eg ApierV1.GetMaxUsage
type UsageRecord struct {
TOR string
ToR string
RequestType string
Direction string
Tenant string
@@ -745,7 +745,7 @@ type UsageRecord struct {
func (self *UsageRecord) AsStoredCdr(timezone string) (*CDR, error) {
var err error
cdr := &CDR{TOR: self.TOR, RequestType: self.RequestType, Direction: self.Direction, Tenant: self.Tenant, Category: self.Category,
cdr := &CDR{ToR: self.ToR, RequestType: self.RequestType, Direction: self.Direction, Tenant: self.Tenant, Category: self.Category,
Account: self.Account, Subject: self.Subject, Destination: self.Destination}
if cdr.SetupTime, err = utils.ParseTimeDetectLayout(self.SetupTime, timezone); err != nil {
return nil, err
@@ -768,7 +768,7 @@ func (self *UsageRecord) AsStoredCdr(timezone string) (*CDR, error) {
func (self *UsageRecord) AsCallDescriptor(timezone string) (*CallDescriptor, error) {
var err error
cd := &CallDescriptor{
TOR: self.TOR,
TOR: self.ToR,
Direction: self.Direction,
Tenant: self.Tenant,
Category: self.Category,

View File

@@ -34,7 +34,7 @@ func TestHttpJsonPost(t *testing.T) {
if !*testLocal {
return
}
cdrOut := &ExternalCDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf",
cdrOut := &ExternalCDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf",
OriginHost: "192.168.1.1",
Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org",
Category: "call", Account: "account1", Subject: "tgooiscs0014", Destination: "1002",

View File

@@ -33,13 +33,13 @@ func TestCDRInterfaces(t *testing.T) {
}
func TestNewCDRFromExternalCDR(t *testing.T) {
extCdr := &ExternalCDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE,
extCdr := &ExternalCDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE,
OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out",
Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", Supplier: "SUPPL1",
SetupTime: "2013-11-07T08:42:20Z", AnswerTime: "2013-11-07T08:42:26Z", RunID: utils.DEFAULT_RUNID,
Usage: "0.00000001", PDD: "7.0", ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01, Rated: true,
}
eStorCdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE,
eStorCdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE,
OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out",
Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", Supplier: "SUPPL1",
SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID,
@@ -53,7 +53,7 @@ func TestNewCDRFromExternalCDR(t *testing.T) {
}
func TestCDRClone(t *testing.T) {
storCdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE,
storCdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE,
OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out",
Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", Supplier: "SUPPL1",
SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID,
@@ -65,7 +65,7 @@ func TestCDRClone(t *testing.T) {
}
func TestFieldAsString(t *testing.T) {
cdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf",
cdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf",
OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org",
Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC),
AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID,
@@ -122,7 +122,7 @@ func TestFieldAsString(t *testing.T) {
}
func TestFieldsAsString(t *testing.T) {
cdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf",
cdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf",
OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org",
Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC),
AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID,
@@ -136,7 +136,7 @@ func TestFieldsAsString(t *testing.T) {
}
func TestPassesFieldFilter(t *testing.T) {
cdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf",
cdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf",
OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org",
Category: "call", Account: "1001", Subject: "1001", Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC),
AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID,
@@ -165,7 +165,7 @@ func TestPassesFieldFilter(t *testing.T) {
if pass, _ := cdr.PassesFieldFilter(acntPrefxFltr); pass {
t.Error("Passing filter")
}
torFltr, _ := utils.NewRSRField(`^TOR::*voice/`)
torFltr, _ := utils.NewRSRField(`^ToR::*voice/`)
if pass, _ := cdr.PassesFieldFilter(torFltr); !pass {
t.Error("Not passing filter")
}
@@ -281,7 +281,7 @@ func TestFormatUsage(t *testing.T) {
if cdr.FormatUsage("default") != "10" {
t.Error("Wrong usage format: ", cdr.FormatUsage("default"))
}
cdr = CDR{TOR: utils.DATA, Usage: time.Duration(1640113000000000)}
cdr = CDR{ToR: utils.DATA, Usage: time.Duration(1640113000000000)}
if cdr.FormatUsage("default") != "1640113" {
t.Error("Wrong usage format: ", cdr.FormatUsage("default"))
}
@@ -296,7 +296,7 @@ func TestFormatUsage(t *testing.T) {
}
func TestCDRAsHttpForm(t *testing.T) {
storCdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf",
storCdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf",
OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out",
Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002",
SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID,
@@ -358,7 +358,7 @@ func TestCDRAsHttpForm(t *testing.T) {
}
func TestCDRForkCdr(t *testing.T) {
storCdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE,
storCdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE,
OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out",
Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002",
SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), PDD: time.Duration(200) * time.Millisecond,
@@ -373,7 +373,7 @@ func TestCDRForkCdr(t *testing.T) {
if err != nil {
t.Error("Unexpected error received", err)
}
expctSplRatedCdr := &CDR{CGRID: storCdr.CGRID, TOR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED,
expctSplRatedCdr := &CDR{CGRID: storCdr.CGRID, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED,
Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002",
SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), PDD: time.Duration(200) * time.Millisecond, AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC),
Usage: time.Duration(10) * time.Second, Supplier: "suppl1", ExtraFields: map[string]string{"field_extr1": "val_extr1", "field_extr2": "valextr2"},
@@ -384,7 +384,7 @@ func TestCDRForkCdr(t *testing.T) {
}
func TestCDRForkCdrStaticVals(t *testing.T) {
storCdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf",
storCdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf",
OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out",
Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002",
SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID,
@@ -409,7 +409,7 @@ func TestCDRForkCdrStaticVals(t *testing.T) {
if err != nil {
t.Error("Unexpected error received", err)
}
expctRatedCdr2 := &CDR{CGRID: storCdr.CGRID, TOR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_POSTPAID,
expctRatedCdr2 := &CDR{CGRID: storCdr.CGRID, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_POSTPAID,
Direction: "*in", Tenant: "cgrates.com", Category: "premium_call", Account: "first_account", Subject: "first_subject", Destination: "1002",
SetupTime: time.Date(2013, 12, 7, 8, 42, 24, 0, time.UTC),
AnswerTime: time.Date(2013, 12, 7, 8, 42, 26, 0, time.UTC), Usage: time.Duration(12) * time.Second, PDD: time.Duration(3) * time.Second,
@@ -429,14 +429,14 @@ func TestCDRForkCdrStaticVals(t *testing.T) {
}
func TestCDRForkCdrFromMetaDefaults(t *testing.T) {
storCdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf",
storCdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf",
OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org",
Category: "call", Account: "1001", Subject: "1001", Destination: "1002",
SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID,
Usage: time.Duration(10) * time.Second, PDD: time.Duration(4) * time.Second, Supplier: "SUPPL3",
ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01,
}
expctCdr := &CDR{CGRID: storCdr.CGRID, TOR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED,
expctCdr := &CDR{CGRID: storCdr.CGRID, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED,
Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002",
SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC),
Usage: time.Duration(10) * time.Second, PDD: time.Duration(4) * time.Second, Supplier: "SUPPL3", Cost: 1.01,
@@ -463,13 +463,13 @@ func TestCDRForkCdrFromMetaDefaults(t *testing.T) {
}
func TestCDRAsExternalCDR(t *testing.T) {
storCdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE,
storCdr := CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE,
OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out",
Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002",
SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID,
Usage: time.Duration(10), PDD: time.Duration(7) * time.Second, Supplier: "SUPPL1",
ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01}
expectOutCdr := &ExternalCDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE,
expectOutCdr := &ExternalCDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE,
OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out",
Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002",
SetupTime: "2013-11-07T08:42:20Z", AnswerTime: "2013-11-07T08:42:26Z", RunID: utils.DEFAULT_RUNID,
@@ -481,7 +481,7 @@ func TestCDRAsExternalCDR(t *testing.T) {
}
func TestCDREventFields(t *testing.T) {
cdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf",
cdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf",
OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "dan", Subject: "dans",
Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 27, 0, time.UTC),
RunID: utils.DEFAULT_RUNID, Usage: time.Duration(10) * time.Second, Supplier: "suppl1",
@@ -547,11 +547,11 @@ func TestCDREventFields(t *testing.T) {
}
func TesUsageReqAsCDR(t *testing.T) {
setupReq := &UsageRecord{TOR: utils.VOICE, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call",
setupReq := &UsageRecord{ToR: utils.VOICE, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call",
Account: "1001", Subject: "1001", Destination: "1002",
SetupTime: "2013-11-07T08:42:20Z", AnswerTime: "2013-11-07T08:42:26Z", Usage: "0.00000001",
}
eStorCdr := &CDR{TOR: utils.VOICE, RequestType: utils.META_RATED, Direction: "*out",
eStorCdr := &CDR{ToR: utils.VOICE, RequestType: utils.META_RATED, Direction: "*out",
Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002",
SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), Usage: time.Duration(10)}
if CDR, err := setupReq.AsStoredCdr(""); err != nil {
@@ -562,11 +562,11 @@ func TesUsageReqAsCDR(t *testing.T) {
}
func TestUsageReqAsCD(t *testing.T) {
req := &UsageRecord{TOR: utils.VOICE, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call",
req := &UsageRecord{ToR: utils.VOICE, RequestType: utils.META_RATED, Direction: "*out", Tenant: "cgrates.org", Category: "call",
Account: "1001", Subject: "1001", Destination: "1002",
SetupTime: "2013-11-07T08:42:20Z", AnswerTime: "2013-11-07T08:42:26Z", Usage: "0.00000001",
}
eCD := &CallDescriptor{TOR: req.TOR, Direction: req.Direction,
eCD := &CallDescriptor{TOR: req.ToR, Direction: req.Direction,
Tenant: req.Tenant, Category: req.Category, Account: req.Account, Subject: req.Subject, Destination: req.Destination,
TimeStart: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), TimeEnd: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).Add(time.Duration(10))}
if cd, err := req.AsCallDescriptor(""); err != nil {

View File

@@ -135,7 +135,7 @@ func (self *CdrServer) RateCDRs(cgrIds, runIds, tors, cdrHosts, cdrSources, Requ
} else if rerateRated {
costStart = utils.Float64Pointer(0.0)
}
cdrs, _, err := self.cdrDb.GetCDRs(&utils.CDRsFilter{CGRIDs: cgrIds, RunIDs: runIds, TORs: tors, Sources: cdrSources,
cdrs, _, err := self.cdrDb.GetCDRs(&utils.CDRsFilter{CGRIDs: cgrIds, RunIDs: runIds, ToRs: tors, Sources: cdrSources,
RequestTypes: RequestTypes, Directions: directions, Tenants: tenants, Categories: categories, Accounts: accounts,
Subjects: subjects, DestinationPrefixes: destPrefixes,
OrderIDStart: orderIdStart, OrderIDEnd: orderIdEnd, AnswerTimeStart: &timeStart, AnswerTimeEnd: &timeEnd,
@@ -355,7 +355,7 @@ func (self *CdrServer) getCostFromRater(cdr *CDR) (*CallCost, error) {
timeStart = cdr.SetupTime
}
cd := &CallDescriptor{
TOR: cdr.TOR,
TOR: cdr.ToR,
Direction: cdr.Direction,
Tenant: cdr.Tenant,
Category: cdr.Category,

View File

@@ -94,7 +94,7 @@ func (cs *CdrStats) AcceptCdr(cdr *CDR) bool {
return false
}
}
if len(cs.TOR) > 0 && !utils.IsSliceMember(cs.TOR, cdr.TOR) {
if len(cs.TOR) > 0 && !utils.IsSliceMember(cs.TOR, cdr.ToR) {
return false
}
if len(cs.CdrHost) > 0 && !utils.IsSliceMember(cs.CdrHost, cdr.OriginHost) {

View File

@@ -61,7 +61,7 @@ func (cgrCdr CgrCdr) getExtraFields() map[string]string {
func (cgrCdr CgrCdr) AsStoredCdr(timezone string) *CDR {
storCdr := new(CDR)
storCdr.CGRID = cgrCdr.getCGRID(timezone)
storCdr.TOR = cgrCdr[utils.TOR]
storCdr.ToR = cgrCdr[utils.TOR]
storCdr.OriginID = cgrCdr[utils.ACCID]
storCdr.OriginHost = cgrCdr[utils.CDRHOST]
storCdr.Source = cgrCdr[utils.CDRSOURCE]

View File

@@ -40,7 +40,7 @@ func TestCgrCdrAsCDR(t *testing.T) {
utils.ACCOUNT: "1001", utils.SUBJECT: "1001", utils.DESTINATION: "1002", utils.SETUP_TIME: "2013-11-07T08:42:20Z", utils.ANSWER_TIME: "2013-11-07T08:42:26Z",
utils.USAGE: "10", utils.SUPPLIER: "SUPPL1", "field_extr1": "val_extr1", "fieldextr2": "valextr2"}
setupTime, _ := utils.ParseTimeDetectLayout(cgrCdr[utils.SETUP_TIME], "")
expctRtCdr := &CDR{CGRID: utils.Sha1(cgrCdr[utils.ACCID], setupTime.String()), TOR: utils.VOICE, OriginID: cgrCdr[utils.ACCID], OriginHost: cgrCdr[utils.CDRHOST],
expctRtCdr := &CDR{CGRID: utils.Sha1(cgrCdr[utils.ACCID], setupTime.String()), ToR: utils.VOICE, OriginID: cgrCdr[utils.ACCID], OriginHost: cgrCdr[utils.CDRHOST],
Source: cgrCdr[utils.CDRSOURCE],
RequestType: cgrCdr[utils.REQTYPE],
Direction: cgrCdr[utils.DIRECTION], Tenant: cgrCdr[utils.TENANT], Category: cgrCdr[utils.CATEGORY], Account: cgrCdr[utils.ACCOUNT], Subject: cgrCdr[utils.SUBJECT],
@@ -60,7 +60,7 @@ func TestReplicatedCgrCdrAsCDR(t *testing.T) {
utils.ACCOUNT: "1001", utils.SUBJECT: "1001", utils.DESTINATION: "1002", utils.SETUP_TIME: "2013-11-07T08:42:20Z", utils.PDD: "0.200", utils.ANSWER_TIME: "2013-11-07T08:42:26Z",
utils.USAGE: "10", utils.SUPPLIER: "SUPPL1", utils.DISCONNECT_CAUSE: "NORMAL_CLEARING", utils.COST: "0.12", utils.RATED: "true", "field_extr1": "val_extr1", "fieldextr2": "valextr2"}
expctRtCdr := &CDR{CGRID: cgrCdr[utils.CGRID],
TOR: cgrCdr[utils.TOR],
ToR: cgrCdr[utils.TOR],
OriginID: cgrCdr[utils.ACCID],
OriginHost: cgrCdr[utils.CDRHOST],
Source: cgrCdr[utils.CDRSOURCE],

View File

@@ -121,7 +121,7 @@ func (fsCdr FSCdr) searchExtraField(field string, body map[string]interface{}) (
func (fsCdr FSCdr) AsStoredCdr(timezone string) *CDR {
storCdr := new(CDR)
storCdr.CGRID = fsCdr.getCGRID(timezone)
storCdr.TOR = utils.VOICE
storCdr.ToR = utils.VOICE
storCdr.OriginID = fsCdr.vars[FS_UUID]
storCdr.OriginHost = fsCdr.vars[FS_IP]
storCdr.Source = FS_CDR_SOURCE

View File

@@ -55,7 +55,7 @@ func TestCDRFields(t *testing.T) {
}
setupTime, _ := utils.ParseTimeDetectLayout("1436280728", "")
answerTime, _ := utils.ParseTimeDetectLayout("1436280728", "")
expctCDR := &CDR{CGRID: "164b0422fdc6a5117031b427439482c6a4f90e41", TOR: utils.VOICE, OriginID: "e3133bf7-dcde-4daf-9663-9a79ffcef5ad",
expctCDR := &CDR{CGRID: "164b0422fdc6a5117031b427439482c6a4f90e41", ToR: utils.VOICE, OriginID: "e3133bf7-dcde-4daf-9663-9a79ffcef5ad",
OriginHost: "127.0.0.1", Source: "freeswitch_json", Direction: utils.OUT, Category: "call", RequestType: utils.META_PREPAID, Tenant: "cgrates.org", Account: "1001", Subject: "1001",
Destination: "1003", SetupTime: setupTime, PDD: time.Duration(28) * time.Millisecond, AnswerTime: answerTime, Usage: time.Duration(66) * time.Second, Supplier: "supplier1",
DisconnectCause: "NORMAL_CLEARING", ExtraFields: map[string]string{"sip_user_agent": "PJSUA v2.3 Linux-3.2.0.4/x86_64/glibc-2.13"}, Cost: -1}

View File

@@ -56,7 +56,7 @@ func TestResponderGetDerivedChargers(t *testing.T) {
func TestResponderGetDerivedMaxSessionTime(t *testing.T) {
testTenant := "vdf"
cdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf",
cdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf",
OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_RATED, Direction: "*out", Tenant: testTenant, Category: "call", Account: "dan", Subject: "dan",
Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC),
RunID: utils.DEFAULT_RUNID, Usage: time.Duration(10) * time.Second, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"},
@@ -122,7 +122,7 @@ func TestResponderGetDerivedMaxSessionTime(t *testing.T) {
func TestResponderGetSessionRuns(t *testing.T) {
testTenant := "vdf"
cdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, TOR: utils.VOICE, OriginID: "dsafdsaf",
cdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf",
OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_PREPAID, Direction: "*out", Tenant: testTenant, Category: "call", Account: "dan2", Subject: "dan2",
Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), PDD: 3 * time.Second,
AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), Supplier: "suppl1",

View File

@@ -56,7 +56,7 @@ func TestStatsValue(t *testing.T) {
func TestStatsSimplifyCDR(t *testing.T) {
cdr := &CDR{
TOR: "tor",
ToR: "tor",
OriginID: "accid",
OriginHost: "cdrhost",
Source: "cdrsource",
@@ -85,7 +85,7 @@ func TestStatsSimplifyCDR(t *testing.T) {
func TestAcceptCdr(t *testing.T) {
sq := NewStatsQueue(nil)
cdr := &CDR{
TOR: "tor",
ToR: "tor",
OriginID: "accid",
OriginHost: "cdrhost",
Source: "cdrsource",

View File

@@ -88,7 +88,7 @@ func testSetCDR(cdrStorage CdrStorage) error {
OriginHost: "127.0.0.1",
Source: "testSetCDRs",
OriginID: "testevent1",
TOR: utils.VOICE,
ToR: utils.VOICE,
RequestType: utils.META_PREPAID,
Direction: utils.OUT,
Tenant: "cgrates.org",
@@ -119,7 +119,7 @@ func testSetCDR(cdrStorage CdrStorage) error {
OriginHost: "127.0.0.1",
Source: "testSetCDRs",
OriginID: "testevent1",
TOR: utils.VOICE,
ToR: utils.VOICE,
RequestType: utils.META_PREPAID,
Direction: utils.OUT,
Tenant: "cgrates.org",

View File

@@ -758,7 +758,7 @@ func (ms *MongoStorage) GetCDRs(qryFltr *utils.CDRsFilter) ([]*CDR, int64, error
filters := bson.M{
"cgrid": bson.M{"$in": qryFltr.CGRIDs, "$nin": qryFltr.NotCGRIDs},
"mediationrunid": bson.M{"$in": qryFltr.RunIDs, "$nin": qryFltr.NotRunIDs},
"tor": bson.M{"$in": qryFltr.TORs, "$nin": qryFltr.NotTORs},
"tor": bson.M{"$in": qryFltr.ToRs, "$nin": qryFltr.NotToRs},
"cdrhost": bson.M{"$in": qryFltr.OriginHosts, "$nin": qryFltr.NotOriginHosts},
"cdrsource": bson.M{"$in": qryFltr.Sources, "$nin": qryFltr.NotSources},
"reqtype": bson.M{"$in": qryFltr.RequestTypes, "$nin": qryFltr.NotRequestTypes},

View File

@@ -628,7 +628,7 @@ func (self *SQLStorage) SetCDR(cdr *CDR, allowUpdate bool) error {
OriginHost: cdr.OriginHost,
Source: cdr.Source,
OriginID: cdr.OriginID,
Tor: cdr.TOR,
Tor: cdr.ToR,
RequestType: cdr.RequestType,
Direction: cdr.Direction,
Tenant: cdr.Tenant,
@@ -660,7 +660,7 @@ func (self *SQLStorage) SetCDR(cdr *CDR, allowUpdate bool) error {
OriginHost: cdr.OriginHost,
Source: cdr.Source,
OriginID: cdr.OriginID,
Tor: cdr.TOR,
Tor: cdr.ToR,
RequestType: cdr.RequestType,
Direction: cdr.Direction,
Tenant: cdr.Tenant,
@@ -714,11 +714,11 @@ func (self *SQLStorage) GetCDRs(qryFltr *utils.CDRsFilter) ([]*CDR, int64, error
if len(qryFltr.NotRunIDs) != 0 {
q = q.Where("run_id not in (?)", qryFltr.NotRunIDs)
}
if len(qryFltr.TORs) != 0 {
q = q.Where("tor in (?)", qryFltr.TORs)
if len(qryFltr.ToRs) != 0 {
q = q.Where("tor in (?)", qryFltr.ToRs)
}
if len(qryFltr.NotTORs) != 0 {
q = q.Where("tor not in (?)", qryFltr.NotTORs)
if len(qryFltr.NotToRs) != 0 {
q = q.Where("tor not in (?)", qryFltr.NotToRs)
}
if len(qryFltr.OriginHosts) != 0 {
q = q.Where("origin_host in (?)", qryFltr.OriginHosts)
@@ -932,7 +932,7 @@ func (self *SQLStorage) GetCDRs(qryFltr *utils.CDRsFilter) ([]*CDR, int64, error
OriginHost: result.OriginHost,
Source: result.Source,
OriginID: result.OriginID,
TOR: result.Tor,
ToR: result.Tor,
RequestType: result.RequestType,
Direction: result.Direction,
Tenant: result.Tenant,

View File

@@ -30,7 +30,7 @@ import (
func TestNewSureTaxRequest(t *testing.T) {
CGRID := utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC).String())
cdr := &CDR{CGRID: CGRID, OrderID: 123, TOR: utils.VOICE,
cdr := &CDR{CGRID: CGRID, OrderID: 123, ToR: utils.VOICE,
OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: utils.UNIT_TEST, RequestType: utils.META_RATED, Direction: "*out",
Tenant: "cgrates.org", Category: "call", Account: "1001", Subject: "1001", Destination: "1002", Supplier: "SUPPL1",
SetupTime: time.Date(2013, 11, 7, 8, 42, 20, 0, time.UTC), AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), RunID: utils.DEFAULT_RUNID,

View File

@@ -582,16 +582,16 @@ func TestUsersAddUpdateRemoveIndexes(t *testing.T) {
func TestUsersUsageRecordGetLoadUserProfile(t *testing.T) {
userService = &UserMap{
table: map[string]map[string]string{
"test:user": map[string]string{"TOR": "01", "RequestType": "1", "Direction": "*out", "Category": "c1", "Account": "dan", "Subject": "0723", "Destination": "+401", "SetupTime": "s1", "AnswerTime": "t1", "Usage": "10"},
":user": map[string]string{"TOR": "02", "RequestType": "2", "Direction": "*out", "Category": "c2", "Account": "ivo", "Subject": "0724", "Destination": "+402", "SetupTime": "s2", "AnswerTime": "t2", "Usage": "11"},
"test:": map[string]string{"TOR": "03", "RequestType": "3", "Direction": "*out", "Category": "c3", "Account": "elloy", "Subject": "0725", "Destination": "+403", "SetupTime": "s3", "AnswerTime": "t3", "Usage": "12"},
"test1:user1": map[string]string{"TOR": "04", "RequestType": "4", "Direction": "*out", "Category": "call", "Account": "rif", "Subject": "0726", "Destination": "+404", "SetupTime": "s4", "AnswerTime": "t4", "Usage": "13"},
"test:user": map[string]string{utils.TOR: "01", "RequestType": "1", "Direction": "*out", "Category": "c1", "Account": "dan", "Subject": "0723", "Destination": "+401", "SetupTime": "s1", "AnswerTime": "t1", "Usage": "10"},
":user": map[string]string{utils.TOR: "02", "RequestType": "2", "Direction": "*out", "Category": "c2", "Account": "ivo", "Subject": "0724", "Destination": "+402", "SetupTime": "s2", "AnswerTime": "t2", "Usage": "11"},
"test:": map[string]string{utils.TOR: "03", "RequestType": "3", "Direction": "*out", "Category": "c3", "Account": "elloy", "Subject": "0725", "Destination": "+403", "SetupTime": "s3", "AnswerTime": "t3", "Usage": "12"},
"test1:user1": map[string]string{utils.TOR: "04", "RequestType": "4", "Direction": "*out", "Category": "call", "Account": "rif", "Subject": "0726", "Destination": "+404", "SetupTime": "s4", "AnswerTime": "t4", "Usage": "13"},
},
index: make(map[string]map[string]bool),
}
ur := &UsageRecord{
TOR: utils.USERS,
ToR: utils.USERS,
RequestType: utils.USERS,
Direction: "*out",
Tenant: "",
@@ -609,7 +609,7 @@ func TestUsersUsageRecordGetLoadUserProfile(t *testing.T) {
t.Error("Error loading user profile: ", err)
}
expected := &UsageRecord{
TOR: "04",
ToR: "04",
RequestType: "4",
Direction: "*out",
Tenant: "",
@@ -629,16 +629,16 @@ func TestUsersUsageRecordGetLoadUserProfile(t *testing.T) {
func TestUsersExternalCDRGetLoadUserProfileExtraFields(t *testing.T) {
userService = &UserMap{
table: map[string]map[string]string{
"test:user": map[string]string{"TOR": "01", "RequestType": "1", "Direction": "*out", "Category": "c1", "Account": "dan", "Subject": "0723", "Destination": "+401", "SetupTime": "s1", "AnswerTime": "t1", "Usage": "10"},
":user": map[string]string{"TOR": "02", "RequestType": "2", "Direction": "*out", "Category": "c2", "Account": "ivo", "Subject": "0724", "Destination": "+402", "SetupTime": "s2", "AnswerTime": "t2", "Usage": "11"},
"test:": map[string]string{"TOR": "03", "RequestType": "3", "Direction": "*out", "Category": "c3", "Account": "elloy", "Subject": "0725", "Destination": "+403", "SetupTime": "s3", "AnswerTime": "t3", "Usage": "12"},
"test1:user1": map[string]string{"TOR": "04", "RequestType": "4", "Direction": "*out", "Category": "call", "Account": "rif", "Subject": "0726", "Destination": "+404", "SetupTime": "s4", "AnswerTime": "t4", "Usage": "13", "Test": "1"},
"test:user": map[string]string{utils.TOR: "01", "RequestType": "1", "Direction": "*out", "Category": "c1", "Account": "dan", "Subject": "0723", "Destination": "+401", "SetupTime": "s1", "AnswerTime": "t1", "Usage": "10"},
":user": map[string]string{utils.TOR: "02", "RequestType": "2", "Direction": "*out", "Category": "c2", "Account": "ivo", "Subject": "0724", "Destination": "+402", "SetupTime": "s2", "AnswerTime": "t2", "Usage": "11"},
"test:": map[string]string{utils.TOR: "03", "RequestType": "3", "Direction": "*out", "Category": "c3", "Account": "elloy", "Subject": "0725", "Destination": "+403", "SetupTime": "s3", "AnswerTime": "t3", "Usage": "12"},
"test1:user1": map[string]string{utils.TOR: "04", "RequestType": "4", "Direction": "*out", "Category": "call", "Account": "rif", "Subject": "0726", "Destination": "+404", "SetupTime": "s4", "AnswerTime": "t4", "Usage": "13", "Test": "1"},
},
index: make(map[string]map[string]bool),
}
ur := &ExternalCDR{
TOR: utils.USERS,
ToR: utils.USERS,
RequestType: utils.USERS,
Direction: "*out",
Tenant: "",
@@ -659,7 +659,7 @@ func TestUsersExternalCDRGetLoadUserProfileExtraFields(t *testing.T) {
t.Error("Error loading user profile: ", err)
}
expected := &ExternalCDR{
TOR: "04",
ToR: "04",
RequestType: "4",
Direction: "*out",
Tenant: "",
@@ -682,16 +682,16 @@ func TestUsersExternalCDRGetLoadUserProfileExtraFields(t *testing.T) {
func TestUsersExternalCDRGetLoadUserProfileExtraFieldsNotFound(t *testing.T) {
userService = &UserMap{
table: map[string]map[string]string{
"test:user": map[string]string{"TOR": "01", "RequestType": "1", "Direction": "*out", "Category": "c1", "Account": "dan", "Subject": "0723", "Destination": "+401", "SetupTime": "s1", "AnswerTime": "t1", "Usage": "10"},
":user": map[string]string{"TOR": "02", "RequestType": "2", "Direction": "*out", "Category": "c2", "Account": "ivo", "Subject": "0724", "Destination": "+402", "SetupTime": "s2", "AnswerTime": "t2", "Usage": "11"},
"test:": map[string]string{"TOR": "03", "RequestType": "3", "Direction": "*out", "Category": "c3", "Account": "elloy", "Subject": "0725", "Destination": "+403", "SetupTime": "s3", "AnswerTime": "t3", "Usage": "12"},
"test1:user1": map[string]string{"TOR": "04", "RequestType": "4", "Direction": "*out", "Category": "call", "Account": "rif", "Subject": "0726", "Destination": "+404", "SetupTime": "s4", "AnswerTime": "t4", "Usage": "13", "Test": "2"},
"test:user": map[string]string{utils.TOR: "01", "RequestType": "1", "Direction": "*out", "Category": "c1", "Account": "dan", "Subject": "0723", "Destination": "+401", "SetupTime": "s1", "AnswerTime": "t1", "Usage": "10"},
":user": map[string]string{utils.TOR: "02", "RequestType": "2", "Direction": "*out", "Category": "c2", "Account": "ivo", "Subject": "0724", "Destination": "+402", "SetupTime": "s2", "AnswerTime": "t2", "Usage": "11"},
"test:": map[string]string{utils.TOR: "03", "RequestType": "3", "Direction": "*out", "Category": "c3", "Account": "elloy", "Subject": "0725", "Destination": "+403", "SetupTime": "s3", "AnswerTime": "t3", "Usage": "12"},
"test1:user1": map[string]string{utils.TOR: "04", "RequestType": "4", "Direction": "*out", "Category": "call", "Account": "rif", "Subject": "0726", "Destination": "+404", "SetupTime": "s4", "AnswerTime": "t4", "Usage": "13", "Test": "2"},
},
index: make(map[string]map[string]bool),
}
ur := &ExternalCDR{
TOR: utils.USERS,
ToR: utils.USERS,
RequestType: utils.USERS,
Direction: "*out",
Tenant: "",
@@ -716,16 +716,16 @@ func TestUsersExternalCDRGetLoadUserProfileExtraFieldsNotFound(t *testing.T) {
func TestUsersExternalCDRGetLoadUserProfileExtraFieldsSet(t *testing.T) {
userService = &UserMap{
table: map[string]map[string]string{
"test:user": map[string]string{"TOR": "01", "RequestType": "1", "Direction": "*out", "Category": "c1", "Account": "dan", "Subject": "0723", "Destination": "+401", "SetupTime": "s1", "AnswerTime": "t1", "Usage": "10"},
":user": map[string]string{"TOR": "02", "RequestType": "2", "Direction": "*out", "Category": "c2", "Account": "ivo", "Subject": "0724", "Destination": "+402", "SetupTime": "s2", "AnswerTime": "t2", "Usage": "11"},
"test:": map[string]string{"TOR": "03", "RequestType": "3", "Direction": "*out", "Category": "c3", "Account": "elloy", "Subject": "0725", "Destination": "+403", "SetupTime": "s3", "AnswerTime": "t3", "Usage": "12"},
"test1:user1": map[string]string{"TOR": "04", "RequestType": "4", "Direction": "*out", "Category": "call", "Account": "rif", "Subject": "0726", "Destination": "+404", "SetupTime": "s4", "AnswerTime": "t4", "Usage": "13", "Test": "1", "Best": "BestValue"},
"test:user": map[string]string{utils.TOR: "01", "RequestType": "1", "Direction": "*out", "Category": "c1", "Account": "dan", "Subject": "0723", "Destination": "+401", "SetupTime": "s1", "AnswerTime": "t1", "Usage": "10"},
":user": map[string]string{utils.TOR: "02", "RequestType": "2", "Direction": "*out", "Category": "c2", "Account": "ivo", "Subject": "0724", "Destination": "+402", "SetupTime": "s2", "AnswerTime": "t2", "Usage": "11"},
"test:": map[string]string{utils.TOR: "03", "RequestType": "3", "Direction": "*out", "Category": "c3", "Account": "elloy", "Subject": "0725", "Destination": "+403", "SetupTime": "s3", "AnswerTime": "t3", "Usage": "12"},
"test1:user1": map[string]string{utils.TOR: "04", "RequestType": "4", "Direction": "*out", "Category": "call", "Account": "rif", "Subject": "0726", "Destination": "+404", "SetupTime": "s4", "AnswerTime": "t4", "Usage": "13", "Test": "1", "Best": "BestValue"},
},
index: make(map[string]map[string]bool),
}
ur := &ExternalCDR{
TOR: utils.USERS,
ToR: utils.USERS,
RequestType: utils.USERS,
Direction: "*out",
Tenant: "",
@@ -747,7 +747,7 @@ func TestUsersExternalCDRGetLoadUserProfileExtraFieldsSet(t *testing.T) {
t.Error("Error loading user profile: ", err)
}
expected := &ExternalCDR{
TOR: "04",
ToR: "04",
RequestType: "4",
Direction: "*out",
Tenant: "",
@@ -772,7 +772,7 @@ func TestUsersCallDescLoadUserProfile(t *testing.T) {
userService = &UserMap{
table: map[string]map[string]string{
"cgrates.org:dan": map[string]string{"RequestType": "*prepaid", "Category": "call1", "Account": "dan", "Subject": "dan", "Cli": "+4986517174963"},
"cgrates.org:danvoice": map[string]string{"TOR": "*voice", "RequestType": "*prepaid", "Category": "call1", "Account": "dan", "Subject": "0723"},
"cgrates.org:danvoice": map[string]string{utils.TOR: "*voice", "RequestType": "*prepaid", "Category": "call1", "Account": "dan", "Subject": "0723"},
"cgrates:rif": map[string]string{"RequestType": "*postpaid", "Direction": "*out", "Category": "call", "Account": "rif", "Subject": "0726"},
},
index: make(map[string]map[string]bool),
@@ -813,14 +813,14 @@ func TestUsersCDRLoadUserProfile(t *testing.T) {
userService = &UserMap{
table: map[string]map[string]string{
"cgrates.org:dan": map[string]string{"RequestType": "*prepaid", "Category": "call1", "Account": "dan", "Subject": "dan", "Cli": "+4986517174963"},
"cgrates.org:danvoice": map[string]string{"TOR": "*voice", "RequestType": "*prepaid", "Category": "call1", "Account": "dan", "Subject": "0723"},
"cgrates.org:danvoice": map[string]string{utils.TOR: "*voice", "RequestType": "*prepaid", "Category": "call1", "Account": "dan", "Subject": "0723"},
"cgrates:rif": map[string]string{"RequestType": "*postpaid", "Direction": "*out", "Category": "call", "Account": "rif", "Subject": "0726"},
},
index: make(map[string]map[string]bool),
}
startTime := time.Now()
cdr := &CDR{
TOR: "*sms",
ToR: "*sms",
RequestType: utils.USERS,
Tenant: utils.USERS,
Category: utils.USERS,
@@ -833,7 +833,7 @@ func TestUsersCDRLoadUserProfile(t *testing.T) {
ExtraFields: map[string]string{"Cli": "+4986517174963"},
}
expected := &CDR{
TOR: "*sms",
ToR: "*sms",
RequestType: "*prepaid",
Tenant: "cgrates.org",
Category: "call1",