mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
ExternalAttributeProfile.Substitutes
This commit is contained in:
committed by
Dan Christian Bogos
parent
886b853767
commit
11e713ee72
@@ -153,7 +153,7 @@ func testAttributeSGetAttributeForEvent(t *testing.T) {
|
||||
FilterIDs: []string{"FLTR_ACNT_1007"},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 1, 14, 0, 0, 0, 0, time.UTC)},
|
||||
Substitute: []*engine.AttributeSubstitute{
|
||||
Substitutes: []*engine.AttributeSubstitute{
|
||||
&engine.AttributeSubstitute{
|
||||
FieldName: utils.ACCOUNT,
|
||||
Initial: utils.ANY,
|
||||
@@ -202,8 +202,8 @@ func testAttributeSGetAttributeForEvent(t *testing.T) {
|
||||
} else if !reflect.DeepEqual(eAttrPrf.ActivationInterval.ExpiryTime.Local(), attrReply.ActivationInterval.ExpiryTime.Local()) {
|
||||
t.Errorf("Expecting: %s, received: %s",
|
||||
eAttrPrf.ActivationInterval.ExpiryTime.Local(), attrReply.ActivationInterval.ExpiryTime.Local())
|
||||
} else if !reflect.DeepEqual(eAttrPrf.Substitute, attrReply.Substitute) && !reflect.DeepEqual(reverseSubstitute, attrReply.Substitute) {
|
||||
t.Errorf("Expecting: %s, received: %s", utils.ToJSON(eAttrPrf.Substitute), utils.ToJSON(attrReply.Substitute))
|
||||
} else if !reflect.DeepEqual(eAttrPrf.Substitutes, attrReply.Substitutes) && !reflect.DeepEqual(reverseSubstitute, attrReply.Substitutes) {
|
||||
t.Errorf("Expecting: %s, received: %s", utils.ToJSON(eAttrPrf.Substitutes), utils.ToJSON(attrReply.Substitutes))
|
||||
} else if !reflect.DeepEqual(eAttrPrf.Weight, attrReply.Weight) {
|
||||
t.Errorf("Expecting: %s, received: %s", eAttrPrf.Weight, attrReply.Weight)
|
||||
}
|
||||
@@ -268,7 +268,7 @@ func testAttributeSSetAlsPrf(t *testing.T) {
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(),
|
||||
},
|
||||
Substitute: []*engine.AttributeSubstitute{
|
||||
Substitutes: []*engine.AttributeSubstitute{
|
||||
&engine.AttributeSubstitute{
|
||||
FieldName: "FL1",
|
||||
Initial: "In1",
|
||||
@@ -291,15 +291,15 @@ func testAttributeSSetAlsPrf(t *testing.T) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", alsPrf.FilterIDs, reply.FilterIDs)
|
||||
} else if !reflect.DeepEqual(alsPrf.ActivationInterval, reply.ActivationInterval) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", alsPrf.ActivationInterval, reply.ActivationInterval)
|
||||
} else if !reflect.DeepEqual(len(alsPrf.Substitute), len(reply.Substitute)) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(alsPrf.Substitute), utils.ToJSON(reply.Substitute))
|
||||
} else if !reflect.DeepEqual(len(alsPrf.Substitutes), len(reply.Substitutes)) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(alsPrf.Substitutes), utils.ToJSON(reply.Substitutes))
|
||||
} else if !reflect.DeepEqual(alsPrf.ID, reply.ID) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", alsPrf.ID, reply.ID)
|
||||
}
|
||||
}
|
||||
|
||||
func testAttributeSUpdateAlsPrf(t *testing.T) {
|
||||
alsPrf.Substitute = []*engine.AttributeSubstitute{
|
||||
alsPrf.Substitutes = []*engine.AttributeSubstitute{
|
||||
&engine.AttributeSubstitute{
|
||||
FieldName: "FL1",
|
||||
Initial: "In1",
|
||||
@@ -326,8 +326,8 @@ func testAttributeSUpdateAlsPrf(t *testing.T) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", alsPrf.FilterIDs, reply.FilterIDs)
|
||||
} else if !reflect.DeepEqual(alsPrf.ActivationInterval, reply.ActivationInterval) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", alsPrf.ActivationInterval, reply.ActivationInterval)
|
||||
} else if !reflect.DeepEqual(len(alsPrf.Substitute), len(reply.Substitute)) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(alsPrf.Substitute), utils.ToJSON(reply.Substitute))
|
||||
} else if !reflect.DeepEqual(len(alsPrf.Substitutes), len(reply.Substitutes)) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(alsPrf.Substitutes), utils.ToJSON(reply.Substitutes))
|
||||
} else if !reflect.DeepEqual(alsPrf.ID, reply.ID) {
|
||||
t.Errorf("Expecting : %+v, received: %+v", alsPrf.ID, reply.ID)
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ func TestExternalAttributeProfileAsAttributeProfile(t *testing.T) {
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(),
|
||||
},
|
||||
Substitute: []*AttributeSubstitute{
|
||||
Substitutes: []*AttributeSubstitute{
|
||||
&AttributeSubstitute{
|
||||
FieldName: "FL1",
|
||||
Initial: "In1",
|
||||
@@ -104,7 +104,7 @@ func TestNewExternalAttributeProfileFromAttributeProfile(t *testing.T) {
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(),
|
||||
ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(),
|
||||
},
|
||||
Substitute: []*AttributeSubstitute{
|
||||
Substitutes: []*AttributeSubstitute{
|
||||
&AttributeSubstitute{
|
||||
FieldName: "FL1",
|
||||
Initial: "In1",
|
||||
|
||||
@@ -59,7 +59,7 @@ type ExternalAttributeProfile struct {
|
||||
Context string // bind this AttributeProfile to specific context
|
||||
FilterIDs []string
|
||||
ActivationInterval *utils.ActivationInterval // Activation interval
|
||||
Substitute []*AttributeSubstitute
|
||||
Substitutes []*AttributeSubstitute
|
||||
Weight float64
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ func (eap *ExternalAttributeProfile) AsAttributeProfile() *AttributeProfile {
|
||||
Weight: eap.Weight,
|
||||
}
|
||||
alsMap := make(map[string]map[string]*AttributeSubstitute)
|
||||
for _, als := range eap.Substitute {
|
||||
for _, als := range eap.Substitutes {
|
||||
alsMap[als.FieldName] = make(map[string]*AttributeSubstitute)
|
||||
alsMap[als.FieldName][als.Initial] = als
|
||||
}
|
||||
@@ -92,7 +92,7 @@ func NewExternalAttributeProfileFromAttributeProfile(alsPrf *AttributeProfile) *
|
||||
}
|
||||
for key, val := range alsPrf.Substitutes {
|
||||
for key2, val2 := range val {
|
||||
extals.Substitute = append(extals.Substitute, &AttributeSubstitute{
|
||||
extals.Substitutes = append(extals.Substitutes, &AttributeSubstitute{
|
||||
FieldName: key,
|
||||
Initial: key2,
|
||||
Alias: val2.Alias,
|
||||
|
||||
Reference in New Issue
Block a user