示例#1
0
  @Override
  @Secured
  public TestExecution updateTestExecution(TestExecution testExecution) throws ServiceException {
    TestExecution execEntity = testExecutionDAO.get(testExecution.getId());
    if (execEntity == null) {
      throw new ServiceException("serviceException.testExecutionNotFound", testExecution.getName());
    }
    // this is what can be updated here
    execEntity.setName(testExecution.getName());
    execEntity.setStarted(testExecution.getStarted());
    execEntity.setComment(testExecution.getComment());
    execEntity.setTags(new ArrayList<>());

    for (Tag tag : testExecution.getTags()) {
      Tag tagEntity = tagDAO.findByName(tag.getName());
      if (tagEntity == null) {
        Tag newTag = new Tag();
        newTag.setName(tag.getName());
        tagEntity = tagDAO.create(newTag);
      }

      Collection<TestExecution> tagTestExecutions = tagEntity.getTestExecutions();
      if (tagTestExecutions == null) {
        tagEntity.setTestExecutions(new ArrayList<>());
      }

      tagEntity.getTestExecutions().add(execEntity);
      execEntity.getTags().add(tagEntity);
    }
    TestExecution execClone = cloneAndFetch(execEntity, true, true, true, true, true);
    return execClone;
  }
示例#2
0
  @Override
  @Secured
  public void removeTestExecution(TestExecution testExecution) throws ServiceException {
    TestExecution freshTestExecution = testExecutionDAO.get(testExecution.getId());
    if (freshTestExecution == null) {
      throw new ServiceException("serviceException.testExecutionNotFound", testExecution.getName());
    }
    for (TestExecutionParameter testExecutionParameter : freshTestExecution.getParameters()) {
      testExecutionParameterDAO.remove(testExecutionParameter);
    }
    for (Value value : freshTestExecution.getValues()) {
      for (ValueParameter valueParameter : value.getParameters()) {
        valueParameterDAO.remove(valueParameter);
      }
      valueDAO.remove(value);
    }

    Iterator<TestExecutionAttachment> allTestExecutionAttachments =
        freshTestExecution.getAttachments().iterator();
    while (allTestExecutionAttachments.hasNext()) {
      testExecutionAttachmentDAO.remove(allTestExecutionAttachments.next());
      allTestExecutionAttachments.remove();
    }
    testExecutionDAO.remove(freshTestExecution);
  }