/*
   * Test method for {@link de.uni.freiburg.iig.telematik.sepia.petrinet.ifnet.RegularIFNetTransition#checkValidity()}. Check whether a transition with delete consumes but does not produce a token with a certain color.
   */
  @Test
  public void testCheckValidityDelete() throws ParameterException {

    // Get a simple standard SNet and one of its transitions
    IFNet sNet = IFNetTestUtil.createSimpleIFNet();
    RegularIFNetTransition rt = (RegularIFNetTransition) sNet.getTransition("t0");

    // Set "delete" to a produced color
    HashSet<AccessMode> dAccess = new HashSet<AccessMode>();
    dAccess.add(AccessMode.DELETE);
    rt.setAccessMode("blue", dAccess);

    try {
      rt.checkValidity();
      fail("A transition with delete on a certain color cannot produce this color!");
    } catch (PNValidationException e1) {
    }

    // clean up ...
    dAccess.clear();
    dAccess.add(AccessMode.CREATE);
    rt.setAccessMode("blue", dAccess);

    // set delete to a color which is not consumed
    HashSet<AccessMode> dAccess2 = new HashSet<AccessMode>();
    dAccess2.add(AccessMode.DELETE);
    rt.setAccessMode("pink", dAccess2);

    try {
      rt.checkValidity();
      fail("A transition with delete on a certain color must consume this color!");
    } catch (PNValidationException e1) {
    }
  }
  /*
   * Test method for {@link de.uni.freiburg.iig.telematik.sepia.petrinet.ifnet.RegularIFNetTransition#checkValidity()}. Check whether a valid transition is reported to be valid.
   */
  @Test
  public void testCheckValidityValid() throws ParameterException {

    // Get a simple standard SNet
    IFNet sNet = IFNetTestUtil.createSimpleIFNet();

    RegularIFNetTransition rt = (RegularIFNetTransition) sNet.getTransition("t0");
    try {
      rt.checkValidity();
    } catch (PNValidationException e1) {
      fail("CheckValidity throws an exception for a valid SNet transition.");
    }
  }
  /*
   * Test method for {@link de.uni.freiburg.iig.telematik.sepia.petrinet.ifnet.RegularIFNetTransition#checkValidity()}. Check whether a transition with neither creates nor deletes on a certain token color process that color.
   */
  @Test
  public void testCheckValidityProcess() throws ParameterException {

    // Get a simple standard SNet and one of its transitions
    IFNet sNet = IFNetTestUtil.createSimpleIFNet();
    RegularIFNetTransition rt = (RegularIFNetTransition) sNet.getTransition("t0");

    // Set "read" to a consumed but not produced color
    HashSet<AccessMode> rAccess = new HashSet<AccessMode>();
    rAccess.add(AccessMode.READ);
    rt.setAccessMode("red", rAccess);

    try {
      rt.checkValidity();
      fail("A token color which is only read must be consumed and produced.");
    } catch (PNValidationException e1) {
    }
  }
  /*
   * Test method for {@link de.uni.freiburg.iig.telematik.sepia.petrinet.ifnet.RegularIFNetTransition#checkValidity()}. Check whether a transition with create and delete is reported to be valid.
   */
  @Test
  public void testCheckValidityCreateDelete() throws ParameterException {

    // Get a simple standard SNet and one of its transtitions
    IFNet sNet = IFNetTestUtil.createSimpleIFNet();
    RegularIFNetTransition rt = (RegularIFNetTransition) sNet.getTransition("t0");

    // Set "create" and "delete" mode for one color
    HashSet<AccessMode> cdAccess = new HashSet<AccessMode>();
    cdAccess.add(AccessMode.DELETE);
    cdAccess.add(AccessMode.CREATE);
    rt.setAccessMode("pink", cdAccess);

    try {
      rt.checkValidity();
      fail("A transition with create and delete on the same color is not valid!.");
    } catch (PNValidationException e1) {
    }
  }