Skip to content

Commit

Permalink
fixing subscription failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
kmrdhruv committed May 18, 2024
1 parent 19a1363 commit 68bc1b3
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class SubscriptionHandlersTest extends WebTestBase {
SubscriptionHandlers subscriptionHandlers;
SubscriptionService subscriptionService;
ProjectService projectService;
TopicService<VaradhiTopic> topicService;

public static VaradhiSubscription getVaradhiSubscription(
String subscriptionName, Project project, VaradhiTopic topic
Expand Down Expand Up @@ -91,7 +92,7 @@ public void PreTest() throws InterruptedException {
super.setUp();
subscriptionService = mock(SubscriptionService.class);
projectService = mock(ProjectService.class);
TopicService<VaradhiTopic> topicService = mock(VaradhiTopicService.class);
topicService = mock(VaradhiTopicService.class);
subscriptionHandlers = new SubscriptionHandlers(subscriptionService, projectService, topicService);

Route routeCreate = router.post("/projects/:project/subscriptions").handler(bodyHandler).handler(ctx -> {
Expand Down Expand Up @@ -131,8 +132,10 @@ public void PostTest() throws InterruptedException {
void testSubscriptionCreate() throws InterruptedException {
HttpRequest<Buffer> request = createRequest(HttpMethod.POST, getSubscriptionsUrl(project));
SubscriptionResource resource = getSubscriptionResource("sub12", project, topicResource);
VaradhiTopic vTopic = VaradhiTopic.of(topicResource);
doReturn(vTopic).when(topicService).get(topicResource.getProject() + "." + topicResource.getName());

VaradhiSubscription subscription = getVaradhiSubscription("sub12", project, VaradhiTopic.of(topicResource));
VaradhiSubscription subscription = getVaradhiSubscription("sub12", project, vTopic);
when(subscriptionService.createSubscription(any())).thenReturn(subscription);
SubscriptionResource created = sendRequestWithBody(request, resource, SubscriptionResource.class);
assertEquals(
Expand Down Expand Up @@ -202,8 +205,10 @@ void testSubscriptionDelete() throws InterruptedException {
void testSubscriptionUpdate() throws InterruptedException {
HttpRequest<Buffer> request = createRequest(HttpMethod.PUT, getSubscriptionUrl("sub1", project));
SubscriptionResource resource = getSubscriptionResource("sub1", project, topicResource);
VaradhiTopic vTopic = VaradhiTopic.of(topicResource);
doReturn(vTopic).when(topicService).get(topicResource.getProject() + "." + topicResource.getName());

VaradhiSubscription subscription = getVaradhiSubscription("sub1", project, VaradhiTopic.of(topicResource));
VaradhiSubscription subscription = getVaradhiSubscription("sub1", project, vTopic);
ArgumentCaptor<VaradhiSubscription> captor = ArgumentCaptor.forClass(VaradhiSubscription.class);
when(subscriptionService.updateSubscription(captor.capture())).thenReturn(subscription);

Expand Down

0 comments on commit 68bc1b3

Please sign in to comment.