Skip to content

Commit

Permalink
Pdubuilder test (#5)
Browse files Browse the repository at this point in the history
* Added GHA for ccc service model

* Split the pdubuilder into top level messages and add unit tests

* Added encoder and decoder test

* Apply suggestions from code review

---------

Co-authored-by: gab-arrobo <[email protected]>
  • Loading branch information
Agarwal-Shivansh and gab-arrobo authored Jun 2, 2024
1 parent 9a5dac0 commit 97d7cfc
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 2 deletions.
27 changes: 27 additions & 0 deletions servicemodels/e2sm_ccc/pdubuilder/cc-action-definition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package pdubuilder
import (
"testing"

encoder "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/encoder"
e2smcccv1 "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/v1/e2sm-ccc-ies"
e2smcommoniesv1 "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/v1/e2sm-common-ies"
"github.com/stretchr/testify/assert"
Expand All @@ -14,6 +15,21 @@ import (
func TestCreateE2SmCCcRIcactionDefinition(t *testing.T) {
ricStyleType := &e2smcommoniesv1.RicStyleType{}
actionDefinitionFormat := &e2smcccv1.ActionDefinitionFormat{}

result, err := CreateE2SmCCcRIcactionDefinition(ricStyleType, actionDefinitionFormat)

encodedMsg, err := encoder.PerEncodeE2SmCCcRIcactionDefinition(result)
assert.NoError(t, err)
assert.NotNil(t, encodedMsg)
decodedMsg, err := encoder.PerDecodeE2SmCCcRIcactionDefinition(encodedMsg)
assert.NoError(t, err)
assert.NotNil(t, decodedMsg)
assert.Equal(t, result, decodedMsg)
assert.NoError(t, err)
assert.NotNil(t, result)
err = result.Validate()
assert.NoError(t, err)

result, err := CreateE2SmCCcRIcactionDefinition(ricStyleType, actionDefinitionFormat)
assert.NoError(t, err)
assert.NotNil(t, result)
Expand All @@ -30,6 +46,11 @@ func TestCreateListOfRanconfigurationStructuresForAdf(t *testing.T) {
result, err := CreateListOfRanconfigurationStructuresForAdf(value)
assert.NoError(t, err)
assert.NotNil(t, result)

for _, item := range result.Value {
err = item.Validate()
assert.NoError(t, err)
}
}

func TestCreateE2SmCCcActionDefinitionFormat1(t *testing.T) {
Expand All @@ -46,6 +67,9 @@ func TestCreateE2SmCCcActionDefinitionFormat1(t *testing.T) {
result, err := CreateE2SmCCcActionDefinitionFormat1(listOfNodeLevelRanconfigurationStructuresForAdf)
assert.NoError(t, err)
assert.NotNil(t, result)

err = result.Validate()
assert.NoError(t, err)
}

func TestCreateE2SmCCcActionDefinitionFormat2(t *testing.T) {
Expand All @@ -61,4 +85,7 @@ func TestCreateE2SmCCcActionDefinitionFormat2(t *testing.T) {
result, err := CreateE2SmCCcActionDefinitionFormat2(listOfCellConfigurationsToBeReportedForAdf)
assert.NoError(t, err)
assert.NotNil(t, result)
err = result.Validate()
assert.NoError(t, err)

}
16 changes: 16 additions & 0 deletions servicemodels/e2sm_ccc/pdubuilder/ccc-control-header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package pdubuilder
import (
"testing"

encoder "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/encoder"
e2smcccv1 "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/v1/e2sm-ccc-ies"
e2smcommoniesv1 "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/v1/e2sm-common-ies"
"github.com/stretchr/testify/assert"
Expand All @@ -17,11 +18,26 @@ func TestCreateE2SmCCcRIcControlHeader(t *testing.T) {
result, err := CreateE2SmCCcRIcControlHeader(controlHeaderFormat)
assert.NoError(t, err)
assert.NotNil(t, result)

encodedMsg, err := encoder.PerEncodeE2SmCCcRIcControlHeader(result)
assert.NoError(t, err)
assert.NotNil(t, encodedMsg)
decodedMsg, err := encoder.PerDecodeE2SmCCcRIcControlHeader(encodedMsg)
assert.NoError(t, err)
assert.NotNil(t, decodedMsg)
assert.Equal(t, result, decodedMsg)
err = result.Validate()
assert.NoError(t, err)

}

func TestCreateE2SmCCcControlHeaderFormat1(t *testing.T) {
ricStyleType := &e2smcommoniesv1.RicStyleType{}
result, err := CreateE2SmCCcControlHeaderFormat1(ricStyleType)
assert.NoError(t, err)
assert.NotNil(t, result)

err = result.Validate()
assert.NoError(t, err)

}
9 changes: 9 additions & 0 deletions servicemodels/e2sm_ccc/pdubuilder/ccc-control-message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package pdubuilder
import (
"testing"

encoder "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/encoder"
e2smcccv1 "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/v1/e2sm-ccc-ies"
"github.com/stretchr/testify/assert"
)
Expand All @@ -15,6 +16,14 @@ func TestCreateE2SmCCcRIcControlMessage(t *testing.T) {
result, err := CreateE2SmCCcRIcControlMessage(controlMessageFormat)
assert.NoError(t, err)
assert.NotNil(t, result)

encodedMsg, err := encoder.PerEncodeE2SmCCcRIcControlMessage(result)
assert.NoError(t, err)
assert.NotNil(t, encodedMsg)
decodedMsg, err := encoder.PerDecodeE2SmCCcRIcControlMessage(encodedMsg)
assert.NoError(t, err)
assert.NotNil(t, decodedMsg)

}

func TestCreateE2SmCCcControlMessageFormat1(t *testing.T) {
Expand Down
17 changes: 17 additions & 0 deletions servicemodels/e2sm_ccc/pdubuilder/ccc-control-outcome_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,26 @@ package pdubuilder
import (
"testing"

encoder "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/encoder"
e2smcccv1 "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/v1/e2sm-ccc-ies"
"github.com/stretchr/testify/assert"
)

func TestCreateE2SmCCcRIcControlOutcome(t *testing.T) {
controlOutcomeFormat := &e2smcccv1.ControlOutcomeFormat{}
result, err := CreateE2SmCCcRIcControlOutcome(controlOutcomeFormat)

encodedMsg, err := encoder.PerEncodeE2SmCCcRIcControlOutcome(result)
assert.NoError(t, err)
assert.NotNil(t, encodedMsg)
decodedMsg, err := encoder.PerDecodeE2SmCCcRIcControlOutcome(encodedMsg)
assert.NoError(t, err)
assert.NotNil(t, decodedMsg)
assert.Equal(t, result, decodedMsg)
assert.NoError(t, err)
assert.NotNil(t, result)
err = result.Validate()
assert.NoError(t, err)
assert.NoError(t, err)
assert.NotNil(t, result)
}
Expand All @@ -22,11 +35,15 @@ func TestCreateControlOutcomeFormatE2SmCccControlOutcomeFormat1(t *testing.T) {
result, err := CreateControlOutcomeFormatE2SmCccControlOutcomeFormat1(e2SmCccControlOutcomeFormat1)
assert.NoError(t, err)
assert.NotNil(t, result)
err = result.Validate()
assert.NoError(t, err)
}

func TestCreateControlOutcomeFormatE2SmCccControlOutcomeFormat2(t *testing.T) {
e2SmCccControlOutcomeFormat2 := &e2smcccv1.E2SmCCcControlOutcomeFormat2{}
result, err := CreateControlOutcomeFormatE2SmCccControlOutcomeFormat2(e2SmCccControlOutcomeFormat2)
assert.NoError(t, err)
assert.NotNil(t, result)
err = result.Validate()
assert.NoError(t, err)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,26 @@ package pdubuilder
import (
"testing"

encoder "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/encoder"
e2smcccv1 "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/v1/e2sm-ccc-ies"
"github.com/stretchr/testify/assert"
)

func TestCreateE2SmCCcRIceventTriggerDefinition(t *testing.T) {
eventTriggerDefinitionFormat := &e2smcccv1.EventTriggerDefinitionFormat{}
result, err := CreateE2SmCCcRIceventTriggerDefinition(eventTriggerDefinitionFormat)

encodedMsg, err := encoder.PerEncodeE2SmCCcRIceventTriggerDefinition(result)
assert.NoError(t, err)
assert.NotNil(t, encodedMsg)
decodedMsg, err := encoder.PerDecodeE2SmCCcRIceventTriggerDefinition(encodedMsg)
assert.NoError(t, err)
assert.NotNil(t, decodedMsg)
assert.Equal(t, result, decodedMsg)
assert.NoError(t, err)
assert.NotNil(t, result)
err = result.Validate()
assert.NoError(t, err)
assert.NoError(t, err)
assert.NotNil(t, result)
}
Expand All @@ -28,6 +41,9 @@ func TestCreateE2SmCCcEventTriggerDefinitionFormat1(t *testing.T) {
result, err := CreateE2SmCCcEventTriggerDefinitionFormat1(listOfNodeLevelConfigurationStructuresForEventTrigger)
assert.NoError(t, err)
assert.NotNil(t, result)
err = result.Validate()
assert.NoError(t, err)

}

func TestCreateListOfRanconfigurationStructuresForEventTrigger(t *testing.T) {
Expand All @@ -38,48 +54,63 @@ func TestCreateListOfRanconfigurationStructuresForEventTrigger(t *testing.T) {
result, err := CreateListOfRanconfigurationStructuresForEventTrigger(value)
assert.NoError(t, err)
assert.NotNil(t, result)

err = result.Validate()
assert.NoError(t, err)
}

func TestCreateRanConfigurationStructureName(t *testing.T) {
value := []byte("Test")
result, err := CreateRanConfigurationStructureName(value)
assert.NoError(t, err)
assert.NotNil(t, result)
err = result.Validate()
assert.NoError(t, err)
}

func TestCreateListOfAttributes(t *testing.T) {
value := []*e2smcccv1.AttributeName{}
result, err := CreateListOfAttributes(value)
assert.NoError(t, err)
assert.NotNil(t, result)
err = result.Validate()
assert.NoError(t, err)
}

func TestCreateAttributeName(t *testing.T) {
value := []byte("Test")
result, err := CreateAttributeName(value)
assert.NoError(t, err)
assert.NotNil(t, result)
err = result.Validate()
assert.NoError(t, err)
}

func TestCreateE2SmCCcEventTriggerDefinitionFormat3(t *testing.T) {
period := int32(10)
result, err := CreateE2SmCCcEventTriggerDefinitionFormat3(period)
assert.NoError(t, err)
assert.NotNil(t, result)
err = result.Validate()
assert.NoError(t, err)
}

func TestCreateEventTriggerDefinitionFormatE2SmCccEventTriggerDefinitionFormat1(t *testing.T) {
e2SmCccEventTriggerDefinitionFormat1 := &e2smcccv1.E2SmCCcEventTriggerDefinitionFormat1{}
result, err := CreateEventTriggerDefinitionFormatE2SmCccEventTriggerDefinitionFormat1(e2SmCccEventTriggerDefinitionFormat1)
assert.NoError(t, err)
assert.NotNil(t, result)
err = result.Validate()
assert.NoError(t, err)
}

func TestCreateEventTriggerDefinitionFormatE2SmCccEventTriggerDefinitionFormat2(t *testing.T) {
e2SmCccEventTriggerDefinitionFormat2 := &e2smcccv1.E2SmCCcEventTriggerDefinitionFormat2{}
result, err := CreateEventTriggerDefinitionFormatE2SmCccEventTriggerDefinitionFormat2(e2SmCccEventTriggerDefinitionFormat2)
assert.NoError(t, err)
assert.NotNil(t, result)
err = result.Validate()
assert.NoError(t, err)
}

func TestCreateEventTriggerDefinitionFormatE2SmCccEventTriggerDefinitionFormat3(t *testing.T) {
Expand All @@ -88,4 +119,6 @@ func TestCreateEventTriggerDefinitionFormatE2SmCccEventTriggerDefinitionFormat3(
result, err := CreateEventTriggerDefinitionFormatE2SmCccEventTriggerDefinitionFormat3(e2SmCccEventTriggerDefinitionFormat3)
assert.NoError(t, err)
assert.NotNil(t, result)
err = result.Validate()
assert.NoError(t, err)
}
19 changes: 17 additions & 2 deletions servicemodels/e2sm_ccc/pdubuilder/ccc-indication-header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,28 @@
package pdubuilder

import (
e2smcccv1 "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/v1/e2sm-ccc-ies"

encoder "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/encoder"
e2smcccv1 "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/v1/e2sm-ccc-ies"
e2smcccv1 "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/v1/e2sm-ccc-ies"
"testing"

"github.com/stretchr/testify/assert"
)

func TestCreateE2SmCCcRIcIndicationHeader(t *testing.T) {
indicationHeaderFormat := &e2smcccv1.IndicationHeaderFormat{}
result, err := CreateE2SmCCcRIcIndicationHeader(indicationHeaderFormat)
encodedMsg, err := encoder.PerEncodeE2SmCCcRIcIndicationHeader(result)
assert.NoError(t, err)
assert.NotNil(t, encodedMsg)
decodedMsg, err := encoder.PerDecodeE2SmCCcRIcIndicationHeader(encodedMsg)
assert.NoError(t, err)
assert.NotNil(t, decodedMsg)
assert.Equal(t, result, decodedMsg)
assert.NoError(t, err)
assert.NotNil(t, result)
err = result.Validate()
assert.NoError(t, err)
assert.NoError(t, err)
assert.NotNil(t, result)
}
Expand All @@ -24,4 +36,7 @@ func TestCreateE2SmCCcIndicationHeaderFormat1(t *testing.T) {
result, err := CreateE2SmCCcIndicationHeaderFormat1(indicationReason, eventTime)
assert.NoError(t, err)
assert.NotNil(t, result)
err = result.Validate()
assert.NoError(t, err)

}
19 changes: 19 additions & 0 deletions servicemodels/e2sm_ccc/pdubuilder/ccc-indication-message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package pdubuilder

import (
"testing"
encoder "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/encoder"

e2smcccv1 "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_ccc/v1/e2sm-ccc-ies"
"github.com/stretchr/testify/assert"
Expand All @@ -13,6 +14,18 @@ import (
func TestCreateE2SmCCcRIcIndicationMessage(t *testing.T) {
indicationMessageFormat := &e2smcccv1.IndicationMessageFormat{}
result, err := CreateE2SmCCcRIcIndicationMessage(indicationMessageFormat)

encodedMsg, err := encoder.PerEncodeE2SmCCcRIcIndicationMessage(result)
assert.NoError(t, err)
assert.NotNil(t, encodedMsg)
decodedMsg, err := encoder.PerDecodeE2SmCCcRIcIndicationMessage(encodedMsg)
assert.NoError(t, err)
assert.NotNil(t, decodedMsg)
assert.Equal(t, result, decodedMsg)
assert.NoError(t, err)
assert.NotNil(t, result)
err = result.Validate()
assert.NoError(t, err)
assert.NoError(t, err)
assert.NotNil(t, result)
}
Expand All @@ -25,13 +38,17 @@ func TestCreateE2SmCCcIndicationMessageFormat1(t *testing.T) {
result, err := CreateE2SmCCcIndicationMessageFormat1(listOfConfigurationStructuresReported)
assert.NoError(t, err)
assert.NotNil(t, result)
err = result.Validate()
assert.NoError(t, err)
}

func TestCreateListOfConfigurationsReported(t *testing.T) {
value := []*e2smcccv1.ConfigurationStructure{{}}
result, err := CreateListOfConfigurationsReported(value)
assert.NoError(t, err)
assert.NotNil(t, result)
err = result.Validate()
assert.NoError(t, err)
}

func TestCreateE2SmCCcIndicationMessageFormat2(t *testing.T) {
Expand All @@ -42,4 +59,6 @@ func TestCreateE2SmCCcIndicationMessageFormat2(t *testing.T) {
result, err := CreateE2SmCCcIndicationMessageFormat2(listOfCellsReported)
assert.NoError(t, err)
assert.NotNil(t, result)
err = result.Validate()
assert.NoError(t, err)
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ func TestCreateListOfCellsForRanfunctionDefinition(t *testing.T) {
result, err := CreateListOfCellsForRanfunctionDefinition(value)
assert.NoError(t, err)
assert.NotNil(t, result)
err = result.Validate()
assert.NoError(t, err)
}

0 comments on commit 97d7cfc

Please sign in to comment.