Examples of DataList


Examples of com.linkedin.data.DataList

  public static class FooRecordArray extends WrappingArrayTemplate<FooRecord>
  {
    public static final ArrayDataSchema SCHEMA = (ArrayDataSchema) DataTemplateUtil.parseSchema("{ \"type\" : \"array\", \"items\" : { \"type\" : \"record\", \"name\" : \"Foo\", \"fields\" : [ { \"name\" : \"bar\", \"type\" : \"string\" } ] } }");
    public FooRecordArray()
    {
      this(new DataList());
    }
View Full Code Here

Examples of com.linkedin.data.DataList

    {
      this(new DataList());
    }
    public FooRecordArray(int capacity)
    {
      this(new DataList(capacity));
    }
View Full Code Here

Examples of com.linkedin.data.DataList

    {
      this(new DataList(capacity));
    }
    public FooRecordArray(Collection<FooRecord> c)
    {
      this(new DataList(c.size()));
      addAll(c);
    }
View Full Code Here

Examples of com.linkedin.data.DataList

    {
      dataMapsOfRecordTemplates.add(recordTemplate.data());
    }
    DataMap dataMapCollection = new DataMap();
    dataMapCollection.put(CollectionResponse.ELEMENTS,
                          new DataList(dataMapsOfRecordTemplates));
    return new CollectionResponse<T>(dataMapCollection, entryClass);
  }
View Full Code Here

Examples of com.linkedin.data.DataList

    DataMap actual = new DataMap();
    actual.put("key1", "value1");

    DataMap expected = new DataMap();
    expected.put("key1", "value1");
    expected.put("key2", new DataList());
    expected.put("key3", new DataMap());

    try
    {
      DataAssert.assertDataMapsEqual(actual, expected, Collections.<String>emptySet(), false);
View Full Code Here

Examples of com.linkedin.data.DataList

      }

      // test wrapping
      array1.clear();
      array1.addAll(input);
      DataList dataList2 = new DataList();
      ArrayTemplate array2 = DataTemplateUtil.wrap(dataList2, schema, templateClass); // with schema arg
      for (E e : input)
      {
        if (e instanceof DataTemplate)
        {
          dataList2.add(((DataTemplate<?>) e).data());
        }
        else if (e instanceof Enum)
        {
          dataList2.add(e.toString());
        }
        else
        {
          dataList2.add(e);
        }
      }
      assertEquals(array1, array2);
      ArrayTemplate array2a = DataTemplateUtil.wrap(dataList2, templateClass); // without schema arg
      assertEquals(array1, array2a);
View Full Code Here

