LimsFactory { @NotNull @VisibleForTesting static Map<String, LimsJsonSubmissionData> readLimsJsonSubmissions(@NotNull String limsJsonPath) throws FileNotFoundException { Gson gson = LimsGsonAdapter.buildSubmissionGson(); JsonObject jsonObject = new JsonParser().parse(new FileReader(limsJsonPath)).getAsJsonObject(); Set<Map.Entry<String, JsonElement>> jsonSubmissions = jsonObject.getAsJsonObject("submissions").entrySet(); Map<String, LimsJsonSubmissionData> limsDataPerSubmission = Maps.newHashMap(); jsonSubmissions.forEach(jsonSubmission -> { JsonObject jsonSampleObject = jsonSubmission.getValue().getAsJsonObject(); String projectType = jsonSampleObject.get("project_type").getAsString(); if (projectType.contains("CORE")) { try { LimsJsonSubmissionData limsJsonSubmissionData = gson.fromJson(jsonSubmission.getValue(), LimsJsonSubmissionData.class); limsDataPerSubmission.put(limsJsonSubmissionData.submission(), limsJsonSubmissionData); } catch (JsonSyntaxException exception) { LOGGER.warn("Could not convert JSON element to LimsJsonSubmissionData: {} - message: {}", jsonSubmission.getValue(), exception.getMessage()); } } }); return limsDataPerSubmission; } private  LimsFactory(); @NotNull static Lims fromLimsDirectory(@NotNull String limsDirectory); @NotNull static Lims empty();  }
@Test public void readSubmissionsCorrectlyFromJsonFile() throws FileNotFoundException { Map<String, LimsJsonSubmissionData> dataPerSubmission = LimsFactory.readLimsJsonSubmissions(LIMS_DIRECTORY + File.separator + "lims.json"); assertEquals(1, dataPerSubmission.size()); String submission = "ABCDEF123"; LimsJsonSubmissionData submissionData = dataPerSubmission.get(submission); assertEquals(submission, submissionData.submission()); }