Skip to content

Commit 1a2fc77

Browse files
committed
initial commit
1 parent ebebbc9 commit 1a2fc77

File tree

3 files changed

+99
-0
lines changed

3 files changed

+99
-0
lines changed

azurefunctions/src/main/java/com/microsoft/durabletask/azurefunctions/HttpManagementPayload.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,22 @@ public String getRestartPostUri() {
9494
return restartPostUri;
9595
}
9696

97+
/**
98+
* Gets the HTTP POST instance suspend endpoint.
99+
*
100+
* @return The HTTP URL for posting instance suspend commands.
101+
*/
102+
public String getSuspendPostUri() {
103+
return this.suspendPostUri;
104+
}
105+
106+
/**
107+
* Gets the HTTP POST instance resume endpoint.
108+
*
109+
* @return The HTTP URL for posting instance resume commands.
110+
*/
111+
public String getResumePostUri() {
112+
return this.resumePostUri;
113+
}
114+
97115
}

endtoendtests/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ targetCompatibility = '1.8'
3232

3333
compileJava.options.encoding = 'UTF-8'
3434

35+
test {
36+
useJUnitPlatform()
37+
}
38+
3539
task endToEndTest(type: Test) {
3640
useJUnitPlatform {
3741
includeTags 'e2e'
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package com.functions;
2+
3+
import com.microsoft.durabletask.azurefunctions.HttpManagementPayload;
4+
import org.junit.jupiter.api.DisplayName;
5+
import org.junit.jupiter.api.Test;
6+
7+
import static org.junit.jupiter.api.Assertions.*;
8+
9+
/**
10+
* Unit tests for {@link HttpManagementPayload}.
11+
*/
12+
public class HttpManagementPayloadTest {
13+
14+
private static final String INSTANCE_ID = "test-instance-id";
15+
private static final String INSTANCE_STATUS_URL = "http://localhost:7071/runtime/webhooks/durabletask/instances/test-instance-id";
16+
private static final String QUERY_STRING = "code=abc123";
17+
18+
private HttpManagementPayload createPayload() {
19+
return new HttpManagementPayload(INSTANCE_ID, INSTANCE_STATUS_URL, QUERY_STRING);
20+
}
21+
22+
@Test
23+
@DisplayName("getId should return the instance ID")
24+
public void getId_ReturnsInstanceId() {
25+
HttpManagementPayload payload = createPayload();
26+
assertEquals(INSTANCE_ID, payload.getId());
27+
}
28+
29+
@Test
30+
@DisplayName("getStatusQueryGetUri should return correct URL")
31+
public void getStatusQueryGetUri_ReturnsCorrectUrl() {
32+
HttpManagementPayload payload = createPayload();
33+
assertEquals(INSTANCE_STATUS_URL + "?" + QUERY_STRING, payload.getStatusQueryGetUri());
34+
}
35+
36+
@Test
37+
@DisplayName("getSendEventPostUri should return correct URL")
38+
public void getSendEventPostUri_ReturnsCorrectUrl() {
39+
HttpManagementPayload payload = createPayload();
40+
assertEquals(INSTANCE_STATUS_URL + "/raiseEvent/{eventName}?" + QUERY_STRING, payload.getSendEventPostUri());
41+
}
42+
43+
@Test
44+
@DisplayName("getTerminatePostUri should return correct URL")
45+
public void getTerminatePostUri_ReturnsCorrectUrl() {
46+
HttpManagementPayload payload = createPayload();
47+
assertEquals(INSTANCE_STATUS_URL + "/terminate?reason={text}&" + QUERY_STRING, payload.getTerminatePostUri());
48+
}
49+
50+
@Test
51+
@DisplayName("getPurgeHistoryDeleteUri should return correct URL")
52+
public void getPurgeHistoryDeleteUri_ReturnsCorrectUrl() {
53+
HttpManagementPayload payload = createPayload();
54+
assertEquals(INSTANCE_STATUS_URL + "?" + QUERY_STRING, payload.getPurgeHistoryDeleteUri());
55+
}
56+
57+
@Test
58+
@DisplayName("getRestartPostUri should return correct URL")
59+
public void getRestartPostUri_ReturnsCorrectUrl() {
60+
HttpManagementPayload payload = createPayload();
61+
assertEquals(INSTANCE_STATUS_URL + "/restart?" + QUERY_STRING, payload.getRestartPostUri());
62+
}
63+
64+
@Test
65+
@DisplayName("getSuspendPostUri should return correct URL")
66+
public void getSuspendPostUri_ReturnsCorrectUrl() {
67+
HttpManagementPayload payload = createPayload();
68+
assertEquals(INSTANCE_STATUS_URL + "/suspend?reason={text}&" + QUERY_STRING, payload.getSuspendPostUri());
69+
}
70+
71+
@Test
72+
@DisplayName("getResumePostUri should return correct URL")
73+
public void getResumePostUri_ReturnsCorrectUrl() {
74+
HttpManagementPayload payload = createPayload();
75+
assertEquals(INSTANCE_STATUS_URL + "/resume?reason={text}&" + QUERY_STRING, payload.getResumePostUri());
76+
}
77+
}

0 commit comments

Comments
 (0)