/*
 * Copyright 2021 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.android.gnd.persistence.local;

import static com.google.common.truth.Truth.assertThat;

import com.google.android.gnd.model.observation.DateResponse;
import com.google.android.gnd.model.observation.TimeResponse;
import java.time.Instant;
import java.time.LocalDate;
import java.time.Month;
import java.time.ZoneId;
import java.util.Date;
import org.junit.Test;

public class DateTimeResponseTest {

  // Sat, 23 Oct 2021 07:30:45 (Local Time)
  private static final Instant EXPECTED_INSTANT =
      LocalDate.of(2021, Month.OCTOBER, 23)
          .atTime(7, 30, 45)
          .atZone(ZoneId.systemDefault())
          .toInstant();

  private Date getExpectedDate() {
    return Date.from(EXPECTED_INSTANT);
  }

  @Test
  public void testTimeResponse_textDetails() {
    assertThat(new TimeResponse(getExpectedDate()).getDetailsText()).isEqualTo("07:30");
  }

  @Test
  public void testDateResponse_textDetails() {
    assertThat(new DateResponse(getExpectedDate()).getDetailsText()).isEqualTo("2021-10-23");
  }
}

@@ -1014,154 +1014,98 @@
 %0A%0A  
-// Sat, 23 Oct 2021 07:30:45 (Local Time)%0A  private static final Instant EXPECTED_INSTANT =%0A      LocalDate.of(2021, Month.OCTOBER, 23)%0A          
+@Test%0A  public void testTimeResponse_textDetails() %7B%0A    Instant instant = LocalDate.now()
 .atT
@@ -1118,27 +1118,16 @@
  30, 45)
-%0A          
 .atZone(
@@ -1153,19 +1153,8 @@
 t())
-%0A          
 .toI
@@ -1166,144 +1166,8 @@
 t();
-%0A%0A  private Date getExpectedDate() %7B%0A    return Date.from(EXPECTED_INSTANT);%0A  %7D%0A%0A  @Test%0A  public void testTimeResponse_textDetails() %7B
 %0A   
@@ -1195,32 +1195,33 @@
 esponse(
-getExpectedDate(
+Date.from(instant
 )).getDe
@@ -1309,24 +1309,190 @@
 Details() %7B%0A
+    Instant instant =%0A        LocalDate.of(2021, Month.OCTOBER, 23)%0A            .atStartOfDay()%0A            .atZone(ZoneId.systemDefault())%0A            .toInstant();%0A
     assertTh
@@ -1515,24 +1515,25 @@
 nse(
-getExpectedDate(
+Date.from(instant
 )).g

Create expected date within the test method