use of com.ge.verdict.synthesis.VerdictSynthesis.Approach in project VERDICT by ge-high-assurance.
the class VerdictSynthesisTest method partialSolutionTest.
@Test
public void partialSolutionTest() {
CostModel costModel = new CostModel(new File(getClass().getResource("partialCosts.xml").getPath()));
int dal = 2;
SystemModel system = new SystemModel("C1");
Attack attack1 = new Attack(system.getAttackable(), "A1", "An attack", Prob.certain(), CIA.I);
Defense defense1 = new Defense(attack1);
defense1.addDefenseClause(Collections.singletonList(new Defense.DefenseLeaf("D1", Optional.of(new com.ge.verdict.attackdefensecollector.Pair<>("D1", 1)))));
ADTree adtree = new ADOr(new ADAnd(new ADNot(defense1), attack1));
for (Approach approach : Approach.values()) {
{
DLeaf.Factory factoryPartial = new DLeaf.Factory();
Optional<Pair<Set<ComponentDefense>, Double>> resultPartial = VerdictSynthesis.performSynthesisSingle(DTreeConstructor.construct(adtree, costModel, dal, true, false, factoryPartial), dal, factoryPartial, approach);
Assertions.assertThat(resultPartial.isPresent());
Assertions.assertThat(resultPartial.get().right).isEqualTo(1);
}
{
DLeaf.Factory factoryTotal = new DLeaf.Factory();
Optional<Pair<Set<ComponentDefense>, Double>> resultTotal = VerdictSynthesis.performSynthesisSingle(DTreeConstructor.construct(adtree, costModel, dal, false, false, factoryTotal), dal, factoryTotal, approach);
Assertions.assertThat(resultTotal.isPresent());
Assertions.assertThat(resultTotal.get().right).isEqualTo(2);
}
}
}
use of com.ge.verdict.synthesis.VerdictSynthesis.Approach in project VERDICT by ge-high-assurance.
the class VerdictSynthesisTest method unmitigatedMixedTest.
@Test
public void unmitigatedMixedTest() {
DLeaf.Factory factory = new DLeaf.Factory();
SystemModel system = new SystemModel("S1");
int targetDal = 1;
Fraction[] costs = Util.fractionCosts(new double[] { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 });
DLeaf dleaf = new DLeaf("S1", "D1", "A2", 0, targetDal, costs, factory);
DTree dtree = new DOr(new ALeaf(new Attack(system.getAttackable(), "A1", "An attack", Prob.certain(), CIA.I)), dleaf);
for (Approach approach : Approach.values()) {
Optional<Pair<Set<ComponentDefense>, Double>> result = VerdictSynthesis.performSynthesisSingle(dtree, targetDal, factory, approach);
Assertions.assertThat(result.isPresent());
Assertions.assertThat(result.get().left).hasSize(1);
Assertions.assertThat(result.get().left).contains(dleaf.componentDefense);
Assertions.assertThat(result.get().right).isEqualTo(5);
}
}
use of com.ge.verdict.synthesis.VerdictSynthesis.Approach in project VERDICT by ge-high-assurance.
the class VerdictSynthesisTest method unmitigatedTest.
@Test
public void unmitigatedTest() {
DLeaf.Factory factory = new DLeaf.Factory();
SystemModel system = new SystemModel("S1");
DTree dtree = new ALeaf(new Attack(system.getAttackable(), "A1", "An attack", Prob.certain(), CIA.I));
for (Approach approach : Approach.values()) {
Assertions.assertThat(VerdictSynthesis.performSynthesisSingle(dtree, 1, factory, approach)).isEmpty();
}
}
use of com.ge.verdict.synthesis.VerdictSynthesis.Approach in project VERDICT by ge-high-assurance.
the class VerdictSynthesisTest method performSynthesisTest.
@Test
public void performSynthesisTest() {
for (Approach approach : Approach.values()) {
performSynthesisTestInternal(new int[] { 1, 2, 3 }, new String[] { "C1", "C2" }, approach);
performSynthesisTestInternal(new int[] { 3, 2, 1 }, new String[] { "C3", "C2" }, approach);
performSynthesisTestInternal(new int[] { 1, 3, 2 }, new String[] { "C1", "C3" }, approach);
}
}
Aggregations