OperationUtil { public static Iterable<? extends ElementId> toElementIds(final Object... input) { if (null == input) { return null; } return Arrays.stream(input).map(new ToElementId()).collect(Collectors.toList()); } private  OperationUtil(); static Iterable<? extends ElementId> toElementIds(final Object... input); static Iterable<? extends ElementId> toElementIds(final Iterable<?> input); static Iterable<?> fromElementIds(final Iterable<? extends ElementId> input); static Iterable<? extends EntityId> toEntityIds(final Object... input); static Iterable<? extends EntityId> toEntityIds(final Iterable<?> input); static Iterable<?> fromEntityIds(final Iterable<? extends EntityId> input); static Operation extractNextOp(final Iterator<Operation> itr);  }
@Test public void shouldReturnNullIfConvertObjectArrayToElementIdsWithNullInput() { final Object[] input = null; final Iterable<? extends ElementId> output = OperationUtil.toElementIds(input); assertNull(output); }
@Test public void shouldConvertObjectArrayToElementIds() { final Object[] input = { 1, "2", new EntitySeed("3"), new Entity("group", "4"), new EdgeSeed("5", 6), new Edge("group", 7L, 8, true), null }; final Iterable<? extends ElementId> output = OperationUtil.toElementIds(input); final ArrayList<ElementId> expected = Lists.newArrayList( new EntitySeed(1), new EntitySeed("2"), new EntitySeed("3"), new Entity("group", "4"), new EdgeSeed("5", 6), new Edge("group", 7L, 8, true), null ); assertEquals(expected, Lists.newArrayList(output)); }
@Test public void shouldConvertIterableToElementIds() { final Iterable<Object> input = Arrays.asList( 1, "2", new EntitySeed("3"), new Entity("group", "4"), new EdgeSeed("5", 6), new Edge("group", 7L, 8, true), null ); final Iterable<? extends ElementId> output = OperationUtil.toElementIds(input); final ArrayList<ElementId> expected = Lists.newArrayList( new EntitySeed(1), new EntitySeed("2"), new EntitySeed("3"), new Entity("group", "4"), new EdgeSeed("5", 6), new Edge("group", 7L, 8, true), null ); assertEquals(expected, Lists.newArrayList(output)); }