DEV Community

loading...

Discussion on: Why Java Interfaces Are Terrible

Collapse
goaty92 profile image
goaty92

If Database only needs to work with those two method then the Java way to do is to write an implementation class for DynamoImpl which is a wrapper of your production AmazonDynamoDB, but only exposes those two methods publicly.

Mockito is a good framework that will probably have most of the features you'd want. What are you trying to do specificly? In Mockito you can do things like "create a (mock) object that implement this interface, but when method A() is called return some fake data" or stuffs like that.

Thread Thread
forstmeier profile image
John Forstmeier Author

Yes, Database only needs those two methods (right now, if I expand it later, I can add those methods); ideally, I want to be able to hit the "put" and "get" methods within the Database class without actually touching the production DynamoDB (which it wouldn't be able to do from a local run anyway without additional configuration).