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