Skip to content

[MetricsAdvisor] Made NotificationHook abstract#22345

Merged
kinelski merged 2 commits intoAzure:mainfrom
kinelski:ma-abstract
Jul 1, 2021
Merged

[MetricsAdvisor] Made NotificationHook abstract#22345
kinelski merged 2 commits intoAzure:mainfrom
kinelski:ma-abstract

Conversation

@kinelski
Copy link
Contributor

@kinelski kinelski commented Jun 30, 2021

Making NotificationHook abstract after architect feedback.

Similar changes are expected for MetricFeedback, DataFeedSource, and DataSourceCredentialEntity.

@kinelski kinelski added the Client This issue is related to a non-management package label Jun 30, 2021
@kinelski kinelski self-assigned this Jun 30, 2021
Comment on lines +91 to +96
public SubstringConstraint ContainsJsonString(string propertyName, string propertyValue) =>
Contains.Substring($"\"{propertyName}\":\"{propertyValue}\"");

// Currently only supports a single-element array.
public SubstringConstraint ContainsJsonStringArray(string propertyName, string elementValue) =>
Contains.Substring($"\"{propertyName}\":[\"{elementValue}\"]");
Copy link
Contributor Author

@kinelski kinelski Jun 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convenience methods to make Asserts prettier (examples in tests).

@kinelski kinelski marked this pull request as ready for review June 30, 2021 22:40
@kinelski kinelski requested review from maririos and removed request for KrzysztofCwalina and tg-msft June 30, 2021 22:40
MockRequest request = mockTransport.Requests.Last();
string content = ReadContent(request);

Assert.That(request.Uri.Path, Is.EqualTo($"/metricsadvisor/v1.0/hooks/{FakeGuid}"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you really need to validate the uri? I didn't see anything in your code that will modify this.
Also, consider making the version match the version the user sets in the client so you don't have to update this test every time you update the service version.

Copy link
Contributor Author

@kinelski kinelski Jul 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're checking that we could get and send back every NotificationHook property. We're doing it for the URI as well because that's the only way of validating the Id property (we don't send it as part of the JSON body).

You have a point about the version. I'll update the assertion to a Contains.Substring(FakeGuid) given that we just want to test if the ID is being sent correctly.

@kinelski kinelski merged commit 4d0e869 into Azure:main Jul 1, 2021
@kinelski kinelski deleted the ma-abstract branch July 1, 2021 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Client This issue is related to a non-management package Cognitive - Metrics Advisor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants