blob: d896e53f3cbd15905f90c7202b8d0ae33a0784c3 [file] [log] [blame]
Matteo Scandolo8a574812021-05-20 15:18:53 -07001/*
2 * Copyright 2018-present Open Networking Foundation
3
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 (
Andrea Campanella10426e22021-10-15 17:58:04 +020020 "github.com/opencord/omci-lib-go/v2"
21 me "github.com/opencord/omci-lib-go/v2/generated"
Matteo Scandolo8a574812021-05-20 15:18:53 -070022 "github.com/stretchr/testify/assert"
23 "testing"
24)
25
26func TestSetRequest(t *testing.T) {
27
28 meId := GenerateUniPortEntityId(1)
29
30 meParams := me.ParamData{
31 EntityID: meId.ToUint16(),
32 Attributes: me.AttributeValueMap{
33 "AdministrativeState": 1,
34 },
35 }
36 meInstance, omciError := me.NewPhysicalPathTerminationPointEthernetUni(meParams)
37 if omciError.GetError() != nil {
38 t.Fatal(omciError.GetError())
39 }
40
41 pkt, err := CreateSetRequest(meInstance, 1)
42 assert.NoError(t, err)
43
44 omciPkt, omciMsg, err := ParseOpenOltOmciPacket(pkt)
45 assert.NoError(t, err)
46 assert.Equal(t, omciMsg.MessageType, omci.SetRequestType)
47
48 msgObj, _ := ParseSetRequest(omciPkt)
49
50 assert.Equal(t, meId.ToUint16(), msgObj.EntityInstance)
51 assert.Equal(t, uint8(1), msgObj.Attributes["AdministrativeState"])
52
53}