コード例 #1
0
  /**
   * Tests <code>{@link CopilotProjectDAOImpl#delete(long)}</code> method.
   *
   * @throws CopilotDAOException if any error occurs
   */
  @Test
  @SuppressWarnings("unchecked")
  public void testDelete2() throws CopilotDAOException {

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

    TestHelper.persistCopilotProjectDependencies(hibernateTemplate, copilotProfile, copilotProject);

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

    CopilotProjectInfo copilotProjectInfo = TestHelper.createCopilotProjectInfo();
    copilotProjectInfo.setCopilotProjectId(copilotProject.getId());
    copilotProjectInfo.setInfoType(copilotProjectInfoType);
    copilotProject.getProjectInfos().add(copilotProjectInfo);
    hibernateTemplate.save(copilotProject);

    instance.delete(copilotProject.getId());

    Assert.assertEquals(
        "None entity in database should exist.",
        0,
        hibernateTemplate.find("from CopilotProject").size());
    Assert.assertEquals(
        "None entity in database should exist.",
        0,
        hibernateTemplate.find("from CopilotProjectInfo").size());
  }
コード例 #2
0
  /**
   * Tests <code>{@link CopilotProjectDAOImpl#delete(long)}</code> method.
   *
   * <p>{@link CopilotDAOException} is expected.
   *
   * @throws CopilotDAOException if any error occurs
   */
  @Test(expected = CopilotDAOException.class)
  public void testDeleteFailure3() throws CopilotDAOException {

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

    copilotProjectDAO.delete(1L);
  }
コード例 #3
0
  /**
   * Tests <code>{@link CopilotProjectDAOImpl#delete(long)}</code> method.
   *
   * @throws CopilotDAOException if any error occurs
   */
  @Test
  @SuppressWarnings("unchecked")
  public void testDelete1() throws CopilotDAOException {

    CopilotProfile copilotProfile1 = TestHelper.createCopilotProfile();
    CopilotProject copilotProject1 = TestHelper.createCopilotProject();

    TestHelper.persistCopilotProjectDependencies(
        hibernateTemplate, copilotProfile1, copilotProject1);
    hibernateTemplate.save(copilotProject1);

    CopilotProfile copilotProfile2 = TestHelper.createCopilotProfile();
    CopilotProject copilotProject2 = TestHelper.createCopilotProject();

    TestHelper.persistCopilotProjectDependencies(
        hibernateTemplate, copilotProfile2, copilotProject2);
    hibernateTemplate.save(copilotProject2);

    instance.delete(copilotProject1.getId());

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

    Assert.assertEquals(
        "One entity in database should still exist.",
        1,
        hibernateTemplate.find("from CopilotProject").size());
    Assert.assertEquals("Entity was not deleted.", 0, result.size());

    instance.delete(copilotProject2.getId());

    result = hibernateTemplate.find("from CopilotProject where id = ?", copilotProject2.getId());

    Assert.assertEquals(
        "None entity in database should exist.",
        0,
        hibernateTemplate.find("from CopilotProject").size());
    Assert.assertEquals("Entity was not deleted.", 0, result.size());
  }
コード例 #4
0
  /**
   * Tests <code>{@link CopilotProjectDAOImpl#delete(long)}</code> method when entity id is 0.
   *
   * <p>{@link IllegalArgumentException} is expected.
   *
   * @throws CopilotDAOException if any error occurs
   */
  @Test(expected = IllegalArgumentException.class)
  public void testDeleteZero() throws CopilotDAOException {

    instance.delete(0L);
  }
コード例 #5
0
  /**
   * Tests <code>{@link CopilotProjectDAOImpl#delete(long)}</code> method.
   *
   * <p>{@link com.topcoder.direct.services.copilot.dao.EntityNotFoundException} is expected.
   *
   * @throws CopilotDAOException if any error occurs
   */
  @Test(expected = EntityNotFoundException.class)
  public void testDeleteFailure1() throws CopilotDAOException {

    instance.delete(1L);
  }