Matteo Scandolo | 8a57481 | 2021-05-20 15:18:53 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package omci |
| 18 | |
| 19 | import ( |
Andrea Campanella | 10426e2 | 2021-10-15 17:58:04 +0200 | [diff] [blame] | 20 | "github.com/opencord/omci-lib-go/v2" |
| 21 | me "github.com/opencord/omci-lib-go/v2/generated" |
Matteo Scandolo | 8a57481 | 2021-05-20 15:18:53 -0700 | [diff] [blame] | 22 | "github.com/stretchr/testify/assert" |
| 23 | "testing" |
| 24 | ) |
| 25 | |
| 26 | func 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 | } |