@Test public void testToEntityResponse() { try { List<Entry> entries = new ArrayList<>(); Entry entry = new DefaultEntry(); entry.setDn(DN); entry.add("givenName", "gabi"); entries.add(entry); List<Field> fields = new ArrayList<>(); Field fieldName = new Field(); fieldName.setName("givenName"); fieldName.setType(FieldType.FIRST_NAME); fields.add(fieldName); List<EntityResponse> responses = new ApacheAPIConverter().toEntityResponse(entries, fields); assertTrue(((ArrayList<Field>)responses.get(0).getValue()).get(0).getType() == FieldType.FIRST_NAME); } catch (LdapException e) { e.printStackTrace(); } }
List<EntityResponse> toEntityResponse(List<Entry> entries, List<Field> requestedFields) { List<EntityResponse> entResponses = new ArrayList<>(); for (Entry ent : entries) { EntityResponse entResponse = new EntityResponse(); entResponse.setKey(ent.getDn().getName()); for (Attribute att : ent.getAttributes()) { for (Field field : requestedFields) { if (field.getName().equals("*") || field.getName().equalsIgnoreCase(att.getId())) { att.iterator().forEachRemaining(value -> { entResponse.addValue(value.getValue(), att.getId(), field.getType()); }); } } } entResponses.add(entResponse); } return entResponses; }
ApacheAPIConverter { List<EntityResponse> toEntityResponse(List<Entry> entries, List<Field> requestedFields) { List<EntityResponse> entResponses = new ArrayList<>(); for (Entry ent : entries) { EntityResponse entResponse = new EntityResponse(); entResponse.setKey(ent.getDn().getName()); for (Attribute att : ent.getAttributes()) { for (Field field : requestedFields) { if (field.getName().equals("*") || field.getName().equalsIgnoreCase(att.getId())) { att.iterator().forEachRemaining(value -> { entResponse.addValue(value.getValue(), att.getId(), field.getType()); }); } } } entResponses.add(entResponse); } return entResponses; } }
ApacheAPIConverter { List<EntityResponse> toEntityResponse(List<Entry> entries, List<Field> requestedFields) { List<EntityResponse> entResponses = new ArrayList<>(); for (Entry ent : entries) { EntityResponse entResponse = new EntityResponse(); entResponse.setKey(ent.getDn().getName()); for (Attribute att : ent.getAttributes()) { for (Field field : requestedFields) { if (field.getName().equals("*") || field.getName().equalsIgnoreCase(att.getId())) { att.iterator().forEachRemaining(value -> { entResponse.addValue(value.getValue(), att.getId(), field.getType()); }); } } } entResponses.add(entResponse); } return entResponses; }  }
ApacheAPIConverter { List<EntityResponse> toEntityResponse(List<Entry> entries, List<Field> requestedFields) { List<EntityResponse> entResponses = new ArrayList<>(); for (Entry ent : entries) { EntityResponse entResponse = new EntityResponse(); entResponse.setKey(ent.getDn().getName()); for (Attribute att : ent.getAttributes()) { for (Field field : requestedFields) { if (field.getName().equals("*") || field.getName().equalsIgnoreCase(att.getId())) { att.iterator().forEachRemaining(value -> { entResponse.addValue(value.getValue(), att.getId(), field.getType()); }); } } } entResponses.add(entResponse); } return entResponses; }  Modification toModification(ModificationDetails modificationDetails); }
ApacheAPIConverter { List<EntityResponse> toEntityResponse(List<Entry> entries, List<Field> requestedFields) { List<EntityResponse> entResponses = new ArrayList<>(); for (Entry ent : entries) { EntityResponse entResponse = new EntityResponse(); entResponse.setKey(ent.getDn().getName()); for (Attribute att : ent.getAttributes()) { for (Field field : requestedFields) { if (field.getName().equals("*") || field.getName().equalsIgnoreCase(att.getId())) { att.iterator().forEachRemaining(value -> { entResponse.addValue(value.getValue(), att.getId(), field.getType()); }); } } } entResponses.add(entResponse); } return entResponses; }  Modification toModification(ModificationDetails modificationDetails);  }