ParameterXmlContentHandler { protected Object getSelections( final ParameterDefinitionEntry parameter, final Set<String> changedParameters, final ParameterDependencyGraph dependencies, final Map<String, Object> inputs ) { Objects.requireNonNull( changedParameters ); Objects.requireNonNull( parameter ); Objects.requireNonNull( inputs ); final String pName = parameter.getName(); if ( changedParameters.isEmpty() ) { return inputs.get( pName ); } if ( !( parameter instanceof ListParameter ) ) { return inputs.get( pName ); } final ListParameter listParameter = (ListParameter) parameter; final boolean isVerifiedValue = listParameter.isStrictValueCheck(); final boolean ifChangedParameter = changedParameters.contains( pName ); final boolean isDependency = dependencies.doesDependencyExist( pName ); return isVerifiedValue || ifChangedParameter || !isDependency ? inputs.get( pName ) : null; } ParameterXmlContentHandler( final ParameterContentGenerator contentGenerator, final boolean paginate ); static String convertParameterValueToString( final ParameterDefinitionEntry parameter,
                                                      final ParameterContext context, final Object value,
                                                      final Class<?> type ); void createParameterContent( final OutputStream outputStream,
                                      final Serializable fileId,
                                      final String path,
                                      boolean overrideOutputType,
                                      final MasterReport sourceReport ); static final String SYS_PARAM_ACCEPTED_PAGE; static final String SYS_PARAM_RENDER_MODE; static final String SYS_PARAM_CONTENT_LINK; static final String SYS_PARAM_SESSION_ID; static final String SYS_SERVER_NAMESPACE; }
@Test public void testGetSelections() throws ReportDataFactoryException, BeanException { final Map<String, Object> inputs = new HashMap<String, Object>() { { put( "unchanged_parent", "value0" ); put( "changed_unverified", "value" ); put( "unchanged_unverified", "value1" ); put( "verified", "value2" ); put( "plain", "value3" ); } }; final Set<String> changedParameters = Collections.singleton( "changed_unverified" ); final ParameterDefinitionEntry changed = new DefaultListParameter( "query", "keyColumn", "textColumn", "changed_unverified", false, false, String.class ); final ParameterDefinitionEntry unchanged = new DefaultListParameter( "query", "keyColumn", "textColumn", "unchanged_unverified", false, false, String.class ); final ParameterDefinitionEntry verified = new DefaultListParameter( "query", "keyColumn", "textColumn", "verified", false, true, String.class ); final ParameterDefinitionEntry plain = new PlainParameter( "plain", String.class ); final ParameterDependencyGraph dependencyGraph = new ParameterDependencyGraph( "unchanged_parent", "changed_unverified", "unchanged_unverified", "verified", "plain" ); dependencyGraph.addDependency( "unchanged_parent", "unchanged_unverified" ); final ParameterDependencyGraph noDependencyGraph = new ParameterDependencyGraph(); final Object changedResult = handler.getSelections( changed, new HashSet<>(), dependencyGraph, inputs ); final Object unchangedResult = handler.getSelections( unchanged, new HashSet<>(), dependencyGraph, inputs ); final Object verifiedResult = handler.getSelections( verified, new HashSet<>(), dependencyGraph, inputs ); final Object plainResult = handler.getSelections( plain, new HashSet<>(), dependencyGraph, inputs ); assertEquals( "value", changedResult ); assertEquals( "value1", unchangedResult ); assertEquals( "value2", verifiedResult ); assertEquals( "value3", plainResult ); final Object changedResult1 = handler.getSelections( changed, changedParameters, dependencyGraph, inputs ); final Object unchangedResult1 = handler.getSelections( unchanged, changedParameters, dependencyGraph, inputs ); final Object verifiedResult1 = handler.getSelections( verified, changedParameters, dependencyGraph, inputs ); final Object plainResult1 = handler.getSelections( plain, changedParameters, dependencyGraph, inputs ); assertEquals( "value", changedResult1 ); assertEquals( null, unchangedResult1 ); assertEquals( "value2", verifiedResult1 ); assertEquals( "value3", plainResult1 ); final Object changedResult2 = handler.getSelections( changed, changedParameters, noDependencyGraph, inputs ); final Object unchangedResult2 = handler.getSelections( unchanged, changedParameters, noDependencyGraph, inputs ); final Object verifiedResult2 = handler.getSelections( verified, changedParameters, noDependencyGraph, inputs ); final Object plainResult2 = handler.getSelections( plain, changedParameters, noDependencyGraph, inputs ); assertEquals( "value", changedResult2 ); assertEquals( "value1", unchangedResult2 ); assertEquals( "value2", verifiedResult2 ); assertEquals( "value3", plainResult2 ); }