@Test public void findLocalTeiDiffer() throws IOException { mockServer.expect( ExpectedCount.once(), requestTo( "http: "eventDate,dueDate,coordinate,lastUpdated,dataValues%5BdataElement,value,providedElsewhere,lastUpdated,storedBy%5D&skipPaging=true" ) ) .andExpect( method( HttpMethod.GET ) ).andRespond( withSuccess( IOUtils.resourceToByteArray( "/org/dhis2/fhir/adapter/dhis/tracker/program/impl/events.json" ), MediaType.APPLICATION_JSON ) ); try ( final RequestCacheContext cacheContext = requestCacheService.createRequestCacheContext() ) { cacheContext.setAttribute( LocalDhisResourceRepositoryTemplate.CONTAINER_REQUEST_CACHE_ATTRIBUTE_NAME, new LocalDhisResourceRepositoryContainerImpl( Collections.singleton( Event.class ) ) ); Collection<Event> events = service.find( "kgdyunhUgg", "gjddShhdfgh", "Jskdsjeua1s", "jdhshdfj", false ); Assert.assertEquals( 2, events.size() ); events = service.find( "kgdyunhUgg", "gjddShhdfgh", "Jskdsjeua1s", "adhshdfj", true ); Assert.assertEquals( 0, events.size() ); } mockServer.verify(); }
@HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @Cacheable( key = "{'find', #a0, #a1, #a2, #a3}", condition = "#a4 == false", cacheManager = "dhisCacheManager", cacheNames = "events" ) public Collection<Event> find( @Nonnull String programId, @Nonnull String programStageId, @Nonnull String enrollmentId, @Nonnull String trackedEntityInstanceId, boolean localOnly ) { return findRefreshed( programId, programStageId, enrollmentId, trackedEntityInstanceId, localOnly ); }
EventServiceImpl implements EventService, LocalDhisRepositoryPersistCallback<Event> { @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @Cacheable( key = "{'find', #a0, #a1, #a2, #a3}", condition = "#a4 == false", cacheManager = "dhisCacheManager", cacheNames = "events" ) public Collection<Event> find( @Nonnull String programId, @Nonnull String programStageId, @Nonnull String enrollmentId, @Nonnull String trackedEntityInstanceId, boolean localOnly ) { return findRefreshed( programId, programStageId, enrollmentId, trackedEntityInstanceId, localOnly ); } }
EventServiceImpl implements EventService, LocalDhisRepositoryPersistCallback<Event> { @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @Cacheable( key = "{'find', #a0, #a1, #a2, #a3}", condition = "#a4 == false", cacheManager = "dhisCacheManager", cacheNames = "events" ) public Collection<Event> find( @Nonnull String programId, @Nonnull String programStageId, @Nonnull String enrollmentId, @Nonnull String trackedEntityInstanceId, boolean localOnly ) { return findRefreshed( programId, programStageId, enrollmentId, trackedEntityInstanceId, localOnly ); } @Autowired  EventServiceImpl( @Nonnull @Qualifier( "userDhis2RestTemplate" ) RestTemplate restTemplate, @Nonnull RequestCacheService requestCacheService, @Nonnull PolledProgramRetriever polledProgramRetriever ); }
EventServiceImpl implements EventService, LocalDhisRepositoryPersistCallback<Event> { @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @Cacheable( key = "{'find', #a0, #a1, #a2, #a3}", condition = "#a4 == false", cacheManager = "dhisCacheManager", cacheNames = "events" ) public Collection<Event> find( @Nonnull String programId, @Nonnull String programStageId, @Nonnull String enrollmentId, @Nonnull String trackedEntityInstanceId, boolean localOnly ) { return findRefreshed( programId, programStageId, enrollmentId, trackedEntityInstanceId, localOnly ); } @Autowired  EventServiceImpl( @Nonnull @Qualifier( "userDhis2RestTemplate" ) RestTemplate restTemplate, @Nonnull RequestCacheService requestCacheService, @Nonnull PolledProgramRetriever polledProgramRetriever ); @Nonnull @Override DhisResourceType getDhisResourceType(); @HystrixCommand( ignoreExceptions = { DhisConflictException.class, UnauthorizedException.class } ) @Override boolean delete( @Nonnull String eventId ); @Override void persistDeleteById( @Nonnull Collection<String> ids, @Nullable Consumer<LocalDhisRepositoryPersistResult> resultConsumer ); @Override boolean persistDeleteById( @Nonnull String id ); @HystrixCommand( ignoreExceptions = { DhisConflictException.class, UnauthorizedException.class } ) @Nonnull @Override @CacheEvict( key = "{'find', #a0.programId, #a0.programStageId, #a0.enrollmentId, #a0.trackedEntityInstanceId}", cacheManager = "dhisCacheManager", cacheNames = "events" ) Event createOrMinimalUpdate( @Nonnull Event event ); @Override void persistSave( @Nonnull Collection<Event> resources, boolean create, @Nullable Consumer<LocalDhisRepositoryPersistResult> resultConsumer ); @Override @Nonnull Event persistSave( @Nonnull Event resource ); @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @CachePut( key = "{'find', #a0, #a1, #a2, #a3}", condition = "#a4 == false", cacheManager = "dhisCacheManager", cacheNames = "events" ) Collection<Event> findRefreshed( @Nonnull String programId, @Nonnull String programStageId,
        @Nonnull String enrollmentId, @Nonnull String trackedEntityInstanceId, boolean localOnly ); @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @Cacheable( key = "{'find', #a0, #a1, #a2, #a3}", condition = "#a4 == false", cacheManager = "dhisCacheManager", cacheNames = "events" ) Collection<Event> find( @Nonnull String programId, @Nonnull String programStageId,
        @Nonnull String enrollmentId, @Nonnull String trackedEntityInstanceId, boolean localOnly ); @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override Optional<Event> findOneById( @Nonnull String eventId ); @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override Optional<Event> findOneDeletedById( @Nonnull String eventId ); @Nonnull @Override Instant poll( @Nonnull DhisSyncGroup group, @Nonnull Instant lastUpdated, int toleranceMillis, int maxSearchCount, @Nonnull Set<String> excludedStoredBy, @Nonnull Consumer<Collection<ProcessedItemInfo>> consumer ); @HystrixCommand( ignoreExceptions = { UnauthorizedException.class, DhisFindException.class } ) @Nonnull @Override DhisResourceResult<Event> find( @Nullable String programId, @Nullable String programStageId, @Nonnull UriFilterApplier uriFilterApplier, int from, int max ); }
EventServiceImpl implements EventService, LocalDhisRepositoryPersistCallback<Event> { @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @Cacheable( key = "{'find', #a0, #a1, #a2, #a3}", condition = "#a4 == false", cacheManager = "dhisCacheManager", cacheNames = "events" ) public Collection<Event> find( @Nonnull String programId, @Nonnull String programStageId, @Nonnull String enrollmentId, @Nonnull String trackedEntityInstanceId, boolean localOnly ) { return findRefreshed( programId, programStageId, enrollmentId, trackedEntityInstanceId, localOnly ); } @Autowired  EventServiceImpl( @Nonnull @Qualifier( "userDhis2RestTemplate" ) RestTemplate restTemplate, @Nonnull RequestCacheService requestCacheService, @Nonnull PolledProgramRetriever polledProgramRetriever ); @Nonnull @Override DhisResourceType getDhisResourceType(); @HystrixCommand( ignoreExceptions = { DhisConflictException.class, UnauthorizedException.class } ) @Override boolean delete( @Nonnull String eventId ); @Override void persistDeleteById( @Nonnull Collection<String> ids, @Nullable Consumer<LocalDhisRepositoryPersistResult> resultConsumer ); @Override boolean persistDeleteById( @Nonnull String id ); @HystrixCommand( ignoreExceptions = { DhisConflictException.class, UnauthorizedException.class } ) @Nonnull @Override @CacheEvict( key = "{'find', #a0.programId, #a0.programStageId, #a0.enrollmentId, #a0.trackedEntityInstanceId}", cacheManager = "dhisCacheManager", cacheNames = "events" ) Event createOrMinimalUpdate( @Nonnull Event event ); @Override void persistSave( @Nonnull Collection<Event> resources, boolean create, @Nullable Consumer<LocalDhisRepositoryPersistResult> resultConsumer ); @Override @Nonnull Event persistSave( @Nonnull Event resource ); @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @CachePut( key = "{'find', #a0, #a1, #a2, #a3}", condition = "#a4 == false", cacheManager = "dhisCacheManager", cacheNames = "events" ) Collection<Event> findRefreshed( @Nonnull String programId, @Nonnull String programStageId,
        @Nonnull String enrollmentId, @Nonnull String trackedEntityInstanceId, boolean localOnly ); @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @Cacheable( key = "{'find', #a0, #a1, #a2, #a3}", condition = "#a4 == false", cacheManager = "dhisCacheManager", cacheNames = "events" ) Collection<Event> find( @Nonnull String programId, @Nonnull String programStageId,
        @Nonnull String enrollmentId, @Nonnull String trackedEntityInstanceId, boolean localOnly ); @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override Optional<Event> findOneById( @Nonnull String eventId ); @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override Optional<Event> findOneDeletedById( @Nonnull String eventId ); @Nonnull @Override Instant poll( @Nonnull DhisSyncGroup group, @Nonnull Instant lastUpdated, int toleranceMillis, int maxSearchCount, @Nonnull Set<String> excludedStoredBy, @Nonnull Consumer<Collection<ProcessedItemInfo>> consumer ); @HystrixCommand( ignoreExceptions = { UnauthorizedException.class, DhisFindException.class } ) @Nonnull @Override DhisResourceResult<Event> find( @Nullable String programId, @Nullable String programStageId, @Nonnull UriFilterApplier uriFilterApplier, int from, int max );  }