Package net.sf.pmr.agilePlanning.domain.story

Examples of net.sf.pmr.agilePlanning.domain.story.Story


     * </ul>
     */
    public void testDelete() {
     

        Story storyToDelete = new StoryImpl();
        storyToDelete.setPersistanceVersion(1);
        storyToDelete.setPersistanceVersion(5);
       
        int persistanceId = 1;
        long persistanceVersion = 4;

        // recherche de la story dans la repository
        mockStoryRepository.expectFindByPersistanceId(persistanceId, storyToDelete);
       
        // validation
        mockStoryValidator.expectValidateForDelete(storyToDelete, errors);

        // enregistrement de la story dans la repository
        mockStoryRepository.expectDelete(storyToDelete);

        // appel de la méthode de mise à jour
        Errors errorsFromService = storyService.delete(persistanceId, persistanceVersion);

        // Vérification les appels
        MockCore.verify();

        // aucune erreur n'est retournée car pas d'erreur de validation
        assertFalse(errorsFromService.hasErrors());
       
        // vérification de la mise à jour de  de la version de cette story pour la gestion de la concurrence d'accès
        assertEquals("persistanceVersion", persistanceVersion, storyToDelete.getPersistanceVersion());
     
    }
View Full Code Here


     * <li>retour d'une erreur</li>
     * </ul>
     */
    public void testDeleteWhenValidationFails() {

        Story storyToDelete = new StoryImpl();
        storyToDelete.setPersistanceVersion(1);
        storyToDelete.setPersistanceVersion(5);
       
        int persistanceId = 1;
        long persistanceVersion = 4;

        // recherche de la story dans la repository
        mockStoryRepository.expectFindByPersistanceId(persistanceId, storyToDelete);
       
        // validation
        errors.reject("code");
        mockStoryValidator.expectValidateForDelete(storyToDelete, errors);

        // appel de la méthode de mise à jour
        Errors errorsFromService = storyService.delete(persistanceId, persistanceVersion);

        // Vérification les appels
        MockCore.verify();

        // une erreur est retournée
        assertTrue(errorsFromService.hasErrors());
       
        // vérification de la mise à jour de  de la version de cette story pour la gestion de la concurrence d'accès
        assertEquals("persistanceVersion", persistanceVersion, storyToDelete.getPersistanceVersion());
     
    }
View Full Code Here

    /**
     * @see net.sf.pmr.keopsframework.data.DomainObjectRootAggregateMapper#addOrUpdate(java.lang.Object)
     */
    public void addOrUpdate(final DomainObject story) {

        Story storyToAddorUpdate = (Story) story;

        getHibernateTemplate().saveOrUpdate(storyToAddorUpdate);

    }
