LogDataListPersistanceVer2 implements LogDataListPersistance { public List<LogData> loadLogsList(InputStream in) throws IOException { BufferedReader bin = new BufferedReader(new InputStreamReader(in, "UTF-8")); String line = bin.readLine(); String[] split = line.split(FIELD_SEPERATOR_TO_SPLIT); HashMap<String, Integer> fieldMapping = new HashMap<>(); for (int i = 0; i < split.length; i++) { String string = split[i]; fieldMapping.put(string, Integer.valueOf(i)); } ArrayList<LogData> list = new ArrayList<>(); while ((line = bin.readLine()) != null) { String[] params = line.split(FIELD_SEPERATOR_TO_SPLIT); if (params.length < split.length) { String[] newParams = new String[split.length]; System.arraycopy(params, 0, newParams, 0, params.length); for (int i = params.length; i < newParams.length; i++) { newParams[i] = ""; } params = newParams; } LogData parseLogData = parseLogData(params, fieldMapping); list.add(parseLogData); } return list; }  void saveLogsList(OutputStream out, List<LogData> list); List<LogData> loadLogsList(InputStream in); static final String HEADER_ID; static final String HEADER_TIMESTAMP; static final String HEADER_MESSAGE; static final String HEADER_CLASS; static final String HEADER_METHOD; static final String HEADER_LEVEL; static final String HEADER_LOGGER; static final String HEADER_THREAD; static final String HEADER_MDC; static final String HEADER_NDC; static final String HEADER_FILE; static final String HEADER_LINE; static final String HEADER_LOG_SOURCE; static final String HEADER_NOTE; static final String HEADER_MARKED; static final String HEADER_MARKED_COLOR; static final String FIELD_SEPERATOR; static final String FIELD_SEPERATOR_TO_SPLIT; }
@Test public void testLogDataWithoutPropertiesColumn() throws IOException { InputStream in = this.getClass().getClassLoader().getResourceAsStream("persistance/logs_without_properties_column.txt"); List<LogData> loadLogsList = ver2.loadLogsList(in); AssertJUnit.assertEquals(40, loadLogsList.size()); Map<String, String> propertiesRead = loadLogsList.get(0).getProperties(); AssertJUnit.assertEquals(0, propertiesRead.size()); }