Package org.jboss.metatype.api.values

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


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

      int myHashCode = compositeMetaType.hashCode() + "value1".hashCode() + new Integer(2).hashCode();
      assertEquals("Wrong hash code generated", myHashCode, v.hashCode());
   }
View Full Code Here


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

      String toString = v.toString();

      assertTrue("toString() should contain the composite type", toString.indexOf(compositeMetaType.toString()) != -1);
      assertTrue("toString() should contain name1", toString.indexOf("name1") != -1);
      assertTrue("toString() should contain value1", toString.indexOf("value1") != -1);
      assertTrue("toString() should contain name2=", toString.indexOf("name2") != -1);
View Full Code Here

    */
   public void testSerialization() throws Exception
   {
      CompositeMetaType compositeMetaType = initCompositeMetaType();
      Map<String, MetaValue> map = initMapValues();
      CompositeValue v = new CompositeValueSupport(compositeMetaType, map);
      byte[] bytes = serialize(v);
      Object result = deserialize(bytes);
      assertEquals(v, result);
   }
View Full Code Here

     
      TableValue expected = new TableValueSupport(tableType);
      String[] itemNames = DefaultMetaTypeFactory.MAP_ITEM_NAMES;
     
      MetaValue[] keyValues1 = {SimpleValueSupport.wrap("Hello")};
      CompositeValueSupport key1 = new CompositeValueSupport(keyType, new String[]{"key"}, keyValues1);
      MetaValue[] itemValues = new MetaValue[] {key1, SimpleValueSupport.wrap(new Integer(1)) };
      expected.put(new CompositeValueSupport(entryType, itemNames, itemValues));

      MetaValue[] keyValues2 = {SimpleValueSupport.wrap("Goodbye")};
      CompositeValueSupport key2 = new CompositeValueSupport(keyType, new String[]{"key"}, keyValues2);
      itemValues = new MetaValue[] { key2, SimpleValueSupport.wrap(new Integer(2)) };
      expected.put(new CompositeValueSupport(entryType, itemNames, itemValues));

      MetaValue result = createMetaValue(map, collectionType);
      TableValue actual = assertInstanceOf(result, TableValue.class);
     
      getLog().debug("Map Value: " + actual);
View Full Code Here

      MutableCompositeMetaType compositeType = new MutableCompositeMetaType(TestSimpleComposite.class.getName(), TestSimpleComposite.class.getName());
      compositeType.addItem("something", "something", SimpleMetaType.STRING);
      compositeType.freeze();

      String[] compositeNames = { "something" };
      CompositeValue compositeValue = new CompositeValueSupport(compositeType, compositeNames, new MetaValue[] { SimpleValueSupport.wrap("Hello") });
     
      MetaValue[] itemValues = new MetaValue[] { compositeValue, SimpleValueSupport.wrap(new Integer(1)) };
      expected.put(new CompositeValueSupport(entryType, itemNames, itemValues));

      compositeValue = new CompositeValueSupport(compositeType, compositeNames, new MetaValue[] { SimpleValueSupport.wrap("Goodbye") });
      itemValues = new MetaValue[] { compositeValue, SimpleValueSupport.wrap(new Integer(2)) };
      expected.put(new CompositeValueSupport(entryType, itemNames, itemValues));

      MetaValue result = createMetaValue(map, collectionType);
      TableValue actual = assertInstanceOf(result, TableValue.class);
     
      getLog().debug("Map Value: " + actual);
View Full Code Here

      String[] itemNames = initKeys();
      MetaValue[] itemValues = initValues();

      try
      {
         new CompositeValueSupport(null, itemNames, itemValues);
         fail("Excepted IllegalArgumentException for null composite type");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }

      try
      {
         new CompositeValueSupport(compositeMetaType, null, itemValues);
         fail("Excepted IllegalArgumentException for null item names");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }

      try
      {
         new CompositeValueSupport(compositeMetaType, new String[0], itemValues);
         fail("Excepted IllegalArgumentException for empty item names");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }

      try
      {
         new CompositeValueSupport(compositeMetaType, itemNames, null);
         fail("Excepted IllegalArgumentException for null item values");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }

      try
      {
         new CompositeValueSupport(compositeMetaType, itemNames, new MetaValue[0]);
         fail("Excepted IllegalArgumentException for empty item values");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }

      try
      {
         new CompositeValueSupport(compositeMetaType, new String[] { "name1", null }, itemValues);
         fail("Excepted IllegalArgumentException for a null item name");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }

      try
      {
         new CompositeValueSupport(compositeMetaType, new String[] { "name1", "" }, itemValues);
         fail("Excepted IllegalArgumentException for an empty item name");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }

      try
      {
         new CompositeValueSupport(compositeMetaType, itemNames, new MetaValue[] { initStringWrong() });
         fail("Excepted IllegalArgumentException for mismatch in number of itemNames/itemValues");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }

      try
      {
         new CompositeValueSupport(compositeMetaType, new String[] { "name1", "wrongName" }, itemValues);
         fail("Excepted IllegalArgumentException for an item name not in the composite type");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }

      try
      {
         new CompositeValueSupport(compositeMetaType, itemNames, new MetaValue[] { initStringValue1(), initStringWrong() });
         fail("Excepted IllegalArgumentException for an item value of the wrong type");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }

      new CompositeValueSupport(compositeMetaType, itemNames, new MetaValue[] { initStringValue1(), null });
      new CompositeValueSupport(compositeMetaType, itemNames, new MetaValue[] { initStringValue1(), initIntegerNull() });
   }
