@Test public void testWithMessyString() { Diagnos res = factory.createDiagnosFromString(REALLY_MESSY_LINE, false); assertNotNull(res); assertEquals("A050", res.getKod()); assertEquals("Matförgiftning orsakad av stafylokocker", res.getBeskrivning()); }
public Diagnos createDiagnosFromString(String line, boolean firstLineInFile) { if (Strings.nullToEmpty(line).trim().isEmpty()) { return null; } String cleanedLine = removeUnwantedCharacters(line, firstLineInFile); int firstSpacePos = cleanedLine.indexOf(SPACE); if (firstSpacePos == -1) { return null; } String kodStr = cleanedLine.substring(0, firstSpacePos); String beskStr = cleanedLine.substring(firstSpacePos + 1); Diagnos d = new Diagnos(); d.setKod(kodStr.toUpperCase()); d.setBeskrivning(beskStr); return d; }
DiagnosRepositoryFactory { public Diagnos createDiagnosFromString(String line, boolean firstLineInFile) { if (Strings.nullToEmpty(line).trim().isEmpty()) { return null; } String cleanedLine = removeUnwantedCharacters(line, firstLineInFile); int firstSpacePos = cleanedLine.indexOf(SPACE); if (firstSpacePos == -1) { return null; } String kodStr = cleanedLine.substring(0, firstSpacePos); String beskStr = cleanedLine.substring(firstSpacePos + 1); Diagnos d = new Diagnos(); d.setKod(kodStr.toUpperCase()); d.setBeskrivning(beskStr); return d; } }
DiagnosRepositoryFactory { public Diagnos createDiagnosFromString(String line, boolean firstLineInFile) { if (Strings.nullToEmpty(line).trim().isEmpty()) { return null; } String cleanedLine = removeUnwantedCharacters(line, firstLineInFile); int firstSpacePos = cleanedLine.indexOf(SPACE); if (firstSpacePos == -1) { return null; } String kodStr = cleanedLine.substring(0, firstSpacePos); String beskStr = cleanedLine.substring(firstSpacePos + 1); Diagnos d = new Diagnos(); d.setKod(kodStr.toUpperCase()); d.setBeskrivning(beskStr); return d; }  }
DiagnosRepositoryFactory { public Diagnos createDiagnosFromString(String line, boolean firstLineInFile) { if (Strings.nullToEmpty(line).trim().isEmpty()) { return null; } String cleanedLine = removeUnwantedCharacters(line, firstLineInFile); int firstSpacePos = cleanedLine.indexOf(SPACE); if (firstSpacePos == -1) { return null; } String kodStr = cleanedLine.substring(0, firstSpacePos); String beskStr = cleanedLine.substring(firstSpacePos + 1); Diagnos d = new Diagnos(); d.setKod(kodStr.toUpperCase()); d.setBeskrivning(beskStr); return d; }  DiagnosRepository createAndInitDiagnosRepository(List<String> filesList, Charset fileEncoding); void populateRepoFromDiagnosisCodeFile(String fileUrl, DiagnosRepositoryImpl diagnosRepository,
                                                  Charset fileEncoding); Diagnos createDiagnosFromString(String line, boolean firstLineInFile); }
DiagnosRepositoryFactory { public Diagnos createDiagnosFromString(String line, boolean firstLineInFile) { if (Strings.nullToEmpty(line).trim().isEmpty()) { return null; } String cleanedLine = removeUnwantedCharacters(line, firstLineInFile); int firstSpacePos = cleanedLine.indexOf(SPACE); if (firstSpacePos == -1) { return null; } String kodStr = cleanedLine.substring(0, firstSpacePos); String beskStr = cleanedLine.substring(firstSpacePos + 1); Diagnos d = new Diagnos(); d.setKod(kodStr.toUpperCase()); d.setBeskrivning(beskStr); return d; }  DiagnosRepository createAndInitDiagnosRepository(List<String> filesList, Charset fileEncoding); void populateRepoFromDiagnosisCodeFile(String fileUrl, DiagnosRepositoryImpl diagnosRepository,
                                                  Charset fileEncoding); Diagnos createDiagnosFromString(String line, boolean firstLineInFile);  }