Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Unreleased

* Add getSuspendPostUri and getResumePostUri getters to HttpManagementPayload ([#264](https://github.com/microsoft/durabletask-java/pull/264))

## v1.7.0
* Add descriptive error when orchestration type is not registered ([#261](https://github.com/microsoft/durabletask-java/pull/261))
* Update all dependencies to latest versions ([#260](https://github.com/microsoft/durabletask-java/pull/260))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,22 @@ public String getRestartPostUri() {
return restartPostUri;
}

/**
* Gets the HTTP POST instance suspend endpoint.
*
* @return The HTTP URL for posting instance suspend commands.
*/
public String getSuspendPostUri() {
return this.suspendPostUri;
}

/**
* Gets the HTTP POST instance resume endpoint.
*
* @return The HTTP URL for posting instance resume commands.
*/
public String getResumePostUri() {
return this.resumePostUri;
}

}
6 changes: 6 additions & 0 deletions endtoendtests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ targetCompatibility = '1.8'

compileJava.options.encoding = 'UTF-8'

test {
useJUnitPlatform {
excludeTags 'e2e'
}
}

task endToEndTest(type: Test) {
useJUnitPlatform {
includeTags 'e2e'
Expand Down
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());
}
}
Loading