-
Notifications
You must be signed in to change notification settings - Fork 15
Add getSuspendPostUri and getResumePostUri getters to HttpManagementPayload #264
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| package com.functions; | ||
|
|
||
| import com.microsoft.durabletask.azurefunctions.HttpManagementPayload; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.*; | ||
|
|
||
| /** | ||
| * Unit tests for {@link HttpManagementPayload}. | ||
| */ | ||
| public class HttpManagementPayloadTest { | ||
|
|
||
| private static final String INSTANCE_ID = "test-instance-id"; | ||
| private static final String INSTANCE_STATUS_URL = "http://localhost:7071/runtime/webhooks/durabletask/instances/test-instance-id"; | ||
| private static final String QUERY_STRING = "code=abc123"; | ||
|
|
||
| private HttpManagementPayload createPayload() { | ||
| return new HttpManagementPayload(INSTANCE_ID, INSTANCE_STATUS_URL, QUERY_STRING); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("getId should return the instance ID") | ||
| public void getId_ReturnsInstanceId() { | ||
| HttpManagementPayload payload = createPayload(); | ||
| assertEquals(INSTANCE_ID, payload.getId()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("getStatusQueryGetUri should return correct URL") | ||
| public void getStatusQueryGetUri_ReturnsCorrectUrl() { | ||
| HttpManagementPayload payload = createPayload(); | ||
| assertEquals(INSTANCE_STATUS_URL + "?" + QUERY_STRING, payload.getStatusQueryGetUri()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("getSendEventPostUri should return correct URL") | ||
| public void getSendEventPostUri_ReturnsCorrectUrl() { | ||
| HttpManagementPayload payload = createPayload(); | ||
| assertEquals(INSTANCE_STATUS_URL + "/raiseEvent/{eventName}?" + QUERY_STRING, payload.getSendEventPostUri()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("getTerminatePostUri should return correct URL") | ||
| public void getTerminatePostUri_ReturnsCorrectUrl() { | ||
| HttpManagementPayload payload = createPayload(); | ||
| assertEquals(INSTANCE_STATUS_URL + "/terminate?reason={text}&" + QUERY_STRING, payload.getTerminatePostUri()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("getPurgeHistoryDeleteUri should return correct URL") | ||
| public void getPurgeHistoryDeleteUri_ReturnsCorrectUrl() { | ||
| HttpManagementPayload payload = createPayload(); | ||
| assertEquals(INSTANCE_STATUS_URL + "?" + QUERY_STRING, payload.getPurgeHistoryDeleteUri()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("getRestartPostUri should return correct URL") | ||
| public void getRestartPostUri_ReturnsCorrectUrl() { | ||
| HttpManagementPayload payload = createPayload(); | ||
| assertEquals(INSTANCE_STATUS_URL + "/restart?" + QUERY_STRING, payload.getRestartPostUri()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("getSuspendPostUri should return correct URL") | ||
| public void getSuspendPostUri_ReturnsCorrectUrl() { | ||
| HttpManagementPayload payload = createPayload(); | ||
| assertEquals(INSTANCE_STATUS_URL + "/suspend?reason={text}&" + QUERY_STRING, payload.getSuspendPostUri()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("getResumePostUri should return correct URL") | ||
| public void getResumePostUri_ReturnsCorrectUrl() { | ||
| HttpManagementPayload payload = createPayload(); | ||
| assertEquals(INSTANCE_STATUS_URL + "/resume?reason={text}&" + QUERY_STRING, payload.getResumePostUri()); | ||
| } | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [F2] Missing getRewindPostUri test (Low / P3) -- This test class covers 8 of the 9 getters but is missing getRewindPostUri(). Adding it would complete full coverage. Suggested test: assertEquals(INSTANCE_STATUS_URL + /rewind?reason={text}& + QUERY_STRING, payload.getRewindPostUri()); |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[F1] Unit tests placed in wrong module (Medium / P2)
HttpManagementPayload belongs to the azurefunctions module, but this test file is in endtoendtests. Since these are pure unit tests (no Functions host, no external dependencies), they should live in azurefunctions/src/test/java/com/microsoft/durabletask/azurefunctions/HttpManagementPayloadTest.java with package com.microsoft.durabletask.azurefunctions.
Consequences of current placement:
Suggestion: Move this file to azurefunctions/src/test/ and revert the endtoendtests/build.gradle change.