Skip to content

Commit

Permalink
Merge pull request #5 from unrec/rename-rated-item
Browse files Browse the repository at this point in the history
Rename RatedItem class
  • Loading branch information
unrec authored Dec 2, 2022
2 parents 35bec40 + c67d0ff commit a2e4096
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

version = "0.0.2"
version = "0.0.3"
group = "com.unrec"
description = "imdb-csv-parser"
java.sourceCompatibility = JavaVersion.VERSION_11
Expand Down
12 changes: 6 additions & 6 deletions src/main/kotlin/com/unrec/imdb/csv/parser/ImdbCsvParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ class ImdbCsvParser {
.addArrayColumn("Directors")
.build()

fun parse(inputStream: InputStream): List<RatedItem> {
return csvMapper.readerFor(RatedItem::class.java)
fun parse(inputStream: InputStream): List<ParsedItem> {
return csvMapper.readerFor(ParsedItem::class.java)
.with(schema)
.readValues<RatedItem>(inputStream)
.readValues<ParsedItem>(inputStream)
.readAll()
}

fun parse(file: File): List<RatedItem> {
return csvMapper.readerFor(RatedItem::class.java)
fun parse(file: File): List<ParsedItem> {
return csvMapper.readerFor(ParsedItem::class.java)
.with(schema)
.readValues<RatedItem>(file)
.readValues<ParsedItem>(file)
.readAll()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat
import com.fasterxml.jackson.annotation.JsonProperty
import java.time.LocalDate

data class RatedItem(
data class ParsedItem(
@field:JsonProperty("Const")
val id: String? = null,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal class ImdbCsvParserTest {
@Test
internal fun `Parse 5 exact records from the File`() {
// given
val ratedItems = TestData.ratedItems
val ratedItems = TestData.parsedItems

// when
val items = parser.parse(File(pathToFiveItems))
Expand All @@ -42,7 +42,7 @@ internal class ImdbCsvParserTest {
items.size shouldBe 5
items.forEach { item ->
val ratedItem = ratedItems.find { it.id == item.id }!!
item.shouldBeEqualToIgnoringFields(ratedItem, RatedItem::genres, RatedItem::directors)
item.shouldBeEqualToIgnoringFields(ratedItem, ParsedItem::genres, ParsedItem::directors)
item.directors shouldContainExactlyInAnyOrder ratedItem.directors
item.genres shouldContainExactlyInAnyOrder ratedItem.genres
}
Expand Down
12 changes: 6 additions & 6 deletions src/test/kotlin/com/unrec/imdb/csv/parser/TestData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import java.time.LocalDate

object TestData {

val ratedItems = listOf(
RatedItem(
val parsedItems = listOf(
ParsedItem(
"tt0110912",
10,
LocalDate.parse("2010-01-17"),
Expand All @@ -20,7 +20,7 @@ object TestData {
LocalDate.parse("1994-05-21"),
listOf("Quentin Tarantino")
),
RatedItem(
ParsedItem(
"tt0401792",
10,
LocalDate.parse("2019-10-21"),
Expand All @@ -35,7 +35,7 @@ object TestData {
LocalDate.parse("2005-03-28"),
listOf("Frank Miller", "Quentin Tarantino", "Robert Rodriguez")
),
RatedItem(
ParsedItem(
"tt7366338",
9,
LocalDate.parse("2019-06-14"),
Expand All @@ -50,7 +50,7 @@ object TestData {
LocalDate.parse("2019-05-06"),
emptyList()
),
RatedItem(
ParsedItem(
"tt1625351",
6,
LocalDate.parse("2011-03-18"),
Expand All @@ -65,7 +65,7 @@ object TestData {
LocalDate.parse("2011-02-27"),
listOf("Don Mischer", "Troy Miller")
),
RatedItem(
ParsedItem(
"tt0291337",
10,
LocalDate.parse("2010-02-11"),
Expand Down

0 comments on commit a2e4096

Please sign in to comment.