本文整理汇总了Java中eu.atos.sla.enforcement.TestAgreementFactory类的典型用法代码示例。如果您正苦于以下问题:Java TestAgreementFactory类的具体用法?Java TestAgreementFactory怎么用?Java TestAgreementFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TestAgreementFactory类属于eu.atos.sla.enforcement包,在下文中一共展示了TestAgreementFactory类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import eu.atos.sla.enforcement.TestAgreementFactory; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
String kpiName = "LATENCY";
String constraint = kpiName + " LT 100";
contract = TestAgreementFactory.newAgreement(
Arrays.asList(
TestAgreementFactory.newGuaranteeTerm(
kpiName,
constraint,
Arrays.<IPenaltyDefinition>asList(
new PenaltyDefinition(1, _0, "discount", "euro", "10", "P1D"),
new PenaltyDefinition(2, _2, "terminate", "", "", ""),
new PenaltyDefinition(2, _3, "discount", "euro", "10", ""),
new PenaltyDefinition(3, _3, "discount", "euro", "10", ""),
new PenaltyDefinition(3, _5, "discount", "euro", "10", "")
)
)
)
);
violations = new IViolation[times.length];
for (int i = 0; i < violations.length; i++) {
if (times[i] != 0) {
IViolation violation = newViolation(i);
violations[i] = violation;
}
}
}
示例2: testEvaluate
import eu.atos.sla.enforcement.TestAgreementFactory; //导入依赖的package包/类
@Test
public void testEvaluate() {
SimpleBusinessValuesEvaluator bvEval = new SimpleBusinessValuesEvaluator();
bvEval.setCompensationRepository(new DummyViolationRepository(Arrays.asList(violations)));
IGuaranteeTerm term = contract.getGuaranteeTerms().get(0);
List<? extends ICompensation> compensations;
for (int i = 0; i < times.length; i++) {
Date now = new Date(i * 1000);
List<IViolation> newViolations = (times[i] != 0)?
Collections.singletonList(TestAgreementFactory.newViolation(contract, term, null, now)) :
Collections.<IViolation>emptyList();
compensations = bvEval.evaluate(
contract,
term,
newViolations,
now
);
for (IPenaltyDefinition def : contract.getGuaranteeTerms().get(0).getBusinessValueList().getPenalties()) {
int count = def.getCount();
int step = (int)def.getTimeInterval().getTime() / 1000;
boolean expectedPenalty = sum(times, i - step, i) >= count;
boolean actualPenalty = foundPenaltyDefinition(def, compensations);
if (expectedPenalty != actualPenalty) {
assertEquals(expectedPenalty, actualPenalty);
}
assertEquals(expectedPenalty, actualPenalty);
}
}
}
示例3: setUp
import eu.atos.sla.enforcement.TestAgreementFactory; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
String kpiName = "LATENCY";
String constraint = kpiName + " LT 100";
contract = TestAgreementFactory.newAgreement(
Arrays.asList(
TestAgreementFactory.newGuaranteeTerm(
kpiName,
constraint,
Arrays.<IPenaltyDefinition>asList(
new PenaltyDefinition(1, _0, "discount", "euro", "10", "P1D"),
new PenaltyDefinition(2, _2, "terminate", "", "", ""),
new PenaltyDefinition(2, _3, "discount", "euro", "10", ""),
new PenaltyDefinition(3, _3, "discount", "euro", "10", ""),
new PenaltyDefinition(3, _5, "discount", "euro", "10", "")
)
)
)
);
violations = new IViolation[times.length];
for (int i = 0; i < violations.length; i++) {
if (times[i] != 0) {
IViolation violation = newViolation(i);
violations[i] = violation;
}
}
}
示例4: testEvaluate
import eu.atos.sla.enforcement.TestAgreementFactory; //导入依赖的package包/类
@Test
public void testEvaluate() {
SimpleBusinessValuesEvaluator bvEval = new SimpleBusinessValuesEvaluator();
bvEval.setCompensationRepository(new DummyViolationRepository(Arrays.asList(violations)));
IGuaranteeTerm term = contract.getGuaranteeTerms().get(0);
List<? extends ICompensation> compensations;
for (int i = 0; i < times.length; i++) {
Date now = new Date(i * 1000);
List<IViolation> newViolations = (times[i] != 0)?
Collections.singletonList(TestAgreementFactory.newViolation(contract, term, null, now)) :
Collections.<IViolation>emptyList();
compensations = bvEval.evaluate(
contract,
term,
newViolations,
now
);
for (IPenaltyDefinition def : contract.getGuaranteeTerms().get(0).getBusinessValueList().getPenalties()) {
int count = def.getCount();
int step = (int)def.getTimeInterval().getTime() / 1000;
boolean expectedPenalty = sum(times, i - step, i) >= count;
boolean actualPenalty = foundPenaltyDefinition(def, compensations);
if (expectedPenalty != actualPenalty) {
assertEquals(expectedPenalty, actualPenalty);
}
assertEquals(expectedPenalty, actualPenalty);
}
}
}