Skip to content
Snippets Groups Projects
Commit bee69b7c authored by Nikhil Singh[MicroSoft]'s avatar Nikhil Singh[MicroSoft] Committed by Komal Makkar
Browse files

Update Test Ack Flow

parent 0d94ff18
No related branches found
No related tags found
1 merge request!114Update Test Ack Flow
......@@ -16,7 +16,6 @@ package org.opengroup.osdu.register.provider.azure.subscriber;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.register.provider.interfaces.subscriber.ISubscriptionRepository;
import org.opengroup.osdu.register.provider.interfaces.subscriber.ITestSubscription;
import org.opengroup.osdu.register.subscriber.model.HmacSecret;
import org.opengroup.osdu.register.subscriber.model.Subscription;
......@@ -29,7 +28,7 @@ import org.springframework.stereotype.Component;
public class TestSubscriptionAzure implements ITestSubscription {
private final static String INTEGRATION_TEST_CORRELATION_ID = "storage-notification-it";
@Autowired
private ISubscriptionRepository subscriptionRepository;
private CosmosSubscription cosmosSubscription;
@Autowired
private JaxRsDpsLog logger;
@Autowired
......@@ -50,7 +49,7 @@ public class TestSubscriptionAzure implements ITestSubscription {
HmacSecret secret = new HmacSecret();
secret.setValue("TestAcknowledgementSubscription");
subscription.setSecret(secret);
subscription = subscriptionRepository.create(subscription);
subscription = cosmosSubscription.createSubscription(subscription);
logger.debug("Successfully created Acknowledgement Subscription");
}
}
......
......@@ -21,12 +21,9 @@ import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.register.provider.interfaces.subscriber.ISubscriptionRepository;
import org.opengroup.osdu.register.subscriber.model.HmacSecret;
import org.opengroup.osdu.register.subscriber.model.Subscription;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.*;
@ExtendWith(MockitoExtension.class)
......@@ -34,7 +31,7 @@ public class TestSubscriptionAzureTest {
private final static String INTEGRATION_TEST_CORRELATION_ID = "storage-notification-it";
@Mock
private ISubscriptionRepository subscriptionRepository;
private CosmosSubscription cosmosSubscription;
@Mock
private JaxRsDpsLog logger;
@Mock
......@@ -45,26 +42,12 @@ public class TestSubscriptionAzureTest {
@Test
public void shouldCreateTestAcknowledgementSubscription() throws Exception {
when(dpsHeaders.getCorrelationId()).thenReturn(INTEGRATION_TEST_CORRELATION_ID);
when(subscriptionRepository.create(getSubscription())).thenReturn(getSubscription());
when(cosmosSubscription.createSubscription(getSubscription())).thenReturn(getSubscription());
sut.performTestAcknowledgement();
verify(logger, times(1)).debug("Successfully created Acknowledgement Subscription");
verify(subscriptionRepository, times(1)).create(getSubscription());
}
@Test
public void shouldThrowExceptionWhenSubscriptionCreationFailed() throws Exception {
when(dpsHeaders.getCorrelationId()).thenReturn(INTEGRATION_TEST_CORRELATION_ID);
when(subscriptionRepository.create(getSubscription())).thenThrow(new Exception());
Exception exception = assertThrows(Exception.class, () -> {
sut.performTestAcknowledgement();
});
assertNotNull(exception);
verify(logger, times(0)).debug("Successfully created Acknowledgement Subscription");
verify(subscriptionRepository, times(1)).create(getSubscription());
verify(cosmosSubscription, times(1)).createSubscription(getSubscription());
}
@Test
......@@ -74,7 +57,7 @@ public class TestSubscriptionAzureTest {
sut.performTestAcknowledgement();
verify(logger, times(0)).debug("Successfully created Acknowledgement Subscription");
verify(subscriptionRepository, times(0)).create(getSubscription());
verify(cosmosSubscription, times(0)).createSubscription(getSubscription());
}
private Subscription getSubscription() {
......
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