Search in sources :

Example 16 with DLeaf

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);
}
Also used : DLeaf(com.ge.verdict.synthesis.dtree.DLeaf) ComponentDefense(com.ge.verdict.synthesis.dtree.DLeaf.ComponentDefense) ArrayList(java.util.ArrayList) Fraction(org.apache.commons.math3.fraction.Fraction) File(java.io.File) Test(org.junit.Test)

Aggregations

DLeaf (com.ge.verdict.synthesis.dtree.DLeaf)16 Fraction (org.apache.commons.math3.fraction.Fraction)14 Test (org.junit.Test)14 ADTree (com.ge.verdict.attackdefensecollector.adtree.ADTree)11 DTree (com.ge.verdict.synthesis.dtree.DTree)11 ADOr (com.ge.verdict.attackdefensecollector.adtree.ADOr)9 DOr (com.ge.verdict.synthesis.dtree.DOr)9 ADAnd (com.ge.verdict.attackdefensecollector.adtree.ADAnd)7 DAnd (com.ge.verdict.synthesis.dtree.DAnd)7 File (java.io.File)6 ADNot (com.ge.verdict.attackdefensecollector.adtree.ADNot)5 Attack (com.ge.verdict.attackdefensecollector.adtree.Attack)5 Defense (com.ge.verdict.attackdefensecollector.adtree.Defense)5 SystemModel (com.ge.verdict.attackdefensecollector.model.SystemModel)5 ALeaf (com.ge.verdict.synthesis.dtree.ALeaf)3 ComponentDefense (com.ge.verdict.synthesis.dtree.DLeaf.ComponentDefense)3 ResultsInstance (com.ge.verdict.vdm.synthesis.ResultsInstance)3 Pair (com.ge.verdict.synthesis.util.Pair)2 AttackDefenseCollector (com.ge.verdict.attackdefensecollector.AttackDefenseCollector)1 Pair (com.ge.verdict.attackdefensecollector.Pair)1