Package org.jboss.dependency.spi

Examples of org.jboss.dependency.spi.Cardinality


      assertEquals(Cardinality.ZERO_TO_ONE, Cardinality.toCardinality("0..1"));
      assertEquals(Cardinality.ZERO_TO_MANY, Cardinality.toCardinality("0..n"));
      assertEquals(Cardinality.ONE_TO_ONE, Cardinality.toCardinality("1..1"));
      assertEquals(Cardinality.ONE_TO_MANY, Cardinality.toCardinality("1..n"));

      Cardinality c1 = Cardinality.toCardinality("2..20");
      assertEquals(2, c1.getLeft());
      assertEquals(20, c1.getRight());

      Cardinality c2 = Cardinality.createCardinality(2, 20);
      assertEquals(2, c2.getLeft());
      assertEquals(20, c2.getRight());

      Cardinality c3 = Cardinality.createUnlimitedCardinality(10);
      assertEquals(10, c3.getLeft());
      assertTrue(c3.isRightInfinity());

      Cardinality c4 = Cardinality.createLimitedCardinality(10);
      assertEquals(0, c4.getLeft());
      assertEquals(10, c4.getRight());

      Cardinality c5 = Cardinality.createCardinality(Cardinality.INFINITY, Cardinality.INFINITY);
      assertTrue(c5.isLeftInfinity());
      assertTrue(c5.isRightInfinity());
   }
View Full Code Here


      assertTrue(c5.isRightInfinity());
   }

   public void testRangeCardinality() throws Throwable
   {
      Cardinality c1 = Cardinality.fromString("5..10");
      assertTrue(c1.isInRange(5));
      assertTrue(c1.isInRange(7));
      assertTrue(c1.isInRange(10));
      assertFalse(c1.isInRange(-1));
      assertFalse(c1.isInRange(3));
      assertFalse(c1.isInRange(20));
      assertFalse(c1.isInRange(Cardinality.INFINITY));

      Cardinality c2 = Cardinality.ZERO_TO_MANY;
      assertFalse(c2.isInRange(-1));
      assertTrue(c2.isInRange(0));
      assertTrue(c2.isInRange(Integer.MAX_VALUE));

      Cardinality c3 = Cardinality.ONE_TO_MANY;
      assertFalse(c3.isInRange(-1));
      assertFalse(c3.isInRange(0));
      assertTrue(c3.isInRange(1));
      assertTrue(c3.isInRange(Integer.MAX_VALUE));

      Cardinality c4 = Cardinality.createCardinality(Cardinality.INFINITY, Cardinality.INFINITY);
      assertFalse(c4.isInRange(-1));
      assertFalse(c4.isInRange(0));
      assertFalse(c4.isInRange(1));
      assertFalse(c4.isInRange(10));
      assertFalse(c4.isInRange(Integer.MAX_VALUE));
   }
View Full Code Here

TOP

Related Classes of org.jboss.dependency.spi.Cardinality

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.