Search in sources :

Example 1 with ServerChallengeModel

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);
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) ArrayList(java.util.ArrayList) ServerChallengeModel(org.wso2.identity.integration.test.rest.api.server.challenge.v1.model.ServerChallengeModel) Gson(com.google.gson.Gson) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 ArrayList (java.util.ArrayList)1 BeforeTest (org.testng.annotations.BeforeTest)1 Test (org.testng.annotations.Test)1 ServerChallengeModel (org.wso2.identity.integration.test.rest.api.server.challenge.v1.model.ServerChallengeModel)1