Repository: corona-warn-app/cwa-server
File: services/submission/src/test/java/app/coronawarn/server/services/submission/validation/EventCheckinDataValidatorTest.java (Java)

Code before:
  void should_return_true_if_checkin_data_has_correct_trl_values(int correctTrl) {
    SubmissionPayload newPayload = SubmissionPayload.newBuilder()
        .addAllCheckIns(List.of(CheckIn.newBuilder().setCheckinTime(CORRECT_CHECKIN_TIME)
            .setCheckoutTime(CORRECT_CHECKOUT_TIME).setTrl(correctTrl).build()))
        .build();

    boolean result = validator.verify(newPayload, mockValidatorContext);
    assertTrue(result);
  }

  @ParameterizedTest
  @ValueSource(ints = {-1, 0})
  void should_return_false_if_checkin_data_has_wrong_checkin_time_values(int startTime) {
    SubmissionPayload newPayload = SubmissionPayload.newBuilder()
        .addAllCheckIns(List.of(
            CheckIn.newBuilder().setCheckinTime(startTime).setCheckoutTime(CORRECT_CHECKOUT_TIME)
                .setTrl(CORRECT_TRL).build()))
        .build();

    boolean result = validator.verify(newPayload, mockValidatorContext);
    assertFalse(result);
  }

  @ParameterizedTest
  @ValueSource(ints = {1, 15, 30, 100})
  void should_return_false_if_checkin_data_has_correct_checkin_time_values(int startTime) {
    SubmissionPayload newPayload = SubmissionPayload.newBuilder()
        .addAllCheckIns(List.of(
            CheckIn.newBuilder().setCheckinTime(startTime).setCheckoutTime(startTime + 1)
                .setTrl(CORRECT_TRL).build()))
        .build();

    boolean result = validator.verify(newPayload, mockValidatorContext);
    assertTrue(result);
  }

  @Test
  void should_return_false_if_checkout_time_is_equal_or_before_checkin_time() {
    SubmissionPayload newPayload = SubmissionPayload.newBuilder()
        .addAllCheckIns(List.of(CheckIn.newBuilder().setCheckinTime(CORRECT_CHECKOUT_TIME)
            .setCheckoutTime(CORRECT_CHECKOUT_TIME).setTrl(CORRECT_TRL).build()))
        .build();

    boolean result = validator.verify(newPayload, mockValidatorContext);
    assertFalse(result);

    newPayload = SubmissionPayload.newBuilder()
        .addAllCheckIns(List.of(CheckIn.newBuilder().setCheckinTime(CORRECT_CHECKOUT_TIME)
            .setCheckoutTime(CORRECT_CHECKOUT_TIME - 1).setTrl(CORRECT_TRL).build()))
        .build();


Review comment (suggestion):
```suggestion
  void should_return_true_if_checkin_data_has_correct_checkin_time_values(int startTime) {
```

Code after:
  void should_return_true_if_checkin_data_has_correct_trl_values(int correctTrl) {
    SubmissionPayload newPayload = SubmissionPayload.newBuilder()
        .addAllCheckIns(List.of(CheckIn.newBuilder().setCheckinTime(CORRECT_CHECKIN_TIME)
            .setCheckoutTime(CORRECT_CHECKOUT_TIME).setTrl(correctTrl).build()))
        .build();

    boolean result = validator.verify(newPayload, mockValidatorContext);
    assertTrue(result);
  }

  @ParameterizedTest
  @ValueSource(ints = {-1, 0})
  void should_return_false_if_checkin_data_has_wrong_checkin_time_values(int startTime) {
    SubmissionPayload newPayload = SubmissionPayload.newBuilder()
        .addAllCheckIns(List.of(
            CheckIn.newBuilder().setCheckinTime(startTime).setCheckoutTime(CORRECT_CHECKOUT_TIME)
                .setTrl(CORRECT_TRL).build()))
        .build();

    boolean result = validator.verify(newPayload, mockValidatorContext);
    assertFalse(result);
  }

  @ParameterizedTest
  @ValueSource(ints = {1, 15, 30, 100})
  void should_return_true_if_checkin_data_has_correct_checkin_time_values(int startTime) {
    SubmissionPayload newPayload = SubmissionPayload.newBuilder()
        .addAllCheckIns(List.of(
            CheckIn.newBuilder().setCheckinTime(startTime).setCheckoutTime(startTime + 1)
                .setTrl(CORRECT_TRL).build()))
        .build();

    boolean result = validator.verify(newPayload, mockValidatorContext);
    assertTrue(result);
  }

  @Test
  void should_return_false_if_checkout_time_is_equal_or_before_checkin_time() {
    SubmissionPayload newPayload = SubmissionPayload.newBuilder()
        .addAllCheckIns(List.of(CheckIn.newBuilder().setCheckinTime(CORRECT_CHECKOUT_TIME)
            .setCheckoutTime(CORRECT_CHECKOUT_TIME).setTrl(CORRECT_TRL).build()))
        .build();

    boolean result = validator.verify(newPayload, mockValidatorContext);
    assertFalse(result);

    newPayload = SubmissionPayload.newBuilder()
        .addAllCheckIns(List.of(CheckIn.newBuilder().setCheckinTime(CORRECT_CHECKOUT_TIME)
            .setCheckoutTime(CORRECT_CHECKOUT_TIME - 1).setTrl(CORRECT_TRL).build()))
        .build();