View Full Code Here

      MutableCompositeMetaType compositeType = new MutableCompositeMetaType(TestSimpleComposite.class.getName(), TestSimpleComposite.class.getName());
      compositeType.addItem("something", "something", SimpleMetaType.STRING);
      compositeType.freeze();

      String[] compositeNames = { "something" };
      CompositeValue compositeValue = new CompositeValueSupport(compositeType, compositeNames, new MetaValue[] { SimpleValueSupport.wrap("Hello") });
     
      MetaValue[] keyValues1 = {SimpleValueSupport.wrap("Hello")};
      CompositeValueSupport key1 = new CompositeValueSupport(keyType, new String[]{"key"}, keyValues1);
      MetaValue[] itemValues = new MetaValue[] { key1, compositeValue };
      expected.put(new CompositeValueSupport(entryType, itemNames, itemValues));

      MetaValue[] keyValues2 = {SimpleValueSupport.wrap("Goodbye")};
      CompositeValueSupport key2 = new CompositeValueSupport(keyType, new String[]{"key"}, keyValues2);
      compositeValue = new CompositeValueSupport(compositeType, compositeNames, new MetaValue[] { SimpleValueSupport.wrap("Goodbye") });
      itemValues = new MetaValue[] { key2, compositeValue };
      expected.put(new CompositeValueSupport(entryType, itemNames, itemValues));

      MetaValue result = createMetaValue(map, collectionType);
      TableValue actual = assertInstanceOf(result, TableValue.class);
     
      getLog().debug("Map Value: " + actual);
View Full Code Here

      CompositeMetaType compositeMetaType = initCompositeMetaType();
      Map<String, MetaValue> map = initMapValues();

      try
      {
         new CompositeValueSupport(null, map);
         fail("Excepted IllegalArgumentException for null composite type");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }

      try
      {
         HashMap<String, MetaValue> map2 = new HashMap<String, MetaValue>();
         map2.put("name1", initStringValue1());
         map2.put(null, initInteger2());
         new CompositeValueSupport(compositeMetaType, map2);
         fail("Excepted IllegalArgumentException for a null key in map");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }

      try
      {
         HashMap<String, MetaValue> map2 = new HashMap<String, MetaValue>();
         map2.put("name1", initStringValue1());
         map2.put("", initInteger2());
         new CompositeValueSupport(compositeMetaType, map2);
         fail("Excepted IllegalArgumentException for an empty key in map");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }

      try
      {
         HashMap<String, MetaValue> map2 = new HashMap<String, MetaValue>();
         map2.put("name1", initStringValue1());
         map2.put("wrongName", initInteger2());
         new CompositeValueSupport(compositeMetaType, map2);
         fail("Excepted IllegalArgumentException for an item name not in the composite type");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }

      try
      {
         HashMap<String, MetaValue> map2 = new HashMap<String, MetaValue>();
         map2.put("name1", initStringValue1());
         map2.put("name2", initStringWrong());
         new CompositeValueSupport(compositeMetaType, map2);
         fail("Excepted IllegalArgumentException for an item value of the wrong type");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }

      HashMap<String, MetaValue> map2 = new HashMap<String, MetaValue>();
      map2.put("name1", initStringValue1());
      map2.put("name2", null);
      new CompositeValueSupport(compositeMetaType, map2);

      map2 = new HashMap<String, MetaValue>();
      map2.put("name1", initStringValue1());
      map2.put("name2", initIntegerNull());
      new CompositeValueSupport(compositeMetaType, map2);
   }
View Full Code Here

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

      try
      {
         data.get(null);
         fail("Excepted IllegalArgumentException for get and a null key");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }

      try
      {
         data.get("");
         fail("Excepted IllegalArgumentException for get and an empty key");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }

      try
      {
         data.get("wrong");
         fail("Excepted IllegalArgumentException for get and a wrong key");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }

      try
      {
         data.getAll(new String[] { "name1", null });
         fail("Excepted IllegalArgumentException for getAll and a null key");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }

      try
      {
         data.getAll(new String[] { "name1", "" });
         fail("Excepted IllegalArgumentException for getAll and an empty key");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }

      try
      {
         data.getAll(new String[] { "name1", "wrong" });
         fail("Excepted IllegalArgumentException for getAll and an invalid key");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
View Full Code Here

   }

   public MetaValue buildMetaValue(MetaType metaType, TestOverrideComposite object)
   {
      CompositeMetaType compositeType = (CompositeMetaType) metaType;
      CompositeValueSupport result = new CompositeValueSupport(compositeType);
      result.set("somethingElse", SimpleValueSupport.wrap(object.getSomething()));
      return result;
   }
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.