2 * Copyright (c) 2015 Cable Television Laboratories, Inc and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.pcmm.gates.impl;
10 import org.junit.Assert;
11 import org.junit.Test;
12 import org.umu.cops.stack.COPSMsgParser;
15 * Tests the data holder class GateId to ensure both construction and byte parsing result in correct object creation.
17 public class GateIDTest {
20 public void construction() {
21 final GateID gateID = new GateID(9);
23 // Check the object's bytes
24 final byte[] dataBytes = gateID.getBytes();
25 Assert.assertEquals(9, gateID.getGateID());
26 Assert.assertEquals(4, dataBytes.length);
27 Assert.assertEquals(9, COPSMsgParser.bytesToInt(dataBytes[0], dataBytes[1], dataBytes[2], dataBytes[3]));
29 // Check the byte parsing
30 final GateID parsed = GateID.parse(dataBytes);
31 Assert.assertEquals(gateID, parsed);
35 public void byteParsing() {
36 final GateID gateID = new GateID(10);
37 final GateID parsed = GateID.parse(gateID.getBytes());
38 Assert.assertEquals(gateID, parsed);