@BeforeClass
  public static void init() {

    setEncapsulationAction = new SetTaggedEthernetEncapsulationAction();
    removeEncapsulationAction = new RemoveTaggedEthernetEncapsulationAction();
    setVlanAction = new SetVlanIdAction();

    setEncapsulationAction.setModelToUpdate(new ComputerSystem());
    removeEncapsulationAction.setModelToUpdate(new ComputerSystem());
    setVlanAction.setModelToUpdate(new ComputerSystem());

    protocolManager = new ProtocolManager();
    try {
      protocolSessionManager =
          (ProtocolSessionManager) protocolManager.getProtocolSessionManager(resourceId);
      protocolSessionManager.setEventManager(new MockEventManager());
      netconfContext = newSessionContextNetconf();
      protocolManager.sessionFactoryAdded(
          new NetconfProtocolSessionFactory(),
          new HashMap<String, String>() {
            {
              put(ProtocolSessionContext.PROTOCOL, "netconf");
            }
          });
      protocolSessionManager.registerContext(netconfContext);
    } catch (ProtocolException e) {
      e.printStackTrace();
    }
  }
 @Test
 public void TestActionID() {
   Assert.assertEquals(
       ActionConstants.SET_TAGGEDETHERNET_ENCAPSULATION, setEncapsulationAction.getActionID());
   Assert.assertEquals(
       ActionConstants.REMOVE_TAGGEDETHERNET_ENCAPSULATION,
       removeEncapsulationAction.getActionID());
   Assert.assertEquals(ActionConstants.SET_VLANID, setVlanAction.getActionID());
 }
  @Test
  public void checkParamsTest() throws ActionException {

    LogicalPort phyFeIface = createPhysicalInterface("fe-0/3/1");
    LogicalPort phyLtIface = createPhysicalInterface("lt-1/2/0");
    LogicalPort feIface = createEthernetPort("fe-0/3/1", 2);
    LogicalPort ltIface = createLogicalTunnelPort("lt-1/2/0", 2);

    Assert.assertTrue(setEncapsulationAction.checkParams(phyFeIface));
    Assert.assertTrue(setEncapsulationAction.checkParams(ltIface));
    Assert.assertTrue(removeEncapsulationAction.checkParams(phyFeIface));
    Assert.assertTrue(removeEncapsulationAction.checkParams(ltIface));

    try {
      setEncapsulationAction.checkParams(phyLtIface);
      Assert.fail("SetTaggedEthEncapsulation on physical lt interface should fail");
    } catch (ActionException e) {
    }
    try {
      setEncapsulationAction.checkParams(feIface);
      Assert.fail("SetTaggedEthEncapsulation on logical fe interface should fail");
    } catch (ActionException e) {
    }
    try {
      removeEncapsulationAction.checkParams(phyLtIface);
      Assert.fail("RemoveTaggedEthEncapsulation on physical lt interface should fail");
    } catch (ActionException e) {
    }
    try {
      removeEncapsulationAction.checkParams(feIface);
      Assert.fail("RemoveTaggedEthEncapsulation on logical fe interface should fail");
    } catch (ActionException e) {
    }

    try {
      setVlanAction.checkParams(phyFeIface);
      Assert.fail("Set vlanid action on physical interface should fail");
    } catch (ActionException e) {
    }
    try {
      setVlanAction.checkParams(phyLtIface);
      Assert.fail("Set vlanid action on physical interface should fail");
    } catch (ActionException e) {
    }

    try {
      setVlanAction.checkParams(feIface);
      Assert.fail("Set vlanid action without vlan should fail");
    } catch (ActionException e) {
    }
    try {
      setVlanAction.checkParams(ltIface);
      Assert.fail("Set vlanid action without vlan should fail");
    } catch (ActionException e) {
    }

    // add vlans
    phyFeIface = addVlanToIface(phyFeIface, 12);
    phyLtIface = addVlanToIface(phyLtIface, 12);
    feIface = addVlanToIface(feIface, 12);
    ltIface = addVlanToIface(ltIface, 12);

    try {
      setVlanAction.checkParams(phyFeIface);
      Assert.fail("Set vlanid action on physical interface should fail");
    } catch (ActionException e) {
    }
    try {
      setVlanAction.checkParams(phyLtIface);
      Assert.fail("Set vlanid action on physical interface should fail");
    } catch (ActionException e) {
    }
    Assert.assertTrue(setVlanAction.checkParams(feIface));
    Assert.assertTrue(setVlanAction.checkParams(ltIface));

    // use invalid vlans
    LogicalPort feIface2 = createEthernetPort("fe-0/3/1", 2);
    LogicalPort ltIface2 = createLogicalTunnelPort("lt-1/2/0", 2);
    feIface2 = addVlanToIface(feIface2, 8888);
    ltIface2 = addVlanToIface(ltIface2, 8888);

    try {
      setVlanAction.checkParams(feIface2);
      Assert.fail("Set vlanid action with invalid vlan id should fail");
    } catch (ActionException e) {
    }
    try {
      setVlanAction.checkParams(ltIface2);
      Assert.fail("Set vlanid action with invalid vlan id should fail");
    } catch (ActionException e) {
    }
  }