@Test public void findOneById() throws IOException { mockServer.expect( requestTo( "http: "dataValues%5BdataElement,value,providedElsewhere,lastUpdated,storedBy%5D" ) ) .andExpect( method( HttpMethod.GET ) ).andRespond( withSuccess( IOUtils.resourceToByteArray( "/org/dhis2/fhir/adapter/dhis/tracker/program/impl/event.json" ), MediaType.APPLICATION_JSON ) ); Optional<? extends Event> ou = service.findOneById( "jShdkweusi2" ); Assert.assertTrue( ou.isPresent() ); Assert.assertEquals( "jShdkweusi2", ou.get().getId() ); Assert.assertEquals( "Jskdsjeua1s", ou.get().getEnrollmentId() ); Assert.assertEquals( ZonedDateTime.of( 2018, 10, 5, 22, 12, 34, 998000000, ZoneId.systemDefault() ).toLocalDateTime(), ou.get().getEventDate().toLocalDateTime() ); Assert.assertEquals( ZonedDateTime.of( 2018, 10, 6, 22, 12, 34, 998000000, ZoneId.systemDefault() ).toLocalDateTime(), ou.get().getDueDate().toLocalDateTime() ); Assert.assertEquals( EventStatus.ACTIVE, ou.get().getStatus() ); Assert.assertEquals( "jdhshdfj", ou.get().getTrackedEntityInstanceId() ); Assert.assertEquals( "kgdyunhUgg", ou.get().getProgramId() ); Assert.assertEquals( "gjddShhdfgh", ou.get().getProgramStageId() ); Assert.assertEquals( "jhgtJgrygffg", ou.get().getOrgUnitId() ); Assert.assertEquals( new Location( 64.89767, -86.78866 ), ou.get().getCoordinate() ); }
@HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override public Optional<Event> findOneById( @Nonnull String eventId ) { return resourceRepositoryTemplate.findOneById( eventId, this::_findOneById ); }
EventServiceImpl implements EventService, LocalDhisRepositoryPersistCallback<Event> { @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override public Optional<Event> findOneById( @Nonnull String eventId ) { return resourceRepositoryTemplate.findOneById( eventId, this::_findOneById ); } }
EventServiceImpl implements EventService, LocalDhisRepositoryPersistCallback<Event> { @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override public Optional<Event> findOneById( @Nonnull String eventId ) { return resourceRepositoryTemplate.findOneById( eventId, this::_findOneById ); } @Autowired  EventServiceImpl( @Nonnull @Qualifier( "userDhis2RestTemplate" ) RestTemplate restTemplate, @Nonnull RequestCacheService requestCacheService, @Nonnull PolledProgramRetriever polledProgramRetriever ); }
EventServiceImpl implements EventService, LocalDhisRepositoryPersistCallback<Event> { @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override public Optional<Event> findOneById( @Nonnull String eventId ) { return resourceRepositoryTemplate.findOneById( eventId, this::_findOneById ); } @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 public Optional<Event> findOneById( @Nonnull String eventId ) { return resourceRepositoryTemplate.findOneById( eventId, this::_findOneById ); } @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 );  }