So I break down my code a bit to make it more general and also easier for others to understand with the similar issue
this is my main code:
protected void methodA(String name) {
Invocation.Builder requestBuilder = webTarget.request();
requestBuilder.header(HttpHeaders.AUTHORIZATION, authent.getPassword());
response = request.invoke();
if (response.equals("unsuccessfull")) {
log.warn("warning blabla: {} ({})");
} else {
log.info("info blabla {}");
}
}
}
}
while my test code looks like this:
@Test
public void testMethodA() throws Exception {
final String name = "testName";
this.subject.methodA(name);
Authent authent = Mockito.mock(Authent.class);
when(authent.getPassword()).thenReturn("testPW");
assertEquals(1, logger.infos.size());
}
as I said the code is more complex I broke it down and made it shorter..... hope still it is readable.
My problem is not that my when().thenReturn()
doesn't work and therefore my code doesn't proceed further.... I guess my mocking doesn't work properly for some reason.