@Test public void getLatestActiveLocalOnly() { try ( final RequestCacheContext cacheContext = requestCacheService.createRequestCacheContext() ) { cacheContext.setAttribute( LocalDhisResourceRepositoryTemplate.CONTAINER_REQUEST_CACHE_ATTRIBUTE_NAME, new LocalDhisResourceRepositoryContainerImpl( Collections.singleton( Enrollment.class ) ) ); Optional<? extends Enrollment> ou = service.findLatestActive( "ur1Edk5Oe2n", "tPeQKGUIowE", true ); Assert.assertFalse( ou.isPresent() ); } mockServer.verify(); }
@HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @Cacheable( key = "{'findLatestActive', #a0, #a1}", condition = "#a2 == false", cacheManager = "dhisCacheManager", cacheNames = "enrollments" ) public Optional<Enrollment> findLatestActive( @Nonnull String programId, @Nonnull String trackedEntityInstanceId, boolean localOnly ) { return findLatestActiveRefreshed( programId, trackedEntityInstanceId, localOnly ); }
EnrollmentServiceImpl implements EnrollmentService, LocalDhisRepositoryPersistCallback<Enrollment> { @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @Cacheable( key = "{'findLatestActive', #a0, #a1}", condition = "#a2 == false", cacheManager = "dhisCacheManager", cacheNames = "enrollments" ) public Optional<Enrollment> findLatestActive( @Nonnull String programId, @Nonnull String trackedEntityInstanceId, boolean localOnly ) { return findLatestActiveRefreshed( programId, trackedEntityInstanceId, localOnly ); } }
EnrollmentServiceImpl implements EnrollmentService, LocalDhisRepositoryPersistCallback<Enrollment> { @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @Cacheable( key = "{'findLatestActive', #a0, #a1}", condition = "#a2 == false", cacheManager = "dhisCacheManager", cacheNames = "enrollments" ) public Optional<Enrollment> findLatestActive( @Nonnull String programId, @Nonnull String trackedEntityInstanceId, boolean localOnly ) { return findLatestActiveRefreshed( programId, trackedEntityInstanceId, localOnly ); } @Autowired  EnrollmentServiceImpl( @Nonnull @Qualifier( "userDhis2RestTemplate" ) RestTemplate restTemplate, @Nonnull EventService eventService, @Nonnull RequestCacheService requestCacheService ); }
EnrollmentServiceImpl implements EnrollmentService, LocalDhisRepositoryPersistCallback<Enrollment> { @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @Cacheable( key = "{'findLatestActive', #a0, #a1}", condition = "#a2 == false", cacheManager = "dhisCacheManager", cacheNames = "enrollments" ) public Optional<Enrollment> findLatestActive( @Nonnull String programId, @Nonnull String trackedEntityInstanceId, boolean localOnly ) { return findLatestActiveRefreshed( programId, trackedEntityInstanceId, localOnly ); } @Autowired  EnrollmentServiceImpl( @Nonnull @Qualifier( "userDhis2RestTemplate" ) RestTemplate restTemplate, @Nonnull EventService eventService, @Nonnull RequestCacheService requestCacheService ); @Nonnull @Override DhisResourceType getDhisResourceType(); @HystrixCommand( ignoreExceptions = { UnauthorizedException.class, DhisFindException.class } ) @Nonnull @Override DhisResourceResult<Enrollment> find( @Nonnull UriFilterApplier uriFilterApplier, int from, int max ); @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @CachePut( key = "{'findLatestActive', #a0, #a1}", condition = "#a2 == false", cacheManager = "dhisCacheManager", cacheNames = "enrollments" ) Optional<Enrollment> findLatestActiveRefreshed( @Nonnull String programId, @Nonnull String trackedEntityInstanceId, boolean localOnly ); @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @Cacheable( key = "{'findLatestActive', #a0, #a1}", condition = "#a2 == false", cacheManager = "dhisCacheManager", cacheNames = "enrollments" ) Optional<Enrollment> findLatestActive( @Nonnull String programId, @Nonnull String trackedEntityInstanceId, boolean localOnly ); @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override Optional<Enrollment> findOneById( @Nonnull String id ); @HystrixCommand( ignoreExceptions = { DhisConflictException.class, UnauthorizedException.class } ) @Nonnull @Override @CacheEvict( key = "{'findLatestActive', #a0.programId, #a0.trackedEntityInstanceId}", cacheManager = "dhisCacheManager", cacheNames = "enrollments" ) Enrollment createOrUpdate( @Nonnull Enrollment enrollment ); @Override void persistSave( @Nonnull Collection<Enrollment> resources, boolean create, @Nullable Consumer<LocalDhisRepositoryPersistResult> resultConsumer ); @Override @Nonnull Enrollment persistSave( @Nonnull Enrollment resource ); @HystrixCommand( ignoreExceptions = { DhisConflictException.class, UnauthorizedException.class } ) @Override boolean delete( @Nonnull String enrollmentId ); @Override void persistDeleteById( @Nonnull Collection<String> ids, @Nullable Consumer<LocalDhisRepositoryPersistResult> resultConsumer ); @Override boolean persistDeleteById( @Nonnull String id ); }
EnrollmentServiceImpl implements EnrollmentService, LocalDhisRepositoryPersistCallback<Enrollment> { @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @Cacheable( key = "{'findLatestActive', #a0, #a1}", condition = "#a2 == false", cacheManager = "dhisCacheManager", cacheNames = "enrollments" ) public Optional<Enrollment> findLatestActive( @Nonnull String programId, @Nonnull String trackedEntityInstanceId, boolean localOnly ) { return findLatestActiveRefreshed( programId, trackedEntityInstanceId, localOnly ); } @Autowired  EnrollmentServiceImpl( @Nonnull @Qualifier( "userDhis2RestTemplate" ) RestTemplate restTemplate, @Nonnull EventService eventService, @Nonnull RequestCacheService requestCacheService ); @Nonnull @Override DhisResourceType getDhisResourceType(); @HystrixCommand( ignoreExceptions = { UnauthorizedException.class, DhisFindException.class } ) @Nonnull @Override DhisResourceResult<Enrollment> find( @Nonnull UriFilterApplier uriFilterApplier, int from, int max ); @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @CachePut( key = "{'findLatestActive', #a0, #a1}", condition = "#a2 == false", cacheManager = "dhisCacheManager", cacheNames = "enrollments" ) Optional<Enrollment> findLatestActiveRefreshed( @Nonnull String programId, @Nonnull String trackedEntityInstanceId, boolean localOnly ); @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @Cacheable( key = "{'findLatestActive', #a0, #a1}", condition = "#a2 == false", cacheManager = "dhisCacheManager", cacheNames = "enrollments" ) Optional<Enrollment> findLatestActive( @Nonnull String programId, @Nonnull String trackedEntityInstanceId, boolean localOnly ); @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override Optional<Enrollment> findOneById( @Nonnull String id ); @HystrixCommand( ignoreExceptions = { DhisConflictException.class, UnauthorizedException.class } ) @Nonnull @Override @CacheEvict( key = "{'findLatestActive', #a0.programId, #a0.trackedEntityInstanceId}", cacheManager = "dhisCacheManager", cacheNames = "enrollments" ) Enrollment createOrUpdate( @Nonnull Enrollment enrollment ); @Override void persistSave( @Nonnull Collection<Enrollment> resources, boolean create, @Nullable Consumer<LocalDhisRepositoryPersistResult> resultConsumer ); @Override @Nonnull Enrollment persistSave( @Nonnull Enrollment resource ); @HystrixCommand( ignoreExceptions = { DhisConflictException.class, UnauthorizedException.class } ) @Override boolean delete( @Nonnull String enrollmentId ); @Override void persistDeleteById( @Nonnull Collection<String> ids, @Nullable Consumer<LocalDhisRepositoryPersistResult> resultConsumer ); @Override boolean persistDeleteById( @Nonnull String id );  }