View Full Code Here

         iteration.setPersistanceVersion(iterationPersistanceVersion);

         // recherche de chaque story
         for (Integer id : storyPersistanceIds) {
       
           Story story = storyRepository.findByPersistanceId(id);

           if (story != null) {
             // ajout au set de story de l'iteration
             iteration.getStories().add(story);
           }
View Full Code Here

         iteration.setPersistanceVersion(iterationPersistanceVersion);

         // recherche de chaque story
         for (Integer id : storyPersistanceIds) {
       
           Story story = storyRepository.findByPersistanceId(id);

           if (story != null) {
             // ajout au set de story de l'iteration
             iteration.getStories().remove(story);
           }
View Full Code Here

     */
    public Errors add(final int projectPersistanceId, final String shortDescription, final String description,
            final double daysEstimated, final int businessValueId, final int riskLevelId) {

        // buid the story
        Story story = this.buildStory(projectPersistanceId, shortDescription, description, daysEstimated,
                businessValueId, riskLevelId);

        // validate
        Errors errors = storyValidator.validate(story);

View Full Code Here

     */
    public Errors addTask(final int storyPersistanceId, final double numberOfIdealDays, final String shortDescription,
            final int developperPersistanceId) {
     
        // find the story
        Story story = storyRepository.findByPersistanceId(storyPersistanceId);
       
    // if the story is not found, return a global error
    if (story == null) {
      Errors errros = AgilePlanningObjectFactory.getErrors();
      errros.reject("story.doesntExistsInDatabase");
      return errros;
    }

        // else build the object to persist
        Task task = AgilePlanningObjectFactory.getTask();
        User user = CoreObjectFactory.getUser();
        user.setPersistanceId(developperPersistanceId);

        task.setOwner(user);
        task.setDaysEstimated(numberOfIdealDays);
        task.setShortDescription(shortDescription);

        // validate
        Errors errors = taskValidator.validate(task);

        // persist
        if (!errors.hasErrors()) {
                story.getTasks().add(task);
                storyRepository.addOrUpdate(story);

        }

        return errors;
View Full Code Here

     * @see net.sf.pmr.agilePlanning.service.StoryService#delete(int, long)
     */
     public Errors delete(int persistanceId, long persistanceVersion) {
    
         // find the story to delete in the repository
         Story story = storyRepository.findByPersistanceId(persistanceId);

     // if the story is not found, return a global error
     if (story == null) {
       Errors errors = AgilePlanningObjectFactory.getErrors();
       errors.reject("story.doesntExistsInDatabase");
       return errors;
     }
        
         // if the story is found, update the persistanceVersion for concurrency management
         story.setPersistanceVersion(persistanceVersion);
 
         // validate
         Errors errors = storyValidator.validateForDelete(story);

         // delete if validation is ok
View Full Code Here

     */
    public Errors update(final String shortDescription, final String description, final double daysEstimated,
            final int businessValueId, final int riskLevelId, final int persistanceId, final long persistanceVersion) {

        // find the story to update in the repository
        Story story = storyRepository.findByPersistanceId(persistanceId);

    // if the story is not found, return a global error
    if (story == null) {
      Errors errros = AgilePlanningObjectFactory.getErrors();
      errros.reject("story.doesntExistsInDatabase");
      return errros;
    }

       
        // update the story
        story.setShortDescription(shortDescription);
        story.setDescription(description);
        story.setDaysEstimated(daysEstimated);
        story.setPersistanceId(persistanceId);
        story.setPersistanceVersion(persistanceVersion);

        // find the riskLevel and business value
        BusinessValue businessValue = businessValueRepository.findById(businessValueId);
        story.setBusinessValue(businessValue);

        RiskLevel riskLevel = riskLevelRepository.findById(riskLevelId);
        story.setRiskLevel(riskLevel);

        // validate
        Errors errors = storyValidator.validate(story);

        // persist
View Full Code Here

      final double numberOfIdealDays, final String shortDescription,
      final int developperPersistanceId, final int persistanceId,
      final long persistanceVersion) {

    // find the story
    Story story = storyRepository.findByPersistanceId(storyPersistanceId);

    // if the story is not found, return a global error
    if (story == null) {
      Errors errros = AgilePlanningObjectFactory.getErrors();
      errros.reject("story.doesntExistsInDatabase");
      return errros;
    }

    // else, build the object to persist
    Task task = AgilePlanningObjectFactory.getTask();
    User user = CoreObjectFactory.getUser();
    user.setPersistanceId(developperPersistanceId);

    task.setOwner(user);
    task.setPersistanceId(persistanceId);
    task.setPersistanceVersion(persistanceVersion);
    task.setDaysEstimated(numberOfIdealDays);
    task.setShortDescription(shortDescription);

    // validate
    Errors errors = taskValidator.validate(task);

    if (!errors.hasErrors()) {

      // find the task to update
      for (Iterator iterator = story.getTasks().iterator(); iterator
          .hasNext();) {
        Task taskToUpdate = (Task) iterator.next();

        if (task.getPersistanceId() == taskToUpdate.getPersistanceId()) {
View Full Code Here

TOP

Related Classes of net.sf.pmr.agilePlanning.domain.story.Story

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.