Examples of com.linkedin.data.DataList

  {
    try
    {
      Exception exc = null;
      ArrayTemplate arrayTemplateBad = templateClass.newInstance();
      DataList badDataList = new DataList();
      ArrayTemplate badWrappedArrayTemplate = DataTemplateUtil.wrap(badDataList, schema, templateClass);

      List<E> badIn = (List<E>) badInput;

      // add(E element)
      for (E o : badIn)
      {
        try
        {
          exc = null;
          arrayTemplateBad.add(o);
        }
        catch (Exception e)
        {
          exc = e;
        }
        assertTrue(exc != null);
        assertTrue(o == null || exc instanceof ClassCastException);
        assertTrue(o != null || exc instanceof NullPointerException);
      }

      // add(int index, E element)
      for (Object o : badIn)
      {
        try
        {
          exc = null;
          arrayTemplateBad.add(0, (E) o);
        }
        catch (Exception e)
        {
          exc = e;
        }
        assertTrue(exc != null);
        assertTrue(o == null || exc instanceof ClassCastException);
        assertTrue(o != null || exc instanceof NullPointerException);
      }

      // addAll(Collection<E> c)
      try
      {
        exc = null;
        arrayTemplateBad.addAll(badIn);
      }
      catch (Exception e)
      {
        exc = e;
      }
      assertTrue(exc != null);
      assertTrue(exc instanceof ClassCastException);

      // set(int index, E element)
      arrayTemplateBad.addAll(good);
      assertTrue(arrayTemplateBad.size() > 1);
      for (Object o : badIn)
      {
        try
        {
          exc = null;
          arrayTemplateBad.set(0, (E) o);
        }
        catch (Exception e)
        {
          exc = e;
        }
        assertTrue(exc != null);
        assertTrue(o == null || exc instanceof ClassCastException);
        assertTrue(o != null || exc instanceof NullPointerException);
      }

      // listIterator add
      for (Object o : badIn)
      {
        try
        {
          exc = null;
          ListIterator<E> it = arrayTemplateBad.listIterator(0);
          it.add((E) o);
        }
        catch (Exception e)
        {
          exc = e;
        }
        assertTrue(exc != null);
        assertTrue(o == null || exc instanceof ClassCastException);
        assertTrue(o != null || exc instanceof NullPointerException);
      }

      // listIterator set
      for (Object o : badIn)
      {
        try
        {
          exc = null;
          ListIterator<E> it = arrayTemplateBad.listIterator(0);
          it.next();
          it.set((E) o);
        }
        catch (Exception e)
        {
          exc = e;
        }
        assertTrue(exc != null);
        assertTrue(o == null || exc instanceof ClassCastException);
        assertTrue(o != null || exc instanceof NullPointerException);
      }

      badDataList.clear();
      badDataList.addAll(badOutput);
      badWrappedArrayTemplate = DataTemplateUtil.wrap(badDataList, schema, templateClass);

      // Get returns bad
      for (int i = 0; i < badWrappedArrayTemplate.size(); ++i)
      {
        try
        {
          exc = null;
          badWrappedArrayTemplate.get(i);
        }
        catch (Exception e)
        {
          exc = e;
        }
        assertTrue(exc != null);
        assertTrue(exc instanceof TemplateOutputCastException);
      }

      // Set returns bad
      badDataList.clear();
      badDataList.addAll(badOutput);
      assertEquals(badWrappedArrayTemplate.size(), badOutput.size());
      for (int i = 0; i < badWrappedArrayTemplate.size(); ++i)
      {
        try
        {
          exc = null;
          badWrappedArrayTemplate.set(i, good.get(0));
        }
        catch (Exception e)
        {
          exc = e;
        }
        assertTrue(exc != null);
        assertTrue(exc instanceof TemplateOutputCastException);
      }

      // Remove returns bad
      badDataList.clear();
      badDataList.addAll(badOutput);
      assertEquals(badWrappedArrayTemplate.size(), badOutput.size());
      for (int i = 0; i < badWrappedArrayTemplate.size(); ++i)
      {
        try
        {
          exc = null;
          badWrappedArrayTemplate.remove(0);
        }
        catch (Exception e)
        {
          exc = e;
        }
        assertTrue(exc != null);
        assertTrue(exc instanceof TemplateOutputCastException);
      }

      // Iterator returns bad
      for (Object o : badOutput)
      {
        badDataList.clear();
        badDataList.add(o);
        try
        {
          exc = null;
          badWrappedArrayTemplate.iterator().next();
        }
        catch (Exception e)
        {
          exc = e;
        }
        assertTrue(exc != null);
        assertTrue(exc instanceof TemplateOutputCastException);
      }

      // ListIterator returns bad
      for (Object o : badOutput)
      {
        badDataList.clear();
        badDataList.add(o);
        try
        {
          exc = null;
          badWrappedArrayTemplate.listIterator().next();
        }
        catch (Exception e)
        {
          exc = e;
        }
        assertTrue(exc != null);
        assertTrue(exc instanceof TemplateOutputCastException);
      }
      for (Object o : badOutput)
      {
        badDataList.clear();
        badDataList.add(o);
        try
        {
          exc = null;
          badWrappedArrayTemplate.listIterator(badWrappedArrayTemplate.size()).previous();
        }
View Full Code Here

Examples of com.linkedin.data.DataList

      // deleteCommand value is of type DataList
      assert deleteCommand.getClass() == DataList.class;
      // data is of type DataMap
      assert data.getClass() == DataMap.class;

      DataList delDataList = (DataList) deleteCommand;
      DataMap dataDataMap = (DataMap) data;

      for (Object key : delDataList)
      {
        if (usedFields.containsKey(key))
View Full Code Here

Examples of com.linkedin.data.DataList

        assertEquals(castTo.get(i), array1.get(i));
        assertEquals(array1.data().get(i), castTo.get(i));
      }

      // test underlying is non-native, convert on get to element type on get.
      DataList dataList2 = new DataList(castFrom);
      ArrayTemplate array2 = DataTemplateUtil.wrap(dataList2, schema, templateClass);
      for (int i = 0; i < castTo.size(); ++i)
      {
        assertSame(dataList2.get(i), castFrom.get(i));
        assertEquals(castTo.get(i), array2.get(i));
      }
    }
    catch (InstantiationException exc)
    {
View Full Code Here

Examples of com.linkedin.data.DataList

    ArrayDataSchema schema = (ArrayDataSchema) DataTemplateUtil.parseSchema("{ \"type\" : \"array\", \"items\" : \"boolean\" }");

    List<Boolean> input = Arrays.asList(true, false); // must be unique
    List<Boolean> adds = Arrays.asList(false, true, true, false);
    List<Object> badInput = asList(1, 2L, 3f, 4.0, "hello", ByteString.empty(), new StringMap(), new StringArray(), null);
    List<Object> badOutput = asList(1, 2L, 3f, 4.0, "hello", ByteString.empty(), new DataMap(), new DataList());

    testArray(BooleanArray.class, schema, input, adds);
    testArrayBadInput(BooleanArray.class, schema, input, badInput, badOutput);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.