DtoHelper { public static Map<Long, FieldDto> asFieldMapById(Collection<FieldDto> fields) { Map<Long, FieldDto> fieldMap = new HashMap<>(); for (FieldDto field : fields) { fieldMap.put(field.getId(), field); } return fieldMap; } private  DtoHelper(); static Map<Long, FieldDto> asFieldMapById(Collection<FieldDto> fields); static Map<String, FieldDto> asFieldMapByName(Collection<FieldDto> fields); static FieldDto findByName(Collection<FieldDto> fields, String name); static FieldDto findById(Collection<FieldDto> fields, Long id);  }
@Test public void shouldReturnFieldListAsMapById() { List<FieldDto> fields = simpleFieldsList(); Map<Long, FieldDto> fieldMap = DtoHelper.asFieldMapById(fields); for (long i = 4; i < 9; i++) { assertMapEntry(fieldMap, i, "name" + i, i); } }