Package org.jboss.metatype.api.values

Examples of org.jboss.metatype.api.values.CompositeValueSupport


     
      CollectionMetaType arrayType = assertInstanceOf(resolve(type), CollectionMetaType.class);
      CompositeMetaType compositeType = assertInstanceOf(resolve(TestSimpleComposite.class), CompositeMetaType.class);
      String[] itemNames = { "something" };
      MetaValue[] itemValues = { SimpleValueSupport.wrap("Hello") };
      CompositeValue helloValue = new CompositeValueSupport(compositeType, itemNames, itemValues);
      itemValues = new MetaValue[] { SimpleValueSupport.wrap("Goodbye") };
      CompositeValue goodbyeValue = new CompositeValueSupport(compositeType, itemNames, itemValues);
      MetaValue[] metaArray = { helloValue, goodbyeValue };
      CollectionValueSupport expected = new CollectionValueSupport(arrayType, metaArray);
     
      MetaValue result = createMetaValue(collection, type);
      CollectionValue actual = assertInstanceOf(result, CollectionValue.class);
View Full Code Here


      TestSimpleComposite[] array = { hello, goodbye };
      ArrayMetaType arrayType = assertInstanceOf(resolve(array.getClass()), ArrayMetaType.class);
      CompositeMetaType compositeType = assertInstanceOf(resolve(TestSimpleComposite.class), CompositeMetaType.class);
      String[] itemNames = { "something" };
      MetaValue[] itemValues = { SimpleValueSupport.wrap("Hello") };
      CompositeValue helloValue = new CompositeValueSupport(compositeType, itemNames, itemValues);
      itemValues = new MetaValue[] { SimpleValueSupport.wrap("Goodbye") };
      CompositeValue goodbyeValue = new CompositeValueSupport(compositeType, itemNames, itemValues);
      MetaValue[] metaArray = { helloValue, goodbyeValue };
      ArrayValueSupport expected = new ArrayValueSupport(arrayType, metaArray);
     
      MetaValue result = createMetaValue(array);
      ArrayValue actual = assertInstanceOf(result, ArrayValue.class);
View Full Code Here

   {
      CompositeMetaType compositeMetaType = initCompositeMetaType();
      Map<String, MetaValue> map = initMapValues();
      String[] keys = initKeys();
      MetaValue[] values = initValues();
      new CompositeValueSupport(compositeMetaType, map);
      new CompositeValueSupport(compositeMetaType, keys, values);
   }
View Full Code Here

    */
   public void testGetCompositeMetaType() throws Exception
   {
      CompositeMetaType compositeMetaType = initCompositeMetaType();
      Map<String, MetaValue> map = initMapValues();
      CompositeValue v = new CompositeValueSupport(compositeMetaType, map);
      assertEquals(compositeMetaType, v.getMetaType());
   }
View Full Code Here

    */
   public void testGet()throws Exception
   {
      CompositeMetaType compositeMetaType = initCompositeMetaType();
      Map<String, MetaValue> map = initMapValues();
      CompositeValue v = new CompositeValueSupport(compositeMetaType, map);

      assertEquals(initStringValue1(), v.get("name1"));
      assertEquals(initInteger2(), v.get("name2"));
   }
View Full Code Here

   {
      SimpleValue value1 = initStringValue1();
      SimpleValue integer2 = initInteger2();
      CompositeMetaType compositeMetaType = initCompositeMetaType();
      Map<String, MetaValue> map = initMapValues();
      CompositeValue v = new CompositeValueSupport(compositeMetaType, map);

      MetaValue[] result = v.getAll(new String[] { "name1", "name2" });
      assertEquals(value1, result[0]);
      assertEquals(integer2, result[1]);
      result = v.getAll(new String[] { "name2", "name1" });
      assertEquals(value1, result[1]);
      assertEquals(integer2, result[0]);
      result = v.getAll(new String[] { "name1" });
      assertEquals(value1, result[0]);
      result = v.getAll(new String[] { "name2" });
      assertEquals(integer2, result[0]);
   }
View Full Code Here

    */
   public void testContainsKey() throws Exception
   {
      CompositeMetaType compositeMetaType = initCompositeMetaType();
      Map<String, MetaValue> map = initMapValues();
      CompositeValue v = new CompositeValueSupport(compositeMetaType, map);
      assertTrue("data should contain key name1", v.containsKey("name1"));
      assertTrue("data should contain key name2", v.containsKey("name2"));
      assertFalse("data should not contain key nameX", v.containsKey("nameX"));
      assertFalse("data should not contain key null", v.containsKey(null));
      assertFalse("data should not contain key <empty>", v.containsKey(""));
   }
