Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for @Wither in couchbase container (issues: #784) #810

Merged
merged 1 commit into from Jul 31, 2018
Merged

Fix for @Wither in couchbase container (issues: #784) #810

merged 1 commit into from Jul 31, 2018

Conversation

klara-l
Copy link
Contributor

@klara-l klara-l commented Jul 30, 2018

  • Replaced Wither annotation with own with methods
    These methods do not clone the instance and therefore do not default to
    the standard alpine:3.5 image

  • Added test to verify that the image name is not overridden by withXXX

  • Made CouchbaseContainer conforming to other modules' containers
    Replaced the extends mechanism by the project standard

Thanks to @RobNE for the contribution

@@ -50,49 +49,38 @@
* optimized by Tayeb Chlyah
*/
@AllArgsConstructor
public class CouchbaseContainer extends GenericContainer<CouchbaseContainer> {
public class CouchbaseContainer <SELF extends CouchbaseContainer<SELF>> extends GenericContainer<SELF> {
Copy link
Member

Choose a reason for hiding this comment

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

CouchbaseContainer is a final container and doesn't need SELF typing. Any good reason to add it back?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see why testcontainers should forbid subclassing the couchbase container. This gives a user the possiblity to add something they need.

Aside from a slightly more complex definition on the class line, this adds a lot of flexibility for adding new with methods without disallowing chaining at the configuration level.

Example:

MyCouchbaseContainer c = new MyCouchbaseContainer()
    .withClusterUsername("admin") // returns CouchbaseContainer
    .withRoles("role1", "role2"...) // implemented in MyCouchbaseContainer and cannot be chained from CouchbaseContainer
    .withClusterPassword("mops");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another reason is consistency. A lot of containers ins the modules project provide exactly the same style.

Copy link
Member

Choose a reason for hiding this comment

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

the problem is that some languages (ahem Kotlin ahem) really suck at handling such types :D

This is why we decided to use self-typing only on base classes and not the final ones (new modules have that)

Also, Testcontainers 2.0 will have a new, generic-less DSL

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So you suggest to revert that change?

And using return self(); is still okay?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, please.

return self() is okay :)

@bsideup bsideup added this to the next milestone Jul 31, 2018
  These methods do not clone the instance and therefore do not default to
  the standard alpine:3.5 image

- Added test to verify that the image name is not overridden by withXXX

- Made CouchbaseContainer conforming to other modules' containers
  Replaced the extends mechanism by the project standard
@bsideup bsideup merged commit 4d5a981 into testcontainers:master Jul 31, 2018
@bsideup
Copy link
Member

bsideup commented Jul 31, 2018

@Kaidowei merged, thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants