I have an application module that installs a DynamoDB module
install(new DynamoDBModule());
In DynamoDBModule we have some code to build the DynamoDb client and initialize the mapper
AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard()
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("http://prod-endpoint:8000", "us-west-2"))
.build();
Now, when I am writing tests, I have to replace this dynamoDB endpoint with a local endpoint and I was wondering what is the simplest way to do this. I am aware of this stackoverflow question, but it would mean writing a lot of code for just a single small change. I would have to create a mock dynamodb module, a mock application module and then I can run something like this in my tests
Guice.createInjector(Modules.override(new AppModule()).with(new TestAppModule()));
Is there a simple way to somehow use or override the test endpoint when running tests and continue using the prod endpoint otherwise.