Skip to content

Conversation

@gigaSproule
Copy link
Contributor

Attempt at fixing issue #71

Copy link
Owner

@manub manub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @gigaSproule - there's only a couple of small things but it looks good and I'm looking to merge after those changes are addressed.


import scala.collection.JavaConverters._

class ConsumerOpsTest extends EmbeddedKafkaSpecSupport with MockitoSugar {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please rename this to ConsumerOpsSpec?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense

val consumer: KafkaConsumer[String, String] = mock[KafkaConsumer[String, String]]
val consumerRecords = new ConsumerRecords[String, String](mapAsJavaMap(Map.empty))

when(consumer.poll(1)).thenReturn(consumerRecords)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe extracting 1 with giving a meaningful value name would be better (here and in subsequent places)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

}

"not retry to get messages with the configured maximum number of attempts when poll succeeds" in {
val consumer: KafkaConsumer[String, String] = mock[KafkaConsumer[String, String]]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explicit types for in-test values are not necessarily needed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sorry, was having difficulties with mocking (was trying ScalaMock, but it wasn't having it)

Try {
import scala.collection.JavaConversions._
consumer.subscribe(List(topic))
import scala.collection.JavaConverters._
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this 👍

build.sbt Outdated
.settings(publishSettings: _*)
.settings(commonSettings: _*)
.settings(commonLibrarySettings)
.settings(libraryDependencies += "org.mockito" % "mockito-core" % "1.8.5" % Test)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a newer version of Mockito? 1.8.5 is quite old.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, yes, it really is!

@gigaSproule
Copy link
Contributor Author

As also mentioned in the issue, I'll fix the tests for Scala 2.11

@gigaSproule
Copy link
Contributor Author

seems like mapAsJavaMap was moved in 2.12, so rather than using the deprecated JavaConversions object, I've use asJava

@manub manub merged commit 8a5b928 into manub:master Mar 11, 2017
@manub
Copy link
Owner

manub commented Mar 11, 2017

Thanks @gigaSproule, will release in the next days.

@oliverlockwood
Copy link
Contributor

Hi @manub, is there any chance of a release including this change, please? It would be useful to me as well.

@manub
Copy link
Owner

manub commented Apr 25, 2017

Sorry, this completely slipped off my radar. Aiming to do this by the weekend.

@manub
Copy link
Owner

manub commented Apr 26, 2017

Released 0.13.0!

@oliverlockwood
Copy link
Contributor

Nice one @manub. I've updated my dependencies and this is working.

Apologies if this is deliberate on your part, but I noticed that https://github.com/manub/scalatest-embedded-kafka/releases has not been updated to mention the new release, and wondered if you had an issue with your automated release tagging. Hope that's useful to know!

@manub
Copy link
Owner

manub commented Apr 26, 2017

Actually that should have worked - I think something went wrong with the release process and I'm not aware of it. Thanks for pointing it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants