Skip to content

Commit

Permalink
Merge pull request #153 from project-sunbird/report_viewer
Browse files Browse the repository at this point in the history
Report viewer
  • Loading branch information
amolnin authored Feb 21, 2019
2 parents 387b07a + 0d9d9c2 commit 3c8eed3
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package org.sunbird.integration.test.user;

import com.consol.citrus.annotations.CitrusTest;
import com.consol.citrus.testng.CitrusParameters;
import org.springframework.http.HttpStatus;
import org.sunbird.integration.test.common.BaseCitrusTestRunner;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

public class ReadUserTypeTest extends BaseCitrusTestRunner {

public static final String TEST_READ_USER_TYPE_FAILURE_WITHOUT_ACCESS_TOKEN =
"testReadUserTypeFailureWithoutAccessToken";

public static final String TEST_READ_USER_TYPE_SUCCESS_WITH_ACCESS_TOKEN =
"testReadUserTypeSuccessWithAccessToken";

public static final String TEMPLATE_DIR = "templates/user/type/read";

private String getReadUserTypeUrl() {
return getLmsApiUriPath("/api/user/v1/type/list", "/v1/user/type/list");
}

@DataProvider(name = "readUserTypeFailureDataProvider")
public Object[][] readUserTypeFailureDataProvider() {

return new Object[][] {
new Object[] {
TEST_READ_USER_TYPE_FAILURE_WITHOUT_ACCESS_TOKEN, false, HttpStatus.UNAUTHORIZED
}
};
}

@DataProvider(name = "readUserTypeSuccessDataProvider")
public Object[][] readUserTypeSuccessDataProvider() {
return new Object[][] {
new Object[] {TEST_READ_USER_TYPE_SUCCESS_WITH_ACCESS_TOKEN, true, HttpStatus.OK},
};
}

@Test(dataProvider = "readUserTypeFailureDataProvider")
@CitrusParameters({"testName", "isAuthRequired", "httpStatusCode"})
@CitrusTest
public void testReadUserTypeFailure(
String testName, boolean isAuthRequired, HttpStatus httpStatusCode) {
getTestCase().setName(testName);
getAuthToken(this, isAuthRequired);
performGetTest(
this,
TEMPLATE_DIR,
testName,
getReadUserTypeUrl(),
isAuthRequired,
httpStatusCode,
RESPONSE_JSON);
}

@Test(dataProvider = "readUserTypeSuccessDataProvider")
@CitrusParameters({"testName", "isAuthRequired", "httpStatusCode"})
@CitrusTest
public void testReadUserTypeSuccess(
String testName, boolean isAuthRequired, HttpStatus httpStatusCode) {
getTestCase().setName(testName);
getAuthToken(this, isAuthRequired);
performGetTest(
this,
TEMPLATE_DIR,
testName,
getReadUserTypeUrl(),
isAuthRequired,
httpStatusCode,
RESPONSE_JSON);
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"id": "api.role.read",
"ver": "v1",
"ts": "@ignore@",
"params": {
"resmsgid": null,
"msgid": "@ignore@",
"err": null,
"status": "success",
"errmsg": null
},
"responseCode": "OK",
"id": "api.role.read",
"ver": "v1",
"ts": "@ignore@",
"params": {
"resmsgid": null,
"msgid": "@ignore@",
"err": null,
"status": "success",
"errmsg": null
},
"responseCode": "OK",
"result": {
"roles": [
{
Expand Down Expand Up @@ -158,18 +158,7 @@
],
"name": "Flag Reviewer",
"id": "FLAG_REVIEWER"
},
{
"actionGroups": [
{
"name": "Report Viewer",
"id": "REPORT_VIEWER",
"actions": []
}
],
"name": "Report Viewer",
"id": "REPORT_VIEWER"
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"id": "api.user.type.list",
"ver": "v1",
"ts": "@ignore@",
"params": {
"resmsgid": null,
"msgid": "@ignore@",
"err": "UNAUTHORIZED_USER",
"status": "SERVER_ERROR",
"errmsg": "You are not authorized."
},
"responseCode": "CLIENT_ERROR",
"result": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"id": "api.user.type.list",
"ver": "v1",
"ts": "@ignore@",
"params": {
"resmsgid": null,
"msgid": "@ignore@",
"err": null,
"status": "success",
"errmsg": null
},
"responseCode": "OK",
"result": {
"response": [
{
"name": "TEACHER",
"id": "TEACHER"
},
{
"name": "OTHER",
"id": "OTHER"
}
]
}
}

0 comments on commit 3c8eed3

Please sign in to comment.