From 64bf3ea8442ddc71901b713018ed6964581b867b Mon Sep 17 00:00:00 2001 From: shourya-solanki Date: Thu, 15 Feb 2024 23:32:00 +0530 Subject: [PATCH 1/2] Issue #KN-945 fix: test case fix --- .../sunbird/graph/nodes/TestDataNode.scala | 5 +- .../cloudstore/StorageServiceTest.scala | 90 +++++++++---------- 2 files changed, 48 insertions(+), 47 deletions(-) diff --git a/ontology-engine/graph-engine_2.12/src/test/scala/org/sunbird/graph/nodes/TestDataNode.scala b/ontology-engine/graph-engine_2.12/src/test/scala/org/sunbird/graph/nodes/TestDataNode.scala index bea4bccac..556bd29e9 100644 --- a/ontology-engine/graph-engine_2.12/src/test/scala/org/sunbird/graph/nodes/TestDataNode.scala +++ b/ontology-engine/graph-engine_2.12/src/test/scala/org/sunbird/graph/nodes/TestDataNode.scala @@ -65,7 +65,7 @@ class TestDataNode extends BaseSpec { assert(node.getMetadata.get("contentType").asInstanceOf[String].equalsIgnoreCase("Resource"))}} } - "createNode with relation" should "create a node successfully" ignore { + "createNode with relation" should "create a node successfully" in { createRelationData() val request = new Request() request.setObjectType("Content") @@ -302,7 +302,7 @@ class TestDataNode extends BaseSpec { }flatMap(f => f) } - "update live node with external props" should "update image node with existing external props in image node" ignore { + "update live node with external props" should "update image node with existing external props in image node" in { graphDb.run("UNWIND [{ownershipType:[\"createdBy\"],copyright:\"Sunbird\",previewUrl:\"https://sunbirddev.blob.core.windows.net/sunbird-content-dev/content/ecml/do_1129067102240194561252-latest\",keywords:[\"Test\"],plugins:\"[{\\\"identifier\\\":\\\"org.ekstep.stage\\\",\\\"semanticVersion\\\":\\\"1.0\\\"},{\\\"identifier\\\":\\\"org.ekstep.shape\\\",\\\"semanticVersion\\\":\\\"1.0\\\"},{\\\"identifier\\\":\\\"org.ekstep.text\\\",\\\"semanticVersion\\\":\\\"1.2\\\"},{\\\"identifier\\\":\\\"org.ekstep.image\\\",\\\"semanticVersion\\\":\\\"1.1\\\"},{\\\"identifier\\\":\\\"org.ekstep.navigation\\\",\\\"semanticVersion\\\":\\\"1.0\\\"}]\",downloadUrl:\"https://sunbirddev.blob.core.windows.net/sunbird-content-dev/ecar_files/do_1129067102240194561252/test-g-kp-2.0-001_1575527499420_do_1129067102240194561252_2.0.ecar\",channel:\"b00bc992ef25f1a9a8d63291e20efc8d\",organisation:[\"Sunbird\"],language:[\"English\"],variants:\"{\\\"spine\\\":{\\\"ecarUrl\\\":\\\"https://sunbirddev.blob.core.windows.net/sunbird-content-dev/ecar_files/do_1129067102240194561252/test-g-kp-2.0-001_1575527499615_do_1129067102240194561252_2.0_spine.ecar\\\",\\\"size\\\":36069.0}}\",mimeType:\"application/vnd.ekstep.ecml-archive\",editorState:\"{\\\"plugin\\\":{\\\"noOfExtPlugins\\\":7,\\\"extPlugins\\\":[{\\\"plugin\\\":\\\"org.ekstep.contenteditorfunctions\\\",\\\"version\\\":\\\"1.2\\\"},{\\\"plugin\\\":\\\"org.ekstep.keyboardshortcuts\\\",\\\"version\\\":\\\"1.0\\\"},{\\\"plugin\\\":\\\"org.ekstep.richtext\\\",\\\"version\\\":\\\"1.0\\\"},{\\\"plugin\\\":\\\"org.ekstep.iterator\\\",\\\"version\\\":\\\"1.0\\\"},{\\\"plugin\\\":\\\"org.ekstep.navigation\\\",\\\"version\\\":\\\"1.0\\\"},{\\\"plugin\\\":\\\"org.ekstep.reviewercomments\\\",\\\"version\\\":\\\"1.0\\\"},{\\\"plugin\\\":\\\"org.ekstep.questionunit.ftb\\\",\\\"version\\\":\\\"1.1\\\"}]},\\\"stage\\\":{\\\"noOfStages\\\":5,\\\"currentStage\\\":\\\"c5ead48c-d574-488b-80d0-6d7db2d60637\\\",\\\"selectedPluginObject\\\":\\\"5b6a5e3d-5e44-4254-8c70-d82d6c13cc2c\\\"},\\\"sidebar\\\":{\\\"selectedMenu\\\":\\\"settings\\\"}}\",appIcon:\"https://sunbirddev.blob.core.windows.net/sunbird-content-dev/content/do_1129067102240194561252/artifact/033019_sz_reviews_feat_1564126718632.thumb.jpg\",assets:[\"do_112835334818643968148\"],appId:\"dev.sunbird.portal\",contentEncoding:\"gzip\",artifactUrl:\"https://sunbirddev.blob.core.windows.net/sunbird-content-dev/content/do_1129067102240194561252/artifact/1575527499196_do_1129067102240194561252.zip\",lockKey:\"b7992ea7-f326-40d0-abdd-1601146bca84\",contentType:\"Resource\",lastUpdatedBy:\"874ed8a5-782e-4f6c-8f36-e0288455901e\",audience:[\"Student\"],visibility:\"Default\",consumerId:\"b3e90b00-1e9f-4692-9290-d014c20625f2\",mediaType:\"content\",osId:\"org.ekstep.quiz.app\",lastPublishedBy:\"Ekstep\",version:2,pragma:[],prevState:\"Review\",license:\"CC BY 4.0\",lastPublishedOn:\"2019-12-05T06:31:39.415+0000\",size:74105,IL_FUNC_OBJECT_TYPE:\"Content\",name:\"TEST-G-KP-2.0-001\",status:\"Live\",totalQuestions:0,code:\"org.sunbird.3qKh9v\",description:\"Test ECML Content\",streamingUrl:\"https://sunbirddev.blob.core.windows.net/sunbird-content-dev/content/ecml/do_1129067102240194561252-latest\",posterImage:\"https://sunbirddev.blob.core.windows.net/sunbird-content-dev/content/do_11281332607717376012/artifact/033019_sz_reviews_feat_1564126718632.jpg\",idealScreenSize:\"normal\",createdOn:\"2019-12-05T06:09:10.490+0000\",contentDisposition:\"inline\",lastUpdatedOn:\"2019-12-05T06:31:37.880+0000\",SYS_INTERNAL_LAST_UPDATED_ON:\"2019-12-05T06:31:40.528+0000\",dialcodeRequired:\"No\",creator:\"Creation\",createdFor:[\"ORG_001\"],lastStatusChangedOn:\"2019-12-05T06:31:37.869+0000\",os:[\"All\"],IL_SYS_NODE_TYPE:\"DATA_NODE\",totalScore:0,pkgVersion:2,versionKey:\"1575527498230\",idealScreenDensity:\"hdpi\",s3Key:\"ecar_files/do_1129067102240194561252/test-g-kp-2.0-001_1575527499420_do_1129067102240194561252_2.0.ecar\",lastSubmittedOn:\"2019-12-05T06:22:33.347+0000\",createdBy:\"874ed8a5-782e-4f6c-8f36-e0288455901e\",compatibilityLevel:2,IL_UNIQUE_ID:\"do_1129067102240194561252\",resourceType:\"Learn\"}] as row CREATE (n:domain) SET n += row") executeCassandraQuery("INSERT into content_store.content_data(content_id, body) values('do_1129067102240194561252', textAsBlob('body'));") val request = new Request() @@ -313,6 +313,7 @@ class TestDataNode extends BaseSpec { request.put("versionKey", "1575527498230") request.put("primaryCategory", "Learning Resource") val updateFuture = DataNode.update(request) + print(" update future node: ", updateFuture.value) updateFuture.map(node => { assert(node.getIdentifier.equalsIgnoreCase("do_1129067102240194561252.img")) val resultSet = session.execute("select blobAsText(body) as body from content_store.content_data where content_id='do_1129067102240194561252.img'") diff --git a/platform-modules/mimetype-manager/src/test/scala/org/sunbird/cloudstore/StorageServiceTest.scala b/platform-modules/mimetype-manager/src/test/scala/org/sunbird/cloudstore/StorageServiceTest.scala index 8bdddd854..4581b22fa 100644 --- a/platform-modules/mimetype-manager/src/test/scala/org/sunbird/cloudstore/StorageServiceTest.scala +++ b/platform-modules/mimetype-manager/src/test/scala/org/sunbird/cloudstore/StorageServiceTest.scala @@ -7,49 +7,49 @@ import java.io.File class StorageServiceTest extends AsyncFlatSpec with Matchers { val ss = new StorageService - // "getService" should "return a Storage Service" in { - // val service = ss.getService - // assert(service != null) - // } - - // "getContainerName" should "return the container name" in { - // val container = ss.getContainerName - // assert(container == "sunbird-content-dev") - // } - - // "getSignedURL" should "return the signed url" in { - // val objectKey = "content" + File.separator + "asset" + File.separator + "do_53245" + File.separator + "abc.png" - // val preSignedURL = ss.getSignedURL(objectKey, Option.apply(600), Option.apply("w")) - // assert(preSignedURL.contains(objectKey)) - // } - - // "getUri" should "return the signed url" in { - // val uri = ss.getUri("content/abc.json") - // assert(uri != null) - // } - - // "getMimeType" should "return the mimetype application/epub+zip for epub" in { - // val result = ss.getMimeType("test.alert.epub") - // assert(result == "application/epub+zip") - // } - - // "getMimeType" should "return the mimetype application/octet-stream for h5p" in { - // val result = ss.getMimeType("test.alert.h5p") - // assert(result == "application/octet-stream") - // } - - // "getMimeType" should "return the mimetype text/csv for csv" in { - // val result = ss.getMimeType("test.alert.csv") - // assert(result == "text/csv") - // } - - // "getMimeType" should "return the mimetype application/pdf for pdf" in { - // val result = ss.getMimeType("test.alert.pdf") - // assert(result == "application/pdf") - // } - - // "getMimeType" should "return the mimetype application/zip for zip" in { - // val result = ss.getMimeType("test.alert.zip") - // assert(result == "application/zip") - // } + "getService" should "return a Storage Service" in { + val service = ss.getService + assert(service != null) + } + + "getContainerName" should "return the container name" in { + val container = ss.getContainerName + assert(container == "sunbird-content-dev") + } + + "getSignedURL" should "return the signed url" in { + val objectKey = "content" + File.separator + "asset" + File.separator + "do_53245" + File.separator + "abc.png" + val preSignedURL = ss.getSignedURL(objectKey, Option.apply(600), Option.apply("w")) + assert(preSignedURL.contains(objectKey)) + } + + "getUri" should "return the signed url" in { + val uri = ss.getUri("content/abc.json") + assert(uri != null) + } + + "getMimeType" should "return the mimetype application/epub+zip for epub" in { + val result = ss.getMimeType("test.alert.epub") + assert(result == "application/epub+zip") + } + + "getMimeType" should "return the mimetype application/octet-stream for h5p" in { + val result = ss.getMimeType("test.alert.h5p") + assert(result == "application/octet-stream") + } + + "getMimeType" should "return the mimetype text/csv for csv" in { + val result = ss.getMimeType("test.alert.csv") + assert(result == "text/csv") + } + + "getMimeType" should "return the mimetype application/pdf for pdf" in { + val result = ss.getMimeType("test.alert.pdf") + assert(result == "application/pdf") + } + + "getMimeType" should "return the mimetype application/zip for zip" in { + val result = ss.getMimeType("test.alert.zip") + assert(result == "application/zip") + } } From b54357cfab9e2920b488b7b58f5dac015760b27d Mon Sep 17 00:00:00 2001 From: shourya-solanki Date: Mon, 19 Feb 2024 11:13:16 +0530 Subject: [PATCH 2/2] Issue #KN-945 fix: test case fix --- .../test/scala/org/sunbird/graph/nodes/TestDataNode.scala | 5 ++--- .../sunbird/mimetype/mgr/impl/EcmlMimeTypeMgrImplTest.scala | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/ontology-engine/graph-engine_2.12/src/test/scala/org/sunbird/graph/nodes/TestDataNode.scala b/ontology-engine/graph-engine_2.12/src/test/scala/org/sunbird/graph/nodes/TestDataNode.scala index 556bd29e9..bea4bccac 100644 --- a/ontology-engine/graph-engine_2.12/src/test/scala/org/sunbird/graph/nodes/TestDataNode.scala +++ b/ontology-engine/graph-engine_2.12/src/test/scala/org/sunbird/graph/nodes/TestDataNode.scala @@ -65,7 +65,7 @@ class TestDataNode extends BaseSpec { assert(node.getMetadata.get("contentType").asInstanceOf[String].equalsIgnoreCase("Resource"))}} } - "createNode with relation" should "create a node successfully" in { + "createNode with relation" should "create a node successfully" ignore { createRelationData() val request = new Request() request.setObjectType("Content") @@ -302,7 +302,7 @@ class TestDataNode extends BaseSpec { }flatMap(f => f) } - "update live node with external props" should "update image node with existing external props in image node" in { + "update live node with external props" should "update image node with existing external props in image node" ignore { graphDb.run("UNWIND [{ownershipType:[\"createdBy\"],copyright:\"Sunbird\",previewUrl:\"https://sunbirddev.blob.core.windows.net/sunbird-content-dev/content/ecml/do_1129067102240194561252-latest\",keywords:[\"Test\"],plugins:\"[{\\\"identifier\\\":\\\"org.ekstep.stage\\\",\\\"semanticVersion\\\":\\\"1.0\\\"},{\\\"identifier\\\":\\\"org.ekstep.shape\\\",\\\"semanticVersion\\\":\\\"1.0\\\"},{\\\"identifier\\\":\\\"org.ekstep.text\\\",\\\"semanticVersion\\\":\\\"1.2\\\"},{\\\"identifier\\\":\\\"org.ekstep.image\\\",\\\"semanticVersion\\\":\\\"1.1\\\"},{\\\"identifier\\\":\\\"org.ekstep.navigation\\\",\\\"semanticVersion\\\":\\\"1.0\\\"}]\",downloadUrl:\"https://sunbirddev.blob.core.windows.net/sunbird-content-dev/ecar_files/do_1129067102240194561252/test-g-kp-2.0-001_1575527499420_do_1129067102240194561252_2.0.ecar\",channel:\"b00bc992ef25f1a9a8d63291e20efc8d\",organisation:[\"Sunbird\"],language:[\"English\"],variants:\"{\\\"spine\\\":{\\\"ecarUrl\\\":\\\"https://sunbirddev.blob.core.windows.net/sunbird-content-dev/ecar_files/do_1129067102240194561252/test-g-kp-2.0-001_1575527499615_do_1129067102240194561252_2.0_spine.ecar\\\",\\\"size\\\":36069.0}}\",mimeType:\"application/vnd.ekstep.ecml-archive\",editorState:\"{\\\"plugin\\\":{\\\"noOfExtPlugins\\\":7,\\\"extPlugins\\\":[{\\\"plugin\\\":\\\"org.ekstep.contenteditorfunctions\\\",\\\"version\\\":\\\"1.2\\\"},{\\\"plugin\\\":\\\"org.ekstep.keyboardshortcuts\\\",\\\"version\\\":\\\"1.0\\\"},{\\\"plugin\\\":\\\"org.ekstep.richtext\\\",\\\"version\\\":\\\"1.0\\\"},{\\\"plugin\\\":\\\"org.ekstep.iterator\\\",\\\"version\\\":\\\"1.0\\\"},{\\\"plugin\\\":\\\"org.ekstep.navigation\\\",\\\"version\\\":\\\"1.0\\\"},{\\\"plugin\\\":\\\"org.ekstep.reviewercomments\\\",\\\"version\\\":\\\"1.0\\\"},{\\\"plugin\\\":\\\"org.ekstep.questionunit.ftb\\\",\\\"version\\\":\\\"1.1\\\"}]},\\\"stage\\\":{\\\"noOfStages\\\":5,\\\"currentStage\\\":\\\"c5ead48c-d574-488b-80d0-6d7db2d60637\\\",\\\"selectedPluginObject\\\":\\\"5b6a5e3d-5e44-4254-8c70-d82d6c13cc2c\\\"},\\\"sidebar\\\":{\\\"selectedMenu\\\":\\\"settings\\\"}}\",appIcon:\"https://sunbirddev.blob.core.windows.net/sunbird-content-dev/content/do_1129067102240194561252/artifact/033019_sz_reviews_feat_1564126718632.thumb.jpg\",assets:[\"do_112835334818643968148\"],appId:\"dev.sunbird.portal\",contentEncoding:\"gzip\",artifactUrl:\"https://sunbirddev.blob.core.windows.net/sunbird-content-dev/content/do_1129067102240194561252/artifact/1575527499196_do_1129067102240194561252.zip\",lockKey:\"b7992ea7-f326-40d0-abdd-1601146bca84\",contentType:\"Resource\",lastUpdatedBy:\"874ed8a5-782e-4f6c-8f36-e0288455901e\",audience:[\"Student\"],visibility:\"Default\",consumerId:\"b3e90b00-1e9f-4692-9290-d014c20625f2\",mediaType:\"content\",osId:\"org.ekstep.quiz.app\",lastPublishedBy:\"Ekstep\",version:2,pragma:[],prevState:\"Review\",license:\"CC BY 4.0\",lastPublishedOn:\"2019-12-05T06:31:39.415+0000\",size:74105,IL_FUNC_OBJECT_TYPE:\"Content\",name:\"TEST-G-KP-2.0-001\",status:\"Live\",totalQuestions:0,code:\"org.sunbird.3qKh9v\",description:\"Test ECML Content\",streamingUrl:\"https://sunbirddev.blob.core.windows.net/sunbird-content-dev/content/ecml/do_1129067102240194561252-latest\",posterImage:\"https://sunbirddev.blob.core.windows.net/sunbird-content-dev/content/do_11281332607717376012/artifact/033019_sz_reviews_feat_1564126718632.jpg\",idealScreenSize:\"normal\",createdOn:\"2019-12-05T06:09:10.490+0000\",contentDisposition:\"inline\",lastUpdatedOn:\"2019-12-05T06:31:37.880+0000\",SYS_INTERNAL_LAST_UPDATED_ON:\"2019-12-05T06:31:40.528+0000\",dialcodeRequired:\"No\",creator:\"Creation\",createdFor:[\"ORG_001\"],lastStatusChangedOn:\"2019-12-05T06:31:37.869+0000\",os:[\"All\"],IL_SYS_NODE_TYPE:\"DATA_NODE\",totalScore:0,pkgVersion:2,versionKey:\"1575527498230\",idealScreenDensity:\"hdpi\",s3Key:\"ecar_files/do_1129067102240194561252/test-g-kp-2.0-001_1575527499420_do_1129067102240194561252_2.0.ecar\",lastSubmittedOn:\"2019-12-05T06:22:33.347+0000\",createdBy:\"874ed8a5-782e-4f6c-8f36-e0288455901e\",compatibilityLevel:2,IL_UNIQUE_ID:\"do_1129067102240194561252\",resourceType:\"Learn\"}] as row CREATE (n:domain) SET n += row") executeCassandraQuery("INSERT into content_store.content_data(content_id, body) values('do_1129067102240194561252', textAsBlob('body'));") val request = new Request() @@ -313,7 +313,6 @@ class TestDataNode extends BaseSpec { request.put("versionKey", "1575527498230") request.put("primaryCategory", "Learning Resource") val updateFuture = DataNode.update(request) - print(" update future node: ", updateFuture.value) updateFuture.map(node => { assert(node.getIdentifier.equalsIgnoreCase("do_1129067102240194561252.img")) val resultSet = session.execute("select blobAsText(body) as body from content_store.content_data where content_id='do_1129067102240194561252.img'") diff --git a/platform-modules/mimetype-manager/src/test/scala/org/sunbird/mimetype/mgr/impl/EcmlMimeTypeMgrImplTest.scala b/platform-modules/mimetype-manager/src/test/scala/org/sunbird/mimetype/mgr/impl/EcmlMimeTypeMgrImplTest.scala index e3bdd7d7b..e8edcf5a2 100644 --- a/platform-modules/mimetype-manager/src/test/scala/org/sunbird/mimetype/mgr/impl/EcmlMimeTypeMgrImplTest.scala +++ b/platform-modules/mimetype-manager/src/test/scala/org/sunbird/mimetype/mgr/impl/EcmlMimeTypeMgrImplTest.scala @@ -101,7 +101,7 @@ class EcmlMimeTypeMgrImplTest extends AsyncFlatSpec with Matchers with AsyncMock }) } - ignore should "review ECML having xml body and return result" in { + it should "review ECML having xml body and return result" ignore { implicit val ss = mock[StorageService] implicit val oec: OntologyEngineContext = mock[OntologyEngineContext] val graphDB = mock[GraphService]