@Test
void maybeAddPolicy() {

    Policy policy1 = new Policy();
    policy1.setName("policy1");
    policy1.setPath("policy1");
    Policy policy2 = new Policy();
    policy2.setName("policy2");
    policy2.setPath("policy2");
    policy1.getDependencies().add(policy2);
    ArrayList<Policy> orderedPolicies = new ArrayList<>();
    HashSet<Policy> seenPolicies = new HashSet<>();
    PolicyEntityBuilder.maybeAddPolicy(bundle, policy1, orderedPolicies, seenPolicies);
    assertEquals(2, orderedPolicies.size());
    assertEquals(policy1, orderedPolicies.get(1));
    assertEquals(policy2, orderedPolicies.get(0));
    PolicyEntityBuilder.maybeAddPolicy(bundle, policy2, orderedPolicies, seenPolicies);
    assertEquals(2, orderedPolicies.size());
    assertEquals(policy1, orderedPolicies.get(1));
    assertEquals(policy2, orderedPolicies.get(0));
    // test dependency loop
    policy2.getDependencies().add(policy1);
    assertThrows(EntityBuilderException.class, () -> PolicyEntityBuilder.maybeAddPolicy(bundle, policy2, new ArrayList<>(), new HashSet<>()));
}