Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Commit

Permalink
Fix typo in world with. Add better documentation comments for the code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Keworker committed Aug 11, 2023
1 parent 205adc7 commit f91a28f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package com.google.samples.apps.sunflower.data

import com.google.samples.apps.sunflower.test.HasSameDateWIth.Companion.hasSameDateWith
import com.google.samples.apps.sunflower.test.HasSameDateWith.Companion.hasSameDateWith
import org.hamcrest.CoreMatchers.`is`
import org.hamcrest.MatcherAssert.assertThat
import org.junit.Assert.assertEquals
import org.junit.Test
import java.util.Calendar

Expand All @@ -30,6 +30,6 @@ internal class GardenPlantingTest {
val calendar = Calendar.getInstance()
assertThat(gardenPlanting.plantDate, hasSameDateWith(calendar))
assertThat(gardenPlanting.lastWateringDate, hasSameDateWith(calendar))
assertEquals(0L, gardenPlanting.gardenPlantingId)
assertThat(gardenPlanting.gardenPlantingId, `is`(0L))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import java.util.Calendar.YEAR
* Calendar matcher.
* Only Year/Month/Day precision is needed for comparing GardenPlanting Calendar entries
*/
internal class HasSameDateWIth(
internal class HasSameDateWith(
private val expected: Calendar
) : TypeSafeDiagnosingMatcher<Calendar>() {
private val formatter = SimpleDateFormat("dd.MM.yyyy")
Expand All @@ -51,7 +51,16 @@ internal class HasSameDateWIth(
}

companion object {
/**
* Creates a matcher for [Calendar]s that only matches when year, month and day of
* actual calendar are equal to year, month and day of expected calendar.
*
* For example:
* <code>assertThat(someDate, hasSameDateWith(Calendar.getInstance()))</code>
*
* @param expected calendar that has expected year, month and day [Calendar]
*/
@Factory
fun hasSameDateWith(expected: Calendar): Matcher<Calendar> = HasSameDateWIth(expected)
fun hasSameDateWith(expected: Calendar): Matcher<Calendar> = HasSameDateWith(expected)
}
}

0 comments on commit f91a28f

Please sign in to comment.