@Test public void isLocal() throws IOException { mockServer.expect( ExpectedCount.once(), requestTo( "http: .andExpect( content().contentTypeCompatibleWith( MediaType.APPLICATION_JSON ) ) .andExpect( content().json( IOUtils.resourceToString( "/org/dhis2/fhir/adapter/dhis/tracker/program/impl/createTrackedEntityInstance.json", StandardCharsets.UTF_8 ) ) ) .andExpect( method( HttpMethod.POST ) ).andRespond( withSuccess( IOUtils.resourceToByteArray( "/org/dhis2/fhir/adapter/dhis/tracker/program/impl/createTrackedEntityInstance-response.json" ), MediaType.APPLICATION_JSON ) ); final TrackedEntityInstance trackedEntityInstance = new TrackedEntityInstance( trackedEntityType, "Jskdsjeua1s", true ); trackedEntityInstance.setOrgUnitId( "pMEnu7BjqMz" ); try ( final RequestCacheContext cacheContext = requestCacheService.createRequestCacheContext() ) { cacheContext.setAttribute( LocalDhisResourceRepositoryTemplate.CONTAINER_REQUEST_CACHE_ATTRIBUTE_NAME, new LocalDhisResourceRepositoryContainerImpl( Collections.singleton( TrackedEntityInstance.class ) ) ); final TrackedEntityInstance createdTrackedEntityInstance = service.createOrUpdate( trackedEntityInstance ); Assert.assertTrue( service.isLocal( "Jskdsjeua1s" ) ); } }
@Override public boolean isLocal( @Nonnull String id ) { return resourceRepositoryTemplate.isLocal( id ); }
TrackedEntityServiceImpl implements TrackedEntityService, LocalDhisRepositoryPersistCallback<TrackedEntityInstance> { @Override public boolean isLocal( @Nonnull String id ) { return resourceRepositoryTemplate.isLocal( id ); } }
TrackedEntityServiceImpl implements TrackedEntityService, LocalDhisRepositoryPersistCallback<TrackedEntityInstance> { @Override public boolean isLocal( @Nonnull String id ) { return resourceRepositoryTemplate.isLocal( id ); } @Autowired  TrackedEntityServiceImpl( @Nonnull @Qualifier( "userDhis2RestTemplate" ) RestTemplate restTemplate, @Nonnull RequestCacheService requestCacheService,
        @Nonnull TrackedEntityMetadataService metadataService, @Nonnull StoredDhisResourceService storedItemService ); }
TrackedEntityServiceImpl implements TrackedEntityService, LocalDhisRepositoryPersistCallback<TrackedEntityInstance> { @Override public boolean isLocal( @Nonnull String id ) { return resourceRepositoryTemplate.isLocal( id ); } @Autowired  TrackedEntityServiceImpl( @Nonnull @Qualifier( "userDhis2RestTemplate" ) RestTemplate restTemplate, @Nonnull RequestCacheService requestCacheService,
        @Nonnull TrackedEntityMetadataService metadataService, @Nonnull StoredDhisResourceService storedItemService ); @Nonnull @Override DhisResourceType getDhisResourceType(); @HystrixCommand( ignoreExceptions = { DhisConflictException.class, UnauthorizedException.class } ) @Override void updateGeneratedValues( @Nonnull TrackedEntityInstance trackedEntityInstance, @Nonnull TrackedEntityType type, @Nonnull Map<RequiredValueType, String> requiredValues ); @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @CachePut( key = "{'findOneById', #a0}", cacheManager = "dhisCacheManager", cacheNames = "trackedEntityInstances" ) Optional<TrackedEntityInstance> findOneByIdRefreshed( @Nonnull String id ); @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @Cacheable( key = "{'findOneById', #a0}", cacheManager = "dhisCacheManager", cacheNames = "trackedEntityInstances" ) Optional<TrackedEntityInstance> findOneById( @Nonnull String id ); @Override boolean isLocal( @Nonnull String id ); @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @CachePut( key = "{'findByAttrValue', #a0, #a1, #a2, #a3}", cacheManager = "dhisCacheManager", cacheNames = "trackedEntityInstances", unless = "#result.size() == 0" ) Collection<TrackedEntityInstance> findByAttrValueRefreshed( @Nonnull String typeId, @Nonnull String attributeId, @Nonnull String value, int maxResult ); @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @Cacheable( key = "{'findByAttrValue', #a0, #a1, #a2, #a3}", cacheManager = "dhisCacheManager", cacheNames = "trackedEntityInstances", unless = "#result.size() == 0" ) Collection<TrackedEntityInstance> findByAttrValue( @Nonnull String typeId, @Nonnull String attributeId, @Nonnull String value, int maxResult ); @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 = { DhisConflictException.class, UnauthorizedException.class } ) @Nonnull @Override TrackedEntityInstance createOrUpdate( @Nonnull TrackedEntityInstance trackedEntityInstance ); @Override void persistSave( @Nonnull Collection<TrackedEntityInstance> resources, boolean create, @Nullable Consumer<LocalDhisRepositoryPersistResult> resultConsumer ); @Override @Nonnull TrackedEntityInstance persistSave( @Nonnull TrackedEntityInstance resource ); @HystrixCommand( ignoreExceptions = { DhisConflictException.class, UnauthorizedException.class } ) @Override boolean delete( @Nonnull String trackedEntityInstanceId ); @Override void persistDeleteById( @Nonnull Collection<String> ids, @Nullable Consumer<LocalDhisRepositoryPersistResult> resultConsumer ); @Override boolean persistDeleteById( @Nonnull String id ); @HystrixCommand( ignoreExceptions = { UnauthorizedException.class, DhisFindException.class } ) @Nonnull @Override DhisResourceResult<TrackedEntityInstance> find( @Nonnull String trackedEntityTypeId, @Nonnull UriFilterApplier uriFilterApplier, int from, int max ); }
TrackedEntityServiceImpl implements TrackedEntityService, LocalDhisRepositoryPersistCallback<TrackedEntityInstance> { @Override public boolean isLocal( @Nonnull String id ) { return resourceRepositoryTemplate.isLocal( id ); } @Autowired  TrackedEntityServiceImpl( @Nonnull @Qualifier( "userDhis2RestTemplate" ) RestTemplate restTemplate, @Nonnull RequestCacheService requestCacheService,
        @Nonnull TrackedEntityMetadataService metadataService, @Nonnull StoredDhisResourceService storedItemService ); @Nonnull @Override DhisResourceType getDhisResourceType(); @HystrixCommand( ignoreExceptions = { DhisConflictException.class, UnauthorizedException.class } ) @Override void updateGeneratedValues( @Nonnull TrackedEntityInstance trackedEntityInstance, @Nonnull TrackedEntityType type, @Nonnull Map<RequiredValueType, String> requiredValues ); @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @CachePut( key = "{'findOneById', #a0}", cacheManager = "dhisCacheManager", cacheNames = "trackedEntityInstances" ) Optional<TrackedEntityInstance> findOneByIdRefreshed( @Nonnull String id ); @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @Cacheable( key = "{'findOneById', #a0}", cacheManager = "dhisCacheManager", cacheNames = "trackedEntityInstances" ) Optional<TrackedEntityInstance> findOneById( @Nonnull String id ); @Override boolean isLocal( @Nonnull String id ); @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @CachePut( key = "{'findByAttrValue', #a0, #a1, #a2, #a3}", cacheManager = "dhisCacheManager", cacheNames = "trackedEntityInstances", unless = "#result.size() == 0" ) Collection<TrackedEntityInstance> findByAttrValueRefreshed( @Nonnull String typeId, @Nonnull String attributeId, @Nonnull String value, int maxResult ); @HystrixCommand( ignoreExceptions = UnauthorizedException.class ) @Nonnull @Override @Cacheable( key = "{'findByAttrValue', #a0, #a1, #a2, #a3}", cacheManager = "dhisCacheManager", cacheNames = "trackedEntityInstances", unless = "#result.size() == 0" ) Collection<TrackedEntityInstance> findByAttrValue( @Nonnull String typeId, @Nonnull String attributeId, @Nonnull String value, int maxResult ); @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 = { DhisConflictException.class, UnauthorizedException.class } ) @Nonnull @Override TrackedEntityInstance createOrUpdate( @Nonnull TrackedEntityInstance trackedEntityInstance ); @Override void persistSave( @Nonnull Collection<TrackedEntityInstance> resources, boolean create, @Nullable Consumer<LocalDhisRepositoryPersistResult> resultConsumer ); @Override @Nonnull TrackedEntityInstance persistSave( @Nonnull TrackedEntityInstance resource ); @HystrixCommand( ignoreExceptions = { DhisConflictException.class, UnauthorizedException.class } ) @Override boolean delete( @Nonnull String trackedEntityInstanceId ); @Override void persistDeleteById( @Nonnull Collection<String> ids, @Nullable Consumer<LocalDhisRepositoryPersistResult> resultConsumer ); @Override boolean persistDeleteById( @Nonnull String id ); @HystrixCommand( ignoreExceptions = { UnauthorizedException.class, DhisFindException.class } ) @Nonnull @Override DhisResourceResult<TrackedEntityInstance> find( @Nonnull String trackedEntityTypeId, @Nonnull UriFilterApplier uriFilterApplier, int from, int max );  }