Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gmitaros committed Oct 6, 2024
1 parent 4b0470c commit 014b804
Showing 1 changed file with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,22 @@ public class CsvParserService implements DataParser {
@PostConstruct
@Transactional
public void init() {
long vesselData = vesselDataRepository.count();
log.info("Found {} vessel data in vessel_data db ", vesselData);
boolean loadData = vesselData <= 0 || loadCsvIfAlreadyHaveData;
if (loadData) {
log.info("CsvParserService will load data from {} file", vesselDataPath);
try (InputStream inputStream = getClass().getResourceAsStream(vesselDataPath)) {
parseAndSave(inputStream);
checkForOutliers();
} catch (Exception e) {
log.error("Error initializing data: ", e);
throw new RuntimeException("Failed to initialize data", e);
synchronized (this) {
long vesselData = vesselDataRepository.count();
log.info("Found {} vessel data in vessel_data db ", vesselData);
boolean loadData = vesselData <= 0 || loadCsvIfAlreadyHaveData;
if (loadData) {
log.info("CsvParserService will load data from {} file", vesselDataPath);
try (InputStream inputStream = getClass().getResourceAsStream(vesselDataPath)) {
parseAndSave(inputStream);
checkForOutliers();
} catch (Exception e) {
log.error("Error initializing data: ", e);
throw new RuntimeException("Failed to initialize data", e);
}
} else {
log.info("Skipping loading again vessel data from CSV file");
}
} else {
log.info("Skipping loading again vessel data from CSV file");
}
}

Expand Down

0 comments on commit 014b804

Please sign in to comment.