@Test public void getDeleteRuleInfo() { final UUID ruleId = UUID.randomUUID(); final RuleInfo<AbstractRule> ruleInfo = new RuleInfo<>( new TrackedEntityRule(), Collections.emptyList() ); Mockito.doReturn( FhirResourceType.PATIENT ).when( fhirClientResource ).getFhirResourceType(); Mockito.doReturn( Optional.of( ruleInfo ) ).when( ruleRepository ).findOneImpByDhisFhirInputData( Mockito.eq( FhirResourceType.PATIENT ), Mockito.eq( DhisResourceType.TRACKED_ENTITY ), Mockito.eq( ruleId ) ); final RuleInfo<? extends AbstractRule> result = service.getDeleteRuleInfo( fhirClientResource, new DhisFhirResourceId( DhisResourceType.TRACKED_ENTITY, "a0123456789", ruleId ) ); Assert.assertSame( ruleInfo, result ); }
@Nullable protected RuleInfo<? extends AbstractRule> getDeleteRuleInfo( @Nonnull FhirClientResource fhirClientResource, @Nonnull DhisFhirResourceId dhisFhirResourceId ) { final RuleInfo<? extends AbstractRule> ruleInfo; if ( dhisFhirResourceId.isQualified() ) { ruleInfo = ruleRepository.findOneImpByDhisFhirInputData( Objects.requireNonNull( fhirClientResource.getFhirResourceType() ), dhisFhirResourceId.getType(), dhisFhirResourceId.getRuleId() ).orElse( null ); } else { ruleInfo = ruleRepository.findOneExpByDhisFhirInputData( fhirClientResource.getFhirResourceType() ) .filter( ri -> ri.getRule().isSimpleFhirId() ).orElse( null ); } return ruleInfo; }
FhirToDhisTransformerServiceImpl implements FhirToDhisTransformerService { @Nullable protected RuleInfo<? extends AbstractRule> getDeleteRuleInfo( @Nonnull FhirClientResource fhirClientResource, @Nonnull DhisFhirResourceId dhisFhirResourceId ) { final RuleInfo<? extends AbstractRule> ruleInfo; if ( dhisFhirResourceId.isQualified() ) { ruleInfo = ruleRepository.findOneImpByDhisFhirInputData( Objects.requireNonNull( fhirClientResource.getFhirResourceType() ), dhisFhirResourceId.getType(), dhisFhirResourceId.getRuleId() ).orElse( null ); } else { ruleInfo = ruleRepository.findOneExpByDhisFhirInputData( fhirClientResource.getFhirResourceType() ) .filter( ri -> ri.getRule().isSimpleFhirId() ).orElse( null ); } return ruleInfo; } }
FhirToDhisTransformerServiceImpl implements FhirToDhisTransformerService { @Nullable protected RuleInfo<? extends AbstractRule> getDeleteRuleInfo( @Nonnull FhirClientResource fhirClientResource, @Nonnull DhisFhirResourceId dhisFhirResourceId ) { final RuleInfo<? extends AbstractRule> ruleInfo; if ( dhisFhirResourceId.isQualified() ) { ruleInfo = ruleRepository.findOneImpByDhisFhirInputData( Objects.requireNonNull( fhirClientResource.getFhirResourceType() ), dhisFhirResourceId.getType(), dhisFhirResourceId.getRuleId() ).orElse( null ); } else { ruleInfo = ruleRepository.findOneExpByDhisFhirInputData( fhirClientResource.getFhirResourceType() ) .filter( ri -> ri.getRule().isSimpleFhirId() ).orElse( null ); } return ruleInfo; } FhirToDhisTransformerServiceImpl( @Nonnull LockManager lockManager,
        @Nonnull FhirResourceRepository fhirResourceRepository, @Nonnull RuleRepository ruleRepository,
        @Nonnull ObjectProvider<List<FhirToDhisTransformer<?, ?>>> transformersProvider,
        @Nonnull ObjectProvider<List<FhirToDhisTransformerUtils>> transformUtilsProvider,
        @Nonnull ScriptExecutor scriptExecutor ); }
