Skip to content

Commit d845b68

Browse files
Add artist class to faker
1 parent 6e9dfe5 commit d845b68

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

src/main/kotlin/io/bloco/faker/Faker.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package io.bloco.faker
22

33
import io.bloco.faker.components.Address
44
import io.bloco.faker.components.App
5+
import io.bloco.faker.components.Artist
56
import io.bloco.faker.components.Avatar
67
import io.bloco.faker.components.Book
78
import io.bloco.faker.components.Bool
@@ -33,6 +34,9 @@ class Faker(val locale: String = DEFAULT_LOCALE) {
3334
@JvmField
3435
val app: App
3536

37+
@JvmField
38+
val artist: Artist
39+
3640
@JvmField
3741
val avatar: Avatar
3842

@@ -103,6 +107,7 @@ class Faker(val locale: String = DEFAULT_LOCALE) {
103107
// Load components
104108
address = data.getComponent(Address::class)
105109
app = data.getComponent(App::class)
110+
artist = data.getComponent(Artist::class)
106111
avatar = data.getComponent(Avatar::class)
107112
book = data.getComponent(Book::class)
108113
bool = data.getComponent(Bool::class)

src/main/kotlin/io/bloco/faker/FakerData.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package io.bloco.faker
22

33
import io.bloco.faker.components.Address
44
import io.bloco.faker.components.App
5+
import io.bloco.faker.components.Artist
56
import io.bloco.faker.components.Avatar
67
import io.bloco.faker.components.Book
78
import io.bloco.faker.components.Bool
@@ -29,6 +30,7 @@ class FakerData(private val data: Map<String, Any>) {
2930
Address(this),
3031
App(this),
3132
Avatar(this),
33+
Artist(this),
3234
Book(this),
3335
Bool(this),
3436
Business(this),
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package io.bloco.faker.components
2+
3+
import io.bloco.faker.FakerComponent
4+
import io.bloco.faker.FakerData
5+
6+
class Artist(data: FakerData) : FakerComponent(data) {
7+
fun name(): String {
8+
return fetch("artist.names")
9+
}
10+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package io.bloco.faker.components
2+
3+
import io.bloco.faker.Faker
4+
import junit.framework.TestCase
5+
import org.junit.Test
6+
7+
class ArtistTest {
8+
private val faker = Faker()
9+
10+
@Test
11+
fun name() {
12+
TestCase.assertNotNull(faker.artist.name())
13+
}
14+
}

0 commit comments

Comments
 (0)