### Question:
ReportParametersHelper { public static Map<String, String[]> toRawParameters(List<ReportParameter> reportParameters){ Map<String, String[]> rawParameters = null; if(reportParameters != null){ rawParameters = new HashMap<String, String[]>(); for(ReportParameter currentParameter : reportParameters){ rawParameters.put(currentParameter.getName(), currentParameter.getValues().toArray(new String[currentParameter.getValues().size()])); } } return rawParameters; }  static Map<String, String[]> toRawParameters(List<ReportParameter> reportParameters); static List<ReportParameter> fromRawParameters(Map<String, String[]> reportParams);  }### Answer:
@Test public void toRawParameters(){ List<ReportParameter> parametersList = new ArrayList<ReportParameter>(); ReportParameter parameter = new ReportParameter(); List<String> values = new LinkedList<String>(); parameter.setName(NAME1); values.add(VALUE1_1); values.add(VALUE1_2); values.add(VALUE1_3); parameter.setValues(values); parametersList.add(parameter); parameter = new ReportParameter(); parameter.setName(NAME2); values = new LinkedList<String>(); values.add(VALUE2_1); values.add(VALUE2_2); values.add(VALUE2_3); parameter.setValues(values); parametersList.add(parameter); final Map<String,String[]> resultMap = ReportParametersHelper.toRawParameters(parametersList); assertNotNull(resultMap); assertEquals(resultMap.size(), 2); for(String currentKey : resultMap.keySet()){ if(NAME1.equals(currentKey)){ String[] name1Values = resultMap.get(currentKey); assertNotNull(name1Values); assertEquals(name1Values.length, 3); Set<String> currentValues = new HashSet<String>(); for(String currentValue : name1Values){ currentValues.add(currentValue); } assertTrue(currentValues.contains(VALUE1_1)); assertTrue(currentValues.contains(VALUE1_2)); assertTrue(currentValues.contains(VALUE1_3)); } else if(NAME2.equals(currentKey)){ String[] name2Values = resultMap.get(currentKey); assertNotNull(name2Values); assertEquals(name2Values.length, 3); Set<String> currentValues = new HashSet<String>(); for(String currentValue : name2Values){ currentValues.add(currentValue); } assertTrue(currentValues.contains(VALUE2_1)); assertTrue(currentValues.contains(VALUE2_2)); assertTrue(currentValues.contains(VALUE2_3)); } else { assertTrue(false); } } }
@Test public void toRawParameters_null(){ assertNull(ReportParametersHelper.toRawParameters(null)); }