BaseEntity implements Serializable { public boolean isNew() { return id == null; } BaseEntity();  BaseEntity(BaseEntity clone); boolean isNew(); Integer getId(); void setId(Integer id); Integer getVersion(); void setVersion(Integer version); @Override String toString();  }
@Test public void isNew() { assertFalse("entity is new.", entity.isNew()); entity.setVersion(null); assertFalse("entity is new.", entity.isNew()); entity.setId(null); assertTrue("entity not new.", entity.isNew()); entity.setVersion(VERSION); assertTrue("entity not new.", entity.isNew()); }