@Test @Transactional(readOnly = false, propagation = Propagation.REQUIRED) public void testStopEnforcement() throws Exception { IEnforcementJob job = saveAgreementAndEnforcementJob(); job.setEnabled(true); enforcementJobDao.save(job); boolean result = service.stopEnforcement(job.getAgreement().getAgreementId()); assertTrue(result); job = service.getEnforcementJob(job.getId()); assertFalse(job.getEnabled()); result = service.startEnforcement("noexiste"); assertFalse(result); }
@Override public boolean stopEnforcement(String agreementId) { IEnforcementJob job = enforcementJobDAO.getByAgreementId(agreementId); if (job == null) { return false; } job.setEnabled(false); enforcementJobDAO.save(job); IAgreement agreement = agreementDAO.getByAgreementId(agreementId); if (agreement.getHasGTermToBeEvaluatedAtEndOfEnformcement()!= null){ if (agreement.getHasGTermToBeEvaluatedAtEndOfEnformcement()){ try{ agreementEnforcement.enforce(agreement, job.getLastExecuted(), true); }catch(Throwable t){ logger.error("Fatal error in stopEnforcement doing enforcement", t); } } } return true; }
EnforcementService implements IEnforcementService { @Override public boolean stopEnforcement(String agreementId) { IEnforcementJob job = enforcementJobDAO.getByAgreementId(agreementId); if (job == null) { return false; } job.setEnabled(false); enforcementJobDAO.save(job); IAgreement agreement = agreementDAO.getByAgreementId(agreementId); if (agreement.getHasGTermToBeEvaluatedAtEndOfEnformcement()!= null){ if (agreement.getHasGTermToBeEvaluatedAtEndOfEnformcement()){ try{ agreementEnforcement.enforce(agreement, job.getLastExecuted(), true); }catch(Throwable t){ logger.error("Fatal error in stopEnforcement doing enforcement", t); } } } return true; } }
EnforcementService implements IEnforcementService { @Override public boolean stopEnforcement(String agreementId) { IEnforcementJob job = enforcementJobDAO.getByAgreementId(agreementId); if (job == null) { return false; } job.setEnabled(false); enforcementJobDAO.save(job); IAgreement agreement = agreementDAO.getByAgreementId(agreementId); if (agreement.getHasGTermToBeEvaluatedAtEndOfEnformcement()!= null){ if (agreement.getHasGTermToBeEvaluatedAtEndOfEnformcement()){ try{ agreementEnforcement.enforce(agreement, job.getLastExecuted(), true); }catch(Throwable t){ logger.error("Fatal error in stopEnforcement doing enforcement", t); } } } return true; }  }
EnforcementService implements IEnforcementService { @Override public boolean stopEnforcement(String agreementId) { IEnforcementJob job = enforcementJobDAO.getByAgreementId(agreementId); if (job == null) { return false; } job.setEnabled(false); enforcementJobDAO.save(job); IAgreement agreement = agreementDAO.getByAgreementId(agreementId); if (agreement.getHasGTermToBeEvaluatedAtEndOfEnformcement()!= null){ if (agreement.getHasGTermToBeEvaluatedAtEndOfEnformcement()){ try{ agreementEnforcement.enforce(agreement, job.getLastExecuted(), true); }catch(Throwable t){ logger.error("Fatal error in stopEnforcement doing enforcement", t); } } } 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); }
EnforcementService implements IEnforcementService { @Override public boolean stopEnforcement(String agreementId) { IEnforcementJob job = enforcementJobDAO.getByAgreementId(agreementId); if (job == null) { return false; } job.setEnabled(false); enforcementJobDAO.save(job); IAgreement agreement = agreementDAO.getByAgreementId(agreementId); if (agreement.getHasGTermToBeEvaluatedAtEndOfEnformcement()!= null){ if (agreement.getHasGTermToBeEvaluatedAtEndOfEnformcement()){ try{ agreementEnforcement.enforce(agreement, job.getLastExecuted(), true); }catch(Throwable t){ logger.error("Fatal error in stopEnforcement doing enforcement", t); } } } 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);  }