Skip to content
Snippets Groups Projects
Commit 679199bd authored by Nikhil Singh[MicroSoft]'s avatar Nikhil Singh[MicroSoft]
Browse files

Commit 21 Contents:

1- Uts Continued
parent 0d0b59ea
No related branches found
No related tags found
2 merge requests!102Locking down maven central,!97Service Bus Create and Delete Support for Subscriptions
Pipeline #55113 failed
......@@ -70,6 +70,7 @@ public class PullSubscriptionTest {
verify(serviceBusManager, times(1)).createSubscription(topicName, subscriptionId);
verify(logger, times(1)).debug(String.format("Pull Subscription with id %s created successfully", subscriptionId));
}
@Test
public void shouldReturn500WhenPullSubscriptionCreationFailed() throws Exception {
lenient().when(factory.getManager()).thenReturn(serviceBusManager);
......@@ -84,6 +85,7 @@ public class PullSubscriptionTest {
verify(factory, times(1)).getManager();
verify(serviceBusManager, times(1)).createSubscription(topicName, subscriptionId);
}
@Test
public void shouldDeletePullSubscription() throws Exception {
lenient().when(factory.getManager()).thenReturn(serviceBusManager);
......@@ -111,4 +113,51 @@ public class PullSubscriptionTest {
verify(factory, times(1)).getManager();
verify(serviceBusManager, times(1)).deleteSubscription(topicName, subscriptionId);
}
@Test
public void shouldThrow500ExceptionWhenDeletingPullSubscription() throws ServiceBusException, InterruptedException {
lenient().when(factory.getManager()).thenReturn(serviceBusManager);
when(serviceBusManager.deleteSubscription(topicName, subscriptionId)).thenThrow(new ServiceBusException(true, SERVICE_BUS_ERROR_MESSAGE));
AppException exception = assertThrows(AppException.class, () -> {
pullSubscription.deleteSubscription(subscriptionId, topicName);
});
assertNotNull(exception);
assertEquals(500, exception.getError().getCode());
assertEquals("Server Error", exception.getError().getReason());
assertEquals("Unexpected error deleting Pull subscription", exception.getError().getMessage());
verify(factory, times(1)).getManager();
verify(serviceBusManager, times(1)).deleteSubscription(topicName, subscriptionId);
verify(logger, times(1)).error("Deleting Pull Subscription failed with error: " + new ServiceBusException(true, SERVICE_BUS_ERROR_MESSAGE).toString());
}
@Test
public void shouldThrow500NullPointerExceptionWhenDeletingPullSubscription() throws ServiceBusException, InterruptedException {
lenient().when(factory.getManager()).thenThrow(new AppException(500, "Null Pointer Exception", MANAGEMENT_CLIENT_ERROR_MESSAGE));
AppException exception = assertThrows(AppException.class, () -> {
pullSubscription.deleteSubscription(subscriptionId, topicName);
});
assertNotNull(exception);
assertEquals(500, exception.getError().getCode());
assertEquals("Null Pointer Exception", exception.getError().getReason());
assertEquals(MANAGEMENT_CLIENT_ERROR_MESSAGE, exception.getError().getMessage());
verify(factory, times(1)).getManager();
verify(serviceBusManager, times(0)).deleteSubscription(topicName, subscriptionId);
}
@Test
public void shouldGetPullSubscription() throws ServiceBusException, InterruptedException {
lenient().when(factory.getManager()).thenReturn(serviceBusManager);
SubscriptionDescription subscriptionDescription = new SubscriptionDescription(topicName, subscriptionId);
when(serviceBusManager.getSubscription(topicName, subscriptionId)).thenReturn(subscriptionDescription);
pullSubscription.checkIfSubscriptionExists(subscriptionId, topicName);
verify(factory, times(1)).getManager();
verify(serviceBusManager, times(1)).getSubscription(topicName, subscriptionId);
verify(logger, times(1)).debug(String.format("Pull Subscription with id %s fetched successfully", subscriptionId));
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment