From 93adaa6c13ec56e475e3fa7e6818cd479651ff19 Mon Sep 17 00:00:00 2001 From: neha0305verma Date: Tue, 17 Dec 2019 23:23:01 +0530 Subject: [PATCH 1/6] getHierarchy FT --- .../kp/test/content/v3/ContentV3Scenario.java | 8 + .../kp/test/content/v3/getHierarchyTest.java | 128 ++++++++++++++ .../sunbird/kp/test/util/TestSetupUtil.java | 14 ++ .../src/test/resources/application.conf | 2 +- .../response.json | 99 +++++++++++ .../response.json | 163 +++++++++++++++++ .../response.json | 14 ++ .../response.json | 153 ++++++++++++++++ .../response.json | 153 ++++++++++++++++ .../response.json | 164 ++++++++++++++++++ 10 files changed, 897 insertions(+), 1 deletion(-) create mode 100644 kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/getHierarchyTest.java create mode 100644 kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithEditMode/response.json create mode 100644 kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithEmptyMode/response.json create mode 100644 kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithInvalidIdentifier/response.json create mode 100644 kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithInvalidMode/response.json create mode 100644 kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithNullMode/response.json create mode 100644 kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithValidIdentifier/response.json diff --git a/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/ContentV3Scenario.java b/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/ContentV3Scenario.java index f0cacffa..386878f8 100644 --- a/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/ContentV3Scenario.java +++ b/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/ContentV3Scenario.java @@ -456,5 +456,13 @@ public class ContentV3Scenario { public static final String TEST_UPDATE_HIERARCHY_WITH_1RESOURCE_ONLY = "testUpdateHierarchyWith1ResourceOnly"; public static final String TEST_UPDATE_HIERARCHY_WITH_MULTILEVEL_UNITS = "testUpdateHierarchyWithMultilevelUnitAnd1Resource"; public static final String TEST_UPDATE_HIERARCHY_WITH_1UNIT_1COLLECTION = "testUpdateHierarchyWith1Unit1CollectionValidRequest"; + + //Get Hierarchy Scenarios + public static final String TEST_GET_HIERARCHY_WITH_VALID_IDENTIFIER = "testGetHierarchyWithValidIdentifier"; + public static final String TEST_GET_HIERARCHY_WITH_INVALID_IDENTIFIER = "testGetHierarchyWithInvalidIdentifier"; + public static final String TEST_GET_HIERARCHY_WITH_EDIT_MODE = "testGetHierarchyWithEditMode"; + public static final String TEST_GET_HIERARCHY_WITH_NULL_MODE = "testGetHierarchyWithNullMode"; + public static final String TEST_GET_HIERARCHY_WITH_INVALID_MODE = "testGetHierarchyWithInvalidMode"; + public static final String TEST_GET_HIERARCHY_WITH_EMPTY_MODE = "testGetHierarchyWithEmptyMode"; } diff --git a/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/getHierarchyTest.java b/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/getHierarchyTest.java new file mode 100644 index 00000000..2717211e --- /dev/null +++ b/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/getHierarchyTest.java @@ -0,0 +1,128 @@ +package org.sunbird.kp.test.content.v3; + +import com.consol.citrus.annotations.CitrusTest; +import com.consol.citrus.testng.CitrusParameters; +import org.springframework.http.HttpStatus; +import org.sunbird.kp.test.common.APIUrl; +import org.sunbird.kp.test.common.BaseCitrusTestRunner; +import org.sunbird.kp.test.util.CollectionUtil; +import org.sunbird.kp.test.util.CollectionUtilPayload; +import org.sunbird.kp.test.util.ContentUtil; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.util.HashMap; +import java.util.Map; + +/** + * Integration Test Cases for Get Hierarchy API + * + * @author Neha Verma + * + * Number of testcases for get : 6 + * Last Count Update: 13-12-2019 + */ +public class getHierarchyTest extends BaseCitrusTestRunner { + + private static final String TEMPLATE_DIR = "templates/content/v3/hierarchy/get"; + private static final String MODE = "?mode="; + private String identifier; + + @Test(dataProvider = "getHierarchyWithValidRequest") + @CitrusParameters ({"testName", "workFlowStatus", "payload", "collectionType", "resourceCount"}) + @CitrusTest + public void getHierarchyWithValidRequest(String testName, String workFlowStatus, String payload, String collectionType, Integer resourceCount) { + Map collectionMap = CollectionUtil.prepareTestCollection(workFlowStatus, this, + new HashMap() {{put("updateHierarchy", payload);}}, collectionType, 0, resourceCount, "application/vnd.ekstep.ecml-archive"); + identifier = (String) collectionMap.get("content_id"); + ContentUtil.publishContent(this, null, "public", identifier, null); + this.variable("rootId", identifier); + performGetTest( + this, + TEMPLATE_DIR, + testName, + APIUrl.READ_CONTENT_HIERARCHY + identifier, + null, + HttpStatus.OK, + null, + RESPONSE_JSON + ); + } + + @Test(dataProvider = "getHierarchyWithInvalidRequest") + @CitrusParameters ({"testName", "workFlowStatus", "payload", "collectionType", "resourceCount", "rootId"}) + @CitrusTest + public void getHierarchyWithInvalidRequest(String testName, String workFlowStatus, String payload, String collectionType, Integer resourceCount, String rootId) { + Map collectionMap = CollectionUtil.prepareTestCollection(workFlowStatus, this, + new HashMap() {{put("updateHierarchy", payload);}}, collectionType, 0, resourceCount, "application/vnd.ekstep.ecml-archive"); + identifier = (String) collectionMap.get("content_id"); + ContentUtil.publishContent(this, null, "public", identifier, null); + performGetTest( + this, + TEMPLATE_DIR, + testName, + APIUrl.READ_CONTENT_HIERARCHY + rootId, + null, + HttpStatus.NOT_FOUND, + null, + RESPONSE_JSON + ); + } + + @Test(dataProvider = "getHierarchyWithMode") + @CitrusParameters ({"testName", "workFlowStatus", "payload", "collectionType", "resourceCount", "mode"}) + @CitrusTest + public void getHierarchyWithMode(String testName, String workFlowStatus, String payload, String collectionType, Integer resourceCount, String mode) { + Map collectionMap = CollectionUtil.prepareTestCollection(workFlowStatus, this, + new HashMap() {{put("updateHierarchy", payload);}}, collectionType, 0, resourceCount, "application/vnd.ekstep.ecml-archive"); + identifier = (String) collectionMap.get("content_id"); + //dirIdMap.put(testName, identifier); + this.variable("rootId", identifier); + performGetTest( + this, + TEMPLATE_DIR, + testName, + APIUrl.READ_CONTENT_HIERARCHY + identifier + MODE + mode, + null, + HttpStatus.OK, + null, + RESPONSE_JSON + ); + } + + @DataProvider + public static Object[][] getHierarchyWithValidRequest() { + return new Object[][]{ + new Object[]{ + ContentV3Scenario.TEST_GET_HIERARCHY_WITH_VALID_IDENTIFIER, "collectionUnitsInLive", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1 + } + }; + } + + @DataProvider + public static Object[][] getHierarchyWithInvalidRequest() { + return new Object[][]{ + new Object[]{ + ContentV3Scenario.TEST_GET_HIERARCHY_WITH_INVALID_IDENTIFIER, "collectionUnitsInLive", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1, "KP_FT_9876543" + } + }; + } + + @DataProvider + public static Object[][] getHierarchyWithMode() { + return new Object[][]{ + new Object[]{ + ContentV3Scenario.TEST_GET_HIERARCHY_WITH_EDIT_MODE, "collectionUnitsInDraft", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1, "edit" + }, + new Object[]{ + ContentV3Scenario.TEST_GET_HIERARCHY_WITH_EMPTY_MODE, "collectionUnitsInLive", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1, "" + }, + new Object[]{ + ContentV3Scenario.TEST_GET_HIERARCHY_WITH_INVALID_MODE, "collectionUnitsInLive", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1, "abc" + }, + new Object[]{ + ContentV3Scenario.TEST_GET_HIERARCHY_WITH_NULL_MODE, "collectionUnitsInLive", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1, null + } + }; + } +} diff --git a/kp_service_test/src/test/java/org/sunbird/kp/test/util/TestSetupUtil.java b/kp_service_test/src/test/java/org/sunbird/kp/test/util/TestSetupUtil.java index 2009b368..5cdf9c99 100644 --- a/kp_service_test/src/test/java/org/sunbird/kp/test/util/TestSetupUtil.java +++ b/kp_service_test/src/test/java/org/sunbird/kp/test/util/TestSetupUtil.java @@ -54,6 +54,7 @@ private static void populateDataIntoValidateFiles(String mainDir, String directo try { FileWriter fileWriter = new FileWriter(file.getPath() + "/" + fileName); HttpResponse jsonNode = Unirest.get(AppConfig.config.getString("kp_base_uri") + "/content/v3/read/" + contentId + "").asString(); +// HttpResponse jsonNode = Unirest.get(AppConfig.config.getString("kp_content_service_base_uri") + "/content/v3/hierarchy/" + contentId + "?mode=").asString(); Response response = objectMapper.readValue(jsonNode.getBody(), Response.class); fileWriter.write(formGeneralAssertions(response)); fileWriter.close(); @@ -82,6 +83,19 @@ private static String formGeneralAssertions(Response response) { .replaceAll("\\s\\d+\\.\\d+","\"@isNumber()@\"") .replaceAll("\\s\\d", "\"@isNumber()@\"") .replaceAll("\"versionKey\"\\W?:\\W\"\\d+\"","\"versionKey\" : \"@ignore@\""); + /*.replaceAll("\"pkgVersion\"\\W?:\\W\\d+\\.\\d+","\"pkgVersion\" : \"@isNumber()@\"") + .replaceAll("\"parent\"\\W?:\\W\"[a-zA-Z://._0-9-]+\"","\"parent\" : \"@ignore@\"") + .replaceAll("\"size\"\\W?:\\W\\d+\\.\\d+","\"size\" : \"@isNumber()@\"") + .replaceAll("\"totalCompressedSize\"\\W?:\\W\\d+\\.\\d+","\"totalCompressedSize\" : \"@isNumber()@\"") + .replaceAll("\"childNodes\"\\W?:\\W\\[[^\\[]*\\]+","\"childNodes\" : \"@ignore@\"") + .replaceAll("\"toc_url\"\\W?:\\W\"[a-zA-Z://._0-9-]+\"","\"toc_url\" : \"@ignore@\"") + .replaceAll("\"leafNodes\"\\W?:\\W\\[[^\\[]*\\]+","\"leafNodes\" : \"@ignore@\"") + .replaceAll("\"version\"\\W?:\\W\\d+","\"version\" : \"@isNumber()@\"") + .replaceAll("\"compatibilityLevel\"\\W?:\\W\\d+","\"compatibilityLevel\" : \"@isNumber()@\"") + .replaceAll("\"leafNodesCount\"\\W?:\\W\\d+","\"leafNodesCount\" : \"@isNumber()@\"") + .replaceAll("\"mimeTypesCount\"\\W?:\\W\\{([^}]+)\\}+","\"mimeTypesCount\" : \"@ignore@\"") + .replaceAll("\"contentTypesCount\"\\W?:\\W\\{([^}]+)\\}+","\"contentTypesCount\" : \"@ignore@\""); +*/ return updatedString; } catch (Exception e) { e.printStackTrace(); diff --git a/kp_service_test/src/test/resources/application.conf b/kp_service_test/src/test/resources/application.conf index fec1ba9b..32df1708 100644 --- a/kp_service_test/src/test/resources/application.conf +++ b/kp_service_test/src/test/resources/application.conf @@ -26,4 +26,4 @@ kp_dial_base_uri=${kp_dial_base_url} kp_dial_api_key=${kp_dial_auth_key} # KP Content Service API's -cs_api_list=["/content/v3/create","/content/v3/read/","/content/v3/update/"] \ No newline at end of file +cs_api_list=["/content/v3/create","/content/v3/read/","/content/v3/update/","/content/v3/hierarchy/"] \ No newline at end of file diff --git a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithEditMode/response.json b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithEditMode/response.json new file mode 100644 index 00000000..24a74185 --- /dev/null +++ b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithEditMode/response.json @@ -0,0 +1,99 @@ +{ + "id" : "api.content.hierarchy.get", + "ver" : "3.0", + "ts" : "@matchesDatePattern('yyyy-MM-dd')@", + "params" : { + "resmsgid" : "@ignore@", + "msgid" : null, + "err" : null, + "status" : "successful", + "errmsg" : null + }, + "responseCode" : "OK", + "result" : { + "content" : { + "ownershipType" : [ "createdBy" ], + "code" : "kp.ft.collection.textbook", + "channel" : "channel-01", + "description" : "KP Integration Test Collection Content", + "language" : [ "English" ], + "mimeType" : "application/vnd.ekstep.content-collection", + "idealScreenSize" : "normal", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "children" : [ { + "parent" : "@ignore@", + "identifier" : "@ignore@", + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "code" : "@ignore@", + "visibility" : "Parent", + "description" : "@ignore@", + "index" : 1, + "mimeType" : "application/vnd.ekstep.content-collection", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "versionKey" : "@ignore@", + "depth" : 1, + "children" : [ { + "ownershipType" : [ "createdBy" ], + "parent" : "@ignore@", + "code" : "kp.ft.resource.ecml", + "channel" : "channel-01", + "description" : "KP Integration Test Content", + "language" : [ "English" ], + "mimeType" : "application/vnd.ekstep.ecml-archive", + "idealScreenSize" : "normal", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentDisposition" : "inline", + "artifactUrl" : "@ignore@", + "contentEncoding" : "gzip", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "dialcodeRequired" : "No", + "contentType" : "Resource", + "identifier" : "@ignore@", + "audience" : [ "Learner" ], + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "os" : [ "All" ], + "visibility" : "Default", + "consumerId" : "@ignore@", + "index" : 1, + "mediaType" : "content", + "osId" : "org.ekstep.quiz.app", + "version" : "@isNumber()@", + "versionKey" : "@ignore@", + "license" : "CC BY 4.0", + "idealScreenDensity" : "hdpi", + "framework" : "NCF", + "depth" : 2, + "compatibilityLevel" : "@isNumber()@", + "name" : "KP Integration Test Content", + "status" : "Live" + } ], + "name" : "@ignore@", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentType" : "TextBook", + "status" : "Draft" + } ], + "contentDisposition" : "inline", + "contentEncoding" : "gzip", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "dialcodeRequired" : "No", + "contentType" : "TextBook", + "audience" : [ "Learner" ], + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "os" : [ "All" ], + "visibility" : "Default", + "childNodes" : "@ignore@", + "consumerId" : "@ignore@", + "mediaType" : "content", + "osId" : "org.ekstep.quiz.app", + "version" : "@isNumber()@", + "versionKey" : "@ignore@", + "license" : "CC BY 4.0", + "idealScreenDensity" : "hdpi", + "depth" : 0, + "framework" : "NCF", + "compatibilityLevel" : 1, + "name" : "KP Integration Test Collection Content", + "status" : "Draft" + } + } +} \ No newline at end of file diff --git a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithEmptyMode/response.json b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithEmptyMode/response.json new file mode 100644 index 00000000..4ccfbc03 --- /dev/null +++ b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithEmptyMode/response.json @@ -0,0 +1,163 @@ +{ + "id" : "api.content.hierarchy.get", + "ver" : "3.0", + "ts" : "@matchesDatePattern('yyyy-MM-dd')@", + "params" : { + "resmsgid" : "@ignore@", + "msgid" : null, + "err" : null, + "status" : "successful", + "errmsg" : null + }, + "responseCode" : "OK", + "result" : { + "content" : { + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "children" : [ { + "parent" : "@ignore@", + "identifier" : "@ignore@", + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "code" : "@ignore@", + "visibility" : "Parent", + "description" : "@ignore@", + "index" : 1, + "mimeType" : "application/vnd.ekstep.content-collection", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "versionKey" : "@ignore@", + "depth" : 1, + "children" : [ { + "ownershipType": [ + "createdBy" + ], + "previewUrl": "@ignore@", + "code": "kp.ft.resource.ecml", + "downloadUrl": "@ignore@", + "channel": "channel-01", + "description": "KP Integration Test Content", + "language": [ + "English" + ], + "variants": { + "spine": { + "ecarUrl": "@ignore@", + "size": "@isNumber()@" + } + }, + "streamingUrl": "@ignore@", + "mimeType": "application/vnd.ekstep.ecml-archive", + "idealScreenSize": "normal", + "publishComment": "OK", + "createdOn": "@matchesDatePattern('yyyy-MM-dd')@", + "contentDisposition": "inline", + "artifactUrl": "@ignore@", + "contentEncoding": "gzip", + "lastUpdatedOn": "@matchesDatePattern('yyyy-MM-dd')@", + "SYS_INTERNAL_LAST_UPDATED_ON": "@matchesDatePattern('yyyy-MM-dd')@", + "dialcodeRequired": "No", + "contentType": "Resource", + "lastUpdatedBy": "KP_FT_PUBLISHER", + "identifier": "@ignore@", + "audience": [ + "Learner" + ], + "lastStatusChangedOn": "@matchesDatePattern('yyyy-MM-dd')@", + "os": [ + "All" + ], + "visibility": "Default", + "consumerId": "@ignore@", + "mediaType": "content", + "osId": "org.ekstep.quiz.app", + "lastPublishedBy": "KP_FT_PUBLISHER", + "version": "@isNumber()@", + "pkgVersion": "@isNumber()@", + "versionKey": "@ignore@", + "license": "CC BY 4.0", + "idealScreenDensity": "hdpi", + "s3Key": "@ignore@", + "framework": "NCF", + "size": "@isNumber()@", + "lastPublishedOn": "@matchesDatePattern('yyyy-MM-dd')@", + "compatibilityLevel": "@isNumber()@", + "name": "KP Integration Test Content", + "publisher": "KP_FT_PUBLISHER", + "status": "Live", + "index": 1, + "depth": 2, + "parent": "@ignore@" + }], + "name" : "@ignore@", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentType" : "TextBook", + "status" : "Live", + "compatibilityLevel" : "@isNumber()@", + "lastPublishedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "pkgVersion" : "@isNumber()@", + "leafNodesCount" : "@isNumber()@", + "downloadUrl" : "@ignore@", + "variants" : "@ignore@" + } ], + "mediaType" : "content", + "name" : "KP Integration Test Collection Content", + "toc_url" : "@ignore@", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "channel" : "channel-01", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "size" : "@isNumber()@", + "identifier" : "@startsWith('KP_FT_')@", + "description" : "KP Integration Test Collection Content", + "ownershipType" : [ "createdBy" ], + "compatibilityLevel" : "@isNumber()@", + "audience" : [ "Learner" ], + "os" : [ "All" ], + "SYS_INTERNAL_LAST_UPDATED_ON" : "@matchesDatePattern('yyyy-MM-dd')@", + "downloadUrl" : "@ignore@", + "framework" : "NCF", + "totalCompressedSize" : "@isNumber()@", + "versionKey" : "@ignore@", + "mimeType" : "application/vnd.ekstep.content-collection", + "code" : "kp.ft.collection.textbook", + "license" : "CC BY 4.0", + "version" : "@isNumber()@", + "contentType" : "TextBook", + "language" : [ "English" ], + "lastPublishedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentTypesCount" : "@ignore@", + "objectType" : "Content", + "lastUpdatedBy" : "KP_FT_PUBLISHER", + "status" : "Live", + "publisher" : "KP_FT_PUBLISHER", + "publishComment" : "OK", + "dialcodeRequired" : "No", + "idealScreenSize" : "normal", + "contentEncoding" : "gzip", + "leafNodesCount" : "@isNumber()@", + "depth" : 0, + "consumerId" : "@ignore@", + "lastPublishedBy" : "KP_FT_PUBLISHER", + "mimeTypesCount" : "@ignore@", + "osId" : "org.ekstep.quiz.app", + "s3Key" : "@ignore@", + "contentDisposition" : "inline", + "childNodes" : "@ignore@", + "visibility" : "Default", + "variants" : { + "online" : { + "ecarUrl" : "@ignore@", + "size" : "@isNumber()@" + }, + "spine" : { + "ecarUrl" : "@ignore@", + "size" : "@isNumber()@" + } + }, + "pkgVersion" : "@isNumber()@", + "idealScreenDensity" : "hdpi", + "collections": [ + ], + "leafNodes": "@ignore@", + "usedByContent": [ + ] + } + } +} \ No newline at end of file diff --git a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithInvalidIdentifier/response.json b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithInvalidIdentifier/response.json new file mode 100644 index 00000000..36e9505f --- /dev/null +++ b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithInvalidIdentifier/response.json @@ -0,0 +1,14 @@ +{ + "id": "api.content.hierarchy.get", + "ver": "3.0", + "ts": "@matchesDatePattern('yyyy-MM-dd')@", + "params": { + "resmsgid": "@ignore@", + "msgid": null, + "err": "RESOURCE_NOT_FOUND", + "status": "failed", + "errmsg": "@ignore@" + }, + "responseCode": "RESOURCE_NOT_FOUND", + "result": {} +} \ No newline at end of file diff --git a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithInvalidMode/response.json b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithInvalidMode/response.json new file mode 100644 index 00000000..a8b90051 --- /dev/null +++ b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithInvalidMode/response.json @@ -0,0 +1,153 @@ +{ + "id" : "api.content.hierarchy.get", + "ver" : "3.0", + "ts" : "@matchesDatePattern('yyyy-MM-dd')@", + "params" : { + "resmsgid" : "@ignore@", + "msgid" : null, + "err" : null, + "status" : "successful", + "errmsg" : null + }, + "responseCode" : "OK", + "result" : { + "content" : { + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "children" : [ { + "parent" : "@ignore@", + "identifier" : "@ignore@", + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "code" : "@ignore@", + "visibility" : "Parent", + "description" : "@ignore@", + "index" : 1, + "mimeType" : "application/vnd.ekstep.content-collection", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "versionKey" : "@ignore@", + "depth" : 1, + "children" : [ { + "ownershipType" : [ "createdBy" ], + "previewUrl" : "@ignore@", + "code" : "kp.ft.resource.ecml", + "downloadUrl" : "@ignore@", + "channel" : "channel-01", + "description" : "KP Integration Test Content", + "language" : [ "English" ], + "variants" : { + "spine" : { + "ecarUrl" : "@ignore@", + "size" : "@isNumber()@" + } + }, + "streamingUrl" :"@ignore@", + "mimeType" : "application/vnd.ekstep.ecml-archive", + "idealScreenSize" : "normal", + "publishComment" : "OK", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentDisposition" : "inline", + "artifactUrl" : "@ignore@", + "contentEncoding" : "gzip", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "SYS_INTERNAL_LAST_UPDATED_ON" : "@matchesDatePattern('yyyy-MM-dd')@", + "dialcodeRequired" : "No", + "contentType" : "Resource", + "lastUpdatedBy" : "KP_FT_PUBLISHER", + "identifier" : "@startsWith('KP_FT_')@", + "audience" : [ "Learner" ], + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "os" : [ "All" ], + "visibility" : "Default", + "consumerId" : "@ignore@", + "mediaType" : "content", + "osId" : "org.ekstep.quiz.app", + "lastPublishedBy" : "KP_FT_PUBLISHER", + "version" : "@isNumber()@", + "pkgVersion" : "@isNumber()@", + "versionKey" : "@ignore@", + "license" : "CC BY 4.0", + "idealScreenDensity" : "hdpi", + "s3Key" : "@ignore@", + "framework" : "NCF", + "size" : "@isNumber()@", + "lastPublishedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "compatibilityLevel" : "@isNumber()@", + "name" : "KP Integration Test Content", + "publisher" : "KP_FT_PUBLISHER", + "status" : "Live", + "index" : 1, + "depth" : 2, + "parent" : "@ignore@" + } ], + "name" : "@ignore@", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentType" : "TextBook", + "status" : "Live", + "compatibilityLevel" : "@isNumber()@", + "lastPublishedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "pkgVersion" : "@isNumber()@", + "leafNodesCount" : "@isNumber()@", + "downloadUrl" : "@ignore@", + "variants" : "@ignore@" + } ], + "mediaType" : "content", + "name" : "KP Integration Test Collection Content", + "toc_url" : "@ignore@", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "channel" : "channel-01", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "size" : "@isNumber()@", + "identifier" : "${rootId}", + "description" : "KP Integration Test Collection Content", + "ownershipType" : [ "createdBy" ], + "compatibilityLevel" : "@isNumber()@", + "audience" : [ "Learner" ], + "os" : [ "All" ], + "collections" : [ ], + "SYS_INTERNAL_LAST_UPDATED_ON" : "@matchesDatePattern('yyyy-MM-dd')@", + "downloadUrl" : "@ignore@", + "usedByContent" : [ ], + "framework" : "NCF", + "totalCompressedSize" : "@isNumber()@", + "versionKey" : "@ignore@", + "mimeType" : "application/vnd.ekstep.content-collection", + "code" : "kp.ft.collection.textbook", + "license" : "CC BY 4.0", + "leafNodes" : "@ignore@", + "version" : "@isNumber()@", + "contentType" : "TextBook", + "language" : [ "English" ], + "lastPublishedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentTypesCount" : "{\"Resource\":1,\"TextBook\":1}", + "objectType" : "Content", + "lastUpdatedBy" : "KP_FT_PUBLISHER", + "status" : "Live", + "publisher" : "KP_FT_PUBLISHER", + "publishComment" : "OK", + "dialcodeRequired" : "No", + "idealScreenSize" : "normal", + "contentEncoding" : "gzip", + "leafNodesCount" : "@isNumber()@", + "depth" : 0, + "consumerId" : "@ignore@", + "lastPublishedBy" : "KP_FT_PUBLISHER", + "mimeTypesCount" : "{\"application/vnd.ekstep.content-collection\":1,\"application/vnd.ekstep.ecml-archive\":1}", + "osId" : "org.ekstep.quiz.app", + "s3Key" : "@ignore@", + "contentDisposition" : "inline", + "childNodes" : "@ignore@", + "visibility" : "Default", + "variants" : { + "online" : { + "ecarUrl" : "@ignore@", + "size" : "@isNumber()@" + }, + "spine" : { + "ecarUrl" : "@ignore@", + "size" : "@isNumber()@" + } + }, + "pkgVersion" : "@isNumber()@", + "idealScreenDensity" : "hdpi" + } + } +} \ No newline at end of file diff --git a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithNullMode/response.json b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithNullMode/response.json new file mode 100644 index 00000000..a8b90051 --- /dev/null +++ b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithNullMode/response.json @@ -0,0 +1,153 @@ +{ + "id" : "api.content.hierarchy.get", + "ver" : "3.0", + "ts" : "@matchesDatePattern('yyyy-MM-dd')@", + "params" : { + "resmsgid" : "@ignore@", + "msgid" : null, + "err" : null, + "status" : "successful", + "errmsg" : null + }, + "responseCode" : "OK", + "result" : { + "content" : { + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "children" : [ { + "parent" : "@ignore@", + "identifier" : "@ignore@", + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "code" : "@ignore@", + "visibility" : "Parent", + "description" : "@ignore@", + "index" : 1, + "mimeType" : "application/vnd.ekstep.content-collection", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "versionKey" : "@ignore@", + "depth" : 1, + "children" : [ { + "ownershipType" : [ "createdBy" ], + "previewUrl" : "@ignore@", + "code" : "kp.ft.resource.ecml", + "downloadUrl" : "@ignore@", + "channel" : "channel-01", + "description" : "KP Integration Test Content", + "language" : [ "English" ], + "variants" : { + "spine" : { + "ecarUrl" : "@ignore@", + "size" : "@isNumber()@" + } + }, + "streamingUrl" :"@ignore@", + "mimeType" : "application/vnd.ekstep.ecml-archive", + "idealScreenSize" : "normal", + "publishComment" : "OK", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentDisposition" : "inline", + "artifactUrl" : "@ignore@", + "contentEncoding" : "gzip", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "SYS_INTERNAL_LAST_UPDATED_ON" : "@matchesDatePattern('yyyy-MM-dd')@", + "dialcodeRequired" : "No", + "contentType" : "Resource", + "lastUpdatedBy" : "KP_FT_PUBLISHER", + "identifier" : "@startsWith('KP_FT_')@", + "audience" : [ "Learner" ], + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "os" : [ "All" ], + "visibility" : "Default", + "consumerId" : "@ignore@", + "mediaType" : "content", + "osId" : "org.ekstep.quiz.app", + "lastPublishedBy" : "KP_FT_PUBLISHER", + "version" : "@isNumber()@", + "pkgVersion" : "@isNumber()@", + "versionKey" : "@ignore@", + "license" : "CC BY 4.0", + "idealScreenDensity" : "hdpi", + "s3Key" : "@ignore@", + "framework" : "NCF", + "size" : "@isNumber()@", + "lastPublishedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "compatibilityLevel" : "@isNumber()@", + "name" : "KP Integration Test Content", + "publisher" : "KP_FT_PUBLISHER", + "status" : "Live", + "index" : 1, + "depth" : 2, + "parent" : "@ignore@" + } ], + "name" : "@ignore@", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentType" : "TextBook", + "status" : "Live", + "compatibilityLevel" : "@isNumber()@", + "lastPublishedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "pkgVersion" : "@isNumber()@", + "leafNodesCount" : "@isNumber()@", + "downloadUrl" : "@ignore@", + "variants" : "@ignore@" + } ], + "mediaType" : "content", + "name" : "KP Integration Test Collection Content", + "toc_url" : "@ignore@", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "channel" : "channel-01", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "size" : "@isNumber()@", + "identifier" : "${rootId}", + "description" : "KP Integration Test Collection Content", + "ownershipType" : [ "createdBy" ], + "compatibilityLevel" : "@isNumber()@", + "audience" : [ "Learner" ], + "os" : [ "All" ], + "collections" : [ ], + "SYS_INTERNAL_LAST_UPDATED_ON" : "@matchesDatePattern('yyyy-MM-dd')@", + "downloadUrl" : "@ignore@", + "usedByContent" : [ ], + "framework" : "NCF", + "totalCompressedSize" : "@isNumber()@", + "versionKey" : "@ignore@", + "mimeType" : "application/vnd.ekstep.content-collection", + "code" : "kp.ft.collection.textbook", + "license" : "CC BY 4.0", + "leafNodes" : "@ignore@", + "version" : "@isNumber()@", + "contentType" : "TextBook", + "language" : [ "English" ], + "lastPublishedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentTypesCount" : "{\"Resource\":1,\"TextBook\":1}", + "objectType" : "Content", + "lastUpdatedBy" : "KP_FT_PUBLISHER", + "status" : "Live", + "publisher" : "KP_FT_PUBLISHER", + "publishComment" : "OK", + "dialcodeRequired" : "No", + "idealScreenSize" : "normal", + "contentEncoding" : "gzip", + "leafNodesCount" : "@isNumber()@", + "depth" : 0, + "consumerId" : "@ignore@", + "lastPublishedBy" : "KP_FT_PUBLISHER", + "mimeTypesCount" : "{\"application/vnd.ekstep.content-collection\":1,\"application/vnd.ekstep.ecml-archive\":1}", + "osId" : "org.ekstep.quiz.app", + "s3Key" : "@ignore@", + "contentDisposition" : "inline", + "childNodes" : "@ignore@", + "visibility" : "Default", + "variants" : { + "online" : { + "ecarUrl" : "@ignore@", + "size" : "@isNumber()@" + }, + "spine" : { + "ecarUrl" : "@ignore@", + "size" : "@isNumber()@" + } + }, + "pkgVersion" : "@isNumber()@", + "idealScreenDensity" : "hdpi" + } + } +} \ No newline at end of file diff --git a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithValidIdentifier/response.json b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithValidIdentifier/response.json new file mode 100644 index 00000000..9e06c597 --- /dev/null +++ b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithValidIdentifier/response.json @@ -0,0 +1,164 @@ +{ + "id" : "api.content.hierarchy.get", + "ver" : "3.0", + "ts" : "@matchesDatePattern('yyyy-MM-dd')@", + "params" : { + "resmsgid" : "@ignore@", + "msgid" : null, + "err" : null, + "status" : "successful", + "errmsg" : null + }, + "responseCode" : "OK", + "result" : { + "content" : { + "appId": "@ignore@", + "ownershipType" : [ "createdBy" ], + "downloadUrl" : "@ignore@", + "channel" : "channel-01", + "language" : [ "English" ], + "variants" : { + "online" : { + "ecarUrl" : "@ignore@", + "size" : "@isNumber()@" + }, + "spine" : { + "ecarUrl" : "@ignore@", + "size" : "@isNumber()@" + } + }, + "mimeType" : "application/vnd.ekstep.content-collection", + "leafNodes" : "@ignore@", + "objectType" : "Content", + "collections" : [ ], + "children" : [ { + "parent" : "@ignore@", + "identifier" : "@ignore@", + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "code" : "@ignore@", + "visibility" : "Parent", + "description" : "@ignore@", + "index" : 1, + "mimeType" : "application/vnd.ekstep.content-collection", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "versionKey" : "@ignore@", + "depth" : 1, + "children" : [ { + "ownershipType" : [ "createdBy" ], + "previewUrl" : "@ignore@", + "downloadUrl" : "@ignore@", + "channel" : "channel-01", + "questions" : [ ], + "language" : [ "English" ], + "variants" : "@ignore@", + "mimeType" : "application/vnd.ekstep.ecml-archive", + "collections" : [ { + "identifier" : "@ignore@", + "name" : "KP Integration Test Collection Content", + "objectType" : "Content", + "relation" : "hasSequenceMember", + "description" : "KP Integration Test Collection Content", + "status" : "Live" + } ], + "children" : [ ], + "appId" : "@ignore@", + "usesContent" : [ ], + "artifactUrl" : "@ignore@", + "contentEncoding" : "gzip", + "contentType" : "Resource", + "item_sets" : [ ], + "lastUpdatedBy" : "KP_FT_PUBLISHER", + "identifier" : "@ignore@", + "audience" : [ "Learner" ], + "visibility" : "Default", + "consumerId" : "@ignore@", + "mediaType" : "content", + "osId" : "org.ekstep.quiz.app", + "lastPublishedBy" : "KP_FT_PUBLISHER", + "version" : 2, + "license" : "CC BY 4.0", + "size" : "@isNumber()@", + "lastPublishedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "concepts" : [ ], + "name" : "KP Integration Test Content", + "publisher" : "KP_FT_PUBLISHER", + "status" : "Live", + "code" : "@ignore@", + "methods" : [ ], + "description" : "KP Integration Test Content", + "streamingUrl" :"@ignore@", + "idealScreenSize" : "normal", + "publishComment" : "OK", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentDisposition" : "inline", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "SYS_INTERNAL_LAST_UPDATED_ON" : "@matchesDatePattern('yyyy-MM-dd')@", + "dialcodeRequired" : "No", + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "os" : [ "All" ], + "libraries" : [ ], + "pkgVersion" : 1.0, + "versionKey" : "@ignore@", + "idealScreenDensity" : "hdpi", + "s3Key" : "@ignore@", + "framework" : "NCF", + "compatibilityLevel" : 1, + "index" : 1, + "depth" : 2 + } ], + "name" : "@ignore@", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentType" : "TextBook", + "status" : "Live", + "compatibilityLevel" : 1, + "lastPublishedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "pkgVersion" : 2.0, + "leafNodesCount" : 1, + "downloadUrl" : "@ignore@", + "variants" : "@ignore@" + } ], + "contentEncoding" : "gzip", + "mimeTypesCount" : "{\"application/vnd.ekstep.content-collection\":1,\"application/vnd.ekstep.ecml-archive\":1}", + "totalCompressedSize" : "@isNumber()@", + "contentType" : "TextBook", + "lastUpdatedBy" : "KP_FT_PUBLISHER", + "identifier" : "${rootId}", + "audience" : [ "Learner" ], + "toc_url" : "@ignore@", + "visibility" : "Default", + "contentTypesCount" : "{\"Resource\":1,\"TextBook\":1}", + "childNodes" : "@ignore@", + "consumerId" : "@ignore@", + "mediaType" : "content", + "osId" : "org.ekstep.quiz.app", + "lastPublishedBy" : "KP_FT_PUBLISHER", + "version" : 2, + "license" : "CC BY 4.0", + "size" : "@isNumber()@", + "lastPublishedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "name" : "KP Integration Test Collection Content", + "publisher" : "KP_FT_PUBLISHER", + "status" : "Live", + "code" : "kp.ft.collection.textbook", + "description" : "KP Integration Test Collection Content", + "publishComment" : "OK", + "idealScreenSize" : "normal", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentDisposition" : "inline", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "SYS_INTERNAL_LAST_UPDATED_ON" : "@matchesDatePattern('yyyy-MM-dd')@", + "dialcodeRequired" : "No", + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "os" : [ "All" ], + "pkgVersion" : 2.0, + "versionKey" : "@ignore@", + "idealScreenDensity" : "hdpi", + "depth" : 0, + "s3Key" : "@ignore@", + "framework" : "NCF", + "leafNodesCount" : 1, + "compatibilityLevel" : 1, + "usedByContent" : [ ] + } + } +} \ No newline at end of file From 1ce22500eb2b9c2499a0e52124659443852ebcb6 Mon Sep 17 00:00:00 2001 From: neha0305verma Date: Wed, 18 Dec 2019 00:03:29 +0530 Subject: [PATCH 2/6] scenarious are added --- .../kp/test/content/v3/ContentV3Scenario.java | 10 ++++++++++ .../kp/test/content/v3/getHierarchyTest.java | 4 ++-- .../response.json | 15 +++------------ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/ContentV3Scenario.java b/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/ContentV3Scenario.java index 386878f8..2bbf16ff 100644 --- a/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/ContentV3Scenario.java +++ b/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/ContentV3Scenario.java @@ -464,5 +464,15 @@ public class ContentV3Scenario { public static final String TEST_GET_HIERARCHY_WITH_NULL_MODE = "testGetHierarchyWithNullMode"; public static final String TEST_GET_HIERARCHY_WITH_INVALID_MODE = "testGetHierarchyWithInvalidMode"; public static final String TEST_GET_HIERARCHY_WITH_EMPTY_MODE = "testGetHierarchyWithEmptyMode"; + public static final String TEST_GET_HIERARCHY_BEFORE_UPDATE = "testGetHierarchyBeforeUpdate"; + public static final String TEST_GET_HIERARCHY_AFTER_UPDATE = "testGetHierarchyAfterUpdate"; + public static final String TEST_GET_HIERARCHY_AFTER_REVIEW = "testGetHierarchyAfterReview"; + public static final String TEST_GET_HIERARCHY_AFTER_REJECT = "testGetHierarchyAfterReject"; + public static final String TEST_GET_HIERARCHY_AFTER_FLAG = "testGetHierarchyAfterFlag"; + public static final String TEST_GET_HIERARCHY_AFTER_FLAG_REJECT = "testGetHierarchyAfterFlagReject"; + public static final String TEST_GET_HIERARCHY_AFTER_FLAG_ACCEPT = "testGetHierarchyAfterFlagAccept"; + public static final String TEST_GET_HIERARCHY_AFTER_DISCARD = "testGetHierarchyAfterDiscard"; + public static final String TEST_GET_HIERARCHY_AFTER_RETIRE = "testGetHierarchyAfterRetire"; + public static final String TEST_GET_HIERARCHY_AFTER_UPDATE_LIVE = "testGetHierarchyAfterRetire"; } diff --git a/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/getHierarchyTest.java b/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/getHierarchyTest.java index 2717211e..7aa98af3 100644 --- a/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/getHierarchyTest.java +++ b/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/getHierarchyTest.java @@ -19,8 +19,8 @@ * * @author Neha Verma * - * Number of testcases for get : 6 - * Last Count Update: 13-12-2019 + * Number of testcases for get : 16 + * Last Count Update: 17-12-2019 */ public class getHierarchyTest extends BaseCitrusTestRunner { diff --git a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithValidIdentifier/response.json b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithValidIdentifier/response.json index 9e06c597..04629023 100644 --- a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithValidIdentifier/response.json +++ b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyWithValidIdentifier/response.json @@ -12,7 +12,6 @@ "responseCode" : "OK", "result" : { "content" : { - "appId": "@ignore@", "ownershipType" : [ "createdBy" ], "downloadUrl" : "@ignore@", "channel" : "channel-01", @@ -30,7 +29,6 @@ "mimeType" : "application/vnd.ekstep.content-collection", "leafNodes" : "@ignore@", "objectType" : "Content", - "collections" : [ ], "children" : [ { "parent" : "@ignore@", "identifier" : "@ignore@", @@ -45,6 +43,7 @@ "depth" : 1, "children" : [ { "ownershipType" : [ "createdBy" ], + "parent": "@ignore@", "previewUrl" : "@ignore@", "downloadUrl" : "@ignore@", "channel" : "channel-01", @@ -52,16 +51,6 @@ "language" : [ "English" ], "variants" : "@ignore@", "mimeType" : "application/vnd.ekstep.ecml-archive", - "collections" : [ { - "identifier" : "@ignore@", - "name" : "KP Integration Test Collection Content", - "objectType" : "Content", - "relation" : "hasSequenceMember", - "description" : "KP Integration Test Collection Content", - "status" : "Live" - } ], - "children" : [ ], - "appId" : "@ignore@", "usesContent" : [ ], "artifactUrl" : "@ignore@", "contentEncoding" : "gzip", @@ -158,6 +147,8 @@ "framework" : "NCF", "leafNodesCount" : 1, "compatibilityLevel" : 1, + "collections": [ + ], "usedByContent" : [ ] } } From abc4ec8168d7eeb855d52df3357f7962b853ff9d Mon Sep 17 00:00:00 2001 From: neha0305verma Date: Mon, 23 Dec 2019 14:45:20 +0530 Subject: [PATCH 3/6] getHierarchy FT --- .../kp/test/content/v3/ContentV3Scenario.java | 10 ++ .../kp/test/content/v3/getHierarchyTest.java | 99 ++++++++++++++- .../sunbird/kp/test/util/CollectionUtil.java | 49 ++++++++ .../org/sunbird/kp/test/util/ContentUtil.java | 2 + .../sunbird/kp/test/util/TestSetupUtil.java | 39 +++--- .../kp/test/util/WorkflowConstants.java | 6 +- .../testGetHierarchyAfterReview/response.json | 14 +++ .../response.json | 118 ++++++++++++++++++ .../testGetHierarchyAfterUpdate/response.json | 14 +++ .../response.json | 117 +++++++++++++++++ .../response.json | 14 +++ .../response.json | 45 +++++++ 12 files changed, 501 insertions(+), 26 deletions(-) create mode 100644 kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterReview/response.json create mode 100644 kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterReviewWithMode/response.json create mode 100644 kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterUpdate/response.json create mode 100644 kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterUpdateWithMode/response.json create mode 100644 kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyBeforeUpdate/response.json create mode 100644 kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyBeforeUpdateWithMode/response.json diff --git a/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/ContentV3Scenario.java b/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/ContentV3Scenario.java index 2bbf16ff..0172cfcd 100644 --- a/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/ContentV3Scenario.java +++ b/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/ContentV3Scenario.java @@ -474,5 +474,15 @@ public class ContentV3Scenario { public static final String TEST_GET_HIERARCHY_AFTER_DISCARD = "testGetHierarchyAfterDiscard"; public static final String TEST_GET_HIERARCHY_AFTER_RETIRE = "testGetHierarchyAfterRetire"; public static final String TEST_GET_HIERARCHY_AFTER_UPDATE_LIVE = "testGetHierarchyAfterRetire"; + public static final String TEST_GET_HIERARCHY_BEFORE_UPDATE_WITH_MODE = "testGetHierarchyBeforeUpdateWithMode"; + public static final String TEST_GET_HIERARCHY_AFTER_UPDATE_WITH_MODE = "testGetHierarchyAfterUpdateWithMode"; + public static final String TEST_GET_HIERARCHY_AFTER_REVIEW_WITH_MODE = "testGetHierarchyAfterReviewWithMode"; + public static final String TEST_GET_HIERARCHY_AFTER_REJECT_WITH_MODE = "testGetHierarchyAfterRejectWithMode"; + public static final String TEST_GET_HIERARCHY_AFTER_FLAG_WITH_MODE = "testGetHierarchyAfterFlagWithMode"; + public static final String TEST_GET_HIERARCHY_AFTER_FLAG_REJECT_WITH_MODE = "testGetHierarchyAfterFlagRejectWithMode"; + public static final String TEST_GET_HIERARCHY_AFTER_FLAG_ACCEPT_WITH_MODE = "testGetHierarchyAfterFlagAcceptWithMode"; + public static final String TEST_GET_HIERARCHY_AFTER_DISCARD_WITH_MODE = "testGetHierarchyAfterDiscardWithMode"; + public static final String TEST_GET_HIERARCHY_AFTER_RETIRE_WITH_MODE = "testGetHierarchyAfterRetireWithMode"; + public static final String TEST_GET_HIERARCHY_AFTER_UPDATE_LIVE_WITH_MODE = "testGetHierarchyAfterRetireWithMode"; } diff --git a/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/getHierarchyTest.java b/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/getHierarchyTest.java index 7aa98af3..82d4ba19 100644 --- a/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/getHierarchyTest.java +++ b/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/getHierarchyTest.java @@ -8,6 +8,8 @@ import org.sunbird.kp.test.util.CollectionUtil; import org.sunbird.kp.test.util.CollectionUtilPayload; import org.sunbird.kp.test.util.ContentUtil; +import org.sunbird.kp.test.util.TestSetupUtil; +import org.testng.annotations.AfterClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -27,16 +29,24 @@ public class getHierarchyTest extends BaseCitrusTestRunner { private static final String TEMPLATE_DIR = "templates/content/v3/hierarchy/get"; private static final String MODE = "?mode="; private String identifier; + private static Map dirIdMap = new HashMap<>(); + +// @AfterClass +// public static void populateAssertionData() { +// TestSetupUtil.createDirectoriesForTestCases(dirIdMap, "response.json", TEMPLATE_DIR); +// } @Test(dataProvider = "getHierarchyWithValidRequest") - @CitrusParameters ({"testName", "workFlowStatus", "payload", "collectionType", "resourceCount"}) + @CitrusParameters ({"testName", "workFlowStatus", "payload", "collectionType", "resourceCount", "publish"}) @CitrusTest - public void getHierarchyWithValidRequest(String testName, String workFlowStatus, String payload, String collectionType, Integer resourceCount) { - Map collectionMap = CollectionUtil.prepareTestCollection(workFlowStatus, this, - new HashMap() {{put("updateHierarchy", payload);}}, collectionType, 0, resourceCount, "application/vnd.ekstep.ecml-archive"); + public void getHierarchyWithValidRequest(String testName, String workFlowStatus, String payload, String collectionType, Integer resourceCount, Boolean publish) { + Map collectionMap = CollectionUtil.prepareTestCollection(workFlowStatus, this, new HashMap() {{put("updateHierarchy", payload);}}, collectionType, 0, resourceCount, "application/vnd.ekstep.ecml-archive"); identifier = (String) collectionMap.get("content_id"); - ContentUtil.publishContent(this, null, "public", identifier, null); + if(publish){ + ContentUtil.publishContent(this, null, "public", identifier, null); + } this.variable("rootId", identifier); + //dirIdMap.put(testName, identifier); performGetTest( this, TEMPLATE_DIR, @@ -76,8 +86,48 @@ public void getHierarchyWithMode(String testName, String workFlowStatus, String Map collectionMap = CollectionUtil.prepareTestCollection(workFlowStatus, this, new HashMap() {{put("updateHierarchy", payload);}}, collectionType, 0, resourceCount, "application/vnd.ekstep.ecml-archive"); identifier = (String) collectionMap.get("content_id"); + this.variable("rootId", identifier); //dirIdMap.put(testName, identifier); + performGetTest( + this, + TEMPLATE_DIR, + testName, + APIUrl.READ_CONTENT_HIERARCHY + identifier + MODE + mode, + null, + HttpStatus.OK, + null, + RESPONSE_JSON + ); + } + + @Test(dataProvider = "getHierarchyWithDifferentStatusWithoutMode") + @CitrusParameters ({"testName", "workFlowStatus", "payload", "collectionType", "resourceCount"}) + @CitrusTest + public void getHierarchyWithDifferentStatusWithoutMode(String testName, String workFlowStatus, String payload, String collectionType, Integer resourceCount) { + Map collectionMap = CollectionUtil.prepareTestCollectionWithoutUpdateHierarchy(workFlowStatus, this,null, collectionType, 0, resourceCount, "application/vnd.ekstep.ecml-archive"); + identifier = (String) collectionMap.get("content_id"); + this.variable("rootId", identifier); + //dirIdMap.put(testName, identifier); + performGetTest( + this, + TEMPLATE_DIR, + testName, + APIUrl.READ_CONTENT_HIERARCHY + identifier, + null, + HttpStatus.OK, + null, + RESPONSE_JSON + ); + } + + @Test(dataProvider = "getHierarchyWithDifferentStatusWithMode") + @CitrusParameters ({"testName", "workFlowStatus", "payload", "collectionType", "resourceCount", "mode"}) + @CitrusTest + public void getHierarchyWithDifferentStatusWithMode(String testName, String workFlowStatus, String payload, String collectionType, Integer resourceCount, String mode) { + Map collectionMap = CollectionUtil.prepareTestCollectionWithoutUpdateHierarchy(workFlowStatus, this,null, collectionType, 0, resourceCount, "application/vnd.ekstep.ecml-archive"); + identifier = (String) collectionMap.get("content_id"); this.variable("rootId", identifier); + //dirIdMap.put(testName, identifier); performGetTest( this, TEMPLATE_DIR, @@ -94,8 +144,18 @@ public void getHierarchyWithMode(String testName, String workFlowStatus, String public static Object[][] getHierarchyWithValidRequest() { return new Object[][]{ new Object[]{ - ContentV3Scenario.TEST_GET_HIERARCHY_WITH_VALID_IDENTIFIER, "collectionUnitsInLive", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1 + ContentV3Scenario.TEST_GET_HIERARCHY_WITH_VALID_IDENTIFIER, "collectionUnitsInLive", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1, true + }, + new Object[]{ + ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_UPDATE, "collectionUnitsInDraft", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1, true + }, + new Object[]{ + ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_REVIEW, "collectionReview", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1, false + }, + new Object[]{ + ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_RETIRE, "collectionRetire", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1, false } + }; } @@ -122,6 +182,33 @@ public static Object[][] getHierarchyWithMode() { }, new Object[]{ ContentV3Scenario.TEST_GET_HIERARCHY_WITH_NULL_MODE, "collectionUnitsInLive", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1, null + }, + new Object[]{ + ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_UPDATE_WITH_MODE, "collectionUnitsInDraft", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1, "edit" + }, + new Object[]{ + ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_REVIEW_WITH_MODE, "collectionReview", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1, "edit" + }, + new Object[]{ + ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_RETIRE_WITH_MODE, "collectionRetire", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1, "edit" + } + }; + } + + @DataProvider + public static Object[][] getHierarchyWithDifferentStatusWithoutMode() { + return new Object[][]{ + new Object[]{ + ContentV3Scenario.TEST_GET_HIERARCHY_BEFORE_UPDATE, "collectionCreate", null, "textBook", 1 + } + }; + } + + @DataProvider + public static Object[][] getHierarchyWithDifferentStatusWithMode() { + return new Object[][]{ + new Object[]{ + ContentV3Scenario.TEST_GET_HIERARCHY_BEFORE_UPDATE_WITH_MODE, "collectionCreate", null, "textBook", 1, "edit" } }; } diff --git a/kp_service_test/src/test/java/org/sunbird/kp/test/util/CollectionUtil.java b/kp_service_test/src/test/java/org/sunbird/kp/test/util/CollectionUtil.java index f5fd201e..c148addf 100644 --- a/kp_service_test/src/test/java/org/sunbird/kp/test/util/CollectionUtil.java +++ b/kp_service_test/src/test/java/org/sunbird/kp/test/util/CollectionUtil.java @@ -121,4 +121,53 @@ public static List getLiveAsset(BaseCitrusTestRunner runner, Integer ass return assetIds; } + /** + * This method will add resources or asset to a Payload collection provided as user's requirements. + * The number of asset or resources to be created should be equal to the placeholders in the dynamic payload. + *

+ * Resource placeholder should be resource_N, for eg: resource_1 + * Asset placeholder should be resource_N for eg: asset_2. + * + * @param workFlow (Mandatory) + * @param runner + * @param payloadMap (Mandatory -> Send new HashMap with (updateHierarchy -> Payload String), If you want to custom resource, pass createResource) + * @param collectionType (For valid collection type see ContentUtil) + * @param assetCount (Number of assets that are needed to replace in the payload) + * @param resourceCount (Number of resources that are needed to replace in the payload + * @param mimeType (This field is optional and can be passed as null for random valid mimeType generation + * @return a map of all the resources/assets added, all unit identifiers and textBook identifier + * @see ContentUtil + */ + public static Map prepareTestCollectionWithoutUpdateHierarchy(String workFlow, BaseCitrusTestRunner runner, Map payloadMap, String collectionType, + Integer assetCount, Integer resourceCount, String mimeType) { + Map collectionMap = new HashMap<>(); + collectionMap.putAll(ContentUtil.createCollectionContent(runner, null, collectionType, null)); + + //Map also has identifiers which is a map of all id's of unit's etc TODO: Return that too + String contentId = (String) collectionMap.get("content_id"); + runner.variable("collectionIdVal", contentId); + runner.variable("versionKey", collectionMap.get("versionKey")); + Map collectionWorkMap = null; + try { + collectionWorkMap = mapper.readValue(WorkflowConstants.collectionWorkFlows, new TypeReference>() { + }); + List contentWorkList = (List) collectionWorkMap.get(workFlow); + Map>> actionMap = ContentUtil.getCollectionWorkFlowMap(runner, contentId, null, null, null); + if (!CollectionUtils.isEmpty(contentWorkList)) { + contentWorkList.forEach(action -> { + Map response = actionMap.get(action).get(); + if (response.get("content") != null) + response = (Map) response.get("content"); + if( null != response.get("identifiers")) + collectionMap.put("identifiers", response.get("identifiers")); + if (StringUtils.isNotBlank((String) response.get("versionKey"))) + runner.variable("versionKeyVal", response.get("versionKey")); + }); + } + } catch (IOException e) { + e.printStackTrace(); + } +// collectionMap = ContentUtil.readCollectionHierarchy(runner, contentId) + return collectionMap; + } } diff --git a/kp_service_test/src/test/java/org/sunbird/kp/test/util/ContentUtil.java b/kp_service_test/src/test/java/org/sunbird/kp/test/util/ContentUtil.java index a8305454..305e21f6 100644 --- a/kp_service_test/src/test/java/org/sunbird/kp/test/util/ContentUtil.java +++ b/kp_service_test/src/test/java/org/sunbird/kp/test/util/ContentUtil.java @@ -1076,6 +1076,8 @@ public static Map>> getCollectionWorkFlowMa put("AcceptFlag", () -> ContentUtil.acceptFlagContent(runner, null, null, contentId, headers)); put("RejectFlag", () -> ContentUtil.rejectFlagContent(runner, null, contentId, headers)); put("Get", () -> ContentUtil.readCollectionHierarchy(runner, contentId)); + put("Create", () -> ContentUtil.readCollectionHierarchy(runner, contentId)); + put("Review", () -> ContentUtil.reviewContent(runner, payload, testName, contentId, headers)); } }; } diff --git a/kp_service_test/src/test/java/org/sunbird/kp/test/util/TestSetupUtil.java b/kp_service_test/src/test/java/org/sunbird/kp/test/util/TestSetupUtil.java index 5cdf9c99..af2d848b 100644 --- a/kp_service_test/src/test/java/org/sunbird/kp/test/util/TestSetupUtil.java +++ b/kp_service_test/src/test/java/org/sunbird/kp/test/util/TestSetupUtil.java @@ -29,16 +29,16 @@ public static void createDirectoriesForTestCases(Map dirIdMap, S File file = new File(mainDir +"/"+ dir); file.mkdir(); if (file.isDirectory()) { - File responseFile = new File(file.getPath() + "/" + "response.json"); - File requestFile = new File(file.getPath() + "/" + "request.json"); - File validateFile = new File(file.getPath() + "/" + "validate.json"); +// File responseFile = new File(file.getPath() + "/" + "response.json"); +// File requestFile = new File(file.getPath() + "/" + "request.json"); +// File validateFile = new File(file.getPath() + "/" + "validate.json"); try { - if (!responseFile.exists()) - responseFile.createNewFile(); - if (!requestFile.exists()) - requestFile.createNewFile(); - if (!validateFile.exists()) - validateFile.createNewFile(); +// if (!responseFile.exists()) +// responseFile.createNewFile(); +// if (!requestFile.exists()) +// requestFile.createNewFile(); +// if (!validateFile.exists()) +// validateFile.createNewFile(); populateDataIntoValidateFiles(mainDir, dir, validationFileName, dirIdMap.get(dir)); } catch (Exception e) { e.printStackTrace(); @@ -53,8 +53,11 @@ private static void populateDataIntoValidateFiles(String mainDir, String directo if (file.isDirectory()) { try { FileWriter fileWriter = new FileWriter(file.getPath() + "/" + fileName); - HttpResponse jsonNode = Unirest.get(AppConfig.config.getString("kp_base_uri") + "/content/v3/read/" + contentId + "").asString(); -// HttpResponse jsonNode = Unirest.get(AppConfig.config.getString("kp_content_service_base_uri") + "/content/v3/hierarchy/" + contentId + "?mode=").asString(); +// HttpResponse jsonNode = Unirest.get(AppConfig.config.getString("kp_base_uri") + "/content/v3/read/" + contentId + "").asString(); + + HttpResponse jsonNode = Unirest.get(AppConfig.config.getString("kp_content_service_base_uri") + "/content/v3/hierarchy/" + contentId).asString(); + +// HttpResponse jsonNode = Unirest.get(AppConfig.config.getString("kp_content_service_base_uri") + "/content/v3/hierarchy/" + contentId + "?mode=edit"").asString(); Response response = objectMapper.readValue(jsonNode.getBody(), Response.class); fileWriter.write(formGeneralAssertions(response)); fileWriter.close(); @@ -79,11 +82,11 @@ private static String formGeneralAssertions(Response response) { .replaceAll("\"s3Key\"\\W?:\\W\"[a-zA-Z:/._0-9-]+\"","\"s3Key\" : \"@ignore@\"") .replaceAll("\"appId\"\\W?:\\W?\"[a-zA-Z.-]+\"","\"appId\" : \"@ignore@\"") .replaceAll("\"consumerId\"\\W?:\\W?\"[a-zA-Z0-9-]+\"","\"consumerId\" : \"@ignore@\"") - .replaceAll("KP_FT_\\d+","\\${contentIdVal}") - .replaceAll("\\s\\d+\\.\\d+","\"@isNumber()@\"") - .replaceAll("\\s\\d", "\"@isNumber()@\"") - .replaceAll("\"versionKey\"\\W?:\\W\"\\d+\"","\"versionKey\" : \"@ignore@\""); - /*.replaceAll("\"pkgVersion\"\\W?:\\W\\d+\\.\\d+","\"pkgVersion\" : \"@isNumber()@\"") +// .replaceAll("KP_FT_\\d+","\\${contentIdVal}") +// .replaceAll("\\s\\d+\\.\\d+","\"@isNumber()@\"") +// .replaceAll("\\s\\d", "\"@isNumber()@\"") + .replaceAll("\"versionKey\"\\W?:\\W\"\\d+\"","\"versionKey\" : \"@ignore@\"") + .replaceAll("\"pkgVersion\"\\W?:\\W\\d+\\.\\d+","\"pkgVersion\" : \"@isNumber()@\"") .replaceAll("\"parent\"\\W?:\\W\"[a-zA-Z://._0-9-]+\"","\"parent\" : \"@ignore@\"") .replaceAll("\"size\"\\W?:\\W\\d+\\.\\d+","\"size\" : \"@isNumber()@\"") .replaceAll("\"totalCompressedSize\"\\W?:\\W\\d+\\.\\d+","\"totalCompressedSize\" : \"@isNumber()@\"") @@ -94,8 +97,8 @@ private static String formGeneralAssertions(Response response) { .replaceAll("\"compatibilityLevel\"\\W?:\\W\\d+","\"compatibilityLevel\" : \"@isNumber()@\"") .replaceAll("\"leafNodesCount\"\\W?:\\W\\d+","\"leafNodesCount\" : \"@isNumber()@\"") .replaceAll("\"mimeTypesCount\"\\W?:\\W\\{([^}]+)\\}+","\"mimeTypesCount\" : \"@ignore@\"") - .replaceAll("\"contentTypesCount\"\\W?:\\W\\{([^}]+)\\}+","\"contentTypesCount\" : \"@ignore@\""); -*/ + .replaceAll("\"contentTypesCount\"\\W?:\\W\\{([^}]+)\\}+","\"contentTypesCount\" : \"@ignore@\"") + .replaceAll("\"errmsg\"\\W?:\\W\\[a-zA-Z0-9-]+","\"errmsg\" : \"@ignore@\""); return updatedString; } catch (Exception e) { e.printStackTrace(); diff --git a/kp_service_test/src/test/java/org/sunbird/kp/test/util/WorkflowConstants.java b/kp_service_test/src/test/java/org/sunbird/kp/test/util/WorkflowConstants.java index 3dfbf22e..ccb3f15e 100644 --- a/kp_service_test/src/test/java/org/sunbird/kp/test/util/WorkflowConstants.java +++ b/kp_service_test/src/test/java/org/sunbird/kp/test/util/WorkflowConstants.java @@ -37,8 +37,10 @@ public class WorkflowConstants { "\"collectionUnitsInDraft\":[\"Update\"],\n" + "\"collectionUnitsInLive\":[\"Update\", \"Publish\"],\n" + "\"collectionRead\":[\"Update\", \"Publish\"],\n" + - "\"collectionUnitsResourcesInDraft\":[\"CreateResources\", \"Update\"]\n" + + "\"collectionUnitsResourcesInDraft\":[\"CreateResources\", \"Update\"],\n" + + "\"collectionCreate\":[\"Create\"],\n"+ + "\"collectionReview\":[\"Update\", \"Review\"],\n"+ + "\"collectionRetire\":[\"Update\", \"Publish\", \"Retire\"]\n"+ "}"; - } diff --git a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterReview/response.json b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterReview/response.json new file mode 100644 index 00000000..aaae515b --- /dev/null +++ b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterReview/response.json @@ -0,0 +1,14 @@ +{ + "id" : "api.content.hierarchy.get", + "ver" : "3.0", + "ts" : "@matchesDatePattern('yyyy-MM-dd')@", + "params" : { + "resmsgid" : "@ignore@", + "msgid" : null, + "err" : "RESOURCE_NOT_FOUND", + "status" : "failed", + "errmsg" : "@ignore@" + }, + "responseCode" : "RESOURCE_NOT_FOUND", + "result" : { } +} \ No newline at end of file diff --git a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterReviewWithMode/response.json b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterReviewWithMode/response.json new file mode 100644 index 00000000..99cc0844 --- /dev/null +++ b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterReviewWithMode/response.json @@ -0,0 +1,118 @@ +{ + "id" : "api.content.hierarchy.get", + "ver" : "3.0", + "ts" : "@matchesDatePattern('yyyy-MM-dd')@", + "params" : { + "resmsgid" : "@ignore@", + "msgid" : null, + "err" : null, + "status" : "successful", + "errmsg" : null + }, + "responseCode" : "OK", + "result" : { + "content" : { + "ownershipType" : [ "createdBy" ], + "code" : "kp.ft.collection.textbook", + "channel" : "channel-01", + "description" : "KP Integration Test Collection Content", + "language" : [ "English" ], + "mimeType" : "application/vnd.ekstep.content-collection", + "idealScreenSize" : "normal", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "children" : [ { + "parent" : "@ignore@", + "identifier" : "@ignore@", + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "code" : "@ignore@", + "visibility" : "Parent", + "description" : "@ignore@", + "index" : 1, + "mimeType" : "application/vnd.ekstep.content-collection", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "versionKey" : "@ignore@", + "depth" : 1, + "children" : [ { + "ownershipType" : [ "createdBy" ], + "parent" : "@ignore@", + "previewUrl" : "@ignore@", + "code" : "kp.ft.resource.ecml", + "downloadUrl" : "@ignore@", + "channel" : "channel-01", + "description" : "KP Integration Test Content", + "language" : [ "English" ], + "variants" : { + "spine" : { + "ecarUrl" : "@ignore@", + "size" : "@isNumber()@" + } + }, + "streamingUrl" :"@ignore@", + "mimeType" : "application/vnd.ekstep.ecml-archive", + "idealScreenSize" : "normal", + "publishComment" : "OK", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentDisposition" : "inline", + "artifactUrl" : "@ignore@", + "contentEncoding" : "gzip", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "SYS_INTERNAL_LAST_UPDATED_ON" : "@matchesDatePattern('yyyy-MM-dd')@", + "dialcodeRequired" : "No", + "contentType" : "Resource", + "lastUpdatedBy" : "KP_FT_PUBLISHER", + "identifier" : "${rootId}", + "audience" : [ "Learner" ], + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "os" : [ "All" ], + "visibility" : "Default", + "consumerId" : "@ignore@", + "index" : 1, + "mediaType" : "content", + "osId" : "org.ekstep.quiz.app", + "lastPublishedBy" : "KP_FT_PUBLISHER", + "version" : "@isNumber()@", + "pkgVersion" : "@isNumber()@", + "versionKey" : "@ignore@", + "license" : "CC BY 4.0", + "idealScreenDensity" : "hdpi", + "s3Key" : "@ignore@", + "framework" : "NCF", + "depth" : 2, + "size" : "@isNumber()@", + "lastPublishedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "compatibilityLevel" : "@isNumber()@", + "name" : "KP Integration Test Content", + "publisher" : "KP_FT_PUBLISHER", + "status" : "Live" + } ], + "name" : "@ignore@", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentType" : "TextBook", + "status" : "Draft" + } ], + "contentDisposition" : "inline", + "contentEncoding" : "gzip", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "dialcodeRequired" : "No", + "contentType" : "TextBook", + "audience" : [ "Learner" ], + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "os" : [ "All" ], + "visibility" : "Default", + "childNodes" : "@ignore@", + "consumerId" : "@ignore@", + "mediaType" : "content", + "osId" : "org.ekstep.quiz.app", + "version" : "@isNumber()@", + "versionKey" : "@ignore@", + "license" : "CC BY 4.0", + "idealScreenDensity" : "hdpi", + "depth" : 0, + "framework" : "NCF", + "lastSubmittedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "compatibilityLevel" : "@isNumber()@", + "name" : "KP Integration Test Collection Content", + "status" : "Review" + } + } +} \ No newline at end of file diff --git a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterUpdate/response.json b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterUpdate/response.json new file mode 100644 index 00000000..aaae515b --- /dev/null +++ b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterUpdate/response.json @@ -0,0 +1,14 @@ +{ + "id" : "api.content.hierarchy.get", + "ver" : "3.0", + "ts" : "@matchesDatePattern('yyyy-MM-dd')@", + "params" : { + "resmsgid" : "@ignore@", + "msgid" : null, + "err" : "RESOURCE_NOT_FOUND", + "status" : "failed", + "errmsg" : "@ignore@" + }, + "responseCode" : "RESOURCE_NOT_FOUND", + "result" : { } +} \ No newline at end of file diff --git a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterUpdateWithMode/response.json b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterUpdateWithMode/response.json new file mode 100644 index 00000000..f5d3cc1c --- /dev/null +++ b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterUpdateWithMode/response.json @@ -0,0 +1,117 @@ +{ + "id" : "api.content.hierarchy.get", + "ver" : "3.0", + "ts" : "@matchesDatePattern('yyyy-MM-dd')@", + "params" : { + "resmsgid" : "@ignore@", + "msgid" : null, + "err" : null, + "status" : "successful", + "errmsg" : null + }, + "responseCode" : "OK", + "result" : { + "content" : { + "ownershipType" : [ "createdBy" ], + "code" : "kp.ft.collection.textbook", + "channel" : "channel-01", + "description" : "KP Integration Test Collection Content", + "language" : [ "English" ], + "mimeType" : "application/vnd.ekstep.content-collection", + "idealScreenSize" : "normal", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "children" : [ { + "parent" : "@ignore@", + "identifier" : "@ignore@", + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "code" : "@ignore@", + "visibility" : "Parent", + "description" : "@ignore@", + "index" : 1, + "mimeType" : "application/vnd.ekstep.content-collection", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "versionKey" : "@ignore@", + "depth" : 1, + "children" : [ { + "ownershipType" : [ "createdBy" ], + "parent" : "@ignore@", + "previewUrl" : "@ignore@", + "code" : "kp.ft.resource.ecml", + "downloadUrl" : "@ignore@", + "channel" : "channel-01", + "description" : "KP Integration Test Content", + "language" : [ "English" ], + "variants" : { + "spine" : { + "ecarUrl" : "@ignore@", + "size" : "@isNumber()@" + } + }, + "streamingUrl" :"@ignore@", + "mimeType" : "application/vnd.ekstep.ecml-archive", + "idealScreenSize" : "normal", + "publishComment" : "OK", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentDisposition" : "inline", + "artifactUrl" : "@ignore@", + "contentEncoding" : "gzip", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "SYS_INTERNAL_LAST_UPDATED_ON" : "@matchesDatePattern('yyyy-MM-dd')@", + "dialcodeRequired" : "No", + "contentType" : "Resource", + "lastUpdatedBy" : "KP_FT_PUBLISHER", + "identifier" : "@ignore@", + "audience" : [ "Learner" ], + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "os" : [ "All" ], + "visibility" : "Default", + "consumerId" : "@ignore@", + "index" : 1, + "mediaType" : "content", + "osId" : "org.ekstep.quiz.app", + "lastPublishedBy" : "KP_FT_PUBLISHER", + "version" : "@isNumber()@", + "pkgVersion" : "@isNumber()@", + "versionKey" : "@ignore@", + "license" : "CC BY 4.0", + "idealScreenDensity" : "hdpi", + "s3Key" : "@ignore@", + "framework" : "NCF", + "depth" : 2, + "size" : "@isNumber()@", + "lastPublishedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "compatibilityLevel" : "@isNumber()@", + "name" : "KP Integration Test Content", + "publisher" : "KP_FT_PUBLISHER", + "status" : "Live" + } ], + "name" : "@ignore@", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentType" : "TextBook", + "status" : "Draft" + } ], + "contentDisposition" : "inline", + "contentEncoding" : "gzip", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "dialcodeRequired" : "No", + "contentType" : "TextBook", + "audience" : [ "Learner" ], + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "os" : [ "All" ], + "visibility" : "Default", + "childNodes" : "@ignore@", + "consumerId" : "@ignore@", + "mediaType" : "content", + "osId" : "org.ekstep.quiz.app", + "version" : "@isNumber()@", + "versionKey" : "@ignore@", + "license" : "CC BY 4.0", + "idealScreenDensity" : "hdpi", + "depth" : 0, + "framework" : "NCF", + "compatibilityLevel" : "@isNumber()@", + "name" : "KP Integration Test Collection Content", + "status" : "Draft" + } + } +} \ No newline at end of file diff --git a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyBeforeUpdate/response.json b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyBeforeUpdate/response.json new file mode 100644 index 00000000..aaae515b --- /dev/null +++ b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyBeforeUpdate/response.json @@ -0,0 +1,14 @@ +{ + "id" : "api.content.hierarchy.get", + "ver" : "3.0", + "ts" : "@matchesDatePattern('yyyy-MM-dd')@", + "params" : { + "resmsgid" : "@ignore@", + "msgid" : null, + "err" : "RESOURCE_NOT_FOUND", + "status" : "failed", + "errmsg" : "@ignore@" + }, + "responseCode" : "RESOURCE_NOT_FOUND", + "result" : { } +} \ No newline at end of file diff --git a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyBeforeUpdateWithMode/response.json b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyBeforeUpdateWithMode/response.json new file mode 100644 index 00000000..bdef44cc --- /dev/null +++ b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyBeforeUpdateWithMode/response.json @@ -0,0 +1,45 @@ +{ + "id" : "api.content.hierarchy.get", + "ver" : "3.0", + "ts" : "@matchesDatePattern('yyyy-MM-dd')@", + "params" : { + "resmsgid" : "@ignore@", + "msgid" : null, + "err" : null, + "status" : "successful", + "errmsg" : null + }, + "responseCode" : "OK", + "result" : { + "content" : { + "ownershipType" : [ "createdBy" ], + "code" : "kp.ft.collection.textbook", + "channel" : "channel-01", + "description" : "KP Integration Test Collection Content", + "language" : [ "English" ], + "mimeType" : "application/vnd.ekstep.content-collection", + "idealScreenSize" : "normal", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentDisposition" : "inline", + "contentEncoding" : "gzip", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "dialcodeRequired" : "No", + "contentType" : "TextBook", + "audience" : [ "Learner" ], + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "os" : [ "All" ], + "visibility" : "Default", + "consumerId" : "@ignore@", + "mediaType" : "content", + "osId" : "org.ekstep.quiz.app", + "version" : "@isNumber()@", + "versionKey" : "@ignore@", + "license" : "CC BY 4.0", + "idealScreenDensity" : "hdpi", + "framework" : "NCF", + "compatibilityLevel" : "@isNumber()@", + "name" : "KP Integration Test Collection Content", + "status" : "Draft" + } + } +} \ No newline at end of file From 30412c82204b607e9b828828b381f19c1a9cb55d Mon Sep 17 00:00:00 2001 From: neha0305verma Date: Fri, 27 Dec 2019 14:49:08 +0530 Subject: [PATCH 4/6] gethierarchy ft --- .../kp/test/common/BaseCitrusTestRunner.java | 1 + .../kp/test/content/v3/ContentV3Scenario.java | 12 +-- .../kp/test/content/v3/getHierarchyTest.java | 97 +++++++++--------- .../sunbird/kp/test/util/CollectionUtil.java | 50 ---------- .../kp/test/util/WorkflowConstants.java | 3 +- .../testGetHierarchyAfterFlag/response.json | 98 +++++++++++++++++++ .../testGetHierarchyAfterRetire/response.json | 14 +++ .../response_image.json} | 2 +- .../response_image.json} | 0 .../response_image.json} | 0 10 files changed, 165 insertions(+), 112 deletions(-) create mode 100644 kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterFlag/response.json create mode 100644 kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterRetire/response.json rename kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/{testGetHierarchyAfterReviewWithMode/response.json => testGetHierarchyAfterReview/response_image.json} (99%) rename kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/{testGetHierarchyAfterUpdateWithMode/response.json => testGetHierarchyAfterUpdate/response_image.json} (100%) rename kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/{testGetHierarchyBeforeUpdateWithMode/response.json => testGetHierarchyBeforeUpdate/response_image.json} (100%) diff --git a/kp_service_test/src/test/java/org/sunbird/kp/test/common/BaseCitrusTestRunner.java b/kp_service_test/src/test/java/org/sunbird/kp/test/common/BaseCitrusTestRunner.java index 7e948aec..9d53a32b 100644 --- a/kp_service_test/src/test/java/org/sunbird/kp/test/common/BaseCitrusTestRunner.java +++ b/kp_service_test/src/test/java/org/sunbird/kp/test/common/BaseCitrusTestRunner.java @@ -27,6 +27,7 @@ public class BaseCitrusTestRunner extends TestNGCitrusTestRunner { public static final String REQUEST_JSON = "request.json"; public static final String RESPONSE_JSON = "response.json"; public static final String VALIDATE_JSON = "validate.json"; + public static final String RESPONSE_JSON_IMAGE = "response_image.json"; private static final String API_KEY = AppConfig.config.getString("kp_api_key"); private static final Boolean IS_USER_AUTH_REQUIRED = AppConfig.config.getBoolean("user_auth_enable"); diff --git a/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/ContentV3Scenario.java b/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/ContentV3Scenario.java index bfd1140c..286dfbfc 100644 --- a/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/ContentV3Scenario.java +++ b/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/ContentV3Scenario.java @@ -477,16 +477,6 @@ public class ContentV3Scenario { public static final String TEST_GET_HIERARCHY_AFTER_FLAG_ACCEPT = "testGetHierarchyAfterFlagAccept"; public static final String TEST_GET_HIERARCHY_AFTER_DISCARD = "testGetHierarchyAfterDiscard"; public static final String TEST_GET_HIERARCHY_AFTER_RETIRE = "testGetHierarchyAfterRetire"; - public static final String TEST_GET_HIERARCHY_AFTER_UPDATE_LIVE = "testGetHierarchyAfterRetire"; - public static final String TEST_GET_HIERARCHY_BEFORE_UPDATE_WITH_MODE = "testGetHierarchyBeforeUpdateWithMode"; - public static final String TEST_GET_HIERARCHY_AFTER_UPDATE_WITH_MODE = "testGetHierarchyAfterUpdateWithMode"; - public static final String TEST_GET_HIERARCHY_AFTER_REVIEW_WITH_MODE = "testGetHierarchyAfterReviewWithMode"; - public static final String TEST_GET_HIERARCHY_AFTER_REJECT_WITH_MODE = "testGetHierarchyAfterRejectWithMode"; - public static final String TEST_GET_HIERARCHY_AFTER_FLAG_WITH_MODE = "testGetHierarchyAfterFlagWithMode"; - public static final String TEST_GET_HIERARCHY_AFTER_FLAG_REJECT_WITH_MODE = "testGetHierarchyAfterFlagRejectWithMode"; - public static final String TEST_GET_HIERARCHY_AFTER_FLAG_ACCEPT_WITH_MODE = "testGetHierarchyAfterFlagAcceptWithMode"; - public static final String TEST_GET_HIERARCHY_AFTER_DISCARD_WITH_MODE = "testGetHierarchyAfterDiscardWithMode"; - public static final String TEST_GET_HIERARCHY_AFTER_RETIRE_WITH_MODE = "testGetHierarchyAfterRetireWithMode"; - public static final String TEST_GET_HIERARCHY_AFTER_UPDATE_LIVE_WITH_MODE = "testGetHierarchyAfterRetireWithMode"; + public static final String TEST_GET_HIERARCHY_AFTER_UPDATE_LIVE = "testGetHierarchyAfterUpdateLive"; } diff --git a/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/getHierarchyTest.java b/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/getHierarchyTest.java index 82d4ba19..0c120ab0 100644 --- a/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/getHierarchyTest.java +++ b/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/getHierarchyTest.java @@ -34,19 +34,16 @@ public class getHierarchyTest extends BaseCitrusTestRunner { // @AfterClass // public static void populateAssertionData() { // TestSetupUtil.createDirectoriesForTestCases(dirIdMap, "response.json", TEMPLATE_DIR); +//// TestSetupUtil.createDirectoriesForTestCases(dirIdMap, "response_image.json", TEMPLATE_DIR); // } @Test(dataProvider = "getHierarchyWithValidRequest") - @CitrusParameters ({"testName", "workFlowStatus", "payload", "collectionType", "resourceCount", "publish"}) + @CitrusParameters ({"testName", "workFlowStatus", "payload", "collectionType", "resourceCount"}) @CitrusTest - public void getHierarchyWithValidRequest(String testName, String workFlowStatus, String payload, String collectionType, Integer resourceCount, Boolean publish) { + public void getHierarchyWithValidRequest(String testName, String workFlowStatus, String payload, String collectionType, Integer resourceCount) { Map collectionMap = CollectionUtil.prepareTestCollection(workFlowStatus, this, new HashMap() {{put("updateHierarchy", payload);}}, collectionType, 0, resourceCount, "application/vnd.ekstep.ecml-archive"); identifier = (String) collectionMap.get("content_id"); - if(publish){ - ContentUtil.publishContent(this, null, "public", identifier, null); - } this.variable("rootId", identifier); - //dirIdMap.put(testName, identifier); performGetTest( this, TEMPLATE_DIR, @@ -66,7 +63,7 @@ public void getHierarchyWithInvalidRequest(String testName, String workFlowStatu Map collectionMap = CollectionUtil.prepareTestCollection(workFlowStatus, this, new HashMap() {{put("updateHierarchy", payload);}}, collectionType, 0, resourceCount, "application/vnd.ekstep.ecml-archive"); identifier = (String) collectionMap.get("content_id"); - ContentUtil.publishContent(this, null, "public", identifier, null); + //ContentUtil.publishContent(this, null, "public", identifier, null); performGetTest( this, TEMPLATE_DIR, @@ -100,11 +97,12 @@ public void getHierarchyWithMode(String testName, String workFlowStatus, String ); } - @Test(dataProvider = "getHierarchyWithDifferentStatusWithoutMode") + @Test(dataProvider = "getHierarchyWithDifferentStatus") @CitrusParameters ({"testName", "workFlowStatus", "payload", "collectionType", "resourceCount"}) @CitrusTest - public void getHierarchyWithDifferentStatusWithoutMode(String testName, String workFlowStatus, String payload, String collectionType, Integer resourceCount) { - Map collectionMap = CollectionUtil.prepareTestCollectionWithoutUpdateHierarchy(workFlowStatus, this,null, collectionType, 0, resourceCount, "application/vnd.ekstep.ecml-archive"); + public void getHierarchyWithDifferentStatus(String testName, String workFlowStatus, String payload, String collectionType, Integer resourceCount) { + Map collectionMap = CollectionUtil.prepareTestCollection(workFlowStatus, this, + new HashMap() {{put("updateHierarchy", payload);}}, collectionType, 0, resourceCount, "application/vnd.ekstep.ecml-archive"); identifier = (String) collectionMap.get("content_id"); this.variable("rootId", identifier); //dirIdMap.put(testName, identifier); @@ -114,48 +112,58 @@ public void getHierarchyWithDifferentStatusWithoutMode(String testName, String w testName, APIUrl.READ_CONTENT_HIERARCHY + identifier, null, - HttpStatus.OK, + HttpStatus.NOT_FOUND, null, RESPONSE_JSON ); +// performGetTest( +// this, +// TEMPLATE_DIR, +// testName, +// APIUrl.READ_CONTENT_HIERARCHY + identifier + MODE + "edit", +// null, +// HttpStatus.OK, +// null, +// RESPONSE_JSON_IMAGE +// ); } - @Test(dataProvider = "getHierarchyWithDifferentStatusWithMode") - @CitrusParameters ({"testName", "workFlowStatus", "payload", "collectionType", "resourceCount", "mode"}) + @Test @CitrusTest - public void getHierarchyWithDifferentStatusWithMode(String testName, String workFlowStatus, String payload, String collectionType, Integer resourceCount, String mode) { - Map collectionMap = CollectionUtil.prepareTestCollectionWithoutUpdateHierarchy(workFlowStatus, this,null, collectionType, 0, resourceCount, "application/vnd.ekstep.ecml-archive"); + public void getHierarchyAfterReview(){ + Map collectionMap = CollectionUtil.prepareTestCollection("collectionReview", this, + new HashMap() {{put("updateHierarchy", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE);}}, "textBook", 0, 1, "application/vnd.ekstep.ecml-archive"); identifier = (String) collectionMap.get("content_id"); this.variable("rootId", identifier); - //dirIdMap.put(testName, identifier); performGetTest( this, TEMPLATE_DIR, - testName, - APIUrl.READ_CONTENT_HIERARCHY + identifier + MODE + mode, + ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_REVIEW, + APIUrl.READ_CONTENT_HIERARCHY + identifier, null, - HttpStatus.OK, + HttpStatus.NOT_FOUND, null, RESPONSE_JSON ); + performGetTest( + this, + TEMPLATE_DIR, + ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_REVIEW, + APIUrl.READ_CONTENT_HIERARCHY + identifier + MODE + "edit", + null, + HttpStatus.OK, + null, + RESPONSE_JSON_IMAGE + ); } + @DataProvider public static Object[][] getHierarchyWithValidRequest() { return new Object[][]{ new Object[]{ ContentV3Scenario.TEST_GET_HIERARCHY_WITH_VALID_IDENTIFIER, "collectionUnitsInLive", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1, true - }, - new Object[]{ - ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_UPDATE, "collectionUnitsInDraft", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1, true - }, - new Object[]{ - ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_REVIEW, "collectionReview", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1, false - }, - new Object[]{ - ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_RETIRE, "collectionRetire", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1, false } - }; } @@ -182,33 +190,24 @@ public static Object[][] getHierarchyWithMode() { }, new Object[]{ ContentV3Scenario.TEST_GET_HIERARCHY_WITH_NULL_MODE, "collectionUnitsInLive", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1, null - }, - new Object[]{ - ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_UPDATE_WITH_MODE, "collectionUnitsInDraft", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1, "edit" - }, - new Object[]{ - ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_REVIEW_WITH_MODE, "collectionReview", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1, "edit" - }, - new Object[]{ - ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_RETIRE_WITH_MODE, "collectionRetire", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1, "edit" - } - }; - } - - @DataProvider - public static Object[][] getHierarchyWithDifferentStatusWithoutMode() { - return new Object[][]{ - new Object[]{ - ContentV3Scenario.TEST_GET_HIERARCHY_BEFORE_UPDATE, "collectionCreate", null, "textBook", 1 } }; } @DataProvider - public static Object[][] getHierarchyWithDifferentStatusWithMode() { + public static Object[][] getHierarchyWithDifferentStatus() { return new Object[][]{ +// new Object[]{ +// ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_UPDATE, "collectionUnitsInDraft", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1 +// }, +// new Object[]{ +// ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_RETIRE, "collectionRetire", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1 +// }, +// new Object[]{ +// ContentV3Scenario.TEST_GET_HIERARCHY_BEFORE_UPDATE, "collectionCreate", null, "textBook", 1 +// }, new Object[]{ - ContentV3Scenario.TEST_GET_HIERARCHY_BEFORE_UPDATE_WITH_MODE, "collectionCreate", null, "textBook", 1, "edit" + ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_FLAG, "collectionInFlagged", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1 } }; } diff --git a/kp_service_test/src/test/java/org/sunbird/kp/test/util/CollectionUtil.java b/kp_service_test/src/test/java/org/sunbird/kp/test/util/CollectionUtil.java index c148addf..59960aba 100644 --- a/kp_service_test/src/test/java/org/sunbird/kp/test/util/CollectionUtil.java +++ b/kp_service_test/src/test/java/org/sunbird/kp/test/util/CollectionUtil.java @@ -120,54 +120,4 @@ public static List getLiveAsset(BaseCitrusTestRunner runner, Integer ass }); return assetIds; } - - /** - * This method will add resources or asset to a Payload collection provided as user's requirements. - * The number of asset or resources to be created should be equal to the placeholders in the dynamic payload. - *

- * Resource placeholder should be resource_N, for eg: resource_1 - * Asset placeholder should be resource_N for eg: asset_2. - * - * @param workFlow (Mandatory) - * @param runner - * @param payloadMap (Mandatory -> Send new HashMap with (updateHierarchy -> Payload String), If you want to custom resource, pass createResource) - * @param collectionType (For valid collection type see ContentUtil) - * @param assetCount (Number of assets that are needed to replace in the payload) - * @param resourceCount (Number of resources that are needed to replace in the payload - * @param mimeType (This field is optional and can be passed as null for random valid mimeType generation - * @return a map of all the resources/assets added, all unit identifiers and textBook identifier - * @see ContentUtil - */ - public static Map prepareTestCollectionWithoutUpdateHierarchy(String workFlow, BaseCitrusTestRunner runner, Map payloadMap, String collectionType, - Integer assetCount, Integer resourceCount, String mimeType) { - Map collectionMap = new HashMap<>(); - collectionMap.putAll(ContentUtil.createCollectionContent(runner, null, collectionType, null)); - - //Map also has identifiers which is a map of all id's of unit's etc TODO: Return that too - String contentId = (String) collectionMap.get("content_id"); - runner.variable("collectionIdVal", contentId); - runner.variable("versionKey", collectionMap.get("versionKey")); - Map collectionWorkMap = null; - try { - collectionWorkMap = mapper.readValue(WorkflowConstants.collectionWorkFlows, new TypeReference>() { - }); - List contentWorkList = (List) collectionWorkMap.get(workFlow); - Map>> actionMap = ContentUtil.getCollectionWorkFlowMap(runner, contentId, null, null, null); - if (!CollectionUtils.isEmpty(contentWorkList)) { - contentWorkList.forEach(action -> { - Map response = actionMap.get(action).get(); - if (response.get("content") != null) - response = (Map) response.get("content"); - if( null != response.get("identifiers")) - collectionMap.put("identifiers", response.get("identifiers")); - if (StringUtils.isNotBlank((String) response.get("versionKey"))) - runner.variable("versionKeyVal", response.get("versionKey")); - }); - } - } catch (IOException e) { - e.printStackTrace(); - } -// collectionMap = ContentUtil.readCollectionHierarchy(runner, contentId) - return collectionMap; - } } diff --git a/kp_service_test/src/test/java/org/sunbird/kp/test/util/WorkflowConstants.java b/kp_service_test/src/test/java/org/sunbird/kp/test/util/WorkflowConstants.java index ccb3f15e..94e95fe6 100644 --- a/kp_service_test/src/test/java/org/sunbird/kp/test/util/WorkflowConstants.java +++ b/kp_service_test/src/test/java/org/sunbird/kp/test/util/WorkflowConstants.java @@ -40,7 +40,8 @@ public class WorkflowConstants { "\"collectionUnitsResourcesInDraft\":[\"CreateResources\", \"Update\"],\n" + "\"collectionCreate\":[\"Create\"],\n"+ "\"collectionReview\":[\"Update\", \"Review\"],\n"+ - "\"collectionRetire\":[\"Update\", \"Publish\", \"Retire\"]\n"+ + "\"collectionRetire\":[\"Update\", \"Publish\", \"Retire\"],\n"+ + "\"collectionInFlagged\":[\"Update\", \"Publish\", \"Flag\"]\n"+ "}"; } diff --git a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterFlag/response.json b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterFlag/response.json new file mode 100644 index 00000000..bf0aaabc --- /dev/null +++ b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterFlag/response.json @@ -0,0 +1,98 @@ +{ + "id" : "api.content.hierarchy.get", + "ver" : "3.0", + "ts" : "@matchesDatePattern('yyyy-MM-dd')@", + "params" : { + "resmsgid" : "@ignore@", + "msgid" : null, + "err" : null, + "status" : "successful", + "errmsg" : null + }, + "responseCode" : "OK", + "result" : { + "content" : { + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "children" : [ { + "parent" : "@ignore@", + "identifier" : "@ignore@", + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "code" : "@ignore@", + "visibility" : "Parent", + "description" : "@ignore@", + "index" : 1, + "mimeType" : "application/vnd.ekstep.content-collection", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "versionKey" : "@ignore@", + "depth" : 1, + "children" : [ ], + "name" : "@ignore@", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentType" : "TextBook", + "status" : "Live", + "compatibilityLevel" : "@isNumber()@", + "lastPublishedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "pkgVersion" : "@isNumber()@", + "leafNodesCount" : "@isNumber()@", + "downloadUrl" : "@ignore@", + "variants" : "@ignore@" + } ], + "mediaType" : "content", + "name" : "KP Integration Test Collection Content", + "toc_url" : "@ignore@", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "channel" : "channel-01", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "size" : "@isNumber()@", + "identifier" : "${rootId}", + "description" : "KP Integration Test Collection Content", + "ownershipType" : [ "createdBy" ], + "compatibilityLevel" : "@isNumber()@", + "audience" : [ "Learner" ], + "os" : [ "All" ], + "SYS_INTERNAL_LAST_UPDATED_ON" : "@matchesDatePattern('yyyy-MM-dd')@", + "downloadUrl" : "@ignore@", + "framework" : "NCF", + "totalCompressedSize" : "@isNumber()@", + "versionKey" : "@ignore@", + "mimeType" : "application/vnd.ekstep.content-collection", + "code" : "kp.ft.collection.textbook", + "license" : "CC BY 4.0", + "version" : "@isNumber()@", + "contentType" : "TextBook", + "language" : [ "English" ], + "lastPublishedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentTypesCount" : "{\"TextBook\":1}", + "objectType" : "Content", + "lastUpdatedBy" : "KP_FT_PUBLISHER", + "status" : "Live", + "publisher" : "KP_FT_PUBLISHER", + "publishComment" : "OK", + "dialcodeRequired" : "No", + "idealScreenSize" : "normal", + "contentEncoding" : "gzip", + "leafNodesCount" : "@isNumber()@", + "depth" : 0, + "consumerId" : "@ignore@", + "lastPublishedBy" : "KP_FT_PUBLISHER", + "mimeTypesCount" : "{\"application/vnd.ekstep.content-collection\":1}", + "osId" : "org.ekstep.quiz.app", + "s3Key" : "@ignore@", + "contentDisposition" : "inline", + "childNodes" : "@ignore@", + "visibility" : "Default", + "variants" : { + "online" : { + "ecarUrl" : "@ignore@", + "size" : "@isNumber()@" + }, + "spine" : { + "ecarUrl" : "@ignore@", + "size" : "@isNumber()@" + } + }, + "pkgVersion" : "@isNumber()@", + "idealScreenDensity" : "hdpi" + } + } +} \ No newline at end of file diff --git a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterRetire/response.json b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterRetire/response.json new file mode 100644 index 00000000..36e9505f --- /dev/null +++ b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterRetire/response.json @@ -0,0 +1,14 @@ +{ + "id": "api.content.hierarchy.get", + "ver": "3.0", + "ts": "@matchesDatePattern('yyyy-MM-dd')@", + "params": { + "resmsgid": "@ignore@", + "msgid": null, + "err": "RESOURCE_NOT_FOUND", + "status": "failed", + "errmsg": "@ignore@" + }, + "responseCode": "RESOURCE_NOT_FOUND", + "result": {} +} \ No newline at end of file diff --git a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterReviewWithMode/response.json b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterReview/response_image.json similarity index 99% rename from kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterReviewWithMode/response.json rename to kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterReview/response_image.json index 99cc0844..b035ff77 100644 --- a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterReviewWithMode/response.json +++ b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterReview/response_image.json @@ -60,7 +60,7 @@ "dialcodeRequired" : "No", "contentType" : "Resource", "lastUpdatedBy" : "KP_FT_PUBLISHER", - "identifier" : "${rootId}", + "identifier" : "@ignore@", "audience" : [ "Learner" ], "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", "os" : [ "All" ], diff --git a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterUpdateWithMode/response.json b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterUpdate/response_image.json similarity index 100% rename from kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterUpdateWithMode/response.json rename to kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterUpdate/response_image.json diff --git a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyBeforeUpdateWithMode/response.json b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyBeforeUpdate/response_image.json similarity index 100% rename from kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyBeforeUpdateWithMode/response.json rename to kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyBeforeUpdate/response_image.json From 064b77735981e7fc83270c0abbd54682a05a7ec2 Mon Sep 17 00:00:00 2001 From: Neha Verma Date: Tue, 7 Jan 2020 10:51:12 +0530 Subject: [PATCH 5/6] FT added for live and image nodes --- .../kp/test/content/v3/getHierarchyTest.java | 92 ++++++++--- .../sunbird/kp/test/util/CollectionUtil.java | 27 ++-- .../sunbird/kp/test/util/TestSetupUtil.java | 6 +- .../kp/test/util/WorkflowConstants.java | 8 +- .../testGetHierarchyAfterFlag/response.json | 61 +++++++- .../response_image.json | 148 ++++++++++++++++++ .../response_image.json | 7 +- .../response_image.json | 13 +- .../request.json | 3 +- 9 files changed, 318 insertions(+), 47 deletions(-) create mode 100644 kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterFlag/response_image.json diff --git a/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/getHierarchyTest.java b/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/getHierarchyTest.java index 0c120ab0..4926cc08 100644 --- a/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/getHierarchyTest.java +++ b/kp_service_test/src/test/java/org/sunbird/kp/test/content/v3/getHierarchyTest.java @@ -31,11 +31,11 @@ public class getHierarchyTest extends BaseCitrusTestRunner { private String identifier; private static Map dirIdMap = new HashMap<>(); -// @AfterClass -// public static void populateAssertionData() { -// TestSetupUtil.createDirectoriesForTestCases(dirIdMap, "response.json", TEMPLATE_DIR); -//// TestSetupUtil.createDirectoriesForTestCases(dirIdMap, "response_image.json", TEMPLATE_DIR); -// } + @AfterClass + public static void populateAssertionData() { + // TestSetupUtil.createDirectoriesForTestCases(dirIdMap, "response.json", TEMPLATE_DIR); + TestSetupUtil.createDirectoriesForTestCases(dirIdMap, "response_image.json", TEMPLATE_DIR); + } @Test(dataProvider = "getHierarchyWithValidRequest") @CitrusParameters ({"testName", "workFlowStatus", "payload", "collectionType", "resourceCount"}) @@ -97,35 +97,66 @@ public void getHierarchyWithMode(String testName, String workFlowStatus, String ); } - @Test(dataProvider = "getHierarchyWithDifferentStatus") + @Test(dataProvider = "getHierarchyLiveAndImageNodes") @CitrusParameters ({"testName", "workFlowStatus", "payload", "collectionType", "resourceCount"}) @CitrusTest - public void getHierarchyWithDifferentStatus(String testName, String workFlowStatus, String payload, String collectionType, Integer resourceCount) { + public void getHierarchyLiveAndImageNodes(String testName, String workFlowStatus, String payload, String collectionType, Integer resourceCount) { Map collectionMap = CollectionUtil.prepareTestCollection(workFlowStatus, this, new HashMap() {{put("updateHierarchy", payload);}}, collectionType, 0, resourceCount, "application/vnd.ekstep.ecml-archive"); identifier = (String) collectionMap.get("content_id"); this.variable("rootId", identifier); - //dirIdMap.put(testName, identifier); + // dirIdMap.put(testName, identifier); +// performGetTest( +// this, +// TEMPLATE_DIR, +// testName, +// APIUrl.READ_CONTENT_HIERARCHY + identifier, +// null, +// HttpStatus.OK, +// null, +// RESPONSE_JSON +// ); performGetTest( this, TEMPLATE_DIR, testName, - APIUrl.READ_CONTENT_HIERARCHY + identifier, + APIUrl.READ_CONTENT_HIERARCHY + identifier + MODE + "edit", null, - HttpStatus.NOT_FOUND, + HttpStatus.OK, null, - RESPONSE_JSON + RESPONSE_JSON_IMAGE ); + } + + @Test(dataProvider = "getHierarchyImageNodes") + @CitrusParameters ({"testName", "workFlowStatus", "payload", "collectionType", "resourceCount"}) + @CitrusTest + public void getHierarchyImageNodes(String testName, String workFlowStatus, String payload, String collectionType, Integer resourceCount) { + Map collectionMap = CollectionUtil.prepareTestCollection(workFlowStatus, this, + new HashMap() {{put("updateHierarchy", payload);}}, collectionType, 0, resourceCount, "application/vnd.ekstep.ecml-archive"); + identifier = (String) collectionMap.get("content_id"); + this.variable("rootId", identifier); + // dirIdMap.put(testName, identifier); // performGetTest( // this, // TEMPLATE_DIR, // testName, -// APIUrl.READ_CONTENT_HIERARCHY + identifier + MODE + "edit", +// APIUrl.READ_CONTENT_HIERARCHY + identifier, // null, -// HttpStatus.OK, +// HttpStatus.NOT_FOUND, // null, -// RESPONSE_JSON_IMAGE +// RESPONSE_JSON // ); + performGetTest( + this, + TEMPLATE_DIR, + testName, + APIUrl.READ_CONTENT_HIERARCHY + identifier + MODE + "edit", + null, + HttpStatus.OK, + null, + RESPONSE_JSON_IMAGE + ); } @Test @@ -195,20 +226,41 @@ public static Object[][] getHierarchyWithMode() { } @DataProvider - public static Object[][] getHierarchyWithDifferentStatus() { + public static Object[][] getHierarchyLiveAndImageNodes() { return new Object[][]{ // new Object[]{ -// ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_UPDATE, "collectionUnitsInDraft", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1 +// ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_RETIRE, "collectionRetire", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1 // }, // new Object[]{ -// ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_RETIRE, "collectionRetire", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1 +// ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_FLAG, "collectionInFlagged", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1 +// } +// //, +// new Object[]{ +// ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_FLAG_ACCEPT, "contentInFlagDraft", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1 +// } + //, +// new Object[]{ +// ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_FLAG_REJECT, "collectionInFlagged", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1 // }, // new Object[]{ -// ContentV3Scenario.TEST_GET_HIERARCHY_BEFORE_UPDATE, "collectionCreate", null, "textBook", 1 +// ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_DISCARD, "collectionDiscarded", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1 +// }, +// new Object[]{ +// ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_UPDATE_LIVE, "collectionUnitsInLiveUpdate", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1 +// }, + + }; + } + + @DataProvider + public static Object[][] getHierarchyImageNodes() { + return new Object[][]{ +// new Object[]{ +// ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_UPDATE, "collectionUnitsInDraft", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1 // }, new Object[]{ - ContentV3Scenario.TEST_GET_HIERARCHY_AFTER_FLAG, "collectionInFlagged", CollectionUtilPayload.UPDATE_HIERARCHY_1_UNIT_1_RESOURCE, "textBook", 1 - } + ContentV3Scenario.TEST_GET_HIERARCHY_BEFORE_UPDATE, "collectionCreate", null, "textBook", 1 + }, }; } } diff --git a/kp_service_test/src/test/java/org/sunbird/kp/test/util/CollectionUtil.java b/kp_service_test/src/test/java/org/sunbird/kp/test/util/CollectionUtil.java index 59960aba..a0b0a671 100644 --- a/kp_service_test/src/test/java/org/sunbird/kp/test/util/CollectionUtil.java +++ b/kp_service_test/src/test/java/org/sunbird/kp/test/util/CollectionUtil.java @@ -48,20 +48,23 @@ public class CollectionUtil { */ public static Map prepareTestCollection(String workFlow, BaseCitrusTestRunner runner, Map payloadMap, String collectionType, Integer assetCount, Integer resourceCount, String mimeType) { - String updateHierarchyPayload = payloadMap.get("updateHierarchy"); + String updateHierarchyPayload = null; Map collectionMap = new HashMap<>(); - if (assetCount != 0) { - List assetIds = getLiveAsset(runner, assetCount, mimeType); - for (String assetId : assetIds) { - collectionMap.put("asset_" + (assetIds.indexOf(assetId) + 1), assetId); - updateHierarchyPayload = updateHierarchyPayload.replace("asset_" + (assetIds.indexOf(assetId) + 1), assetId); + if(!StringUtils.isEmpty(payloadMap.get("updateHierarchy"))) { + updateHierarchyPayload = payloadMap.get("updateHierarchy"); + if (assetCount != 0) { + List assetIds = getLiveAsset(runner, assetCount, mimeType); + for (String assetId : assetIds) { + collectionMap.put("asset_" + (assetIds.indexOf(assetId) + 1), assetId); + updateHierarchyPayload = updateHierarchyPayload.replace("asset_" + (assetIds.indexOf(assetId) + 1), assetId); + } } - } - if (resourceCount != 0) { - List resourceIds = getLiveResources(runner, resourceCount, mimeType, payloadMap.get("createResource")); - for (String resourceId : resourceIds) { - collectionMap.put("resource_" + (resourceIds.indexOf(resourceId) + 1), resourceId); - updateHierarchyPayload = updateHierarchyPayload.replace("resource_" + (resourceIds.indexOf(resourceId) + 1), resourceId); + if (resourceCount != 0) { + List resourceIds = getLiveResources(runner, resourceCount, mimeType, payloadMap.get("createResource")); + for (String resourceId : resourceIds) { + collectionMap.put("resource_" + (resourceIds.indexOf(resourceId) + 1), resourceId); + updateHierarchyPayload = updateHierarchyPayload.replace("resource_" + (resourceIds.indexOf(resourceId) + 1), resourceId); + } } } collectionMap.putAll(ContentUtil.createCollectionContent(runner, null, collectionType, null)); diff --git a/kp_service_test/src/test/java/org/sunbird/kp/test/util/TestSetupUtil.java b/kp_service_test/src/test/java/org/sunbird/kp/test/util/TestSetupUtil.java index af2d848b..7b18a4cf 100644 --- a/kp_service_test/src/test/java/org/sunbird/kp/test/util/TestSetupUtil.java +++ b/kp_service_test/src/test/java/org/sunbird/kp/test/util/TestSetupUtil.java @@ -55,9 +55,11 @@ private static void populateDataIntoValidateFiles(String mainDir, String directo FileWriter fileWriter = new FileWriter(file.getPath() + "/" + fileName); // HttpResponse jsonNode = Unirest.get(AppConfig.config.getString("kp_base_uri") + "/content/v3/read/" + contentId + "").asString(); - HttpResponse jsonNode = Unirest.get(AppConfig.config.getString("kp_content_service_base_uri") + "/content/v3/hierarchy/" + contentId).asString(); +// HttpResponse jsonNode = Unirest.get(AppConfig.config.getString("kp_base_uri") + "/content/v3/hierarchy/" + contentId).asString(); -// HttpResponse jsonNode = Unirest.get(AppConfig.config.getString("kp_content_service_base_uri") + "/content/v3/hierarchy/" + contentId + "?mode=edit"").asString(); + HttpResponse jsonNode = Unirest.get(AppConfig.config.getString("kp_base_uri") + "/content/v3/hierarchy/" + contentId + "?mode=edit").asString(); + + //kp_content_service_base_uri Response response = objectMapper.readValue(jsonNode.getBody(), Response.class); fileWriter.write(formGeneralAssertions(response)); fileWriter.close(); diff --git a/kp_service_test/src/test/java/org/sunbird/kp/test/util/WorkflowConstants.java b/kp_service_test/src/test/java/org/sunbird/kp/test/util/WorkflowConstants.java index 94e95fe6..f6004703 100644 --- a/kp_service_test/src/test/java/org/sunbird/kp/test/util/WorkflowConstants.java +++ b/kp_service_test/src/test/java/org/sunbird/kp/test/util/WorkflowConstants.java @@ -40,8 +40,12 @@ public class WorkflowConstants { "\"collectionUnitsResourcesInDraft\":[\"CreateResources\", \"Update\"],\n" + "\"collectionCreate\":[\"Create\"],\n"+ "\"collectionReview\":[\"Update\", \"Review\"],\n"+ - "\"collectionRetire\":[\"Update\", \"Publish\", \"Retire\"],\n"+ - "\"collectionInFlagged\":[\"Update\", \"Publish\", \"Flag\"]\n"+ + "\"collectionRetire\":[\"Retire\"],\n"+ + "\"collectionInFlagged\":[\"Update\", \"Publish\", \"Get\", \"Flag\"],\n"+ + "\"contentInFlagDraft\" : [\"Update\", \"Publish\", \"Get\", \"Flag\", \"AcceptFlag\"],\n" + + "\"contentInFlagReject\" : [\"Update\", \"Publish\", \"Get\", \"Flag\", \"RejectFlag\"],\n" + + "\"collectionDiscarded\":[\"Discard\"],\n"+ + "\"collectionUnitsInLiveUpdate\":[\"Update\", \"Publish\", \"Update\"]\n" + "}"; } diff --git a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterFlag/response.json b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterFlag/response.json index bf0aaabc..c3838deb 100644 --- a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterFlag/response.json +++ b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterFlag/response.json @@ -25,7 +25,59 @@ "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", "versionKey" : "@ignore@", "depth" : 1, - "children" : [ ], + "children" : [ { + "ownershipType" : [ "createdBy" ], + "previewUrl" : "@ignore@", + "code" : "kp.ft.resource.ecml", + "downloadUrl" : "@ignore@", + "channel" : "channel-01", + "description" : "KP Integration Test Content", + "language" : [ "English" ], + "variants" : { + "spine" : { + "ecarUrl" : "@ignore@", + "size" : "@isNumber()@" + } + }, + "streamingUrl" :"@ignore@", + "mimeType" : "application/vnd.ekstep.ecml-archive", + "idealScreenSize" : "normal", + "publishComment" : "OK", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentDisposition" : "inline", + "artifactUrl" : "@ignore@", + "contentEncoding" : "gzip", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "SYS_INTERNAL_LAST_UPDATED_ON" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentType" : "Resource", + "dialcodeRequired" : "No", + "lastUpdatedBy" : "KP_FT_PUBLISHER", + "identifier" : "@ignore@", + "audience" : [ "Learner" ], + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "os" : [ "All" ], + "visibility" : "Default", + "consumerId" : "@ignore@", + "mediaType" : "content", + "osId" : "org.ekstep.quiz.app", + "lastPublishedBy" : "KP_FT_PUBLISHER", + "version" : "@isNumber()@", + "pkgVersion" : "@isNumber()@", + "versionKey" : "@ignore@", + "license" : "CC BY 4.0", + "idealScreenDensity" : "hdpi", + "s3Key" : "@ignore@", + "framework" : "NCF", + "lastPublishedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "size" : "@isNumber()@", + "compatibilityLevel" : "@isNumber()@", + "name" : "KP Integration Test Content", + "publisher" : "KP_FT_PUBLISHER", + "status" : "Live", + "index" : 1, + "depth" : 2, + "parent" : "@ignore@" + } ], "name" : "@ignore@", "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", "contentType" : "TextBook", @@ -50,19 +102,22 @@ "compatibilityLevel" : "@isNumber()@", "audience" : [ "Learner" ], "os" : [ "All" ], + "collections" : [ ], "SYS_INTERNAL_LAST_UPDATED_ON" : "@matchesDatePattern('yyyy-MM-dd')@", "downloadUrl" : "@ignore@", + "usedByContent" : [ ], "framework" : "NCF", "totalCompressedSize" : "@isNumber()@", "versionKey" : "@ignore@", "mimeType" : "application/vnd.ekstep.content-collection", "code" : "kp.ft.collection.textbook", "license" : "CC BY 4.0", + "leafNodes" : "@ignore@", "version" : "@isNumber()@", "contentType" : "TextBook", "language" : [ "English" ], "lastPublishedOn" : "@matchesDatePattern('yyyy-MM-dd')@", - "contentTypesCount" : "{\"TextBook\":1}", + "contentTypesCount" : "{\"Resource\":1,\"TextBook\":1}", "objectType" : "Content", "lastUpdatedBy" : "KP_FT_PUBLISHER", "status" : "Live", @@ -75,7 +130,7 @@ "depth" : 0, "consumerId" : "@ignore@", "lastPublishedBy" : "KP_FT_PUBLISHER", - "mimeTypesCount" : "{\"application/vnd.ekstep.content-collection\":1}", + "mimeTypesCount" : "{\"application/vnd.ekstep.content-collection\":1,\"application/vnd.ekstep.ecml-archive\":1}", "osId" : "org.ekstep.quiz.app", "s3Key" : "@ignore@", "contentDisposition" : "inline", diff --git a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterFlag/response_image.json b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterFlag/response_image.json new file mode 100644 index 00000000..aa1cfa39 --- /dev/null +++ b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterFlag/response_image.json @@ -0,0 +1,148 @@ +{ + "id" : "api.content.hierarchy.get", + "ver" : "3.0", + "ts" : "@matchesDatePattern('yyyy-MM-dd')@", + "params" : { + "resmsgid" : "@ignore@", + "msgid" : null, + "err" : null, + "status" : "successful", + "errmsg" : null + }, + "responseCode" : "OK", + "result" : { + "content" : { + "ownershipType" : [ "createdBy" ], + "channel" : "channel-01", + "downloadUrl" : "@ignore@", + "language" : [ "English" ], + "variants" : { + "online" : { + "ecarUrl" : "@ignore@", + "size" : "@isNumber()@" + }, + "spine" : { + "ecarUrl" : "@ignore@", + "size" : "@isNumber()@" + } + }, + "mimeType" : "application/vnd.ekstep.content-collection", + "leafNodes" : "@ignore@", + "children" : [ { + "parent" : "@ignore@", + "identifier" : "@ignore@", + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "code" : "2cb4d698-dc19-4f0c-9990-96f49daff753", + "visibility" : "Parent", + "description" : "@ignore@", + "index" : 1, + "mimeType" : "application/vnd.ekstep.content-collection", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "versionKey" : "@ignore@", + "depth" : 1, + "children" : [ { + "ownershipType" : [ "createdBy" ], + "parent" : "@ignore@", + "previewUrl" : "@ignore@", + "code" : "kp.ft.resource.ecml", + "downloadUrl" : "@ignore@", + "channel" : "channel-01", + "description" : "KP Integration Test Content", + "language" : [ "English" ], + "variants" : { + "spine" : { + "ecarUrl" : "@ignore@", + "size" : "@isNumber()@" + } + }, + "streamingUrl" :"@ignore@", + "mimeType" : "application/vnd.ekstep.ecml-archive", + "idealScreenSize" : "normal", + "publishComment" : "OK", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentDisposition" : "inline", + "artifactUrl" : "@ignore@", + "contentEncoding" : "gzip", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "SYS_INTERNAL_LAST_UPDATED_ON" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentType" : "Resource", + "dialcodeRequired" : "No", + "lastUpdatedBy" : "KP_FT_PUBLISHER", + "identifier" : "@ignore@", + "audience" : [ "Learner" ], + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "os" : [ "All" ], + "visibility" : "Default", + "consumerId" : "@ignore@", + "index" : 1, + "mediaType" : "content", + "osId" : "org.ekstep.quiz.app", + "lastPublishedBy" : "KP_FT_PUBLISHER", + "version" : "@isNumber()@", + "pkgVersion" : "@isNumber()@", + "versionKey" : "@ignore@", + "license" : "CC BY 4.0", + "idealScreenDensity" : "hdpi", + "s3Key" : "@ignore@", + "framework" : "NCF", + "depth" : 2, + "lastPublishedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "size" : "@isNumber()@", + "compatibilityLevel" : "@isNumber()@", + "name" : "KP Integration Test Content", + "publisher" : "KP_FT_PUBLISHER", + "status" : "Live" + } ], + "name" : "@ignore@", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentType" : "TextBook", + "status" : "Draft" + } ], + "contentEncoding" : "gzip", + "mimeTypesCount" : "{\"application/vnd.ekstep.content-collection\":1,\"application/vnd.ekstep.ecml-archive\":1}", + "totalCompressedSize" : "@isNumber()@", + "contentType" : "TextBook", + "lastUpdatedBy" : "KP-Tester", + "identifier" : "${rootId}", + "audience" : [ "Learner" ], + "toc_url" : "@ignore@", + "visibility" : "Default", + "contentTypesCount" : "{\"Resource\":1,\"TextBook\":1}", + "childNodes" : "@ignore@", + "consumerId" : "@ignore@", + "mediaType" : "content", + "osId" : "org.ekstep.quiz.app", + "lastPublishedBy" : "KP_FT_PUBLISHER", + "version" : "@isNumber()@", + "license" : "CC BY 4.0", + "lastPublishedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "size" : "@isNumber()@", + "name" : "KP Integration Test Collection Content", + "publisher" : "KP_FT_PUBLISHER", + "status" : "Flagged", + "code" : "kp.ft.collection.textbook", + "flags" : [ "kp-flags", "newKp-flags" ], + "description" : "KP Integration Test Collection Content", + "lastFlaggedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "flaggedBy" : [ "KP-Tester" ], + "publishComment" : "OK", + "idealScreenSize" : "normal", + "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "contentDisposition" : "inline", + "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "SYS_INTERNAL_LAST_UPDATED_ON" : "@matchesDatePattern('yyyy-MM-dd')@", + "dialcodeRequired" : "No", + "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "flagReasons" : [ "Copyright Violation" ], + "os" : [ "All" ], + "pkgVersion" : "@isNumber()@", + "versionKey" : "@ignore@", + "idealScreenDensity" : "hdpi", + "s3Key" : "@ignore@", + "depth" : 0, + "framework" : "NCF", + "leafNodesCount" : "@isNumber()@", + "compatibilityLevel" : "@isNumber()@" + } + } +} \ No newline at end of file diff --git a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterUpdate/response_image.json b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterUpdate/response_image.json index f5d3cc1c..3d4b55f8 100644 --- a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterUpdate/response_image.json +++ b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyAfterUpdate/response_image.json @@ -57,8 +57,8 @@ "contentEncoding" : "gzip", "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", "SYS_INTERNAL_LAST_UPDATED_ON" : "@matchesDatePattern('yyyy-MM-dd')@", - "dialcodeRequired" : "No", "contentType" : "Resource", + "dialcodeRequired" : "No", "lastUpdatedBy" : "KP_FT_PUBLISHER", "identifier" : "@ignore@", "audience" : [ "Learner" ], @@ -78,8 +78,8 @@ "s3Key" : "@ignore@", "framework" : "NCF", "depth" : 2, - "size" : "@isNumber()@", "lastPublishedOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "size" : "@isNumber()@", "compatibilityLevel" : "@isNumber()@", "name" : "KP Integration Test Content", "publisher" : "KP_FT_PUBLISHER", @@ -93,8 +93,9 @@ "contentDisposition" : "inline", "contentEncoding" : "gzip", "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", - "dialcodeRequired" : "No", "contentType" : "TextBook", + "dialcodeRequired" : "No", + "identifier" : "${rootId}", "audience" : [ "Learner" ], "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", "os" : [ "All" ], diff --git a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyBeforeUpdate/response_image.json b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyBeforeUpdate/response_image.json index bdef44cc..69772537 100644 --- a/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyBeforeUpdate/response_image.json +++ b/kp_service_test/src/test/resources/templates/content/v3/hierarchy/get/testGetHierarchyBeforeUpdate/response_image.json @@ -1,5 +1,5 @@ { - "id" : "api.content.hierarchy.get", + "id" : "ekstep.learning.content.hierarchy", "ver" : "3.0", "ts" : "@matchesDatePattern('yyyy-MM-dd')@", "params" : { @@ -13,6 +13,7 @@ "result" : { "content" : { "ownershipType" : [ "createdBy" ], + "parent" : "@ignore@", "code" : "kp.ft.collection.textbook", "channel" : "channel-01", "description" : "KP Integration Test Collection Content", @@ -20,22 +21,26 @@ "mimeType" : "application/vnd.ekstep.content-collection", "idealScreenSize" : "normal", "createdOn" : "@matchesDatePattern('yyyy-MM-dd')@", + "objectType" : "Content", "contentDisposition" : "inline", - "contentEncoding" : "gzip", "lastUpdatedOn" : "@matchesDatePattern('yyyy-MM-dd')@", - "dialcodeRequired" : "No", + "contentEncoding" : "gzip", "contentType" : "TextBook", + "dialcodeRequired" : "No", + "identifier" : "KP_FT_1578373926608", "audience" : [ "Learner" ], "lastStatusChangedOn" : "@matchesDatePattern('yyyy-MM-dd')@", - "os" : [ "All" ], "visibility" : "Default", + "os" : [ "All" ], "consumerId" : "@ignore@", + "index" : null, "mediaType" : "content", "osId" : "org.ekstep.quiz.app", "version" : "@isNumber()@", "versionKey" : "@ignore@", "license" : "CC BY 4.0", "idealScreenDensity" : "hdpi", + "depth" : 0, "framework" : "NCF", "compatibilityLevel" : "@isNumber()@", "name" : "KP Integration Test Collection Content", diff --git a/kp_service_test/src/test/resources/templates/payload/content/createCollectionContentExpect200/request.json b/kp_service_test/src/test/resources/templates/payload/content/createCollectionContentExpect200/request.json index 3c81b72c..fdec3f07 100644 --- a/kp_service_test/src/test/resources/templates/payload/content/createCollectionContentExpect200/request.json +++ b/kp_service_test/src/test/resources/templates/payload/content/createCollectionContentExpect200/request.json @@ -7,7 +7,8 @@ "code": "${codeVal}", "mimeType": "application/vnd.ekstep.content-collection", "contentType": "${contentTypeVal}", - "mediaType": "content" + "mediaType": "content", + "license":"CC BY 4.0" } } } \ No newline at end of file From 7782e0134fcaa6c375ea0c1d6a3e25b15f9a5421 Mon Sep 17 00:00:00 2001 From: Kumar Gauraw Date: Mon, 1 Jun 2020 11:18:15 +0530 Subject: [PATCH 6/6] Issue #SC-0000 fix: updated endpoints --- kp_service_test/src/test/resources/application.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kp_service_test/src/test/resources/application.conf b/kp_service_test/src/test/resources/application.conf index f22101d9..0a3138af 100644 --- a/kp_service_test/src/test/resources/application.conf +++ b/kp_service_test/src/test/resources/application.conf @@ -26,4 +26,4 @@ kp_dial_base_uri=${kp_dial_base_url} kp_dial_api_key=${kp_dial_auth_key} # KP Content Service API's -cs_api_list=["/content/v3/create","/content/v3/read/","/content/v3/update/", "/license/v3/create", "/license/v3/read", "/license/v3/update/", "/license/v3/retire/"] \ No newline at end of file +cs_api_list=["/content/v3/create","/content/v3/read/","/content/v3/update/","/content/v3/upload/","/content/v3/upload/url/","/content/v3/hierarchy/","/content/v3/copy/","/content/v3/flag/","/content/v3/discard/","/license/v3/create", "/license/v3/read", "/license/v3/update/", "/license/v3/retire/","/channel/v3/create","/channel/v3/read/","/channel/v3/update/","/channel/v3/retire/"] \ No newline at end of file