EnforcementService implements IEnforcementService { @Override public boolean startEnforcement(String agreementId) { logger.debug("startEnforcement({})", agreementId); IEnforcementJob job = enforcementJobDAO.getByAgreementId(agreementId); if (job == null) { return false; } job.setEnabled(true); enforcementJobDAO.save(job); IAgreement agreement = agreementDAO.getByAgreementId(agreementId); for (IGuaranteeTerm term : agreement.getGuaranteeTerms()) { if (term.getStatus() == null || GuaranteeTermStatusEnum.NON_DETERMINED.equals(term.getStatus())) { term.setStatus(GuaranteeTermStatusEnum.FULFILLED); } guaranteeTermDAO.save(term); } return true; }  @Override IEnforcementJob getEnforcementJob(Long id); @Override IEnforcementJob getEnforcementJobByAgreementId(String agreementId); @Override List<IEnforcementJob> getEnforcementJobs(); @Override IEnforcementJob createEnforcementJob(IEnforcementJob job); @Override IEnforcementJob createEnforcementJob(String agreementId); @Override boolean deleteEnforcementJobByAgreementId(String agreementId); @Override boolean startEnforcement(String agreementId); @Override boolean stopEnforcement(String agreementId); @Override void saveEnforcementResult(IAgreement agreement,
            Map<IGuaranteeTerm, GuaranteeTermEvaluationResult> enforcementResult); void enforceReceivedMetrics(
            IAgreement agreement, String guaranteeTermName, List<IMonitoringMetric> metrics); @Override void doEnforcement(IAgreement agreement,
            Map<IGuaranteeTerm, List<IMonitoringMetric>> metrics); @Override void saveCheckedGuaranteeTerm(IGuaranteeTerm term);  }
@Test @Transactional(readOnly = false, propagation = Propagation.REQUIRED) public void testStartEnforcement() throws Exception { IEnforcementJob job = saveAgreementAndEnforcementJob(); boolean result = service.startEnforcement(job.getAgreement().getAgreementId()); assertTrue(result); job = service.getEnforcementJob(job.getId()); assertTrue(job.getEnabled()); result = service.startEnforcement("noexiste"); assertFalse(result); }