-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from project-sunbird/BadgingFunctionalTestFix
Badging functional test fix
- Loading branch information
Showing
14 changed files
with
290 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
...pi_test/src/test/java/org/sunbird/integration/test/geolocation/CreateGeolocationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package org.sunbird.integration.test.geolocation; | ||
|
||
import com.consol.citrus.annotations.CitrusTest; | ||
import com.consol.citrus.testng.CitrusParameters; | ||
import javax.ws.rs.core.MediaType; | ||
import org.springframework.http.HttpStatus; | ||
import org.sunbird.common.action.OrgUtil; | ||
import org.sunbird.integration.test.common.BaseCitrusTestRunner; | ||
import org.testng.annotations.DataProvider; | ||
import org.testng.annotations.Test; | ||
|
||
public class CreateGeolocationTest extends BaseCitrusTestRunner { | ||
|
||
private static final String TEST_NAME_CREATE_GEOLOCATION_FAILURE_WITHOUT_ROOT_ORG_ID = | ||
"testCreateGeolocationFailureWithoutRootOrgId"; | ||
private static final String TEST_NAME_CREATE_GEOLOCATION_FAILURE_WITH_EMPTY_ROOT_ORG_ID = | ||
"testCreateGeolocationFailureWithEmptyRootOrgId"; | ||
private static final String TEST_NAME_CREATE_GEOLOCATION_FAILURE_WITH_INVALID_ROOT_ORG_ID = | ||
"testCreateGeolocationFailureWithInvalidRootOrgId"; | ||
|
||
private static final String TEST_NAME_CREATE_GEOLOCATION_SUCCESS_WITH_ROOT_ORG_ID = | ||
"testCreateGeolocationSuccessWithRootOrgId"; | ||
private static final String TEST_NAME_CREATE_GEOLOCATION_SUCCESS_WITH_SUB_ORG_ID = | ||
"testCreateGeolocationSuccessWithSubOrgId"; | ||
|
||
private static final String TEMPLATE_DIR = "templates/geolocation/create"; | ||
|
||
private String getCreateGeolocationUrl() { | ||
return getLmsApiUriPath("/api/org/v1/location/create", "/v1/notification/location/create"); | ||
} | ||
|
||
@DataProvider(name = "createGeolocationDataProviderFailure") | ||
public Object[][] createGeolocationDataProviderFailure() { | ||
return new Object[][] { | ||
new Object[] {TEST_NAME_CREATE_GEOLOCATION_FAILURE_WITHOUT_ROOT_ORG_ID}, | ||
new Object[] {TEST_NAME_CREATE_GEOLOCATION_FAILURE_WITH_EMPTY_ROOT_ORG_ID}, | ||
new Object[] {TEST_NAME_CREATE_GEOLOCATION_FAILURE_WITH_INVALID_ROOT_ORG_ID} | ||
}; | ||
} | ||
|
||
@DataProvider(name = "createGeolocationDataProviderSuccess") | ||
public Object[][] createGeolocationDataProviderSuccess() { | ||
return new Object[][] { | ||
new Object[] {TEST_NAME_CREATE_GEOLOCATION_SUCCESS_WITH_ROOT_ORG_ID, true}, | ||
new Object[] {TEST_NAME_CREATE_GEOLOCATION_SUCCESS_WITH_SUB_ORG_ID, false} | ||
}; | ||
} | ||
|
||
@Test(dataProvider = "createGeolocationDataProviderSuccess") | ||
@CitrusParameters({"testName", "canCreateRootOrg"}) | ||
@CitrusTest | ||
public void testCreateGeolocationSuccess(String testName, boolean canCreateRootOrg) { | ||
beforeTest(testName, canCreateRootOrg); | ||
performPostTest( | ||
this, | ||
TEMPLATE_DIR, | ||
testName, | ||
getCreateGeolocationUrl(), | ||
REQUEST_JSON, | ||
MediaType.APPLICATION_JSON, | ||
true, | ||
HttpStatus.OK, | ||
RESPONSE_JSON); | ||
} | ||
|
||
@Test(dataProvider = "createGeolocationDataProviderFailure") | ||
@CitrusParameters({"testName"}) | ||
@CitrusTest | ||
public void testCreateGeolocationFailure(String testName) { | ||
getTestCase().setName(testName); | ||
getAuthToken(this, true); | ||
performPostTest( | ||
this, | ||
TEMPLATE_DIR, | ||
testName, | ||
getCreateGeolocationUrl(), | ||
REQUEST_JSON, | ||
MediaType.APPLICATION_JSON, | ||
true, | ||
HttpStatus.BAD_REQUEST, | ||
RESPONSE_JSON); | ||
} | ||
|
||
private void beforeTest(String testName, boolean canCreateRootOrg) { | ||
getTestCase().setName(testName); | ||
getAuthToken(this, true); | ||
if (canCreateRootOrg) { | ||
variable("rootOrgChannel", OrgUtil.getRootOrgChannel()); | ||
OrgUtil.getRootOrgId(this, testContext); | ||
} else { | ||
variable("externalId", OrgUtil.getRootOrgChannel()); | ||
variable("provider", OrgUtil.getRootOrgChannel()); | ||
OrgUtil.createSubOrgId(this, testContext); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
.../templates/geolocation/create/testCreateGeolocationFailureWithEmptyRootOrgId/request.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"request": { | ||
"rootOrgId": "", | ||
"data": [ | ||
{ | ||
"location": "someLocation", | ||
"type": "someType" | ||
} | ||
] | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...templates/geolocation/create/testCreateGeolocationFailureWithEmptyRootOrgId/response.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"id": "api.notification.location.create", | ||
"ver": "@ignore@", | ||
"ts": "@ignore@", | ||
"params": { | ||
"resmsgid": "@ignore@", | ||
"msgid": "@ignore@", | ||
"err": "INVALID_ORG_ID", | ||
"status": "INVALID_ORG_ID", | ||
"errmsg": "INVALID_ORG_ID" | ||
}, | ||
"responseCode": "CLIENT_ERROR", | ||
"result": {} | ||
} |
11 changes: 11 additions & 0 deletions
11
...emplates/geolocation/create/testCreateGeolocationFailureWithInvalidRootOrgId/request.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"request": { | ||
"rootOrgId": "invalidOrgId", | ||
"data": [ | ||
{ | ||
"location": "someLocation", | ||
"type": "someType" | ||
} | ||
] | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...mplates/geolocation/create/testCreateGeolocationFailureWithInvalidRootOrgId/response.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"id": "api.notification.location.create", | ||
"ver": "@ignore@", | ||
"ts": "@ignore@", | ||
"params": { | ||
"resmsgid": "@ignore@", | ||
"msgid": "@ignore@", | ||
"err": "INVALID_ORG_ID", | ||
"status": "INVALID_ORG_ID", | ||
"errmsg": "INVALID_ORG_ID" | ||
}, | ||
"responseCode": "CLIENT_ERROR", | ||
"result": {} | ||
} |
10 changes: 10 additions & 0 deletions
10
...es/templates/geolocation/create/testCreateGeolocationFailureWithoutRootOrgId/request.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"request": { | ||
"data": [ | ||
{ | ||
"location": "someLocation", | ||
"type": "someType" | ||
} | ||
] | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...s/templates/geolocation/create/testCreateGeolocationFailureWithoutRootOrgId/response.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"id": "api.notification.location.create", | ||
"ver": "@ignore@", | ||
"ts": "@ignore@", | ||
"params": { | ||
"resmsgid": "@ignore@", | ||
"msgid": "@ignore@", | ||
"err": "INVALID_ORG_ID", | ||
"status": "INVALID_ORG_ID", | ||
"errmsg": "INVALID_ORG_ID" | ||
}, | ||
"responseCode": "CLIENT_ERROR", | ||
"result": {} | ||
} |
11 changes: 11 additions & 0 deletions
11
...urces/templates/geolocation/create/testCreateGeolocationSuccessWithRootOrgId/request.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"request": { | ||
"rootOrgId": "${organisationId}", | ||
"data": [ | ||
{ | ||
"location": "someLocation", | ||
"type": "someType" | ||
} | ||
] | ||
} | ||
} |
Oops, something went wrong.