ToElementId extends KorypheFunction<Object, ElementId> { @Override public ElementId apply(final Object obj) { if (null == obj) { return null; } return obj instanceof ElementId ? (ElementId) obj : new EntitySeed(obj); }  @Override ElementId apply(final Object obj);  }
@Test public void shouldReturnNullIfTheInputIsNull() { final Object input = null; final ToElementId function = new ToElementId(); final ElementId output = function.apply(input); assertNull(output); }
@Test public void shouldReturnEntitySeedIfInputIsAnObject() { final Object input = "item"; final ToElementId function = new ToElementId(); final ElementId output = function.apply(input); assertEquals(new EntitySeed(input), output); }
@Test public void shouldReturnOriginalValueIfInputIsAnEntitySeed() { final EntitySeed input = new EntitySeed("item"); final ToElementId function = new ToElementId(); final ElementId output = function.apply(input); assertSame(input, output); }
@Test public void shouldReturnOriginalValueIfInputIsAnEntity() { final Entity input = new Entity("group", "item"); final ToElementId function = new ToElementId(); final ElementId output = function.apply(input); assertSame(input, output); }
@Test public void shouldReturnOriginalValueIfInputIsAnEdge() { final Edge input = new Edge("group"); final ToElementId function = new ToElementId(); final ElementId output = function.apply(input); assertSame(input, output); }