本文整理汇总了Java中eu.atos.sla.datamodel.bean.Penalty类的典型用法代码示例。如果您正苦于以下问题:Java Penalty类的具体用法?Java Penalty怎么用?Java Penalty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Penalty类属于eu.atos.sla.datamodel.bean包,在下文中一共展示了Penalty类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getById
import eu.atos.sla.datamodel.bean.Penalty; //导入依赖的package包/类
@Test
public void getById() {
Date dateTime = new Date();
IPenaltyDefinition def = new PenaltyDefinition(1, "euro", "100");
savePenaltyDefinition(def);
IViolation violation = new Violation();
violationDao.save(violation);
Penalty expected = new Penalty("agreement-id", dateTime, "kpiname", def, violation);
IPenalty saved = penaltyDao.save(expected);
IPenalty actual = penaltyDao.getById(saved.getId());
/*
* All these should succeed, as expected and actual are the same object after save()
*/
assertEquals(expected.getAgreementId(), actual.getAgreementId());
assertEquals(expected.getDatetime().getTime(), actual.getDatetime().getTime());
assertEquals(expected.getKpiName(), actual.getKpiName());
assertEquals(expected.getUuid(), actual.getUuid());
Assert.assertTrue(expected == actual);
}
示例2: getById
import eu.atos.sla.datamodel.bean.Penalty; //导入依赖的package包/类
@Test
public void getById() {
Date dateTime = new Date();
IPenaltyDefinition def = new PenaltyDefinition(1, "euro", "100");
savePenaltyDefinition(def);
IViolation violation = new Violation();
violationDao.save(violation);
Penalty expected = new Penalty("agreement-id", dateTime, "kpiname", def, violation);
IPenalty saved = penaltyDao.save(expected);
IPenalty actual = penaltyDao.getById(saved.getId());
/*
* All these should succeed, as expected and actual are the same object after save()
*/
assertEquals(expected.getAgreementId(), actual.getAgreementId());
assertEquals(expected.getDatetime().getTime(), actual.getDatetime().getTime());
assertEquals(expected.getKpiName(), actual.getKpiName());
assertEquals(expected.getUuid(), actual.getUuid());
Assert.assertTrue(expected == actual);
}
示例3: evaluate
import eu.atos.sla.datamodel.bean.Penalty; //导入依赖的package包/类
@Override
public List<? extends ICompensation> evaluate(
IAgreement agreement, IGuaranteeTerm term, List<IViolation> newViolations, Date now) {
logger.debug("Evaluating business for {} new violations", newViolations.size());
List<ICompensation> result = new ArrayList<ICompensation>();
IBusinessValueList businessValues = term.getBusinessValueList();
if (businessValues == null) {
/*
* sanity check
*/
return Collections.emptyList();
}
for (IPenaltyDefinition penaltyDef : businessValues.getPenalties()) {
if (penaltyDef.getKind() != CompensationKind.CUSTOM_PENALTY) {
continue;
}
Date violationsBegin = new Date(now.getTime() - penaltyDef.getTimeInterval().getTime());
/*
* TODO: violationsBegin should be max(violationsBegin, select last(penalty) where penalty.definition = def
*/
List<IViolation> oldViolations =
repository.getViolationsByTimeRange(agreement, term.getName(), violationsBegin, now);
if (thereIsPenalty(penaltyDef, newViolations, oldViolations)) {
IPenalty penalty = new Penalty(
agreement.getAgreementId(),
now,
term.getKpiName(),
penaltyDef,
getLastViolation(newViolations, oldViolations));
result.add(penalty);
logger.debug("Raised {}", penalty);
}
}
return result;
}
示例4: search
import eu.atos.sla.datamodel.bean.Penalty; //导入依赖的package包/类
@Override
public List<IPenalty> search(SearchParameters params) {
TypedQuery<IPenalty> query = entityManager.createNamedQuery(
Penalty.Query.SEARCH,
IPenalty.class);
query.setParameter("agreementId", params.getAgreementId());
query.setParameter("termName", params.getGuaranteeTermName());
query.setParameter("begin", params.getBegin());
query.setParameter("end", params.getEnd());
List<IPenalty> penalties = query.getResultList();
return penalties;
}
示例5: serialize
import eu.atos.sla.datamodel.bean.Penalty; //导入依赖的package包/类
/**
* Quick and easy serialization from a model compensation to a jaxb compensation
* @param compensation model compensation to serialize from
* @return corresponding jaxb object
*/
private Object serialize(ICompensation compensation) {
Object result;
if (compensation instanceof Penalty) {
result = new eu.atos.sla.parser.data.Penalty((Penalty)compensation);
}
else {
throw new UnsupportedOperationException("Not implemented");
}
return result;
}
示例6: testOnFinishEvaluation
import eu.atos.sla.datamodel.bean.Penalty; //导入依赖的package包/类
@Test
public void testOnFinishEvaluation() {
IAgreement agreement = new eu.atos.sla.datamodel.bean.Agreement();
agreement.setAgreementId("agreement-id");
IGuaranteeTerm term = new GuaranteeTerm();
term.setKpiName("kpi");
term.setName("TERM");
GuaranteeTermEvaluationResult res = new GuaranteeTermEvaluationResult(
Collections.<IViolation>emptyList(),
Arrays.asList(
new Penalty(agreement.getAgreementId(),
new Date(),
term.getKpiName(),
new PenaltyDefinition(1, new Date(60000), "discount", "euro", "100", "P1M"),
new Violation(agreement, term, null, "", "", new Date())
)
)
);
Map<IGuaranteeTerm, GuaranteeTermEvaluationResult> map =
new HashMap<IGuaranteeTerm, GuaranteeTermEvaluationResult>();
map.put(term, res);
try {
notifier.onFinishEvaluation(agreement, map);
assertTrue(true);
} catch (RestNotifierException e) {
fail("Failed with status " + e.getStatus());
}
}
示例7: evaluate
import eu.atos.sla.datamodel.bean.Penalty; //导入依赖的package包/类
@Override
public List<? extends ICompensation> evaluate(
IAgreement agreement, IGuaranteeTerm term, List<IViolation> newViolations, Date now) {
logger.debug("Evaluating business for {} new violations", newViolations.size());
List<ICompensation> result = new ArrayList<ICompensation>();
IBusinessValueList businessValues = term.getBusinessValueList();
if (businessValues == null) {
/*
* sanity check
*/
return Collections.emptyList();
}
for (IPenaltyDefinition penaltyDef : businessValues.getPenalties()) {
if (penaltyDef.getKind() != CompensationKind.CUSTOM_PENALTY) {
continue;
}
Date violationsBegin = new Date(now.getTime() - penaltyDef.getTimeInterval().getTime());
/*
* TODO: violationsBegin should be max(violationsBegin, select last(penalty) where penalty.definition = def
*/
List<IViolation> oldViolations =
repository.getViolationsByTimeRange(agreement, term.getName(), violationsBegin, now);
if (thereIsPenalty(penaltyDef, newViolations, oldViolations)) {
IPenalty penalty = new Penalty(
agreement.getAgreementId(),
now,
term.getKpiName(),
penaltyDef,
getLastViolation(newViolations, oldViolations));
result.add(penalty);
logger.debug("Raised {}", penalty);
}
}
return result;
}
示例8: search
import eu.atos.sla.datamodel.bean.Penalty; //导入依赖的package包/类
@Override
public List<IPenalty> search(SearchParameters params) {
TypedQuery<IPenalty> query = entityManager.createNamedQuery(
Penalty.Query.SEARCH,
IPenalty.class);
query.setParameter("agreementId", params.getAgreementId());
query.setParameter("termName", params.getGuaranteeTermName());
query.setParameter("begin", params.getBegin());
query.setParameter("end", params.getEnd());
List<IPenalty> penalties = query.getResultList();
return penalties;
}
示例9: getById
import eu.atos.sla.datamodel.bean.Penalty; //导入依赖的package包/类
@Override
public Penalty getById(Long id) {
return entityManager.find(Penalty.class, id);
}
示例10: getById
import eu.atos.sla.datamodel.bean.Penalty; //导入依赖的package包/类
@Override
public Penalty getById(Long id) {
return entityManager.find(Penalty.class, id);
}