@Test public void found() { final LocalDhisResourceRepositoryImpl<TrackedEntityInstance> resourceRepository = new LocalDhisResourceRepositoryImpl<>( TrackedEntityInstance.class ); final WritableTrackedEntityType trackedEntityType = new WritableTrackedEntityType(); trackedEntityType.setAttributes( Collections.emptyList() ); final TrackedEntityInstance trackedEntityInstance1 = new TrackedEntityInstance( trackedEntityType, "a1234567890", false ); final TrackedEntityInstance trackedEntityInstance2 = new TrackedEntityInstance( trackedEntityType, "a1234567891", false ); final TrackedEntityInstance trackedEntityInstance3 = new TrackedEntityInstance( trackedEntityType, "a1234567892", false ); final TrackedEntityInstance savedTrackedEntityInstance3 = new TrackedEntityInstance( trackedEntityType, "a1234567892", false ); resourceRepository.save( savedTrackedEntityInstance3, null ); Assert.assertFalse( resourceRepository.containsCollectionKey( "xyz" ) ); final Collection<TrackedEntityInstance> result = resourceRepository.found( Arrays.asList( trackedEntityInstance1, trackedEntityInstance2, trackedEntityInstance3 ), "xyz" ); Assert.assertTrue( resourceRepository.containsCollectionKey( "xyz" ) ); Assert.assertEquals( 3, result.size() ); Assert.assertFalse( result.contains( trackedEntityInstance3 ) ); Assert.assertThat( result, Matchers.containsInAnyOrder( trackedEntityInstance1, trackedEntityInstance2, savedTrackedEntityInstance3 ) ); }
@Override @Nonnull public Collection<T> found( @Nonnull Collection<T> resources, @Nonnull String key ) { collectionKeys.add( key ); if ( resources.isEmpty() ) { return Collections.emptyList(); } final List<T> result = new ArrayList<>( resources.size() ); resources.forEach( r -> result.add( store( r, null, true ) ) ); return result; }
LocalDhisResourceRepositoryImpl implements LocalDhisResourceRepository<T> { @Override @Nonnull public Collection<T> found( @Nonnull Collection<T> resources, @Nonnull String key ) { collectionKeys.add( key ); if ( resources.isEmpty() ) { return Collections.emptyList(); } final List<T> result = new ArrayList<>( resources.size() ); resources.forEach( r -> result.add( store( r, null, true ) ) ); return result; } }
LocalDhisResourceRepositoryImpl implements LocalDhisResourceRepository<T> { @Override @Nonnull public Collection<T> found( @Nonnull Collection<T> resources, @Nonnull String key ) { collectionKeys.add( key ); if ( resources.isEmpty() ) { return Collections.emptyList(); } final List<T> result = new ArrayList<>( resources.size() ); resources.forEach( r -> result.add( store( r, null, true ) ) ); return result; } LocalDhisResourceRepositoryImpl( @Nonnull Class<T> resourceClass ); }
LocalDhisResourceRepositoryImpl implements LocalDhisResourceRepository<T> { @Override @Nonnull public Collection<T> found( @Nonnull Collection<T> resources, @Nonnull String key ) { collectionKeys.add( key ); if ( resources.isEmpty() ) { return Collections.emptyList(); } final List<T> result = new ArrayList<>( resources.size() ); resources.forEach( r -> result.add( store( r, null, true ) ) ); return result; } LocalDhisResourceRepositoryImpl( @Nonnull Class<T> resourceClass ); @Override @Nonnull T save( @Nonnull T resource, @Nullable Object resourceKey ); @Override boolean deleteById( @Nonnull String id, @Nullable Object resourceKey, @Nonnull Function<String, T> prototypeFunction ); @Override boolean containsCollectionKey( @Nonnull String key ); @Override @Nonnull Collection<T> found( @Nonnull Collection<T> resources, @Nonnull String key ); @Override @Nonnull Optional<T> findOneById( @Nonnull String id ); @Override @Nonnull Collection<T> find( @Nonnull Predicate<T> filter ); @Override @Nonnull Collection<T> find( @Nonnull String trackedEntityInstanceId, @Nonnull Predicate<T> filter ); @Override void applySaves( @Nonnull LocalDhisRepositoryPersistCallback<T> persistCallback, @Nonnull LocalDhisRepositoryResultCallback resultCallback ); @Override void applyDeletes( @Nonnull LocalDhisRepositoryPersistCallback<T> persistCallback, @Nonnull LocalDhisRepositoryResultCallback resultCallback ); }
LocalDhisResourceRepositoryImpl implements LocalDhisResourceRepository<T> { @Override @Nonnull public Collection<T> found( @Nonnull Collection<T> resources, @Nonnull String key ) { collectionKeys.add( key ); if ( resources.isEmpty() ) { return Collections.emptyList(); } final List<T> result = new ArrayList<>( resources.size() ); resources.forEach( r -> result.add( store( r, null, true ) ) ); return result; } LocalDhisResourceRepositoryImpl( @Nonnull Class<T> resourceClass ); @Override @Nonnull T save( @Nonnull T resource, @Nullable Object resourceKey ); @Override boolean deleteById( @Nonnull String id, @Nullable Object resourceKey, @Nonnull Function<String, T> prototypeFunction ); @Override boolean containsCollectionKey( @Nonnull String key ); @Override @Nonnull Collection<T> found( @Nonnull Collection<T> resources, @Nonnull String key ); @Override @Nonnull Optional<T> findOneById( @Nonnull String id ); @Override @Nonnull Collection<T> find( @Nonnull Predicate<T> filter ); @Override @Nonnull Collection<T> find( @Nonnull String trackedEntityInstanceId, @Nonnull Predicate<T> filter ); @Override void applySaves( @Nonnull LocalDhisRepositoryPersistCallback<T> persistCallback, @Nonnull LocalDhisRepositoryResultCallback resultCallback ); @Override void applyDeletes( @Nonnull LocalDhisRepositoryPersistCallback<T> persistCallback, @Nonnull LocalDhisRepositoryResultCallback resultCallback );  }