As the title describes I would like to mock 3 getters of my class for testing purposes as the variables are only available when the program is in operation and a connection is established.
Using JUnit5 my BeforeEach setup:
@BeforeEach
void setUp() {
dataStore = new DataStore();
when(dataStore.getSecurityPrincipal()).thenReturn("CREDENTIALS");
when(dataStore.getSecurityCredentials()).thenReturn("CREDENTIALS");
when(dataStore.getProviderUrl()).thenReturn("CREDENTIALS");
}
But I want all the other methods of this class to remain the same, I thought about doing something like when(dataStore.getExample(anyString(), anyString())).thenCallRealMethod()
for each method but there are a lot of methods and that would mean a lot of extra lines of code. Is there a better way to achieve this?