@Test public void should_create_entry_OK() { List<String> unitIds = Collections.singletonList("aUnitId"); List<ProbativeOperation> operations = Arrays.asList(aRandomProbativeOperation(), aRandomProbativeOperation(), aRandomProbativeOperation()); List<ProbativeCheck> checks = Stream.of(ChecksInformation.values()).map(this::toProbativeCheck).collect(Collectors.toList()); ProbativeReportEntry entry = new ProbativeReportEntry("startDate", unitIds, "objectGroupId", "objectId", "usageVersion", operations, checks); assertThat(entry.getStatus()).isEqualTo(OK); }
@JsonIgnore private StatusCode getStatus(List<ProbativeOperation> operations, List<ProbativeCheck> checks) { if (operations.stream().allMatch(Objects::nonNull) && operations.size() == 3 && checks.stream().allMatch(Objects::nonNull) && checks.stream().allMatch(c -> OK.equals(c.getStatus())) && checks.size() == ChecksInformation.values().length) { return OK; } if (operations.stream().allMatch(Objects::nonNull) && operations.size() == 3 && checks.stream().allMatch(Objects::nonNull) && checks.stream().noneMatch(c -> KO.equals(c.getStatus())) && checks.size() == ChecksInformation.values().length) { return WARNING; } return KO; }
ProbativeReportEntry { @JsonIgnore private StatusCode getStatus(List<ProbativeOperation> operations, List<ProbativeCheck> checks) { if (operations.stream().allMatch(Objects::nonNull) && operations.size() == 3 && checks.stream().allMatch(Objects::nonNull) && checks.stream().allMatch(c -> OK.equals(c.getStatus())) && checks.size() == ChecksInformation.values().length) { return OK; } if (operations.stream().allMatch(Objects::nonNull) && operations.size() == 3 && checks.stream().allMatch(Objects::nonNull) && checks.stream().noneMatch(c -> KO.equals(c.getStatus())) && checks.size() == ChecksInformation.values().length) { return WARNING; } return KO; } }
ProbativeReportEntry { @JsonIgnore private StatusCode getStatus(List<ProbativeOperation> operations, List<ProbativeCheck> checks) { if (operations.stream().allMatch(Objects::nonNull) && operations.size() == 3 && checks.stream().allMatch(Objects::nonNull) && checks.stream().allMatch(c -> OK.equals(c.getStatus())) && checks.size() == ChecksInformation.values().length) { return OK; } if (operations.stream().allMatch(Objects::nonNull) && operations.size() == 3 && checks.stream().allMatch(Objects::nonNull) && checks.stream().noneMatch(c -> KO.equals(c.getStatus())) && checks.size() == ChecksInformation.values().length) { return WARNING; } return KO; } @JsonCreator  ProbativeReportEntry(
        @JsonProperty("unitIds") List<String> unitIds,
        @JsonProperty("objectGroupId") String objectGroupId,
        @JsonProperty("objectId") String objectId,
        @JsonProperty("usageVersion") String usageVersion,
        @JsonProperty("operations") List<ProbativeOperation> operations,
        @JsonProperty("checks") List<ProbativeCheck> checks,
        @JsonProperty("evStartDateTime") String evStartDateTime,
        @JsonProperty("evEndDateTime") String evEndDateTime,
        @JsonProperty("status") StatusCode status);  ProbativeReportEntry(String evStartDateTime, List<String> unitIds, String objectGroupId, String objectId, String usageVersion, List<ProbativeOperation> operations, List<ProbativeCheck> checks); private  ProbativeReportEntry(String evStartDateTime, List<String> unitIds, String objectGroupId, String objectId, String usageVersion); }
