/**
 * Copyright (c) 2016-2020 by the respective copyright holders.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */
package com.zsmartsystems.zigbee.dongle.ember.internal.serializer;

import static org.junit.Assert.assertTrue;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import org.junit.Test;

import com.zsmartsystems.zigbee.dongle.ember.ezsp.structure.EmberInitialSecurityBitmask;
import com.zsmartsystems.zigbee.dongle.ember.internal.serializer.EzspSerializer;

/**
 *
 * @author Chris Jackson
 *
 */
public class EzspSerializerTest {
    @Test
    public void serializeEmberInitialSecurityBitmask() {
        EzspSerializer serializer;
        Set<EmberInitialSecurityBitmask> securityBitmask;

        serializer = new EzspSerializer();
        securityBitmask = new HashSet<EmberInitialSecurityBitmask>();
        securityBitmask.add(EmberInitialSecurityBitmask.EMBER_HAVE_PRECONFIGURED_KEY);
        securityBitmask.add(EmberInitialSecurityBitmask.EMBER_HAVE_NETWORK_KEY);
        securityBitmask.add(EmberInitialSecurityBitmask.EMBER_REQUIRE_ENCRYPTED_KEY);
        serializer.serializeEmberInitialSecurityBitmask(securityBitmask);
        assertTrue(Arrays.equals(new int[] { 0x00, 0x0B }, serializer.getPayload()));

        serializer = new EzspSerializer();
        securityBitmask = new HashSet<EmberInitialSecurityBitmask>();
        securityBitmask.add(EmberInitialSecurityBitmask.EMBER_TRUST_CENTER_USES_HASHED_LINK_KEY);
        serializer.serializeEmberInitialSecurityBitmask(securityBitmask);
        assertTrue(Arrays.equals(new int[] { 0x84, 0x00 }, serializer.getPayload()));

        serializer = new EzspSerializer();
        securityBitmask = new HashSet<EmberInitialSecurityBitmask>();
        securityBitmask.add(EmberInitialSecurityBitmask.EMBER_DISTRIBUTED_TRUST_CENTER_MODE);
        securityBitmask.add(EmberInitialSecurityBitmask.EMBER_HAVE_NETWORK_KEY);
        securityBitmask.add(EmberInitialSecurityBitmask.EMBER_NO_FRAME_COUNTER_RESET);
        serializer.serializeEmberInitialSecurityBitmask(securityBitmask);
        assertTrue(Arrays.equals(new int[] { 0x02, 0x12 }, serializer.getPayload()));
    }
}

@@ -613,89 +613,8 @@
 ask;
-%0Aimport com.zsmartsystems.zigbee.dongle.ember.internal.serializer.EzspSerializer;
 %0A%0A/*
@@ -2285,11 +2285,285 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void serializeInt8S() %7B%0A        EzspSerializer serializer = new EzspSerializer();%0A%0A        serializer.serializeInt8S(5);%0A        serializer.serializeInt8S(-5);%0A        assertTrue(Arrays.equals(new int%5B%5D %7B 0x05, 0xFB %7D, serializer.getPayload()));%0A    %7D
 %0A%7D%0A

Add test for serialising Ember Int8S (#1020)