Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MetricsAdvisor] Made NotificationHook abstract #22345

Merged
merged 2 commits into from
Jul 1, 2021

Conversation

kinelski
Copy link
Member

@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 points to a problem in the data-plane of the library. 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
Member 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 tg-msft and KrzysztofCwalina 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
Member 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 points to a problem in the data-plane of the library. Cognitive - Metrics Advisor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants