use of com.ge.verdict.synthesis.dtree.DLeaf in project VERDICT by ge-high-assurance.
the class VerdictSynthesisTest method decimalCostsTest.
@Test
public void decimalCostsTest() {
CostModel costs = new CostModel(new File(getClass().getResource("decimalCosts.xml").getPath()));
DLeaf.Factory factory = new DLeaf.Factory();
int targetDal = 1;
List<ComponentDefense> leaves = new ArrayList<>();
DLeaf leafA = new DLeaf("A", "A", "A", 0, targetDal, costs, factory, false, false);
DLeaf leafB = new DLeaf("B", "B", "B", 0, targetDal, costs, factory, false, false);
DLeaf leafC = new DLeaf("C", "C", "C", 0, targetDal, costs, factory, false, false);
leaves.add(leafA.componentDefense);
leaves.add(leafB.componentDefense);
leaves.add(leafC.componentDefense);
Assertions.assertThat(leafA.componentDefense.dalToRawCost(targetDal)).isEqualByComparingTo(new Fraction(42, 10));
Assertions.assertThat(leafB.componentDefense.dalToRawCost(targetDal)).isEqualByComparingTo(new Fraction(35, 1000));
Assertions.assertThat(leafC.componentDefense.dalToRawCost(targetDal)).isEqualByComparingTo(new Fraction(1077, 100));
int costLcm = VerdictSynthesis.normalizeCosts(leaves);
Assertions.assertThat(costLcm).isEqualTo(200);
Assertions.assertThat(leafA.componentDefense.dalToNormCost(targetDal)).isEqualTo(840);
Assertions.assertThat(leafB.componentDefense.dalToNormCost(targetDal)).isEqualTo(7);
Assertions.assertThat(leafC.componentDefense.dalToNormCost(targetDal)).isEqualTo(2154);
}
Aggregations