Skip to content

Commit

Permalink
udpated test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
tanya732 committed Nov 29, 2024
1 parent 81d3dc8 commit 4d13440
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/main/java/com/auth0/client/mgmt/PromptsEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ public Request<Prompt> getPrompt() {
}

/**
* Get the prompt.
* Update the prompt.
* A token with {@code update:prompts} scope is required.
* @param prompt the prompt to update.
* @return a Request to execute.
*
* @see <a href="https://auth0.com/docs/api/management/v2#!/prompts/patch-prompts">https://auth0.com/docs/api/management/v2#!/prompts/patch-prompts</a>
Expand Down
1 change: 1 addition & 0 deletions src/test/java/com/auth0/client/MockServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public class MockServer {
public static final String MGMT_RECOVERY_CODE = "src/test/resources/mgmt/recovery_code.json";
public static final String MGMT_IDENTITIES_LIST = "src/test/resources/mgmt/identities_list.json";
public static final String MGMT_PROMPT = "src/test/resources/mgmt/prompt.json";
public static final String MGMT_CUSTOM_TEXT_PROMPT = "src/test/resources/mgmt/custom_text_prompt.json";
public static final String MGMT_PARTIALS_PROMPT = "src/test/resources/mgmt/partials_prompt.json";
public static final String MGMT_GUARDIAN_AUTHENTICATION_POLICIES_LIST = "src/test/resources/mgmt/guardian_authentication_policies_list.json";
public static final String MGMT_GUARDIAN_ENROLLMENT = "src/test/resources/mgmt/guardian_enrollment.json";
Expand Down
12 changes: 8 additions & 4 deletions src/test/java/com/auth0/client/mgmt/PromptsEntityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import java.util.HashMap;
import java.util.Map;

import static com.auth0.client.MockServer.MGMT_PARTIALS_PROMPT;
import static com.auth0.client.MockServer.MGMT_PROMPT;
import static com.auth0.client.MockServer.*;
import static com.auth0.client.RecordedRequestMatcher.hasHeader;
import static com.auth0.client.RecordedRequestMatcher.hasMethodAndPath;
import static org.hamcrest.MatcherAssert.assertThat;
Expand Down Expand Up @@ -86,7 +85,7 @@ public void shouldGetCustomText() throws Exception {
Request<Object> request = api.prompts().getCustomText("login", "en");
assertThat(request, is(notNullValue()));

server.jsonResponse(MGMT_PARTIALS_PROMPT, 200);
server.jsonResponse(MGMT_CUSTOM_TEXT_PROMPT, 200);
Object response = request.execute().getBody();
RecordedRequest recordedRequest = server.takeRequest();

Expand Down Expand Up @@ -120,11 +119,16 @@ public void shouldThrowOnSetCustomTextWhenCustomTextIsNull() throws Exception {

@Test
public void shouldSetCustomText() throws Exception {
Map<String, String> signup = new HashMap<>();
signup.put("description", "Sign up to access amazing features for my login domain");

Map<String, Object> customText = new HashMap<>();
customText.put("signup", signup);

Request<Void> request = api.prompts().setCustomText("login", "en", customText);
assertThat(request, is(notNullValue()));

server.jsonResponse(MGMT_PARTIALS_PROMPT, 200);
server.jsonResponse(MGMT_CUSTOM_TEXT_PROMPT, 200);
request.execute();
RecordedRequest recordedRequest = server.takeRequest();

Expand Down
5 changes: 5 additions & 0 deletions src/test/resources/mgmt/custom_text_prompt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"signup": {
"description": "Sign up to access amazing features for my login domain"
}
}
3 changes: 0 additions & 3 deletions src/test/resources/mgmt/partials_prompt.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
{
"login": {
"description": "Login to ACME's Website"
}
}

0 comments on commit 4d13440

Please sign in to comment.