EntityParserDaoValidatorImpl implements EntityParserDao { @Override public <T extends Serializable> T find(Serializable primaryKey, Class<T> type) { try { T t = type.newInstance(); setPrimaryKey(primaryKey, type, t); return t; } catch (Exception e) { LOG.error(e); return null; } } EntityParserDaoValidatorImpl(); @Override Serializable persist(T object); @Override T find(Serializable primaryKey, Class<T> type);  }
@Test public void when_finding_should_set_proper_id_for_generated_int() { User user = subject.find(1, User.class); assertEquals(1, user.getUserId().intValue()); }
@Test public void when_finding_should_set_proper_id_for_string() { UserRole userRole = subject.find("ADMIN", UserRole.class); assertEquals("ADMIN", userRole.getRole()); }
@Test public void when_finding_should_set_proper_id_for_embeddable_id() { TimesheetEntryId timesheetEntryId = new TimesheetEntryId(new Date(), ProjectAssignmentObjectMother.createProjectAssignment(1)); TimesheetEntry entry = subject.find(timesheetEntryId, TimesheetEntry.class); assertEquals(timesheetEntryId, entry.getEntryId()); }