当前位置: 首页>>代码示例>>Java>>正文


Java TestAgreementFactory类代码示例

本文整理汇总了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;
		}
	}
}
 
开发者ID:Atos-FiwareOps,项目名称:sla-framework,代码行数:31,代码来源:SimpleBusinessValuesEvaluatorTest.java

示例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);
		}
	}
}
 
开发者ID:Atos-FiwareOps,项目名称:sla-framework,代码行数:38,代码来源:SimpleBusinessValuesEvaluatorTest.java

示例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;
        }
    }
}
 
开发者ID:SeaCloudsEU,项目名称:SeaCloudsPlatform,代码行数:31,代码来源:SimpleBusinessValuesEvaluatorTest.java

示例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);
        }
    }
}
 
开发者ID:SeaCloudsEU,项目名称:SeaCloudsPlatform,代码行数:38,代码来源:SimpleBusinessValuesEvaluatorTest.java


注:本文中的eu.atos.sla.enforcement.TestAgreementFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。