/**
   * Tests <code>{@link
   * CopilotProjectDAOImpl#update(com.topcoder.direct.services.copilot.model.IdentifiableEntity)}
   * </code> method.
   *
   * @throws CopilotDAOException if any error occurs
   */
  @Test
  @SuppressWarnings("unchecked")
  public void testUpdate() throws CopilotDAOException {

    CopilotProfile copilotProfile = TestHelper.createCopilotProfile();
    CopilotProject copilotProject = TestHelper.createCopilotProject();

    TestHelper.persistCopilotProjectDependencies(hibernateTemplate, copilotProfile, copilotProject);
    hibernateTemplate.save(copilotProject);

    copilotProject.setCompletionDate(new Date());
    copilotProject.setCustomerFeedback("test customer feedback");
    copilotProject.setCustomerRating(0.9F);
    copilotProject.setPmFeedback("test pm feedback");
    copilotProject.setPmRating(0.9F);

    CopilotProjectInfoType copilotProjectInfoType = TestHelper.createCopilotProjectInfoType();
    hibernateTemplate.save(copilotProjectInfoType);

    CopilotProjectInfo copilotProjectInfo = TestHelper.createCopilotProjectInfo();
    copilotProjectInfo.setInfoType(copilotProjectInfoType);
    copilotProject.getProjectInfos().add(copilotProjectInfo);

    instance.update(copilotProject);

    List<CopilotProject> result =
        (List<CopilotProject>)
            hibernateTemplate.find("from CopilotProject where id = ?", copilotProject.getId());

    assertCopilotProject(copilotProject, result.get(0));
  }
  /**
   * Tests <code>{@link
   * CopilotProjectDAOImpl#update(com.topcoder.direct.services.copilot.model.IdentifiableEntity)}
   * </code> method.
   *
   * <p>{@link CopilotDAOException} is expected.
   *
   * @throws CopilotDAOException if any error occurs
   */
  @Test(expected = CopilotDAOException.class)
  public void testUpdateFailure1() throws CopilotDAOException {

    CopilotProject copilotProject = TestHelper.createCopilotProject();

    Session session = instance.getSession();
    session.save(copilotProject.getStatus());
    session.save(copilotProject);
    session.delete(copilotProject);

    instance.update(copilotProject);
  }
  /**
   * Tests <code>{@link
   * CopilotProjectDAOImpl#update(com.topcoder.direct.services.copilot.model.IdentifiableEntity)}
   * </code> method.
   *
   * <p>{@link CopilotDAOException} is expected.
   *
   * @throws CopilotDAOException if any error occurs
   */
  @Test(expected = CopilotDAOException.class)
  public void testUpdateFailure2() throws CopilotDAOException {

    CopilotProject copilotProject = TestHelper.createCopilotProject();
    copilotProject.setId(1L);

    ApplicationContext applicationContext =
        new ClassPathXmlApplicationContext("invalidApplicationContext.xml");
    CopilotProjectDAOImpl copilotProjectDAO = new CopilotProjectDAOImpl();
    copilotProjectDAO.setSessionFactory(
        (SessionFactory) applicationContext.getBean("sessionFactory"));

    copilotProjectDAO.update(copilotProject);
  }
  /**
   * Tests <code>{@link
   * CopilotProjectDAOImpl#update(com.topcoder.direct.services.copilot.model.IdentifiableEntity)}
   * </code> method when entity has id set to 0.
   *
   * <p>{@link IllegalArgumentException} is expected.
   *
   * @throws CopilotDAOException if any error occurs
   */
  @Test(expected = IllegalArgumentException.class)
  public void testUpdateZero() throws CopilotDAOException {
    CopilotProject copilotProject = new CopilotProject();

    instance.update(copilotProject);
  }
  /**
   * Tests <code>{@link
   * CopilotProjectDAOImpl#update(com.topcoder.direct.services.copilot.model.IdentifiableEntity)}
   * </code> method when entity is null.
   *
   * <p>{@link IllegalArgumentException} is expected.
   *
   * @throws CopilotDAOException if any error occurs
   */
  @Test(expected = IllegalArgumentException.class)
  public void testUpdateNull() throws CopilotDAOException {

    instance.update(null);
  }