Example #1
0
  @Test
  public void testDelete_failure() {

    replayAll();
    projectAction.setConfirmationString("no");
    assertEquals(Action.ERROR, projectAction.delete());

    verifyAll();
  }
Example #2
0
  @Test(expected = ObjectNotFoundException.class)
  public void testDelete_noSuchIteration() {
    projectAction.setProjectId(-1);
    projectBusiness.delete(-1);
    expect(projectBusiness.retrieve(-1)).andThrow(new ObjectNotFoundException());
    replayAll();
    projectAction.setConfirmationString("yes");
    projectAction.delete();

    verifyAll();
  }
Example #3
0
  @Test
  public void testDelete_success() {
    Project proj = new Project();
    Product parent = new Product();
    parent.setId(123);
    proj.setParent(parent);

    expect(projectBusiness.retrieve(1)).andReturn(proj);
    projectBusiness.delete(1);
    replayAll();
    projectAction.setConfirmationString("yes");
    assertEquals(Action.SUCCESS, projectAction.delete());
    assertEquals(123, projectAction.getProductId());
    verifyAll();
  }
Example #4
0
  @Test(expected = ConstraintViolationException.class)
  public void testDelete_forbidden() {
    Project proj = new Project();
    Product prod = new Product();
    prod.setId(123);
    proj.setParent(prod);
    expect(projectBusiness.retrieve(1)).andReturn(proj);
    projectBusiness.delete(1);
    expectLastCall().andThrow(new ConstraintViolationException(null, null, null));
    expect(projectBusiness.retrieve(1)).andReturn(new Project());
    replayAll();
    projectAction.setConfirmationString("yes");
    projectAction.delete();

    verifyAll();
  }