blob: 33ed35a4fac54ed94cb55983e36d696a24c3e3a4 [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 (
20 "github.com/opencord/omci-lib-go"
21 me "github.com/opencord/omci-lib-go/generated"
22 "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}