32e87e8de84a89fd25ccb7dcfae37a027376ea78
[packetcable.git] / packetcable-driver / src / test / java / org / pcmm / gates / impl / GateIDTest.java
1 /*
2  * (c) 2015 Cable Television Laboratories, Inc.  All rights reserved.
3  */
4
5 package org.pcmm.gates.impl;
6
7 import org.junit.Assert;
8 import org.junit.Test;
9 import org.umu.cops.stack.COPSMsgParser;
10
11 /**
12  * Tests the data holder class GateId to ensure both construction and byte parsing result in correct object creation.
13  */
14 public class GateIDTest {
15
16     @Test
17     public void construction() {
18         final GateID gateID = new GateID(9);
19
20         // Check the object's bytes
21         final byte[] dataBytes = gateID.getBytes();
22         Assert.assertEquals(9, gateID.getGateID());
23         Assert.assertEquals(4, dataBytes.length);
24         Assert.assertEquals(9, COPSMsgParser.bytesToInt(dataBytes[0], dataBytes[1], dataBytes[2], dataBytes[3]));
25
26         // Check the byte parsing
27         final GateID parsed = GateID.parse(dataBytes);
28         Assert.assertEquals(gateID, parsed);
29     }
30
31     @Test
32     public void byteParsing() {
33         final GateID gateID = new GateID(10);
34         final GateID parsed = GateID.parse(gateID.getBytes());
35         Assert.assertEquals(gateID, parsed);
36     }
37
38 }