diff options
author | Vlad Uspensky <v.uspenskiy@icloud.com> | 2017-04-13 10:22:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-13 10:22:34 -0700 |
commit | e53941b339c08269c40b0f2bb9eb123917a2f971 (patch) | |
tree | 1c88759d0cd63e5009d3173f695011c447a2e500 /src/test/scala/xyz/driver | |
parent | 24596a3a6f27c53f6c2de844c0f89a9194adb8fb (diff) | |
parent | 2d0aba0eaf360c521d9bcfbf48dc748b777301d2 (diff) | |
download | driver-core-0.12.0.tar.gz driver-core-0.12.0.tar.bz2 driver-core-0.12.0.zip |
Merge pull request #33 from drivergroup/PDW-598v0.12.0
PDW-598 Getting rid of log wrapper
Diffstat (limited to 'src/test/scala/xyz/driver')
-rw-r--r-- | src/test/scala/xyz/driver/core/AuthTest.scala | 2 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/core/MessagesTest.scala | 32 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/core/StatsTest.scala | 43 |
3 files changed, 8 insertions, 69 deletions
diff --git a/src/test/scala/xyz/driver/core/AuthTest.scala b/src/test/scala/xyz/driver/core/AuthTest.scala index d1a37a2..ad8cec8 100644 --- a/src/test/scala/xyz/driver/core/AuthTest.scala +++ b/src/test/scala/xyz/driver/core/AuthTest.scala @@ -8,7 +8,7 @@ import akka.http.scaladsl.testkit.ScalatestRouteTest import org.scalatest.mock.MockitoSugar import org.scalatest.{FlatSpec, Matchers} import xyz.driver.core.auth._ -import xyz.driver.core.logging.NoLogger +import xyz.driver.core.logging._ import xyz.driver.core.rest.{AuthProvider, Authorization, ServiceRequestContext} import scala.concurrent.Future diff --git a/src/test/scala/xyz/driver/core/MessagesTest.scala b/src/test/scala/xyz/driver/core/MessagesTest.scala index 5558156..abc4035 100644 --- a/src/test/scala/xyz/driver/core/MessagesTest.scala +++ b/src/test/scala/xyz/driver/core/MessagesTest.scala @@ -3,11 +3,10 @@ package xyz.driver.core import java.util.Locale import com.typesafe.config.{ConfigException, ConfigFactory} -import org.mockito.Mockito._ import org.scalatest.mock.MockitoSugar import org.scalatest.{FlatSpec, Matchers} -import xyz.driver.core.logging.Logger import xyz.driver.core.messages.Messages +import xyz.driver.core.logging.NoLogger import scala.collection.JavaConversions._ @@ -18,10 +17,9 @@ class MessagesTest extends FlatSpec with Matchers with MockitoSugar { "Messages" should "read messages from config and format with parameters" in { - val log = mock[Logger] val messagesConfig = ConfigFactory.parseMap(englishLocaleMessages) - val messages = Messages.messages(messagesConfig, log, Locale.US) + val messages = Messages.messages(messagesConfig, NoLogger, Locale.US) messages("hello") should be("Hello world!") messages("greeting", "Homer") should be("Hello Homer!") @@ -30,8 +28,6 @@ class MessagesTest extends FlatSpec with Matchers with MockitoSugar { it should "be able to read messages for different locales" in { - val log = mock[Logger] - val messagesConfig = ConfigFactory.parseMap( englishLocaleMessages ++ Map( "zh.hello" -> "你好,世界!", @@ -39,9 +35,9 @@ class MessagesTest extends FlatSpec with Matchers with MockitoSugar { "zh.greetingFullName" -> "你好,{0} {1} {2}!" )) - val englishMessages = Messages.messages(messagesConfig, log, Locale.US) - val englishMessagesToo = Messages.messages(messagesConfig, log, Locale.ENGLISH) - val chineseMessages = Messages.messages(messagesConfig, log, Locale.CHINESE) + val englishMessages = Messages.messages(messagesConfig, NoLogger, Locale.US) + val englishMessagesToo = Messages.messages(messagesConfig, NoLogger, Locale.ENGLISH) + val chineseMessages = Messages.messages(messagesConfig, NoLogger, Locale.CHINESE) englishMessages("hello") should be("Hello world!") englishMessages("greeting", "Homer") should be("Hello Homer!") @@ -59,27 +55,13 @@ class MessagesTest extends FlatSpec with Matchers with MockitoSugar { it should "raise exception when locale is not available" in { - val log = mock[Logger] val messagesConfig = ConfigFactory.parseMap(englishLocaleMessages) an[ConfigException.Missing] should be thrownBy - Messages.messages(messagesConfig, log, Locale.GERMAN) - } - - it should "log a problem, when there is no message for key" in { - - val log = mock[Logger] - val messagesConfig = ConfigFactory.parseMap(englishLocaleMessages) - - val messages = Messages.messages(messagesConfig, log, Locale.US) - - messages("howdy") should be("howdy") - - verify(log).error(s"Message with key 'howdy' not found for locale 'en'") + Messages.messages(messagesConfig, NoLogger, Locale.GERMAN) } it should "be able to read nested keys in multiple forms" in { - val log = mock[Logger] val configString = """ @@ -95,7 +77,7 @@ class MessagesTest extends FlatSpec with Matchers with MockitoSugar { val messagesConfig = ConfigFactory.parseString(configString) - val messages = Messages.messages(messagesConfig, log, Locale.US) + val messages = Messages.messages(messagesConfig, NoLogger, Locale.US) messages("foo.bar") should be("Foo Bar") messages("baz.boo") should be("Baz Boo") diff --git a/src/test/scala/xyz/driver/core/StatsTest.scala b/src/test/scala/xyz/driver/core/StatsTest.scala deleted file mode 100644 index 27ea1bd..0000000 --- a/src/test/scala/xyz/driver/core/StatsTest.scala +++ /dev/null @@ -1,43 +0,0 @@ -package xyz.driver.core - -import org.mockito.Mockito._ -import org.scalatest.mock.MockitoSugar -import org.scalatest.{FlatSpec, Matchers} -import xyz.driver.core.logging.Logger -import xyz.driver.core.stats.LogStats -import xyz.driver.core.time.{Time, TimeRange} - -class StatsTest extends FlatSpec with Matchers with MockitoSugar { - - "Stats" should "format and store all recorded data" in { - - val log = mock[Logger] - val stats = new LogStats(log) - - stats.recordStats(Seq(), TimeRange(Time(2L), Time(5L)), BigDecimal(123.324)) - verify(log).audit(s"(2-5)=123.324") - - stats.recordStats("stat", TimeRange(Time(5L), Time(5L)), BigDecimal(333L)) - verify(log).audit(s"stat(5-5)=333") - - stats.recordStats("stat", Time(934L), 123) - verify(log).audit(s"stat(934-934)=123") - - stats.recordStats("stat", Time(0L), 123) - verify(log).audit(s"stat(0-0)=123") - } - - it should "format BigDecimal with all precision digits" in { - - val log = mock[Logger] - val stats = new LogStats(log) - - stats.recordStats(Seq("root", "group", "stat", "substat"), - TimeRange(Time(1467381889834L), Time(1468937089834L)), - BigDecimal(3.333333333333333)) - verify(log).audit(s"root.group.stat.substat(1467381889834-1468937089834)=3.333333333333333") - - stats.recordStats("stat", Time(1233L), BigDecimal(0.00000000000000000000001)) - verify(log).audit(s"stat(1233-1233)=0.000000000000000000000010") - } -} |