View Full Code Here

      SimpleValue nullString = initStringNull();
      SimpleValue emptyString = initStringEmpty();
      SimpleValue nullInteger = initIntegerNull();
      CompositeMetaType compositeMetaType = initCompositeMetaType();
      Map<String, MetaValue> map = initMapValues();
      CompositeValue v = new CompositeValueSupport(compositeMetaType, map);

      assertTrue("data should contain value value1", v.containsValue(value1));
      assertTrue("data should contain value 2", v.containsValue(integer2));
      assertFalse("data should not contain value name1", v.containsValue(name1));
      assertFalse("data should not contain key null", v.containsValue(null));
      assertFalse("data should not contain key null", v.containsValue(nullString));
      assertFalse("data should not contain key <empty>", v.containsValue(emptyString));

      map.clear();
      map.put("name1", value1);
      map.put("name2", null);
      v = new CompositeValueSupport(compositeMetaType, map);
      assertTrue("data should contain value null", v.containsValue(null));
      assertFalse("data should not contain key null", v.containsValue(nullString));

      map.clear();
      map.put("name1", value1);
      map.put("name2", nullInteger);
      v = new CompositeValueSupport(compositeMetaType, map);
      assertTrue("data should contain value null", v.containsValue(nullInteger));
      assertFalse("data should not contain key null", v.containsValue(null));
   }
View Full Code Here

      SimpleValue emptyString = initStringEmpty();
      SimpleValue nullInteger = initIntegerNull();

      CompositeMetaType compositeMetaType = initCompositeMetaType();
      Map<String, MetaValue> map = initMapValues();
      CompositeValue v = new CompositeValueSupport(compositeMetaType, map);
      Collection<?> values = v.values();
      assertTrue("data values contain 2 elements", values.size() == 2);
      assertTrue("data values should have value1", values.contains(value1));
      assertTrue("data values should have 2", values.contains(integer2));
      assertFalse("data values should not have name1", values.contains(name1));
      assertFalse("data values should not have null", values.contains(null));
      assertFalse("data values should not have null", values.contains(nullString));
      assertFalse("data values should not have <empty>", values.contains(emptyString));

      map.clear();
      map.put("name1", value1);
      map.put("name2", null);
      v = new CompositeValueSupport(compositeMetaType, map);
      values = v.values();
      assertTrue("data values should contain value null", values.contains(null));
      assertFalse("data values should not have null", values.contains(nullString));

      map.clear();
      map.put("name1", value1);
      map.put("name2", nullInteger);
      v = new CompositeValueSupport(compositeMetaType, map);
      values = v.values();
      assertTrue("data values should contain value null", values.contains(nullInteger));
      assertFalse("data values should not have null", values.contains(null));
   }
View Full Code Here

    */
   public void testEquals() throws Exception
   {
      CompositeMetaType compositeMetaType = initCompositeMetaType();
      Map<String, MetaValue> map = initMapValues();
      CompositeValue v = new CompositeValueSupport(compositeMetaType, map);

      assertEquals("data should equal itself", v, v);
      assertNotSame("data should not equal null", v, null);
      assertNotSame("data should not equal non CompositeData", v, new Object());

      CompositeValue v2 = new CompositeValueSupport(compositeMetaType, map);

      assertEquals("data should equal with data2 with different instance of the same composite type", v, v2);
      assertEquals("data should equal with data2 with different instance of the same composite type", v2, v);

      CompositeMetaType compositeMetaType2 = initCompositeMetaType2();
      v2 = new CompositeValueSupport(compositeMetaType2, map);

      assertNotSame("data should not be equal with data2 with different composite type", v, v2);
      assertNotSame("data2 should not be equal with data with different composite type", v2, v);

      Map<String, MetaValue> map2 = initMapValues2();
      v2 = new CompositeValueSupport(compositeMetaType, map2);

      assertNotSame("data should not be equal with data2 with different values", v, v2);
      assertNotSame("data2 should not be equal with data with different value", v2, v);
   }
View Full Code Here

TOP

Related Classes of org.jboss.metatype.api.values.CompositeValueSupport

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.