@Test
void buildBundleWithPasswords() {

    StoredPasswordEntityBuilder builder = new StoredPasswordEntityBuilder(ID_GENERATOR);
    StoredPassword pwd1 = buildStoredPassword(PWD_1);
    StoredPassword pwd2 = buildStoredPassword(PWD_2);
    Bundle bundle = new Bundle();
    bundle.putAllStoredPasswords(ImmutableMap.of(PWD_1, pwd1, PWD_2, pwd2));
    final List<Entity> entities = builder.build(bundle, EntityBuilder.BundleType.ENVIRONMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument());
    // the builder set the id in order for other entities be able to link to the password using it.
    assertNotNull(pwd1.getId());
    assertNotNull(pwd2.getId());
    assertFalse(entities.isEmpty());
    assertEquals(2, entities.size());
    MutableBoolean containsPwd1 = new MutableBoolean();
    MutableBoolean containsPwd2 = new MutableBoolean();
    entities.forEach(e -> {
        switch (e.getName()) {
            case PWD_1:
                checkPassword(containsPwd1, PWD_1, e, pwd1);
                break;
            case PWD_2:
                checkPassword(containsPwd2, PWD_2, e, pwd2);
                break;
            default:
                fail("unexpected password: " + e.getName());
                break;
        }
    });
    assertTrue(containsPwd1.booleanValue());
    assertTrue(containsPwd2.booleanValue());
}