FhirToDhisTransformerServiceImpl implements FhirToDhisTransformerService { @Nullable protected RuleInfo<? extends AbstractRule> getDeleteRuleInfo( @Nonnull FhirClientResource fhirClientResource, @Nonnull DhisFhirResourceId dhisFhirResourceId ) { final RuleInfo<? extends AbstractRule> ruleInfo; if ( dhisFhirResourceId.isQualified() ) { ruleInfo = ruleRepository.findOneImpByDhisFhirInputData( Objects.requireNonNull( fhirClientResource.getFhirResourceType() ), dhisFhirResourceId.getType(), dhisFhirResourceId.getRuleId() ).orElse( null ); } else { ruleInfo = ruleRepository.findOneExpByDhisFhirInputData( fhirClientResource.getFhirResourceType() ) .filter( ri -> ri.getRule().isSimpleFhirId() ).orElse( null ); } return ruleInfo; } FhirToDhisTransformerServiceImpl( @Nonnull LockManager lockManager,
        @Nonnull FhirResourceRepository fhirResourceRepository, @Nonnull RuleRepository ruleRepository,
        @Nonnull ObjectProvider<List<FhirToDhisTransformer<?, ?>>> transformersProvider,
        @Nonnull ObjectProvider<List<FhirToDhisTransformerUtils>> transformUtilsProvider,
        @Nonnull ScriptExecutor scriptExecutor ); @Nonnull @Override FhirToDhisTransformerRequest createTransformerRequest( @Nonnull FhirRequest fhirRequest, @Nonnull FhirClientResource fhirClientResource, @Nonnull IBaseResource originalInput, boolean contained ); @Nullable @Override FhirToDhisDeleteTransformOutcome<? extends DhisResource> delete( @Nonnull FhirClientResource fhirClientResource, @Nonnull DhisFhirResourceId dhisFhirResourceId ); @Nullable @Override FhirToDhisTransformOutcome<? extends DhisResource> transform( @Nonnull FhirToDhisTransformerRequest transformerRequest ); }
FhirToDhisTransformerServiceImpl implements FhirToDhisTransformerService { @Nullable protected RuleInfo<? extends AbstractRule> getDeleteRuleInfo( @Nonnull FhirClientResource fhirClientResource, @Nonnull DhisFhirResourceId dhisFhirResourceId ) { final RuleInfo<? extends AbstractRule> ruleInfo; if ( dhisFhirResourceId.isQualified() ) { ruleInfo = ruleRepository.findOneImpByDhisFhirInputData( Objects.requireNonNull( fhirClientResource.getFhirResourceType() ), dhisFhirResourceId.getType(), dhisFhirResourceId.getRuleId() ).orElse( null ); } else { ruleInfo = ruleRepository.findOneExpByDhisFhirInputData( fhirClientResource.getFhirResourceType() ) .filter( ri -> ri.getRule().isSimpleFhirId() ).orElse( null ); } return ruleInfo; } FhirToDhisTransformerServiceImpl( @Nonnull LockManager lockManager,
        @Nonnull FhirResourceRepository fhirResourceRepository, @Nonnull RuleRepository ruleRepository,
        @Nonnull ObjectProvider<List<FhirToDhisTransformer<?, ?>>> transformersProvider,
        @Nonnull ObjectProvider<List<FhirToDhisTransformerUtils>> transformUtilsProvider,
        @Nonnull ScriptExecutor scriptExecutor ); @Nonnull @Override FhirToDhisTransformerRequest createTransformerRequest( @Nonnull FhirRequest fhirRequest, @Nonnull FhirClientResource fhirClientResource, @Nonnull IBaseResource originalInput, boolean contained ); @Nullable @Override FhirToDhisDeleteTransformOutcome<? extends DhisResource> delete( @Nonnull FhirClientResource fhirClientResource, @Nonnull DhisFhirResourceId dhisFhirResourceId ); @Nullable @Override FhirToDhisTransformOutcome<? extends DhisResource> transform( @Nonnull FhirToDhisTransformerRequest transformerRequest );  }