ProbativeReportEntry { @JsonIgnore private StatusCode getStatus(List<ProbativeOperation> operations, List<ProbativeCheck> checks) { if (operations.stream().allMatch(Objects::nonNull) && operations.size() == 3 && checks.stream().allMatch(Objects::nonNull) && checks.stream().allMatch(c -> OK.equals(c.getStatus())) && checks.size() == ChecksInformation.values().length) { return OK; } if (operations.stream().allMatch(Objects::nonNull) && operations.size() == 3 && checks.stream().allMatch(Objects::nonNull) && checks.stream().noneMatch(c -> KO.equals(c.getStatus())) && checks.size() == ChecksInformation.values().length) { return WARNING; } return KO; } @JsonCreator  ProbativeReportEntry(
        @JsonProperty("unitIds") List<String> unitIds,
        @JsonProperty("objectGroupId") String objectGroupId,
        @JsonProperty("objectId") String objectId,
        @JsonProperty("usageVersion") String usageVersion,
        @JsonProperty("operations") List<ProbativeOperation> operations,
        @JsonProperty("checks") List<ProbativeCheck> checks,
        @JsonProperty("evStartDateTime") String evStartDateTime,
        @JsonProperty("evEndDateTime") String evEndDateTime,
        @JsonProperty("status") StatusCode status);  ProbativeReportEntry(String evStartDateTime, List<String> unitIds, String objectGroupId, String objectId, String usageVersion, List<ProbativeOperation> operations, List<ProbativeCheck> checks); private  ProbativeReportEntry(String evStartDateTime, List<String> unitIds, String objectGroupId, String objectId, String usageVersion); @JsonIgnore static ProbativeReportEntry koFrom(String evStartDateTime, List<String> unitIds, String objectGroupId, String objectId, String usageVersion); @JsonIgnore static ProbativeReportEntry koFrom(String startEntryCreation, List<String> unitIds, String objectGroupId, String objectId, String usageVersion, List<ProbativeOperation> probativeOperations); @JsonIgnore static ProbativeReportEntry koFrom(String startEntryCreation, List<String> unitIds, String objectGroupId, String objectId, String usageVersion, List<ProbativeOperation> probativeOperations, List<ProbativeCheck> probativeChecks); @JsonProperty("unitIds") List<String> getUnitIds(); @JsonProperty("objectGroupId") String getObjectGroupId(); @JsonProperty("objectId") String getObjectId(); @JsonProperty("usageVersion") String getUsageVersion(); @JsonProperty("operations") List<ProbativeOperation> getOperations(); @JsonProperty("checks") List<ProbativeCheck> getChecks(); @JsonProperty("evStartDateTime") String getEvStartDateTime(); @JsonProperty("evEndDateTime") String getEvEndDateTime(); @JsonProperty("status") StatusCode getStatus(); }
ProbativeReportEntry { @JsonIgnore private StatusCode getStatus(List<ProbativeOperation> operations, List<ProbativeCheck> checks) { if (operations.stream().allMatch(Objects::nonNull) && operations.size() == 3 && checks.stream().allMatch(Objects::nonNull) && checks.stream().allMatch(c -> OK.equals(c.getStatus())) && checks.size() == ChecksInformation.values().length) { return OK; } if (operations.stream().allMatch(Objects::nonNull) && operations.size() == 3 && checks.stream().allMatch(Objects::nonNull) && checks.stream().noneMatch(c -> KO.equals(c.getStatus())) && checks.size() == ChecksInformation.values().length) { return WARNING; } return KO; } @JsonCreator  ProbativeReportEntry(
        @JsonProperty("unitIds") List<String> unitIds,
        @JsonProperty("objectGroupId") String objectGroupId,
        @JsonProperty("objectId") String objectId,
        @JsonProperty("usageVersion") String usageVersion,
        @JsonProperty("operations") List<ProbativeOperation> operations,
        @JsonProperty("checks") List<ProbativeCheck> checks,
        @JsonProperty("evStartDateTime") String evStartDateTime,
        @JsonProperty("evEndDateTime") String evEndDateTime,
        @JsonProperty("status") StatusCode status);  ProbativeReportEntry(String evStartDateTime, List<String> unitIds, String objectGroupId, String objectId, String usageVersion, List<ProbativeOperation> operations, List<ProbativeCheck> checks); private  ProbativeReportEntry(String evStartDateTime, List<String> unitIds, String objectGroupId, String objectId, String usageVersion); @JsonIgnore static ProbativeReportEntry koFrom(String evStartDateTime, List<String> unitIds, String objectGroupId, String objectId, String usageVersion); @JsonIgnore static ProbativeReportEntry koFrom(String startEntryCreation, List<String> unitIds, String objectGroupId, String objectId, String usageVersion, List<ProbativeOperation> probativeOperations); @JsonIgnore static ProbativeReportEntry koFrom(String startEntryCreation, List<String> unitIds, String objectGroupId, String objectId, String usageVersion, List<ProbativeOperation> probativeOperations, List<ProbativeCheck> probativeChecks); @JsonProperty("unitIds") List<String> getUnitIds(); @JsonProperty("objectGroupId") String getObjectGroupId(); @JsonProperty("objectId") String getObjectId(); @JsonProperty("usageVersion") String getUsageVersion(); @JsonProperty("operations") List<ProbativeOperation> getOperations(); @JsonProperty("checks") List<ProbativeCheck> getChecks(); @JsonProperty("evStartDateTime") String getEvStartDateTime(); @JsonProperty("evEndDateTime") String getEvEndDateTime(); @JsonProperty("status") StatusCode getStatus();  }