Commit 225a2eeb authored by Komal Makkar's avatar Komal Makkar
Browse files

minor changes

parent 4a9fa49a
Pipeline #21626 failed with stages
in 4 minutes
......@@ -50,7 +50,7 @@ public class EventGridRequestBodyExtractorTest {
public void should_returnTrue_isHandshakeRequest() throws IOException {
// Set up
String validHandshakeRequestRoot =
"[{\"id\":\"2d1781af-3a4c-4d7c-bd0c-e34b19da4e66\",\"topic\":\"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\",\"subject\":\"\",\"data\":{\"validationCode\":\"512d38b6-c7b8-40c8-89fe-f46f9e9622b6\",\"validationUrl\":\"https://rp-eastus2.eventgrid.azure.net:553/eventsubscriptions/estest/validate?id=512d38b6-c7b8-40c8-89fe-f46f9e9622b6&t=2018-04-26T20:30:54.4538837Z&apiVersion=2018-05-01-preview&token=1A1A1A1A\"},\"eventType\":\"Microsoft.EventGrid.SubscriptionValidationEvent\",\"eventTime\":\"2018-01-25T22:12:19.4556811Z\",\"metadataVersion\":\"1\",\"dataVersion\":\"1\"}]";
"[{\"id\":\"2d1781af-3a4c-4d7c-bd0c-e34b19da4e66\",\"topic\":\"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\",\"subject\":\"\",\"data\":{\"validationCode\":\"sample\",\"validationUrl\":\"https://rp-eastus2.eventgrid.azure.net:553/eventsubscriptions/estest/validate?id=sample&t=2018-04-26T20:30:54.4538837Z&apiVersion=2018-05-01-preview&token=1A1A1A1A\"},\"eventType\":\"Microsoft.EventGrid.SubscriptionValidationEvent\",\"eventTime\":\"2018-01-25T22:12:19.4556811Z\",\"metadataVersion\":\"1\",\"dataVersion\":\"1\"}]";
setServletRequest(validHandshakeRequestRoot);
// Act
......@@ -65,7 +65,7 @@ public class EventGridRequestBodyExtractorTest {
public void shouldThrow_whenRequestTypeIsNotright_isHandshakeRequest() throws IOException {
//SetUp
String invalidHandshakeRequestRoot =
"[{\"id\":\"2d1781af-3a4c-4d7c-bd0c-e34b19da4e66\",\"topic\":\"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\",\"subject\":\"\",\"data\":{\"validationCode\":\"512d38b6-c7b8-40c8-89fe-f46f9e9622b6\",\"validationUrl\":\"https://rp-eastus2.eventgrid.azure.net:553/eventsubscriptions/estest/validate?id=512d38b6-c7b8-40c8-89fe-f46f9e9622b6&t=2018-04-26T20:30:54.4538837Z&apiVersion=2018-05-01-preview&token=1A1A1A1A\"},\"eventType\":\"invalid\",\"eventTime\":\"2018-01-25T22:12:19.4556811Z\",\"metadataVersion\":\"1\",\"dataVersion\":\"1\"}]";
"[{\"id\":\"2d1781af-3a4c-4d7c-bd0c-e34b19da4e66\",\"topic\":\"/subscriptions\",\"subject\":\"\",\"data\":{\"validationCode\":\"sample\",\"validationUrl\":\"sample\"},\"eventType\":\"invalid\",\"eventTime\":\"sample\",\"metadataVersion\":\"1\",\"dataVersion\":\"1\"}]";
setServletRequest(invalidHandshakeRequestRoot);
try {
......@@ -85,10 +85,10 @@ public class EventGridRequestBodyExtractorTest {
@Test
public void should_throwWhenAttributesAreMissing_extractDataFromRequestBody() throws IOException {
String[] requestRootWithoutAttributes = {
"[{\"id\":\"32197ce0-3ee7-46e3-92a2-d2788d2b94d2\",\"subject\":\"RecordsChanged\",\"data\":{\"account-id\":\"opendes\",\"correlation-id\":\"c3718fb5-d60e-45bd-a2d3-48d3c2bdd7e7\",\"data-partition-id\":\"opendes\"},\"eventType\":\"RecordsChanged\",\"dataVersion\":\"1.0\",\"metadataVersion\":\"1\",\"eventTime\":\"2020-12-28T12:09:42.331Z\",\"topic\":\"fhtfc\"}]",
"[{\"id\":\"32197ce0-3ee7-46e3-92a2-d2788d2b94d2\",\"subject\":\"RecordsChanged\",\"data\":{\"data\":[{\"id\":\"opendes:doc:6a6f917dbab6479dad548d71515131c5\",\"kind\":\"opendes:at:wellbore:1.0.0\",\"op\":\"create\"},{\"id\":\"opendes:doc:6d6246ace0964b419cec6f32c05c21ae\",\"kind\":\"opendes:at:wellbore:1.0.0\",\"op\":\"create\"}],\"account-id\":\"opendes\",\"data-partition-id\":\"opendes\"},\"eventType\":\"RecordsChanged\",\"dataVersion\":\"1.0\",\"metadataVersion\":\"1\",\"eventTime\":\"2020-12-28T12:09:42.331Z\",\"topic\":\"fhtfc\"}]",
"[{\"id\":\"32197ce0-3ee7-46e3-92a2-d2788d2b94d2\",\"subject\":\"RecordsChanged\",\"data\":{\"data\":[{\"id\":\"opendes:doc:6a6f917dbab6479dad548d71515131c5\",\"kind\":\"opendes:at:wellbore:1.0.0\",\"op\":\"create\"},{\"id\":\"opendes:doc:6d6246ace0964b419cec6f32c05c21ae\",\"kind\":\"opendes:at:wellbore:1.0.0\",\"op\":\"create\"}],\"account-id\":\"opendes\",\"correlation-id\":\"c3718fb5-d60e-45bd-a2d3-48d3c2bdd7e7\"},\"eventType\":\"RecordsChanged\",\"dataVersion\":\"1.0\",\"metadataVersion\":\"1\",\"eventTime\":\"2020-12-28T12:09:42.331Z\",\"topic\":\"fhtfc\"}]",
"[{\"id\":\"32197ce0-3ee7-46e3-92a2-d2788d2b94d2\",\"subject\":\"RecordsChanged\",\"eventType\":\"RecordsChanged\",\"dataVersion\":\"1.0\",\"metadataVersion\":\"1\",\"eventTime\":\"2020-12-28T12:09:42.331Z\",\"topic\":\"fhtfc\"}]"
"[{\"id\":\"sampleid\",\"subject\":\"RecordsChanged\",\"data\":{\"account-id\":\"opendes\",\"correlation-id\":\"sample\",\"data-partition-id\":\"opendes\"},\"eventType\":\"RecordsChanged\",\"dataVersion\":\"1.0\",\"metadataVersion\":\"1\",\"eventTime\":\"sample\",\"topic\":\"fhtfc\"}]",
"[{\"id\":\"sampleid\",\"subject\":\"RecordsChanged\",\"data\":{\"data\":[{\"id\":\"opendes:doc:guid\",\"kind\":\"kimd\",\"op\":\"create\"},{\"id\":\"opendes:doc:\",\"kind\":\"kimd\",\"op\":\"create\"}],\"account-id\":\"opendes\",\"data-partition-id\":\"opendes\"},\"eventType\":\"RecordsChanged\",\"dataVersion\":\"1.0\",\"metadataVersion\":\"1\",\"eventTime\":\"sample\",\"topic\":\"fhtfc\"}]",
"[{\"id\":\"sampleid\",\"subject\":\"RecordsChanged\",\"data\":{\"data\":[{\"id\":\"opendes:doc:guid\",\"kind\":\"kimd\",\"op\":\"create\"},{\"id\":\"opendes:doc:\",\"kind\":\"kimd\",\"op\":\"create\"}],\"account-id\":\"opendes\",\"correlation-id\":\"sample\"},\"eventType\":\"RecordsChanged\",\"dataVersion\":\"1.0\",\"metadataVersion\":\"1\",\"eventTime\":\"sample\",\"topic\":\"fhtfc\"}]",
"[{\"id\":\"sampleid\",\"subject\":\"RecordsChanged\",\"eventType\":\"RecordsChanged\",\"dataVersion\":\"1.0\",\"metadataVersion\":\"1\",\"eventTime\":\"sample\",\"topic\":\"fhtfc\"}]"
};
for (String request : requestRootWithoutAttributes) {
setServletRequest(request);
......@@ -120,7 +120,7 @@ public class EventGridRequestBodyExtractorTest {
" \"validationUrl\": \"testURL\"\n" +
" },\n" +
" \"eventType\": \"Microsoft.EventGrid.SubscriptionValidationEvent\",\n" +
" \"eventTime\": \"2020-08-14T11:18:55.9278057Z\",\n" +
" \"eventTime\": \"sampletime\",\n" +
" \"metadataVersion\": \"1\",\n" +
" \"dataVersion\": \"2\"\n" +
" }]";
......@@ -140,7 +140,7 @@ public class EventGridRequestBodyExtractorTest {
public void should_throwWhenNotHandshakeRequest_getHandshakeResponse() throws IOException {
// Set up
String validHandshakeRequestRoot =
"[{\"id\":\"32197ce0-3ee7-46e3-92a2-d2788d2b94d2\",\"subject\":\"RecordsChanged\",\"data\":{\"data\":[{\"id\":\"opendes:doc:6a6f917dbab6479dad548d71515131c5\",\"kind\":\"opendes:at:wellbore:1.0.0\",\"op\":\"create\"},{\"id\":\"opendes:doc:6d6246ace0964b419cec6f32c05c21ae\",\"kind\":\"opendes:at:wellbore:1.0.0\",\"op\":\"create\"}],\"account-id\":\"opendes\",\"correlation-id\":\"c3718fb5-d60e-45bd-a2d3-48d3c2bdd7e7\",\"data-partition-id\":\"opendes\"},\"eventType\":\"RecordsChanged\",\"dataVersion\":\"1.0\",\"metadataVersion\":\"1\",\"eventTime\":\"2020-12-28T12:09:42.331Z\",\"topic\":\"fhtfc\"}]";
"[{\"id\":\"sampleid\",\"subject\":\"RecordsChanged\",\"data\":{\"data\":[{\"id\":\"opendes:doc:guid\",\"kind\":\"kimd\",\"op\":\"create\"},{\"id\":\"opendes:doc:\",\"kind\":\"kimd\",\"op\":\"create\"}],\"account-id\":\"opendes\",\"correlation-id\":\"sample\",\"data-partition-id\":\"opendes\"},\"eventType\":\"RecordsChanged\",\"dataVersion\":\"1.0\",\"metadataVersion\":\"1\",\"eventTime\":\"sample\",\"topic\":\"fhtfc\"}]";
String expectedResponse = null;
setServletRequest(validHandshakeRequestRoot);
......@@ -164,7 +164,7 @@ public class EventGridRequestBodyExtractorTest {
" \"validationUrl\": \"testURL\"\n" +
" },\n" +
" \"eventType\": \"Microsoft.EventGrid.SubscriptionValidationEvent\",\n" +
" \"eventTime\": \"2020-08-14T11:18:55.9278057Z\",\n" +
" \"eventTime\": \"sampletime\",\n" +
" \"metadataVersion\": \"1\",\n" +
" \"dataVersion\": \"2\"\n" +
" }]";
......@@ -180,7 +180,7 @@ public class EventGridRequestBodyExtractorTest {
@Test
public void should_returnNotificationId_extractNotificationIdFromRequestBody() throws IOException {
// Set Up
String validRequestRoot = "[{\"id\":\"32197ce0-3ee7-46e3-92a2-d2788d2b94d2\",\"subject\":\"RecordsChanged\",\"data\":{\"data\":[{\"id\":\"opendes:doc:6a6f917dbab6479dad548d71515131c5\",\"kind\":\"opendes:at:wellbore:1.0.0\",\"op\":\"create\"},{\"id\":\"opendes:doc:6d6246ace0964b419cec6f32c05c21ae\",\"kind\":\"opendes:at:wellbore:1.0.0\",\"op\":\"create\"}],\"account-id\":\"opendes\",\"correlation-id\":\"c3718fb5-d60e-45bd-a2d3-48d3c2bdd7e7\",\"data-partition-id\":\"opendes\"},\"eventType\":\"RecordsChanged\",\"dataVersion\":\"1.0\",\"metadataVersion\":\"1\",\"eventTime\":\"2020-12-28T12:09:42.331Z\",\"topic\":\"fhtfc\"}]";
String validRequestRoot = "[{\"id\":\"sampleid\",\"subject\":\"RecordsChanged\",\"data\":{\"data\":[{\"id\":\"opendes:doc:guid\",\"kind\":\"kimd\",\"op\":\"create\"},{\"id\":\"opendes:doc\",\"kind\":\"kimd\",\"op\":\"create\"}],\"account-id\":\"opendes\",\"correlation-id\":\"sample\",\"data-partition-id\":\"opendes\"},\"eventType\":\"RecordsChanged\",\"dataVersion\":\"1.0\",\"metadataVersion\":\"1\",\"eventTime\":\"sample\",\"topic\":\"fhtfc\"}]";
setServletRequest(validRequestRoot);
when(this.httpServletRequest.getHeader("Aeg-Subscription-Name")).thenReturn("NotificationId");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment