@Test public void none() { final Script script = new Script(); final ScriptArg scriptArg1 = new ScriptArg(); scriptArg1.setScript( script ); scriptArg1.setDataType( DataType.STRING ); scriptArg1.setDefaultValue( "NONE" ); scriptArg1.setName( "arg1" ); final ScriptArg scriptArg2 = new ScriptArg(); scriptArg2.setScript( script ); scriptArg2.setDataType( DataType.STRING ); scriptArg2.setDefaultValue( "TSTC1" ); scriptArg2.setName( "arg2" ); script.setArguments( Arrays.asList( scriptArg1, scriptArg2 ) ); final ExecutableScript executableScript = new ExecutableScript(); executableScript.setScript( script ); final Code code = new Code(); final Collection<? extends Metadata> deps = resolver.resolveAdditionalDependencies( executableScript ); Mockito.verifyZeroInteractions( codeRepository, codeSetRepository ); }
@Nonnull @Override public Collection<? extends Metadata> resolveAdditionalDependencies( @Nonnull Metadata metadata ) { final ExecutableScript executableScript = (ExecutableScript) metadata; final Set<Metadata> dependencies = Sets.newIdentityHashSet(); final Collection<ScriptArgValue> scriptArgValues = ScriptArgUtils.getScriptArgValues( ObjectUtils.defaultIfNull( executableScript.getScript().getArguments(), Collections.emptyList() ), ObjectUtils.defaultIfNull( executableScript.getOverrideArguments(), Collections.emptyList() ) ); scriptArgValues.stream().filter( sav -> sav.getScriptArg().getDataType() == DataType.CODE ).forEach( sav -> { final Collection<String> codes = extractCodes( sav ); if ( !codes.isEmpty() ) { dependencies.addAll( codeRepository.findAllByCode( codes ) ); } } ); scriptArgValues.stream().filter( sav -> sav.getScriptArg().getDataType() == DataType.CODE_SET ).forEach( sav -> { final Collection<String> codes = extractCodes( sav ); if ( !codes.isEmpty() ) { dependencies.addAll( codeSetRepository.findAllByCode( codes ) ); } } ); return dependencies; }
ExecutableScriptExportDependencyResolver implements MetadataExportDependencyResolver { @Nonnull @Override public Collection<? extends Metadata> resolveAdditionalDependencies( @Nonnull Metadata metadata ) { final ExecutableScript executableScript = (ExecutableScript) metadata; final Set<Metadata> dependencies = Sets.newIdentityHashSet(); final Collection<ScriptArgValue> scriptArgValues = ScriptArgUtils.getScriptArgValues( ObjectUtils.defaultIfNull( executableScript.getScript().getArguments(), Collections.emptyList() ), ObjectUtils.defaultIfNull( executableScript.getOverrideArguments(), Collections.emptyList() ) ); scriptArgValues.stream().filter( sav -> sav.getScriptArg().getDataType() == DataType.CODE ).forEach( sav -> { final Collection<String> codes = extractCodes( sav ); if ( !codes.isEmpty() ) { dependencies.addAll( codeRepository.findAllByCode( codes ) ); } } ); scriptArgValues.stream().filter( sav -> sav.getScriptArg().getDataType() == DataType.CODE_SET ).forEach( sav -> { final Collection<String> codes = extractCodes( sav ); if ( !codes.isEmpty() ) { dependencies.addAll( codeSetRepository.findAllByCode( codes ) ); } } ); return dependencies; } }
ExecutableScriptExportDependencyResolver implements MetadataExportDependencyResolver { @Nonnull @Override public Collection<? extends Metadata> resolveAdditionalDependencies( @Nonnull Metadata metadata ) { final ExecutableScript executableScript = (ExecutableScript) metadata; final Set<Metadata> dependencies = Sets.newIdentityHashSet(); final Collection<ScriptArgValue> scriptArgValues = ScriptArgUtils.getScriptArgValues( ObjectUtils.defaultIfNull( executableScript.getScript().getArguments(), Collections.emptyList() ), ObjectUtils.defaultIfNull( executableScript.getOverrideArguments(), Collections.emptyList() ) ); scriptArgValues.stream().filter( sav -> sav.getScriptArg().getDataType() == DataType.CODE ).forEach( sav -> { final Collection<String> codes = extractCodes( sav ); if ( !codes.isEmpty() ) { dependencies.addAll( codeRepository.findAllByCode( codes ) ); } } ); scriptArgValues.stream().filter( sav -> sav.getScriptArg().getDataType() == DataType.CODE_SET ).forEach( sav -> { final Collection<String> codes = extractCodes( sav ); if ( !codes.isEmpty() ) { dependencies.addAll( codeSetRepository.findAllByCode( codes ) ); } } ); return dependencies; } ExecutableScriptExportDependencyResolver( @Nonnull CodeRepository codeRepository, @Nonnull CodeSetRepository codeSetRepository ); }
ExecutableScriptExportDependencyResolver implements MetadataExportDependencyResolver { @Nonnull @Override public Collection<? extends Metadata> resolveAdditionalDependencies( @Nonnull Metadata metadata ) { final ExecutableScript executableScript = (ExecutableScript) metadata; final Set<Metadata> dependencies = Sets.newIdentityHashSet(); final Collection<ScriptArgValue> scriptArgValues = ScriptArgUtils.getScriptArgValues( ObjectUtils.defaultIfNull( executableScript.getScript().getArguments(), Collections.emptyList() ), ObjectUtils.defaultIfNull( executableScript.getOverrideArguments(), Collections.emptyList() ) ); scriptArgValues.stream().filter( sav -> sav.getScriptArg().getDataType() == DataType.CODE ).forEach( sav -> { final Collection<String> codes = extractCodes( sav ); if ( !codes.isEmpty() ) { dependencies.addAll( codeRepository.findAllByCode( codes ) ); } } ); scriptArgValues.stream().filter( sav -> sav.getScriptArg().getDataType() == DataType.CODE_SET ).forEach( sav -> { final Collection<String> codes = extractCodes( sav ); if ( !codes.isEmpty() ) { dependencies.addAll( codeSetRepository.findAllByCode( codes ) ); } } ); return dependencies; } ExecutableScriptExportDependencyResolver( @Nonnull CodeRepository codeRepository, @Nonnull CodeSetRepository codeSetRepository ); @Override boolean supports( @Nonnull Class<? extends Metadata> metadataClass ); @Nonnull @Override Collection<? extends Metadata> resolveAdditionalDependencies( @Nonnull Metadata metadata ); }
ExecutableScriptExportDependencyResolver implements MetadataExportDependencyResolver { @Nonnull @Override public Collection<? extends Metadata> resolveAdditionalDependencies( @Nonnull Metadata metadata ) { final ExecutableScript executableScript = (ExecutableScript) metadata; final Set<Metadata> dependencies = Sets.newIdentityHashSet(); final Collection<ScriptArgValue> scriptArgValues = ScriptArgUtils.getScriptArgValues( ObjectUtils.defaultIfNull( executableScript.getScript().getArguments(), Collections.emptyList() ), ObjectUtils.defaultIfNull( executableScript.getOverrideArguments(), Collections.emptyList() ) ); scriptArgValues.stream().filter( sav -> sav.getScriptArg().getDataType() == DataType.CODE ).forEach( sav -> { final Collection<String> codes = extractCodes( sav ); if ( !codes.isEmpty() ) { dependencies.addAll( codeRepository.findAllByCode( codes ) ); } } ); scriptArgValues.stream().filter( sav -> sav.getScriptArg().getDataType() == DataType.CODE_SET ).forEach( sav -> { final Collection<String> codes = extractCodes( sav ); if ( !codes.isEmpty() ) { dependencies.addAll( codeSetRepository.findAllByCode( codes ) ); } } ); return dependencies; } ExecutableScriptExportDependencyResolver( @Nonnull CodeRepository codeRepository, @Nonnull CodeSetRepository codeSetRepository ); @Override boolean supports( @Nonnull Class<? extends Metadata> metadataClass ); @Nonnull @Override Collection<? extends Metadata> resolveAdditionalDependencies( @Nonnull Metadata metadata );  }