コード例 #1
0
  public static List<Product> create(
      EntityManager entityManager, int numProducts, int numChildComponentsEach) {

    List<Product> mocks = new ArrayList<Product>(numProducts);
    for (int x = 0; x < numProducts; ++x) {
      Product mock = populate(new Product());
      if (entityManager != null) {
        entityManager.persist(mock);

        Profile defaultAssignee = MockProfileFactory.create(entityManager);
        List<Component> components =
            MockComponentFactory.createWithProduct(entityManager, numChildComponentsEach, mock);
        for (Component component : components) {
          component.setInitialOwner(defaultAssignee);
          defaultAssignee.getInitialOwnerComponents().add(component);
          component.setProduct(mock);
          mock.getComponents().add(component);
          entityManager.persist(component);
        }
        Milestone defaultMilestone = new Milestone();
        defaultMilestone.setProduct(mock);
        mock.getMilestones().add(defaultMilestone);
        defaultMilestone.setValue("---");
        defaultMilestone.setSortkey((short) 0);
        entityManager.persist(defaultMilestone);

        mock.setDefaultmilestone(defaultMilestone.getValue());
      }
      mocks.add(mock);
    }
    return mocks;
  }
コード例 #2
0
  @Test
  public void defaultMilestoneInMilestones() {
    Milestone m = new Milestone();
    m.setValue("bogus value adfasdfadfadfadf");

    mock.setDefaultmilestone(m.getValue());
    internalValidator.validate(mock, result);
    assertHaveValidationError("defaultMilestone.notInAssociatedMilestones");
  }
コード例 #3
0
  private void validateMilestoneMatchesProduct(Task task, Errors errors) {

    for (Milestone productMilestone : task.getProduct().getMilestones()) {
      if (productMilestone.getValue().equals(task.getTargetMilestone())) {
        return;
      }
    }
    // FIXME TASK 168
    // errors.rejectValue("targetMilestone", "milestoneDoesNotMatchProduct");
  }