TrackedEntityInstanceSupplier extends AbstractSupplier<Map<String, Pair<TrackedEntityInstance, Boolean>>> { @Override public Map<String, Pair<TrackedEntityInstance, Boolean>> get( ImportOptions importOptions, List<Event> events ) { if ( events == null ) { return new HashMap<>(); } Set<String> teiUids = events.stream() .filter( e -> e.getTrackedEntityInstance() != null ) .map( Event::getTrackedEntityInstance ).collect( Collectors.toSet() ); if ( isEmpty( teiUids ) ) { return new HashMap<>(); } Multimap<String, String> teiToEvent = HashMultimap.create(); for ( Event event : events ) { teiToEvent.put( event.getTrackedEntityInstance(), event.getUid() ); } Map<String, TrackedEntityInstance> teiMap = getTrackedEntityInstances( teiUids, teiToEvent ); Map<String, Pair<TrackedEntityInstance, Boolean>> result = new HashMap<>(); for ( String event : teiMap.keySet() ) { TrackedEntityInstance tei = teiMap.get( event ); result.put( event, Pair.of( tei, !importOptions.isSkipLastUpdated() ? aclService.canUpdate( importOptions.getUser(), tei ) : null ) ); } return result; } TrackedEntityInstanceSupplier( NamedParameterJdbcTemplate jdbcTemplate,
        AclService aclService ); @Override Map<String, Pair<TrackedEntityInstance, Boolean>> get( ImportOptions importOptions, List<Event> events );  }
@Test public void handleNullEvents() { assertNotNull( subject.get( ImportOptions.getDefaultImportOptions(), null ) ); }