Junits are tested during the maven build as it need not to be connected to an instance while building. Adding to the same reason, we use stubbing [when().thenReturn()] to control the output of each method call.
The other way would be to use a dummy config which you have mentioned, you can create multiple dummy configs for dev, stage & prod and write test cases accordingly.
We had the issue that adobe changed the production version (without warning) of java to one with a known p1 bug which broke all http2 calls to our backend, and all our sites were down for 4 days. Adobes "answer" to this was that it was our fault they broke our environments because we didnt have tests for this. But now you are telling us, we cant call any actual services, we can only call mocks with no data, no proper configs or connections, which is pretty useless. We were hoping to have at lease one API call to our backend as part of the tests run by adobe. If we cant do this, then adobe will be risking causing us major downtime next time they "upgrade" prod without warning. If there is instance to test against, I would suggest tests are of little value.