blob: c82c99814cda408cd9951635b868b90694903722 [file] [log] [blame]
Matteo Scandolo8a574812021-05-20 15:18:53 -07001/*
Joey Armstrong14628cd2023-01-10 08:38:31 -05002 * Copyright 2018-2023 Open Networking Foundation (ONF) and the ONF Contributors
Matteo Scandolo8a574812021-05-20 15:18:53 -07003
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7
8 * http://www.apache.org/licenses/LICENSE-2.0
9
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package omci
18
19import (
Elia Battiston9bfe1102022-02-03 10:38:03 +010020 "testing"
21
Andrea Campanella10426e22021-10-15 17:58:04 +020022 "github.com/opencord/omci-lib-go/v2"
23 me "github.com/opencord/omci-lib-go/v2/generated"
Matteo Scandolo8a574812021-05-20 15:18:53 -070024 "github.com/stretchr/testify/assert"
Matteo Scandolo8a574812021-05-20 15:18:53 -070025)
26
27func TestSetRequest(t *testing.T) {
28
29 meId := GenerateUniPortEntityId(1)
30
31 meParams := me.ParamData{
32 EntityID: meId.ToUint16(),
33 Attributes: me.AttributeValueMap{
Elia Battiston9bfe1102022-02-03 10:38:03 +010034 me.UniG_AdministrativeState: 1,
Matteo Scandolo8a574812021-05-20 15:18:53 -070035 },
36 }
37 meInstance, omciError := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
38 if omciError.GetError() != nil {
39 t.Fatal(omciError.GetError())
40 }
41
42 pkt, err := CreateSetRequest(meInstance, 1)
43 assert.NoError(t, err)
44
45 omciPkt, omciMsg, err := ParseOpenOltOmciPacket(pkt)
46 assert.NoError(t, err)
47 assert.Equal(t, omciMsg.MessageType, omci.SetRequestType)
48
49 msgObj, _ := ParseSetRequest(omciPkt)
50
51 assert.Equal(t, meId.ToUint16(), msgObj.EntityInstance)
Elia Battiston9bfe1102022-02-03 10:38:03 +010052 assert.Equal(t, uint8(1), msgObj.Attributes[me.UniG_AdministrativeState])
Matteo Scandolo8a574812021-05-20 15:18:53 -070053
54}