@Test
public void testfindGroupByName() {

  final String groupName = "engineering";
  final GroupEntity entity = new GroupEntity();
  entity.setGroupName(groupName);
  TypedQuery<GroupEntity> query = createStrictMock(TypedQuery.class);
  // set expectations
  expect(entityManager.createNamedQuery(eq("groupByName"), eq(GroupEntity.class))).andReturn(query);
  expect(query.setParameter("groupname", groupName)).andReturn(query);
  expect(query.getSingleResult()).andReturn(entity);
  replay(entityManager, query);
  final GroupDAO dao = new GroupDAO();
  dao.entityManagerProvider = entityManagerProvider;
  final GroupEntity result = dao.findGroupByName(groupName);
  assertSame(entity, result);
  verify(entityManagerProvider, entityManager, query);
}