@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()); 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()); }
@Override public List<Entity> build(Bundle bundle, BundleType bundleType, Document document) { if (bundle instanceof AnnotatedBundle) { Map<String, StoredPassword> storedPasswordMap = Optional.ofNullable(bundle.getStoredPasswords()).orElse(Collections.emptyMap()); return buildEntities(storedPasswordMap, ((AnnotatedBundle) bundle).getFullBundle(), bundleType, document); } else { return buildEntities(bundle.getStoredPasswords(), bundle, bundleType, document); } }
StoredPasswordEntityBuilder implements EntityBuilder { @Override public List<Entity> build(Bundle bundle, BundleType bundleType, Document document) { if (bundle instanceof AnnotatedBundle) { Map<String, StoredPassword> storedPasswordMap = Optional.ofNullable(bundle.getStoredPasswords()).orElse(Collections.emptyMap()); return buildEntities(storedPasswordMap, ((AnnotatedBundle) bundle).getFullBundle(), bundleType, document); } else { return buildEntities(bundle.getStoredPasswords(), bundle, bundleType, document); } } }
StoredPasswordEntityBuilder implements EntityBuilder { @Override public List<Entity> build(Bundle bundle, BundleType bundleType, Document document) { if (bundle instanceof AnnotatedBundle) { Map<String, StoredPassword> storedPasswordMap = Optional.ofNullable(bundle.getStoredPasswords()).orElse(Collections.emptyMap()); return buildEntities(storedPasswordMap, ((AnnotatedBundle) bundle).getFullBundle(), bundleType, document); } else { return buildEntities(bundle.getStoredPasswords(), bundle, bundleType, document); } } @Inject  StoredPasswordEntityBuilder(IdGenerator idGenerator); }
StoredPasswordEntityBuilder implements EntityBuilder { @Override public List<Entity> build(Bundle bundle, BundleType bundleType, Document document) { if (bundle instanceof AnnotatedBundle) { Map<String, StoredPassword> storedPasswordMap = Optional.ofNullable(bundle.getStoredPasswords()).orElse(Collections.emptyMap()); return buildEntities(storedPasswordMap, ((AnnotatedBundle) bundle).getFullBundle(), bundleType, document); } else { return buildEntities(bundle.getStoredPasswords(), bundle, bundleType, document); } } @Inject  StoredPasswordEntityBuilder(IdGenerator idGenerator); @Override List<Entity> build(Bundle bundle, BundleType bundleType, Document document); @Override @NotNull Integer getOrder(); }
StoredPasswordEntityBuilder implements EntityBuilder { @Override public List<Entity> build(Bundle bundle, BundleType bundleType, Document document) { if (bundle instanceof AnnotatedBundle) { Map<String, StoredPassword> storedPasswordMap = Optional.ofNullable(bundle.getStoredPasswords()).orElse(Collections.emptyMap()); return buildEntities(storedPasswordMap, ((AnnotatedBundle) bundle).getFullBundle(), bundleType, document); } else { return buildEntities(bundle.getStoredPasswords(), bundle, bundleType, document); } } @Inject  StoredPasswordEntityBuilder(IdGenerator idGenerator); @Override List<Entity> build(Bundle bundle, BundleType bundleType, Document document); @Override @NotNull Integer getOrder();  }