use of org.wso2.identity.integration.test.rest.api.server.challenge.v1.model.ServerChallengeModel in project product-is by wso2.
the class ServerChallengeTestCase method addsNewChallengeQuestionSetTest.
/**
* The method is used to add new challenge question set.
*
* @throws JSONException thrown to indicate a problem with the JSON.
*/
@Test
public void addsNewChallengeQuestionSetTest() throws JSONException {
ServerChallengeModel.Questions question = new ServerChallengeModel.Questions(LOCALE, CHALLENGE_QUESTION, QUESTION_ID);
List<ServerChallengeModel.Questions> questions = new ArrayList<>();
questions.add(question);
List<ServerChallengeModel> serverChallenges = new ArrayList<>();
ServerChallengeModel serverChallengeRequest = new ServerChallengeModel(QUESTION_SET_ID, questions);
serverChallenges.add(serverChallengeRequest);
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String jsonRequrst = gson.toJson(serverChallenges);
given().auth().preemptive().basic(USER_NAME, PASSWORD).contentType(ContentType.JSON).header(HttpHeaders.ACCEPT, ContentType.JSON).body(jsonRequrst).log().ifValidationFails().when().post(RESOURCE_PATH).then().assertThat().statusCode(HttpStatus.SC_CREATED).log().ifValidationFails();
getsChallengeQuestionTest(QUESTION_SET_ID, CHALLENGE_QUESTION, QUESTION_ID);
}
Aggregations