EnforcementService implements IEnforcementService { @Override public IEnforcementJob getEnforcementJobByAgreementId(String agreementId) { return enforcementJobDAO.getByAgreementId(agreementId); }  @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 testGetEnforcementJobByAgreementId() throws Exception { Provider provider = new Provider(null, UUID.randomUUID().toString(), "Provider 2"); Template template = new Template(); template.setServiceId("service"); template.setText("asadsad"); template.setUuid(UUID.randomUUID().toString()); template.setProvider(provider); providerDao.save(provider); templateDao.save(template); IAgreement agreement = newAgreement(provider, template); agreementDao.save(agreement); IEnforcementJob expected = newEnforcementJob(agreement); enforcementJobDao.save(expected); IEnforcementJob actual; actual = service.getEnforcementJobByAgreementId(agreement.getAgreementId()); assertTrue(equalJobs(expected, actual)); actual = service.getEnforcementJobByAgreementId("noexiste"); assertNull(actual); }