@Test
public void testSendWebhook() throws KafkaConsumerException {
PodamFactory factory = new PodamFactoryImpl();
WebhookEventDTO<MeetingEventPayload> webhookEventDTO = factory.manufacturePojo(WebhookEventDTO.class, MeetingEventPayload.class);
Mockito.when(u2CBizService.getWebhookFeatureToggleEndpoint(any(), any(), eq("webhook-engine"), any())).thenReturn("https://www.ciscospark.com/v1");
Mockito.doNothing().when(webhookFeignClient).sendWebhookEvent(any(), any(), any());
webhookRemoteService.sendWebhook(webhookEventDTO, "trackingId");
Mockito.verify(webhookFeignClient, Mockito.times(1)).sendWebhookEvent(any(), any(), any());
}
When I run this method directly in IntelliJ IDEA, it works fine. However, when I run it through Maven test, it fails, showing the following error:
[ERROR] WebinarFeignServiceTest.testHeaderInterceptor:44 » UnfinishedStubbing
Unfinished stubbing detected here:
-> at com.cisco.webex.notificationservice.remote.webhook.WebhookRemoteServiceTest.testSendWebhook(WebhookRemoteServiceTest.java:45)
E.g. thenReturn() may be missing.
Examples of correct stubbing:
when(mock.isOk()).thenReturn(true);
when(mock.isOk()).thenThrow(exception);
doThrow(exception).when(mock).someVoidMethod();
Hints:
1. missing thenReturn()
2. you are trying to stub a final method, which is not supported
3. you are stubbing the behaviour of another mock inside before 'thenReturn' instruction is completed
here part of pom
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.7.1</version>
<scope>test</scope>
</dependency>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<trimStackTrace>false</trimStackTrace>
<includes>
<include>**/*Test.java</include>
<include>**/*Tests.java</include>
</includes>
<useUnlimitedThreads>true</useUnlimitedThreads>
<reportFormat>plain</reportFormat>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
I don’t have any idea to this failure.
New contributor
user22990582 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.