Skip to content

Commit

Permalink
Sarthak: Removed the use of awaitality since CountDownLatch does the job
Browse files Browse the repository at this point in the history
  • Loading branch information
msarthak32 committed Feb 25, 2018
1 parent 78b18c8 commit 7bf4923
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 29 deletions.
7 changes: 0 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<kotlin.version>1.2.21</kotlin.version>
<kotlin.test.version>2.0.7</kotlin.test.version>
<version.jacoco>0.8.0</version.jacoco>
<version.dokka>0.9.9</version.dokka>
</properties>

<scm>
Expand Down Expand Up @@ -119,12 +118,6 @@
<version>42.1.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.dokka</groupId>
<artifactId>dokka-maven-plugin</artifactId>
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/com/github/dataanon/dsl/Strategy.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ abstract class Strategy {

fun execute(progressBarEnabled: Boolean = true) {
val latch = CountDownLatch(tables.size)

Flux.fromIterable(tables)
.parallel(tables.size)
.runOn(Schedulers.parallel())
.subscribe { table -> executeOnTable(table, progressBarEnabled, latch) }

latch.await()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import com.github.dataanon.model.DbConfig
import com.github.dataanon.strategy.string.FixedString
import com.github.dataanon.support.MoviesTable
import io.kotlintest.specs.FunSpec
import org.awaitility.Awaitility.await
import java.sql.Date
import java.util.concurrent.TimeUnit
import java.util.regex.Pattern
import kotlin.test.assertEquals
import kotlin.test.assertTrue
Expand All @@ -33,7 +31,6 @@ class SpecialFeaturesIntegrationTest : FunSpec() {
anonymize("GENRE").using(FixedString("Action"))
}.execute(progressBarEnabled = false)

await().timeout(4, TimeUnit.SECONDS).until { destTable.findAll()[0]["TITLE"].toString().equals("MY VALUE") }
val records = destTable.findAll()

assertEquals(1, records.size)
Expand All @@ -57,7 +54,6 @@ class SpecialFeaturesIntegrationTest : FunSpec() {
anonymize("GENRE")
}.execute(progressBarEnabled = true)

await().timeout(2, TimeUnit.SECONDS).until { moviesTable.findAll()[0]["TITLE"].toString().equals("MY VALUE") }
val records = moviesTable.findAll()

assertEquals(1, records.size)
Expand Down Expand Up @@ -86,7 +82,6 @@ class SpecialFeaturesIntegrationTest : FunSpec() {
anonymize("GENRE").using(FixedString("Action"))
}.execute(progressBarEnabled = false)

await().timeout(2, TimeUnit.SECONDS).until { destTable.findAll()[0]["TITLE"].toString().equals("MY VALUE") }
val records = destTable.findAll()

assertEquals(1, records.size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import com.github.dataanon.strategy.string.FixedString
import com.github.dataanon.strategy.string.RandomAlphabetic
import com.github.dataanon.support.MoviesTable
import io.kotlintest.specs.FunSpec
import org.awaitility.Awaitility
import java.sql.Date
import java.util.concurrent.TimeUnit
import java.util.regex.Pattern
import kotlin.test.assertEquals
import kotlin.test.assertTrue
Expand All @@ -27,7 +25,6 @@ class BlacklistMoviesNullValueIntegrationTest : FunSpec() {
anonymize("GENRE").using(RandomAlphabetic())
}.execute(progressBarEnabled = false)

Awaitility.await().timeout(2, TimeUnit.SECONDS).until { moviesTable.findAll()[0]["TITLE"].toString().equals("MY VALUE") }
val records = moviesTable.findAll()

assertEquals(2, records.size)
Expand Down Expand Up @@ -55,7 +52,6 @@ class BlacklistMoviesNullValueIntegrationTest : FunSpec() {
anonymize("GENRE")
}.execute(progressBarEnabled = false)

Awaitility.await().timeout(2, TimeUnit.SECONDS).until { moviesTable.findAll()[0]["TITLE"].toString().equals("MY VALUE") }
val records = moviesTable.findAll()

assertEquals(2, records.size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import com.github.dataanon.model.DbConfig
import com.github.dataanon.strategy.string.FixedString
import com.github.dataanon.support.MoviesTable
import io.kotlintest.specs.FunSpec
import org.awaitility.Awaitility.await
import java.sql.Date
import java.util.concurrent.TimeUnit
import java.util.regex.Pattern
import kotlin.test.assertEquals
import kotlin.test.assertTrue
Expand All @@ -27,7 +25,6 @@ class BlacklistMoviesSimplePrimaryKeyIntegrationTest : FunSpec() {
anonymize("GENRE")
}.execute(progressBarEnabled = false)

await().timeout(2, TimeUnit.SECONDS).until { moviesTable.findAll()[0]["TITLE"].toString().equals("MY VALUE") }
val records = moviesTable.findAll()

assertEquals(1,records.size)
Expand All @@ -49,7 +46,6 @@ class BlacklistMoviesSimplePrimaryKeyIntegrationTest : FunSpec() {
anonymize("GENRE")
}.execute(progressBarEnabled = false)

await().timeout(2, TimeUnit.SECONDS).until { moviesTable.findAll()[0]["TITLE"].toString().equals("MY VALUE") }
val records = moviesTable.findAll()

assertEquals(2,records.size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import com.github.dataanon.strategy.string.FixedString
import com.github.dataanon.support.MoviesTable
import com.github.dataanon.support.RatingsTable
import io.kotlintest.specs.FunSpec
import org.awaitility.Awaitility.await
import java.sql.Date
import java.sql.Timestamp
import java.util.concurrent.TimeUnit
import java.util.regex.Pattern
import kotlin.test.assertEquals
import kotlin.test.assertTrue
Expand All @@ -33,7 +31,6 @@ class BlacklistMultipleTableIntegrationTest : FunSpec() {
}
.execute(progressBarEnabled = false)

await().timeout(2, TimeUnit.SECONDS).until { moviesTable.findAll()[0]["TITLE"].toString().equals("MY VALUE") }
val moviesRecords = moviesTable.findAll()
val ratingRecords = ratingsTable.findAll()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import com.github.dataanon.model.DbConfig
import com.github.dataanon.strategy.number.FixedInt
import com.github.dataanon.support.RatingsTable
import io.kotlintest.specs.FunSpec
import org.awaitility.Awaitility.await
import java.sql.Timestamp
import java.util.concurrent.TimeUnit
import kotlin.test.assertEquals

class BlacklistRatingsCompositePrimaryKeyIntegrationTest : FunSpec() {
Expand All @@ -21,7 +19,6 @@ class BlacklistRatingsCompositePrimaryKeyIntegrationTest : FunSpec() {
anonymize("RATING").using(FixedInt(3))
}.execute(progressBarEnabled = false)

await().timeout(2, TimeUnit.SECONDS).until { ratingsTable.findAll()[0]["RATING"].toString().equals("3") }
val records = ratingsTable.findAll()

assertEquals(2,records.size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import com.github.dataanon.model.DbConfig
import com.github.dataanon.strategy.string.FixedString
import com.github.dataanon.support.MoviesTable
import io.kotlintest.specs.FunSpec
import org.awaitility.Awaitility.await
import java.sql.Date
import java.util.concurrent.TimeUnit
import java.util.regex.Pattern
import kotlin.test.assertEquals
import kotlin.test.assertTrue
Expand All @@ -31,7 +29,6 @@ class WhitelistMoviesSimplePrimaryKeyIntegrationTest : FunSpec() {
anonymize("RELEASE_DATE")
}.execute(progressBarEnabled = false)

await().timeout(2, TimeUnit.SECONDS).until { destTable.findAll()[0]["TITLE"].toString().equals("MY VALUE") }
val records = destTable.findAll()

assertEquals(2,records.size)
Expand Down

0 comments on commit 7bf4923

Please sign in to comment.