How to use TestData method in wpt

Best JavaScript code snippet using wpt

AnzoClientDatasetTest.js

Source:AnzoClientDatasetTest.js Github

copy

Full Screen

...39 setUp: function() {40 },41 runTest: function test_Basics() {42 43 var TestData = new anzo.tests.client.TestData();44 45 var d = new doh.Deferred();46 47 var anzoClient = new anzo.client.AnzoClient(anzo.tests.properties);48 49 anzoClient.connect(d.getTestErrorWrapper(function connected(status, message) {50 tests.assertTrue(status == anzo.messaging.CONNECTION_STATUS_CONNECTED);51 anzo.tests.utilities.reset(anzoClient, d.getTestErrorWrapper(function onResetComplete(suc) {52 tests.assertTrue(suc);53 anzoClient.createReplicaDataset(true, TestData.dataset1, null, null, d.getTestErrorWrapper(function(ds) {54 ds.addNamedGraph(TestData.graph1, d.getTestErrorWrapper(function(g1) {55 g1.add(TestData.subj1, TestData.pred1, TestData.obj1);56 ds.addNamedGraph(TestData.graph2, d.getTestErrorWrapper(function(g2) {57 g2.add(TestData.subj2, TestData.pred2, TestData.obj2);58 ds.addNamedGraph(TestData.graph3, d.getTestErrorWrapper(function(g3) {59 g3.add(TestData.subj3, TestData.pred3, TestData.obj3);60 61 tests.assertTrue(ds.containsNamedGraph(TestData.graph2));62 tests.assertTrue(ds.containsNamedGraph(g2));63 tests.assertTrue(ds.datasetGraph.contains(ds.uri, anzo.client.Vocabulary.namedGraphProperty, g2.namedGraphUri));64 tests.assertTrue(new anzo.utils.Set(ds.getNamedGraphUris()).contains(g2.namedGraphUri));65 tests.assertTrue(ds.getNamedGraph(TestData.graph2) == g2);66 67 68 tests.assertTrue(ds.find(TestData.subj1, TestData.pred1, TestData.obj1)[0].namedGraphUri.equals(g1.namedGraphUri));69 tests.assertTrue(ds.find(TestData.subj2, TestData.pred2, TestData.obj2)[0].namedGraphUri.equals(g2.namedGraphUri));70 tests.assertTrue(ds.find(TestData.subj3, TestData.pred3, TestData.obj3)[0].namedGraphUri.equals(g3.namedGraphUri));71 72 tests.assertTrue(ds.size() == 3);73 tests.assertTrue(ds.size([g2.namedGraphUri, g3.namedGraphUri, 'http://random']) == 2);74 75 tests.assertTrue(!ds.isEmpty());76 tests.assertTrue(ds.isEmpty(['http://random']));77 78 ds.close();79 80 anzoClient.close(d.getTestErrorWrapper(function(status){ d.callback(true); }));81 }));82 83 }));84 }));85 }));86 }));87 }));88 89 return d;90 }91 },92 93 {94 name: "test_Basics2",95 timeout: 20000,96 setUp: function() {97 },98 runTest: function test_Basics2() {99 100 var TestData = new anzo.tests.client.TestData();101 102 var d = new doh.Deferred();103 104 var anzoClient = new anzo.client.AnzoClient(anzo.tests.properties);105 106 anzoClient.connect(d.getTestErrorWrapper(function connected(status, message) {107 tests.assertTrue(status == anzo.messaging.CONNECTION_STATUS_CONNECTED);108 anzo.tests.utilities.reset(anzoClient, d.getTestErrorWrapper(function onResetComplete(suc) {109 tests.assertTrue(suc);110 anzoClient.createReplicaDataset(true, TestData.dataset1, [TestData.graph1, TestData.graph2, TestData.graph3], [TestData.graph2, TestData.graph3, TestData.graph4], d.getTestErrorWrapper(function(ds) {111 ds.addNamedGraph(TestData.graph5, d.getTestErrorWrapper(function(g5) {112 ds.addDefaultGraph(TestData.graph5, d.getTestErrorWrapper(function(g5_1) {113114 tests.assertTrue(ds.getDefaultGraph(TestData.graph1) != null)115 tests.assertFalse(ds.getNamedGraph(TestData.graph1) != null)116 tests.assertTrue(ds.getNamedGraph(TestData.graph2) != null)117 tests.assertTrue(ds.getNamedGraph(TestData.graph3) != null)118 tests.assertTrue(ds.getNamedGraph(TestData.graph4) != null)119 tests.assertFalse(ds.getDefaultGraph(TestData.graph4) != null)120 tests.assertTrue(ds.getDefaultGraph(TestData.graph5) != null)121 122 var g1 = ds.getDefaultGraph(TestData.graph1);123 var g2 = ds.getNamedGraph(TestData.graph2);124 var g3 = ds.getNamedGraph(TestData.graph3);125 var g4 = ds.getNamedGraph(TestData.graph4);126 127 g1.add(TestData.subj1, TestData.pred1, TestData.obj1)128 g2.add(TestData.subj2, TestData.pred2, TestData.obj2)129 g3.add(TestData.subj3, TestData.pred3, TestData.obj3)130 g4.add(TestData.subj4, TestData.pred4, TestData.obj4)131 g5.add(TestData.subj5, TestData.pred5, TestData.obj5)132133 tests.assertTrue(ds.find(TestData.subj1, TestData.pred1, TestData.obj1)[0].namedGraphUri.equals(g1.namedGraphUri));134 tests.assertTrue(ds.find(TestData.subj2, TestData.pred2, TestData.obj2)[0].namedGraphUri.equals(g2.namedGraphUri));135 tests.assertTrue(ds.find(TestData.subj3, TestData.pred3, TestData.obj3)[0].namedGraphUri.equals(g3.namedGraphUri));136 tests.assertTrue(ds.find(TestData.subj4, TestData.pred4, TestData.obj4)[0].namedGraphUri.equals(g4.namedGraphUri));137 tests.assertTrue(ds.find(TestData.subj5, TestData.pred5, TestData.obj5)[0].namedGraphUri.equals(g5.namedGraphUri));138139 tests.assertTrue(ds.find(TestData.subj1, TestData.pred1, TestData.obj1, g1.namedGraphUri).length == 1);140 tests.assertTrue(ds.find(TestData.subj2, TestData.pred2, TestData.obj2, g2.namedGraphUri).length == 1);141 tests.assertTrue(ds.find(TestData.subj3, TestData.pred3, TestData.obj3, g3.namedGraphUri).length == 1);142 tests.assertTrue(ds.find(TestData.subj4, TestData.pred4, TestData.obj4, g4.namedGraphUri).length == 1);143 tests.assertTrue(ds.find(TestData.subj5, TestData.pred5, TestData.obj5, g5.namedGraphUri).length == 1);144145 tests.assertTrue(ds.contains(TestData.subj1, TestData.pred1, TestData.obj1));146 tests.assertTrue(ds.contains(TestData.subj2, TestData.pred2, TestData.obj2));147 tests.assertTrue(ds.contains(TestData.subj3, TestData.pred3, TestData.obj3));148 tests.assertTrue(ds.contains(TestData.subj4, TestData.pred4, TestData.obj4));149 tests.assertTrue(ds.contains(TestData.subj5, TestData.pred5, TestData.obj5));150 151 tests.assertTrue(ds.size() == 5);152 tests.assertTrue(ds.size([g3.namedGraphUri, g4.namedGraphUri, 'http://random']) == 2);153 154 tests.assertTrue(!ds.isEmpty());155 tests.assertTrue(ds.isEmpty(['http://random']));156 tests.assertTrue(!ds.isEmpty([TestData.graph1]));157158 ds.close();159 160 // test loading an existing dataset161 anzoClient.createReplicaDataset(true, TestData.dataset1, null, null, d.getTestErrorWrapper(function(ds) {162163 tests.assertTrue(ds.getDefaultGraph(TestData.graph1) != null)164 tests.assertTrue(ds.getNamedGraph(TestData.graph2) != null)165 tests.assertTrue(ds.getNamedGraph(TestData.graph3) != null)166 tests.assertTrue(ds.getNamedGraph(TestData.graph4) != null)167 tests.assertTrue(ds.getDefaultGraph(TestData.graph5) != null)168 169 ds.clear();170 tests.assertTrue(ds.isEmpty());171 tests.assertTrue(ds.size() == 0);172 173 ds.close();174 175 anzoClient.close(d.getTestErrorWrapper(function(status){ d.callback(true); }));176 177 }));178 }));179 })); 180 }));181 }));182 }));183 184 return d;185 }186 },187 188 {189 name: "test_ReplicatingDatasets",190 timeout: 20000,191 setUp: function() {192 },193 runTest: function test_ReplicatingDatasets() {194 195 var TestData = new anzo.tests.client.TestData();196 197 var d = new doh.Deferred();198 199 var anzoClient = new anzo.client.AnzoClient(anzo.tests.properties);200 201 anzoClient.connect(d.getTestErrorWrapper(function connected(status, message) {202 tests.assertTrue(status == anzo.messaging.CONNECTION_STATUS_CONNECTED);203 anzo.tests.utilities.reset(anzoClient, d.getTestErrorWrapper(function onResetComplete(suc) {204 205 tests.assertTrue(suc);206 207 anzoClient.createReplicaDataset(true, TestData.dataset1, [TestData.graph1, TestData.graph2, TestData.graph3], [TestData.graph2, TestData.graph3, TestData.graph4], d.getTestErrorWrapper(function(ds) {208 209 // make sure the graphs were added to the dataset ...

Full Screen

Full Screen

DatasetTest.js

Source:DatasetTest.js Github

copy

Full Screen

...28 [2930 function test_addAndRemoveGraphs() {31 32 var TestData = new anzo.tests.client.TestData();33 34 var d = new anzo.rdf.Dataset(TestData.dataset1);35 36 var g1, g2, g3, g4, g5, g6, g7;37 38 // =======================================================================================39 // TEST: ADD BY URI TO NAMED GRAPH4041 d.addNamedGraph(TestData.graph1, function(g) { g1 = g; });42 tests.assertTrue(g1 != null);43 tests.assertTrue(d.containsNamedGraph(TestData.graph1));44 tests.assertTrue(d.containsNamedGraph(g1));45 tests.assertTrue(d.datasetGraph.contains(d.uri, anzo.client.Vocabulary.namedGraphProperty, g1.namedGraphUri));46 tests.assertTrue(new anzo.utils.Set(d.getNamedGraphUris()).contains(g1.namedGraphUri));47 tests.assertTrue(d.getNamedGraph(TestData.graph1) == g1);48 tests.assertTrue(d.getNamedGraph(g1) == g1);49 50 // =======================================================================================51 // TEST: ADD BY URI TO DEFAULT GRAPH52 53 d.addDefaultGraph(TestData.graph1, function(g) { g1 = g; });54 tests.assertTrue(g1 != null);55 tests.assertTrue(d.containsDefaultGraph(TestData.graph1));56 tests.assertTrue(d.containsDefaultGraph(g1));57 tests.assertTrue(d.datasetGraph.contains(d.uri, anzo.client.Vocabulary.defaultProperty, g1.namedGraphUri));58 tests.assertTrue(new anzo.utils.Set(d.getDefaultGraphUris()).contains(g1.namedGraphUri));59 tests.assertTrue(d.getDefaultGraph(TestData.graph1) == g1);60 tests.assertTrue(d.getDefaultGraph(g1) == g1);61 62 // =======================================================================================63 // TEST: ADD BY GRAPH TO NAMED GRAPH64 65 var g2 = new anzo.rdf.NamedGraph(TestData.graph2);66 d.addNamedGraph(g2, function(g) { g2 = g; });67 tests.assertTrue(g2 != null);68 tests.assertTrue(d.containsNamedGraph(TestData.graph2));69 tests.assertTrue(d.containsNamedGraph(g2));70 tests.assertTrue(d.datasetGraph.contains(d.uri, anzo.client.Vocabulary.namedGraphProperty, g2.namedGraphUri));71 tests.assertTrue(new anzo.utils.Set(d.getNamedGraphUris()).contains(g2.namedGraphUri));72 tests.assertTrue(d.getNamedGraph(TestData.graph2) == g2);73 74 // =======================================================================================75 // TEST: ADD BY GRAPH TO DEFAULT GRAPH76 77 var g2 = new anzo.rdf.NamedGraph(TestData.graph2);78 d.addDefaultGraph(g2, function(g) { g2 = g; });79 tests.assertTrue(g2 != null);80 tests.assertTrue(d.containsDefaultGraph(TestData.graph2));81 tests.assertTrue(d.containsDefaultGraph(g2));82 tests.assertTrue(d.datasetGraph.contains(d.uri, anzo.client.Vocabulary.defaultGraphProperty, g2.namedGraphUri));83 tests.assertTrue(new anzo.utils.Set(d.getDefaultGraphUris()).contains(g2.namedGraphUri));84 tests.assertTrue(d.getDefaultGraph(TestData.graph2) == g2);85 86 // =======================================================================================87 // TEST: ADD DIRECTLY TO NAMED DATASET GRAPH88 89 d.datasetGraph.add(d.uri, anzo.client.Vocabulary.namedGraphProperty, TestData.graph3);90 g3 = d.getNamedGraph(TestData.graph3);91 tests.assertTrue(d.getNamedGraph(TestData.graph3) != null);92 tests.assertTrue(d.containsNamedGraph(TestData.graph3));93 tests.assertTrue(d.containsNamedGraph(g3));94 tests.assertTrue(d.datasetGraph.contains(d.uri, anzo.client.Vocabulary.namedGraphProperty, g3.namedGraphUri));95 tests.assertTrue(new anzo.utils.Set(d.getNamedGraphUris()).contains(g3.namedGraphUri));96 tests.assertTrue(d.getNamedGraph(TestData.graph3) == g3);97 98 // =======================================================================================99 // TEST: REMOVE BY URI FROM NAMED GRAPH100101 d.removeNamedGraph(TestData.graph1);102 tests.assertFalse(d.containsNamedGraph(TestData.graph1));103 tests.assertFalse(d.containsNamedGraph(g1));104 tests.assertFalse(d.datasetGraph.contains(d.uri, anzo.client.Vocabulary.namedGraphProperty, g1.namedGraphUri));105 tests.assertFalse(new anzo.utils.Set(d.getNamedGraphUris()).contains(g1.namedGraphUri));106 107 // =======================================================================================108 // TEST: REMOVE BY URI FROM DEFAULT GRAPH109110 d.removeDefaultGraph(TestData.graph1);111 tests.assertFalse(d.containsDefaultGraph(TestData.graph1));112 tests.assertFalse(d.containsDefaultGraph(g1));113 tests.assertFalse(d.datasetGraph.contains(d.uri, anzo.client.Vocabulary.defaultGraphProperty, g1.namedGraphUri));114 tests.assertFalse(new anzo.utils.Set(d.getDefaultGraphUris()).contains(g1.namedGraphUri));115 116 // =======================================================================================117 // TEST: REMOVE BY GRAPH FROM NAMED GRAPH118 119 var g2 = new anzo.rdf.NamedGraph(TestData.graph2);120 d.removeNamedGraph(g2);121 tests.assertFalse(d.containsNamedGraph(TestData.graph2));122 tests.assertFalse(d.containsNamedGraph(g2));123 tests.assertFalse(d.datasetGraph.contains(d.uri, anzo.client.Vocabulary.namedGraphProperty, g2.namedGraphUri));124 tests.assertFalse(new anzo.utils.Set(d.getNamedGraphUris()).contains(g2.namedGraphUri));125126 127 // =======================================================================================128 // TEST: REMOVE BY GRAPH FROM DEFAULT GRAPH129 130 var g2 = new anzo.rdf.NamedGraph(TestData.graph2);131 d.removeDefaultGraph(g2);132 tests.assertFalse(d.containsDefaultGraph(TestData.graph2));133 tests.assertFalse(d.containsDefaultGraph(g2));134 tests.assertFalse(d.datasetGraph.contains(d.uri, anzo.client.Vocabulary.defaultGraphProperty, g2.namedGraphUri));135 tests.assertFalse(new anzo.utils.Set(d.getDefaultGraphUris()).contains(g2.namedGraphUri));136 137 // =======================================================================================138 // TEST: REMOVE DIRECTLY FROM NAMED DATASET GRAPH139 140 d.datasetGraph.remove(d.uri, anzo.client.Vocabulary.namedGraphProperty, TestData.graph3);141 tests.assertFalse(d.getNamedGraph(TestData.graph3) != null);142 tests.assertFalse(d.containsNamedGraph(TestData.graph3));143 tests.assertFalse(d.containsNamedGraph(g3));144 tests.assertFalse(d.datasetGraph.contains(d.uri, anzo.client.Vocabulary.namedGraphProperty, g3.namedGraphUri));145 tests.assertFalse(new anzo.utils.Set(d.getNamedGraphUris()).contains(g3.namedGraphUri));146 147 // make sure the in-memory graphs have been removed from the cache148 tests.assertFalse(d.getNamedGraph(TestData.graph1) == g1);149 tests.assertFalse(d.getNamedGraph(TestData.graph2) == g2);150 tests.assertFalse(d.getNamedGraph(TestData.graph3) == g3);151 152 153 154 d.close();155 156 },157 158 function test_QuadStoreMethods() {159 160 var TestData = new anzo.tests.client.TestData();161 162 var ds = new anzo.rdf.Dataset(TestData.dataset1);163 164 var g1, g2, g3, g4, g5, g6, g7;165 166 ds.addNamedGraph(TestData.graph1, function(g) { g1 = g; });167 ds.addNamedGraph(TestData.graph2, function(g) { g2 = g; });168 ds.addNamedGraph(TestData.graph3, function(g) { g3 = g; });169 ds.addNamedGraph(TestData.graph4, function(g) { g4 = g; });170 171 ds.addDefaultGraph(TestData.graph3, function(g) { g3 = g; });172 ds.addDefaultGraph(TestData.graph4, function(g) { g4 = g; });173 ds.addDefaultGraph(TestData.graph5, function(g) { g5 = g; });174 ds.addDefaultGraph(TestData.graph6, function(g) { g6 = g; });175 176 g1.add(TestData.subj1, TestData.pred1, TestData.obj1)177 g2.add(TestData.subj2, TestData.pred2, TestData.obj2)178 g3.add(TestData.subj3, TestData.pred3, TestData.obj3)179 g4.add(TestData.subj4, TestData.pred4, TestData.obj4)180 g5.add(TestData.subj5, TestData.pred5, TestData.obj5)181 g6.add(TestData.subj6, TestData.pred6, TestData.obj6)182 183 tests.assertTrue(ds.find(TestData.subj1, TestData.pred1, TestData.obj1)[0].namedGraphUri.equals(g1.namedGraphUri));184 tests.assertTrue(ds.find(TestData.subj2, TestData.pred2, TestData.obj2)[0].namedGraphUri.equals(g2.namedGraphUri));185 tests.assertTrue(ds.find(TestData.subj3, TestData.pred3, TestData.obj3)[0].namedGraphUri.equals(g3.namedGraphUri));186 tests.assertTrue(ds.find(TestData.subj4, TestData.pred4, TestData.obj4)[0].namedGraphUri.equals(g4.namedGraphUri));187 tests.assertTrue(ds.find(TestData.subj5, TestData.pred5, TestData.obj5)[0].namedGraphUri.equals(g5.namedGraphUri));188 tests.assertTrue(ds.find(TestData.subj6, TestData.pred6, TestData.obj6)[0].namedGraphUri.equals(g6.namedGraphUri));189 tests.assertFalse(ds.find('http://random', TestData.pred6, TestData.obj6).length == 1);190 191 tests.assertTrue(ds.find(TestData.subj1, TestData.pred1, TestData.obj1, g1.namedGraphUri).length == 1);192 tests.assertTrue(ds.find(TestData.subj1, TestData.pred1, TestData.obj1).length == 1);193 tests.assertTrue(ds.find(TestData.subj2, TestData.pred2, TestData.obj2, g2.namedGraphUri).length == 1);194 tests.assertTrue(ds.find(TestData.subj2, TestData.pred2, TestData.obj2).length == 1);195 tests.assertTrue(ds.find(TestData.subj3, TestData.pred3, TestData.obj3, g3.namedGraphUri).length == 1);196 tests.assertTrue(ds.find(TestData.subj3, TestData.pred3, TestData.obj3).length == 1);197 tests.assertTrue(ds.find(TestData.subj4, TestData.pred4, TestData.obj4, g4.namedGraphUri).length == 1);198 tests.assertTrue(ds.find(TestData.subj4, TestData.pred4, TestData.obj4).length == 1);199 tests.assertTrue(ds.find(TestData.subj5, TestData.pred5, TestData.obj5, g5.namedGraphUri).length == 1);200 tests.assertTrue(ds.find(TestData.subj5, TestData.pred5, TestData.obj5).length == 1);201 tests.assertTrue(ds.find(TestData.subj6, TestData.pred6, TestData.obj6, g6.namedGraphUri).length == 1);202 tests.assertTrue(ds.find(TestData.subj6, TestData.pred6, TestData.obj6).length == 1);203 204 tests.assertTrue(ds.contains(TestData.subj1, TestData.pred1, TestData.obj1));205 tests.assertTrue(ds.contains(TestData.subj2, TestData.pred2, TestData.obj2));206 tests.assertTrue(ds.contains(TestData.subj3, TestData.pred3, TestData.obj3));207 tests.assertTrue(ds.contains(TestData.subj4, TestData.pred4, TestData.obj4));208 tests.assertTrue(ds.contains(TestData.subj5, TestData.pred5, TestData.obj5));209 tests.assertTrue(ds.contains(TestData.subj6, TestData.pred6, TestData.obj6));210 tests.assertFalse(ds.contains(TestData.subj6, 'http://random', TestData.obj6));211 212 tests.assertTrue(ds.size() == 6);213 tests.assertTrue(ds.size([g3.namedGraphUri, g4.namedGraphUri, 'http://random']) == 2);214 tests.assertTrue(!ds.isEmpty([TestData.graph1]));215 216 tests.assertTrue(!ds.isEmpty());217 tests.assertTrue(ds.isEmpty(['http://random']));218 219 ds.close();220 },221222 function test_SetNamedGraphs() {223 224 var TestData = new anzo.tests.client.TestData();225 226 var ds = new anzo.rdf.Dataset(TestData.dataset1);227 228 var g1, g2, g3, g4, g5, g6, g7;229 230 ds.setNamedGraphs([TestData.graph1, TestData.graph2, TestData.graph3, TestData.graph4]);231 ds.setDefaultGraphs([TestData.graph3, TestData.graph4, TestData.graph5, TestData.graph6])232 233 g1 = ds.getNamedGraph(TestData.graph1)234 g2 = ds.getNamedGraph(TestData.graph2)235 g3 = ds.getNamedGraph(TestData.graph3)236 g4 = ds.getDefaultGraph(TestData.graph4)237 g5 = ds.getDefaultGraph(TestData.graph5)238 g6 = ds.getDefaultGraph(TestData.graph6)239 240 tests.assertTrue(g1 != null);241 tests.assertTrue(g2 != null);242 tests.assertTrue(g3 != null);243 tests.assertTrue(g4 != null);244 tests.assertTrue(g5 != null);245 tests.assertTrue(g6 != null);246 247 tests.assertTrue(ds.getDefaultGraph(TestData.graph1) == null)248 tests.assertTrue(ds.getNamedGraph(TestData.graph6) == null)249 250 g1.add(TestData.subj1, TestData.pred1, TestData.obj1)251 g2.add(TestData.subj2, TestData.pred2, TestData.obj2)252 g3.add(TestData.subj3, TestData.pred3, TestData.obj3)253 g4.add(TestData.subj4, TestData.pred4, TestData.obj4)254 g5.add(TestData.subj5, TestData.pred5, TestData.obj5)255 g6.add(TestData.subj6, TestData.pred6, TestData.obj6)256 257 tests.assertTrue(ds.find(TestData.subj1, TestData.pred1, TestData.obj1)[0].namedGraphUri.equals(g1.namedGraphUri));258 tests.assertTrue(ds.find(TestData.subj2, TestData.pred2, TestData.obj2)[0].namedGraphUri.equals(g2.namedGraphUri));259 tests.assertTrue(ds.find(TestData.subj3, TestData.pred3, TestData.obj3)[0].namedGraphUri.equals(g3.namedGraphUri));260 tests.assertTrue(ds.find(TestData.subj4, TestData.pred4, TestData.obj4)[0].namedGraphUri.equals(g4.namedGraphUri));261 tests.assertTrue(ds.find(TestData.subj5, TestData.pred5, TestData.obj5)[0].namedGraphUri.equals(g5.namedGraphUri));262 tests.assertTrue(ds.find(TestData.subj6, TestData.pred6, TestData.obj6)[0].namedGraphUri.equals(g6.namedGraphUri));263 tests.assertFalse(ds.find('http://random', TestData.pred6, TestData.obj6).length == 1);264 265 tests.assertTrue(ds.find(TestData.subj1, TestData.pred1, TestData.obj1, g1.namedGraphUri).length == 1);266 tests.assertTrue(ds.find(TestData.subj2, TestData.pred2, TestData.obj2, g2.namedGraphUri).length == 1);267 tests.assertTrue(ds.find(TestData.subj3, TestData.pred3, TestData.obj3, g3.namedGraphUri).length == 1);268 tests.assertTrue(ds.find(TestData.subj4, TestData.pred4, TestData.obj4, g4.namedGraphUri).length == 1);269 tests.assertTrue(ds.find(TestData.subj5, TestData.pred5, TestData.obj5, g5.namedGraphUri).length == 1);270 tests.assertTrue(ds.find(TestData.subj6, TestData.pred6, TestData.obj6, g6.namedGraphUri).length == 1);271 272 tests.assertTrue(ds.contains(TestData.subj1, TestData.pred1, TestData.obj1));273 tests.assertTrue(ds.contains(TestData.subj2, TestData.pred2, TestData.obj2));274 tests.assertTrue(ds.contains(TestData.subj3, TestData.pred3, TestData.obj3));275 tests.assertTrue(ds.contains(TestData.subj4, TestData.pred4, TestData.obj4));276 tests.assertTrue(ds.contains(TestData.subj5, TestData.pred5, TestData.obj5));277 tests.assertTrue(ds.contains(TestData.subj6, TestData.pred6, TestData.obj6));278 tests.assertFalse(ds.contains(TestData.subj6, 'http://random', TestData.obj6));279 280 tests.assertTrue(ds.size() == 6);281 tests.assertTrue(ds.size([g3.namedGraphUri, g4.namedGraphUri, 'http://random']) == 2);282 tests.assertTrue(!ds.isEmpty([TestData.graph1]));283 284 tests.assertTrue(!ds.isEmpty());285 tests.assertTrue(ds.isEmpty(['http://random']));286 287 ds.clear();288 289 tests.assertTrue(ds.getNamedGraphUris().length == 0)290 tests.assertTrue(ds.getDefaultGraphUris().length == 0)291 tests.assertTrue(g1.isEmpty())292 tests.assertTrue(g2.isEmpty())293 tests.assertTrue(g3.isEmpty())294 tests.assertTrue(g4.isEmpty())295 tests.assertTrue(g5.isEmpty())296 tests.assertTrue(g6.isEmpty())297 298 ds.close();299 },300 301 function test_AddRemoveStmts() {302 303 var TestData = new anzo.tests.client.TestData();304 305 var ds = new anzo.rdf.Dataset(TestData.dataset1);306 307 var g1, g2, g3, g4, g5, g6, g7;308 309 ds.setNamedGraphs([TestData.graph1, TestData.graph2, TestData.graph3, TestData.graph4]);310 ds.setDefaultGraphs([TestData.graph3, TestData.graph4, TestData.graph5, TestData.graph6])311 312 g1 = ds.getNamedGraph(TestData.graph1)313 g2 = ds.getNamedGraph(TestData.graph2)314 g3 = ds.getNamedGraph(TestData.graph3)315 g4 = ds.getDefaultGraph(TestData.graph4)316 g5 = ds.getDefaultGraph(TestData.graph5)317 g6 = ds.getDefaultGraph(TestData.graph6) ...

Full Screen

Full Screen

API_All_Verb_spec.js

Source:API_All_Verb_spec.js Github

copy

Full Screen

1const testdata = require("../../../../fixtures/testdata.json");2const apiwidget = require("../../../../locators/apiWidgetslocator.json");3const ApiEditor = require("../../../../locators/ApiEditor.json");4describe("API Panel Test Functionality", function() {5 afterEach(function() {6 cy.get(ApiEditor.ApiActionMenu).click({ force: true });7 cy.get(apiwidget.deleteAPI).click({ force: true });8 cy.wait("@deleteAction").should(9 "have.nested.property",10 "response.body.responseMeta.status",11 200,12 );13 });14 it("PUT Action test API fetaure", function() {15 cy.log("Login Successful");16 cy.NavigateToAPI_Panel();17 cy.log("Navigation to API Panel screen successful");18 cy.CreateAPI("FirstAPI");19 cy.log("Creation of FirstAPI Action successful");20 cy.SelectAction(testdata.putAction);21 cy.EnterSourceDetailsWithbody(22 testdata.baseUrl,23 testdata.methodput,24 testdata.headerKey,25 testdata.headerValue,26 );27 cy.readFile("cypress/fixtures/putjson.txt").then((json) => {28 cy.log(json);29 cy.contains(ApiEditor.bodyTab).click({ force: true });30 cy.xpath(apiwidget.postbody)31 .click({ force: true })32 .focus()33 .type(json, { force: true });34 cy.WaitAutoSave();35 cy.RunAPI();36 cy.validateRequest(testdata.baseUrl, testdata.methodput, testdata.Put);37 });38 cy.ResponseStatusCheck("200 OK");39 cy.log("Response code check successful");40 cy.ResponseCheck("updatedAt");41 cy.log("Response data check successful");42 });43 it("Post Action test API fetaure", function() {44 cy.CreateAPI("FirstAPI");45 cy.log("Creation of FirstAPI Action successful");46 cy.SelectAction(testdata.postAction);47 cy.EnterSourceDetailsWithbody(48 testdata.baseUrl,49 testdata.methodpost,50 testdata.headerKey,51 testdata.headerValue,52 );53 cy.readFile("cypress/fixtures/postjson.txt").then((json) => {54 cy.log(json);55 cy.contains(ApiEditor.bodyTab).click({ force: true });56 cy.xpath(apiwidget.postbody)57 .click({ force: true })58 .focus()59 .type(json, { force: true });60 cy.WaitAutoSave();61 cy.RunAPI();62 cy.validateRequest(testdata.baseUrl, testdata.methodpost, testdata.Post);63 });64 cy.ResponseStatusCheck("201 CREATED");65 cy.log("Response code check successful");66 cy.ResponseCheck("createdAt");67 cy.log("Response data check successful");68 });69 it("PATCH Action test API fetaure", function() {70 cy.CreateAPI("FirstAPI");71 cy.log("Creation of FirstAPI Action successful");72 cy.SelectAction(testdata.patchAction);73 cy.EnterSourceDetailsWithbody(74 testdata.baseUrl,75 testdata.methodpatch,76 testdata.headerKey,77 testdata.headerValue,78 );79 cy.readFile("cypress/fixtures/patchjson.txt").then((json) => {80 cy.log(json);81 cy.contains(ApiEditor.bodyTab).click({ force: true });82 cy.xpath(apiwidget.postbody)83 .click({ force: true })84 .focus()85 .type(json, { force: true });86 cy.WaitAutoSave();87 cy.RunAPI();88 cy.validateRequest(89 testdata.baseUrl,90 testdata.methodpatch,91 testdata.Patch,92 );93 });94 cy.ResponseStatusCheck("200 OK");95 cy.log("Response code check successful");96 cy.ResponseCheck("updatedAt");97 cy.log("Response data check successful");98 });99 it("Delete Action test API fetaure", function() {100 cy.CreateAPI("FirstAPI");101 cy.log("Creation of FirstAPI Action successful");102 cy.SelectAction(testdata.deleteAction);103 cy.EnterSourceDetailsWithbody(104 testdata.baseUrl,105 testdata.methoddelete,106 testdata.headerKey,107 testdata.headerValue,108 );109 cy.WaitAutoSave();110 cy.RunAPI();111 cy.validateRequest(112 testdata.baseUrl,113 testdata.methoddelete,114 testdata.Delete,115 );116 cy.ResponseStatusCheck("200");117 cy.log("Response code check successful");118 });119 it("Test GET Action for mock API with header and pagination", function() {120 const apiname = "SecondAPI";121 cy.CreateAPI(apiname);122 cy.log("Creation of API Action successful");123 cy.enterDatasourceAndPath(testdata.baseUrl, testdata.methods);124 cy.WaitAutoSave();125 cy.RunAPI();126 cy.validateRequest(testdata.baseUrl, testdata.methods, testdata.Get);127 cy.ResponseStatusCheck(testdata.successStatusCode);128 cy.log("Response code check successful");129 cy.ResponseCheck(testdata.responsetext);130 cy.log("Response data check successful");131 cy.switchToPaginationTab();132 cy.selectPaginationType(apiwidget.paginationWithUrl);133 cy.enterUrl(apiname, apiwidget.panigationNextUrl, testdata.nextUrl);134 cy.clickTest(apiwidget.TestNextUrl);135 cy.validateRequest(136 testdata.baseUrl,137 testdata.methods.concat(testdata.next),138 testdata.Get,139 );140 cy.ResponseStatusCheck(testdata.successStatusCode);141 cy.log("Response code check successful");142 cy.ResponseCheck("Josh M Krantz");143 cy.log("Response data check successful");144 cy.enterUrl(apiname, apiwidget.panigationPrevUrl, testdata.prevUrl);145 cy.clickTest(apiwidget.TestPreUrl);146 cy.validateRequest(147 testdata.baseUrl,148 testdata.methods.concat(testdata.prev),149 testdata.Get,150 );151 cy.ResponseStatusCheck(testdata.successStatusCode);152 cy.log("Response code check successful");153 cy.ResponseCheck(testdata.responsetext);154 cy.log("Response data check successful");155 });156 it("API check with query params test API fetaure", function() {157 cy.CreateAPI("ThirdAPI");158 cy.log("Creation of API Action successful");159 cy.enterDatasourceAndPath(testdata.baseUrl, testdata.queryAndValue);160 cy.WaitAutoSave();161 cy.RunAPI();162 cy.validateRequest(testdata.baseUrl, testdata.queryAndValue, testdata.Get);163 cy.ResponseStatusCheck("200 OK");164 cy.log("Response code check successful");165 cy.ResponseCheck(testdata.responsetext3);166 cy.log("Response data check successful");167 });168 it("API check with Invalid Header", function() {169 cy.CreateAPI("FourthAPI");170 cy.log("Creation of API Action successful");171 cy.EnterSourceDetailsWithHeader(172 testdata.baseUrl,173 testdata.methods,174 testdata.headerKey,175 testdata.invalidValue,176 );177 cy.WaitAutoSave();178 cy.RunAPI();179 cy.validateRequest(testdata.baseUrl, testdata.methods, testdata.Get);180 cy.ResponseStatusCheck("5000");181 cy.log("Response code check successful");182 cy.ResponseCheck("Invalid value for Content-Type");183 cy.log("Response data check successful");184 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.error(err);4 console.log(data);5 wpt.getTestResults(data.data.testId, function(err, data) {6 if (err) return console.error(err);7 console.log(data);8 });9});10{ statusCode: 400,11 data: { statusCode: 400, statusText: 'Bad Request' } }12var wpt = require('webpagetest');13var wpt = new WebPageTest('www.webpagetest.org');14 if (err) return console.error(err);15 console.log(data);16 wpt.getTestResults(data.testId, function(err, data) {17 if (err) return console.error(err);18 console.log(data);19 });20});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3var options = {4};5 if (err) return console.error(err);6 console.log('Test Results: ' + data.data.testUrl);7 console.log('View the test at: ' + data.data.userUrl);8 console.log('Test ID: ' + data.data.testId);9 console.log('Test Status: ' + data.data.statusText);10 console.log('Test Results: ' + data.data.summary);11 console.log('Test Results: ' + data.data.median.firstView);12});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt.js');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) throw err;4 console.log(data);5});6var wpt = require('webpagetest.js');7var wpt = new WebPageTest('www.webpagetest.org');8 if (err) throw err;9 console.log(data);10});11var wpt = require('webpagetest.js');12var wpt = new WebPageTest('www.webpagetest.org');13 if (err) throw err;14 console.log(data);15});16var wpt = require('webpagetest.js');17var wpt = new WebPageTest('www.webpagetest.org');18 if (err) throw err;19 console.log(data);20});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.error(err);4 wpt.getTestResults(data.data.testId, function(err, data) {5 console.log(data.data);6 });7});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var test = new wpt('API_KEY');3test.getTestStatus('TEST_ID', function(err, data) {4 console.log(data);5});6var wpt = require('webpagetest');7var test = new wpt('API_KEY');8test.getTestStatus('TEST_ID', function(err, data) {9 console.log(data);10});11var wpt = require('webpagetest');12var test = new wpt('API_KEY');13test.getTestStatus('TEST_ID', function(err, data) {14 console.log(data);15});16var wpt = require('webpagetest');17var test = new wpt('API_KEY');18test.getTestStatus('TEST_ID', function(err, data) {19 console.log(data);20});21var wpt = require('webpagetest');22var test = new wpt('API_KEY');23test.getTestStatus('TEST_ID', function(err, data) {24 console.log(data);25});26var wpt = require('webpagetest');27var test = new wpt('API_KEY');28test.getTestStatus('TEST_ID', function(err, data) {29 console.log(data);30});31var wpt = require('webpagetest');32var test = new wpt('API_KEY');33test.getTestStatus('TEST_ID', function(err, data) {34 console.log(data);35});36var wpt = require('webpagetest');37var test = new wpt('API_KEY');38test.getTestStatus('TEST_ID', function(err, data) {39 console.log(data);40});41var wpt = require('webpagetest');42var test = new wpt('API_KEY');43test.getTestStatus('TEST_ID', function(err, data) {44 console.log(data);45});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2 if (err) return console.error(err);3 console.log(data);4 test.getTestResults(data.data.testId, function(err, data) {5 if (err) return console.error(err);6 console.log(data);7 });8});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful