How to use getObjectType method in Jest

Best JavaScript code snippet using jest

getEntityById_lists.js

Source:getEntityById_lists.js Github

copy

Full Screen

...48notificationHelper.setMessage(messageBody);49var organizationLink = notificationHelper.getOrgLink();50organization = vcdHost.getEntityById(VclFinderType.ORGANIZATION, organizationLink.id);51System.log("organization Name : " + organization.name);52inputName = workflowInputOfType(wf, System.getObjectType(organization));53if (inputName.length) inputProperties.put(inputName, organization);54var notification = notificationHelper.getNotification();55notificationType = VclEventType.getObject(notification.type);56System.log("notificationType : " + notificationType.value);57inputName = workflowInputOfType(wf, System.getObjectType(notificationType));58if (inputName.length) inputProperties.put(inputName, notificationType);59// Filtering out too old messages - not done yet60var timestamp = notification.timestamp;61var year = timestamp.getYear();62var month = timestamp.getMonth()-1;63var day = timestamp.getDay();64var hours = timestamp.getHour();65var minutes = timestamp.getMinute();66var seconds = timestamp.getSecond();67var vcdTimezoneMinutesOffset = timestamp.getTimezone();68//System.log("vCD server offset is GMT" + vcdTimezoneMinutesOffset/60 );69var notificationTime = new Date(year , month , day , hours , minutes , seconds);70System.log("vCD notification (vCD local time) : " + notificationTime);71var vcoLocalTime = new Date();72var vcoTimezoneMinutesOffset = -vcoLocalTime.getTimezoneOffset();73//System.log("vCO server offset is GMT" + (vcoTimezoneMinutesOffset/60) );74var notificationLocalTime = new Date(notificationTime.getTime() - (vcdTimezoneMinutesOffset * 60000) + (vcoTimezoneMinutesOffset * 60000));75System.log("vCD notification (vCO local time) : " + notificationLocalTime);76//System.log("vCO local time : " + vcoLocalTime);77var timeDifference = vcoLocalTime.getTime() - notificationLocalTime.getTime();78System.log("This notification is " + timeDifference/1000 + " seconds old");79Server.log("Notification age", timeDifference/1000 + " seconds");80operationSuccess = notification.operationSuccess;81System.log("operationSuccess : " + operationSuccess);82if (workflowHasInput(wf, "operationSuccess") == true) inputProperties.put("operationSuccess", operationSuccess);83var userLink = notificationHelper.getUserLink();84user = vcdHost.getEntityById(VclFinderType.USER, userLink.id);85if (user != null) {86 System.log("user : " + user.name);87 inputName = workflowInputOfType(wf, System.getObjectType(user));88 if (inputName.length >0) inputProperties.put(inputName, user);89}90var entityLink = notificationHelper.getEntityLink();91System.log("entityLink.type : " + entityLink.type);92System.log("entityLink.name : " + entityLink.name);93//I could have put this in an entity var and pass it to the subworkflows but using attributes is much better to troubleshoot after wf execution94switch(entityLink.type) {95 case "vcloud:blockingTask" : 96 entityBlockingTask = vcdHost.getEntityById(VclFinderType.BLOCKING_TASK, entityLink.id);97 inputName = getWorkflowInputName(wf, "entityBlockingTask", System.getObjectType(entityBlockingTask));98 //inputName = workflowInputOfType(wf, System.getObjectType(entityBlockingTask));99 if (inputName.length >0) inputProperties.put(inputName, entityBlockingTask);100 break;101 case "vcloud:catalog" : 102 entityCatalog = vcdHost.getEntityById(VclFinderType.CATALOG, entityLink.id);103 inputName = getWorkflowInputName(wf, "entityCatalog", System.getObjectType(entityCatalog));104 //inputName = workflowInputOfType(wf, System.getObjectType(entityCatalog));105 if (inputName.length >0) inputProperties.put(inputName, entityCatalog); 106 break;107 108 case "vcloud:catalogitem" : 109 entityCatalogItem = vcdHost.getEntityById(VclFinderType.CATALOG_ITEM, entityLink.id);110 inputName = getWorkflowInputName(wf, "entityCatalogItem", System.getObjectType(entityCatalogItem));111 //inputName = workflowInputOfType(wf, System.getObjectType(entityCatalogItem));112 if (inputName.length >0) inputProperties.put(inputName, entityCatalogItem); 113 break;114 115 case "vcloud:datastore" : 116 entityDatastore = vcdHost.getEntityById(VclFinderType.VMW_DATASTORE, entityLink.id);117 inputName = getWorkflowInputName(wf, "entityDatastore", System.getObjectType(entityDatastore));118 //inputName = workflowInputOfType(wf, System.getObjectType(entityDatastore));119 if (inputName.length >0) inputProperties.put(inputName, entityDatastore); 120 break; 121 122 case "vcloud:disk" : 123 entityDisk = vcdHost.getEntityById(VclFinderType.DISK, entityLink.id);124 inputName = getWorkflowInputName(wf, "entityDisk", System.getObjectType(entityDisk));125 //inputName = workflowInputOfType(wf, System.getObjectType(entityDisk));126 if (inputName.length >0) inputProperties.put(inputName, entityDisk); 127 break;128 129 case "vcloud:gateway" : 130 entityGateway = vcdHost.getEntityById(VclFinderType.GATEWAY, entityLink.id);131 inputName = getWorkflowInputName(wf, "entityGateway", System.getObjectType(entityGateway));132 //inputName = workflowInputOfType(wf, System.getObjectType(entityGateway));133 if (inputName.length >0) inputProperties.put(inputName, entityGateway); 134 break; 135 136 case "vcloud:group" : 137 entityGroup = vcdHost.getEntityById(VclFinderType.GROUP, entityLink.id);138 inputName = getWorkflowInputName(wf, "entityGroup", System.getObjectType(entityGroup));139 //inputName = workflowInputOfType(wf, System.getObjectType(entityGroup));140 if (inputName.length >0) inputProperties.put(inputName, entityGroup); 141 break;142 143 case "vcloud:host" : 144 entityHost = vcdHost.getEntityById(VclFinderType.VMW_HOST, entityLink.id);145 inputName = getWorkflowInputName(wf, "entityHost", System.getObjectType(entityHost));146 //inputName = workflowInputOfType(wf, System.getObjectType(entityHost));147 if (inputName.length >0) inputProperties.put(inputName, entityHost); 148 break;149 case "vcloud:media" : 150 entityMedia = vcdHost.getEntityById(VclFinderType.MEDIA, entityLink.id);151 inputName = getWorkflowInputName(wf, "entityMedia", System.getObjectType(entityMedia));152 //inputName = workflowInputOfType(wf, System.getObjectType(entityMedia));153 if (inputName.length >0) inputProperties.put(inputName, entityMedia); 154 break;155 156 case "vcloud:network" : 157 entityOrgVdcNetwork = vcdHost.getEntityById(VclFinderType.ORG_VDC_NETWORK, entityLink.id);158 if (entityOrgVdcNetwork != null) {159 inputName = getWorkflowInputName(wf, "entityOrgVdcNetwork", System.getObjectType(entityOrgVdcNetwork));160 //inputName = workflowInputOfType(wf, System.getObjectType(entityOrgVdcNetwork));161 if (inputName.length >0) inputProperties.put(inputName, entityOrgVdcNetwork); 162 }163 164 entityVAppNetwork = vcdHost.getEntityById(VclFinderType.VAPP_NETWORK, entityLink.id);165 if (entityVAppNetwork != null) {166 inputName = getWorkflowInputName(wf, "entityVAppNetwork", System.getObjectType(entityVAppNetwork));167 //inputName = workflowInputOfType(wf, System.getObjectType(entityVAppNetwork));168 if (inputName.length >0) inputProperties.put(inputName, entityVAppNetwork); 169 }170 171 entityExternalNetwork = vcdHost.getEntityById(VclFinderType.VMW_EXTERNAL_NETWORK, entityLink.id);172 if (entityExternalNetwork != null) {173 inputName = getWorkflowInputName(wf, "entityExternalNetwork", System.getObjectType(entityExternalNetwork));174 //inputName = workflowInputOfType(wf, System.getObjectType(entityExternalNetwork));175 if (inputName.length >0) inputProperties.put(inputName, entityExternalNetwork); 176 }177 break;178 179 case "vcloud:networkPool" : 180 entityNetworkPool = vcdHost.getEntityById(VclFinderType.VMW_NETWORK_POOL, entityLink.id);181 inputName = getWorkflowInputName(wf, "entityNetworkPool", System.getObjectType(entityNetworkPool));182 //inputName = workflowInputOfType(wf, System.getObjectType(entityNetworkPool));183 if (inputName.length >0) inputProperties.put(inputName, entityNetworkPool); 184 break;185 186 case "vcloud:org" : 187 entityOrganization = vcdHost.getEntityById(VclFinderType.ORGANIZATION, entityLink.id);188 inputName = getWorkflowInputName(wf, "entityOrganization", System.getObjectType(entityOrganization));189 //inputName = workflowInputOfType(wf, System.getObjectType(entityOrganization));190 if (inputName.length >0) inputProperties.put(inputName, entityOrganization); 191 break;192 193 case "vcloud:providervdc" : 194 entityProviderVdc = vcdHost.getEntityById(VclFinderType.VMW_PROVIDER_VDC, entityLink.id);195 inputName = getWorkflowInputName(wf, "entityProviderVdc", System.getObjectType(entityProviderVdc));196 //inputName = workflowInputOfType(wf, System.getObjectType(entityProviderVdc));197 if (inputName.length >0) inputProperties.put(inputName, entityProviderVdc); 198 break;199 // id="urn:vcloud:vdcstorageProfile:59"200 // href="https://vcloud.example.com/api/vdcStorageProfile/59"201 case "vcloud:lr.providervdcstorageclass" : //Bug 890059 202 entityProviderVdcStorageProfile = vcdHost.getEntityById(VclFinderType.VDC_STORAGE_PROFILE, entityLink.id);203 inputName = getWorkflowInputName(wf, "entityProviderVdcStorageProfile", System.getObjectType(entityProviderVdcStorageProfile));204 //inputName = workflowInputOfType(wf, System.getObjectType(entityProviderVdcStorageProfile));205 if (inputName.length >0) inputProperties.put(inputName, entityProviderVdcStorageProfile); 206 break;207 208 case "vcloud:right" : 209 entityRight = vcdHost.getEntityById(VclFinderType.RIGHT, entityLink.id);210 inputName = getWorkflowInputName(wf, "entityRight", System.getObjectType(entityRight));211 //inputName = workflowInputOfType(wf, System.getObjectType(entityRight));212 if (inputName.length >0) inputProperties.put(inputName, entityRight); 213 break;214 215 case "vcloud:role" : 216 entityRole = vcdHost.getEntityById(VclFinderType.ROLE, entityLink.id);217 inputName = getWorkflowInputName(wf, "entityRole", System.getObjectType(entityRole));218 //inputName = workflowInputOfType(wf, System.getObjectType(entityRole));219 if (inputName.length >0) inputProperties.put(inputName, entityRole); 220 break;221 222 case "vcloud:strandeditem" : 223 entityStrandedItem = vcdHost.getEntityById(VclFinderType.STRANDED_ITEM, entityLink.id);224 inputName = getWorkflowInputName(wf, "entityStrandedItem", System.getObjectType(entityStrandedItem));225 //inputName = workflowInputOfType(wf, System.getObjectType(entityStrandedItem));226 if (inputName.length >0) inputProperties.put(inputName, entityStrandedItem); 227 break;228 229 case "vcloud:task" : 230 entityTask = vcdHost.getEntityById(VclFinderType.TASK, entityLink.id);231 inputName = getWorkflowInputName(wf, "entityTask", System.getObjectType(entityTask));232 //inputName = workflowInputOfType(wf, System.getObjectType(entityTask));233 if (inputName.length >0) inputProperties.put(inputName, entityTask); 234 break;235 case "vcloud:user" : 236 entityUser = vcdHost.getEntityById(VclFinderType.USER, entityLink.id);237 inputName = getWorkflowInputName(wf, "entityUser", System.getObjectType(entityUser));238 //inputName = workflowInputOfType(wf, System.getObjectType(entityUser));239 if (inputName.length >0) inputProperties.put(inputName, entityUser); 240 break; 241 242 case "vcloud:vapp" : 243 entityVApp = vcdHost.getEntityById(VclFinderType.VAPP, entityLink.id);244 inputName = getWorkflowInputName(wf, "entityVApp", System.getObjectType(entityVApp));245 //inputName = workflowInputOfType(wf, System.getObjectType(entityVApp));246 if (inputName.length >0) inputProperties.put(inputName, entityVApp); 247 break;248 249 case "vcloud:vapptemplate" : 250 entityVAppTemplate = vcdHost.getEntityById(VclFinderType.VAPP_TEMPLATE, entityLink.id);251 inputName = getWorkflowInputName(wf, "entityVAppTemplate", System.getObjectType(entityVAppTemplate));252 //inputName = workflowInputOfType(wf, System.getObjectType(entityVAppTemplate));253 if (inputName.length >0) inputProperties.put(inputName, entityVAppTemplate); 254 break;255 256 case "vcloud:vdc" : 257 entityVdc = vcdHost.getEntityById(VclFinderType.VDC, entityLink.id);258 inputName = getWorkflowInputName(wf, "entityVdc", System.getObjectType(entityVdc));259 //inputName = workflowInputOfType(wf, System.getObjectType(entityVdc));260 if (inputName.length >0) inputProperties.put(inputName, entityVdc); 261 break;262 263 case "vcloud:lr.vdcstorageclass" : //Bug 890059 264 entityVdcStorageProfile = vcdHost.getEntityById(VclFinderType.VDC_STORAGE_PROFILE, entityLink.id);265 inputName = getWorkflowInputName(wf, "entityVdcStorageProfile", System.getObjectType(entityVdcStorageProfile));266 //inputName = workflowInputOfType(wf, System.getObjectType(entityVdcStorageProfile));267 if (inputName.length >0) inputProperties.put(inputName, entityVdcStorageProfile); 268 break;269 270 case "vcloud:vimserver" : 271 entityVimServer = vcdHost.getEntityById(VclFinderType.VIM_SERVER, entityLink.id);272 inputName = getWorkflowInputName(wf, "entityVimServer", System.getObjectType(entityVimServer));273 //inputName = workflowInputOfType(wf, System.getObjectType(entityVimServer));274 if (inputName.length >0) inputProperties.put(inputName, entityVimServer); 275 break;276 277 case "vcloud:vm" : 278 entityVm = vcdHost.getEntityById(VclFinderType.VM, entityLink.id);279 inputName = getWorkflowInputName(wf, "entityVm", System.getObjectType(entityVm));280 //inputName = workflowInputOfType(wf, System.getObjectType(entityVm));281 if (inputName.length >0) inputProperties.put(inputName, entityVm); 282 break;283 284 default: System.warn("Unidentified entityLink.type : " + entityLink.type);285} 286var taskOwnerLink = notificationHelper.getTaskOwnerLink();287System.log("taskOwnerLink.type : " + taskOwnerLink.type);288System.log("taskOwnerLink.name : " + taskOwnerLink.name);289switch(taskOwnerLink.type) {290 case "vcloud:blockingTask" : 291 taskOwnerBlockingTask = vcdHost.getEntityById(VclFinderType.BLOCKING_TASK, taskOwnerLink.id);292 inputName = getWorkflowInputName(wf, "taskOwnerBlockingTask", System.getObjectType(taskOwnerBlockingTask));293 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerBlockingTask));294 if (inputName.length >0) inputProperties.put(inputName, taskOwnerBlockingTask); 295 break;296 case "vcloud:catalog" : 297 taskOwnerCatalog = vcdHost.getEntityById(VclFinderType.CATALOG, taskOwnerLink.id);298 inputName = getWorkflowInputName(wf, "taskOwnerCatalog", System.getObjectType(taskOwnerCatalog));299 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerCatalog));300 if (inputName.length >0) inputProperties.put(inputName, taskOwnerCatalog); 301 break;302 303 case "vcloud:catalogitem" : 304 taskOwnerCatalogItem = vcdHost.getEntityById(VclFinderType.CATALOG_ITEM, taskOwnerLink.id);305 inputName = getWorkflowInputName(wf, "taskOwnerCatalogItem", System.getObjectType(taskOwnerCatalogItem));306 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerCatalogItem));307 if (inputName.length >0) inputProperties.put(inputName, taskOwnerCatalogItem); 308 break;309 310 case "vcloud:datastore" : 311 taskOwnerDatastore = vcdHost.getEntityById(VclFinderType.VMW_DATASTORE, taskOwnerLink.id);312 inputName = getWorkflowInputName(wf, "taskOwnerDatastore", System.getObjectType(taskOwnerDatastore));313 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerDatastore));314 if (inputName.length >0) inputProperties.put(inputName, taskOwnerDatastore); 315 break;316 317 case "vcloud:disk" : 318 taskOwnerDisk = vcdHost.getEntityById(VclFinderType.DISK, taskOwnerLink.id);319 inputName = getWorkflowInputName(wf, "taskOwnerDisk", System.getObjectType(taskOwnerDisk));320 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerDisk));321 if (inputName.length >0) inputProperties.put(inputName, taskOwnerDisk); 322 break; 323 case "vcloud:gateway" : 324 taskOwnerGateway = vcdHost.getEntityById(VclFinderType.GATEWAY, taskOwnerLink.id);325 inputName = getWorkflowInputName(wf, "taskOwnerGateway", System.getObjectType(taskOwnerGateway));326 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerGateway));327 if (inputName.length >0) inputProperties.put(inputName, taskOwnerGateway); 328 break;329 330 case "vcloud:group" : 331 taskOwnerGroup = vcdHost.getEntityById(VclFinderType.GROUP, taskOwnerLink.id);332 inputName = getWorkflowInputName(wf, "taskOwnerGroup", System.getObjectType(taskOwnerGroup));333 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerGroup));334 if (inputName.length >0) inputProperties.put(inputName, taskOwnerGroup); 335 break;336 337 case "vcloud:host" : 338 taskOwnerHost = vcdHost.getEntityById(VclFinderType.VMW_HOST, taskOwnerLink.id);339 inputName = getWorkflowInputName(wf, "taskOwnerHost", System.getObjectType(taskOwnerHost));340 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerHost));341 if (inputName.length >0) inputProperties.put(inputName, taskOwnerHost); 342 break;343 case "vcloud:media" : 344 taskOwnerMedia = vcdHost.getEntityById(VclFinderType.MEDIA, taskOwnerLink.id);345 inputName = getWorkflowInputName(wf, "taskOwnerMedia", System.getObjectType(taskOwnerMedia));346 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerMedia));347 if (inputName.length >0) inputProperties.put(inputName, taskOwnerMedia); 348 break;349 350 case "vcloud:network" :351 taskOwnerOrgVdcNetwork = vcdHost.getEntityById(VclFinderType.ORG_VDC_NETWORK, entityLink.id);352 if (taskOwnerOrgVdcNetwork != null) {353 inputName = getWorkflowInputName(wf, "taskOwnerOrgVdcNetwork", System.getObjectType(taskOwnerOrgVdcNetwork));354 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerOrgVdcNetwork));355 if (inputName.length >0) inputProperties.put(inputName, taskOwnerOrgVdcNetwork); 356 }357 358 taskOwnerVAppNetwork = vcdHost.getEntityById(VclFinderType.VAPP_NETWORK, entityLink.id);359 if (taskOwnerVAppNetwork != null) {360 inputName = getWorkflowInputName(wf, "taskOwnerVAppNetwork", System.getObjectType(taskOwnerVAppNetwork));361 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerVAppNetwork));362 if (inputName.length >0) inputProperties.put(inputName, taskOwnerVAppNetwork); 363 }364 365 taskOwnerExternalNetwork = vcdHost.getEntityById(VclFinderType.VMW_EXTERNAL_NETWORK, entityLink.id);366 if (taskOwnerExternalNetwork != null) {367 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerExternalNetwork));368 inputName = getWorkflowInputName(wf, "taskOwnerExternalNetwork", System.getObjectType(taskOwnerExternalNetwork));369 if (inputName.length >0) inputProperties.put(inputName, taskOwnerExternalNetwork); 370 }371 break;372 373 case "vcloud:networkPool" : 374 taskOwnerNetworkPool = vcdHost.getEntityById(VclFinderType.VMW_NETWORK_POOL, taskOwnerLink.id);375 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerNetworkPool));376 inputName = getWorkflowInputName(wf, "taskOwnerNetworkPool", System.getObjectType(taskOwnerNetworkPool));377 if (inputName.length >0) inputProperties.put(inputName, taskOwnerNetworkPool); 378 break;379 380 case "vcloud:org" : 381 taskOwnerOrganization = vcdHost.getEntityById(VclFinderType.ORGANIZATION, taskOwnerLink.id);382 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerOrganization));383 inputName = getWorkflowInputName(wf, "taskOwnerOrganization", System.getObjectType(taskOwnerOrganization));384 if (inputName.length >0) inputProperties.put(inputName, taskOwnerOrganization); 385 break;386 387 case "vcloud:providervdc" : 388 taskOwnerProviderVdc = vcdHost.getEntityById(VclFinderType.VMW_PROVIDER_VDC, taskOwnerLink.id);389 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerProviderVdc));390 inputName = getWorkflowInputName(wf, "taskOwnerProviderVdc", System.getObjectType(taskOwnerProviderVdc));391 if (inputName.length >0) inputProperties.put(inputName, taskOwnerProviderVdc); 392 break;393 case "vcloud:lr.providervdcstorageclass" : //Bug 890059 394 taskOwnerProviderVdcStorageProfile = vcdHost.getEntityById(VclFinderType.VDC_STORAGE_PROFILE, taskOwnerLink.id);395 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerProviderVdcStorageProfile));396 inputName = getWorkflowInputName(wf, "taskOwnerProviderVdcStorageProfile", System.getObjectType(taskOwnerProviderVdcStorageProfile));397 if (inputName.length >0) inputProperties.put(inputName, taskOwnerProviderVdcStorageProfile); 398 break; 399 400 case "vcloud:right" : 401 taskOwnerRight = vcdHost.getEntityById(VclFinderType.RIGHT, taskOwnerLink.id);402 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerRight));403 inputName = getWorkflowInputName(wf, "taskOwnerRight", System.getObjectType(taskOwnerRight));404 if (inputName.length >0) inputProperties.put(inputName, taskOwnerRight); 405 break;406 407 case "vcloud:role" : 408 taskOwnerRole = vcdHost.getEntityById(VclFinderType.ROLE, taskOwnerLink.id);409 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerRole));410 inputName = getWorkflowInputName(wf, "taskOwnerRole", System.getObjectType(taskOwnerRole));411 if (inputName.length >0) inputProperties.put(inputName, taskOwnerRole); 412 break;413 case "vcloud:strandeditem" : 414 taskOwnerStrandedItem = vcdHost.getEntityById(VclFinderType.STRANDED_ITEM, taskOwnerLink.id);415 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerStrandedItem));416 inputName = getWorkflowInputName(wf, "taskOwnerStrandedItem", System.getObjectType(taskOwnerStrandedItem));417 if (inputName.length >0) inputProperties.put(inputName, taskOwnerStrandedItem); 418 break;419 420 case "vcloud:task" : 421 taskOwnerTask = vcdHost.getEntityById(VclFinderType.TASK, taskOwnerLink.id);422 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerTask));423 inputName = getWorkflowInputName(wf, "taskOwnerTask", System.getObjectType(taskOwnerTask));424 if (inputName.length >0) inputProperties.put(inputName, taskOwnerTask); 425 break;;426 case "vcloud:user" : 427 taskOwnerUser = vcdHost.getEntityById(VclFinderType.USER, taskOwnerLink.id);428 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerUser));429 inputName = getWorkflowInputName(wf, "taskOwnerUser", System.getObjectType(taskOwnerUser));430 if (inputName.length >0) inputProperties.put(inputName, taskOwnerUser); 431 break; 432 433 case "vcloud:vapp" : 434 taskOwnerVApp = vcdHost.getEntityById(VclFinderType.VAPP, taskOwnerLink.id);435 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerVApp));436 inputName = getWorkflowInputName(wf, "taskOwnerVApp", System.getObjectType(taskOwnerVApp));437 if (inputName.length >0) inputProperties.put(inputName, taskOwnerVApp); 438 break;439 440 case "vcloud:vapptemplate" : 441 taskOwnerVAppTemplate = vcdHost.getEntityById(VclFinderType.VAPP_TEMPLATE, taskOwnerLink.id);442 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerVAppTemplate));443 inputName = getWorkflowInputName(wf, "taskOwnerVAppTemplate", System.getObjectType(taskOwnerVAppTemplate));444 if (inputName.length >0) inputProperties.put(inputName, taskOwnerVAppTemplate); 445 break;446 447 case "vcloud:vdc" : 448 taskOwnerVdc = vcdHost.getEntityById(VclFinderType.VDC, taskOwnerLink.id);449 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerVdc));450 inputName = getWorkflowInputName(wf, "taskOwnerVdc", System.getObjectType(taskOwnerVdc));451 if (inputName.length >0) inputProperties.put(inputName, taskOwnerVdc); 452 break;453 case "vcloud:lr.vdcstorageclass" : //Bug 890059 454 taskOwnerVdcStorageProfile = vcdHost.getEntityById(VclFinderType.VDC_STORAGE_PROFILE, taskOwnerLink.id);455 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerVdcStorageProfile));456 inputName = getWorkflowInputName(wf, "taskOwnerVdcStorageProfile", System.getObjectType(taskOwnerVdcStorageProfile));457 if (inputName.length >0) inputProperties.put(inputName, taskOwnerVdcStorageProfile); 458 break;459 case "vcloud:vimserver" : 460 taskOwnerVimServer = vcdHost.getEntityById(VclFinderType.VIM_SERVER, taskOwnerLink.id);461 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerVimServer));462 inputName = getWorkflowInputName(wf, "taskOwnerVimServer", System.getObjectType(taskOwnerVimServer));463 if (inputName.length >0) inputProperties.put(inputName, taskOwnerVimServer); 464 break;465 case "vcloud:vm" : 466 taskOwnerVm = vcdHost.getEntityById(VclFinderType.VM, taskOwnerLink.id);467 //inputName = workflowInputOfType(wf, System.getObjectType(taskOwnerVm));468 inputName = getWorkflowInputName(wf, "taskOwnerVm", System.getObjectType(taskOwnerVm));469 if (inputName.length >0) inputProperties.put(inputName, taskOwnerVm); 470 break;471 472 default: throw("Unidentified taskOwnerLink.type : " + taskOwnerLink.type);473} 474//Blocking task475if (notificationHelper.isBlockingTask() == true) {476 477 var blockingTaskLink = notificationHelper.getBlockingTaskLink();478 blockingTask == null;479 blockingTask = vcdHost.getEntityById(VclFinderType.BLOCKING_TASK, blockingTaskLink.id);480 if (blockingTask != null) {481 System.log("blockingTask : " + blockingTask.name);482 inputName = workflowInputOfType(wf, System.getObjectType(blockingTask));483 if (inputName.length >0) inputProperties.put(inputName, blockingTask);484 //The task contains a getParams() method containing all the parameters for update operations (for example recomposeVAppParams)485 var taskReference = blockingTask.getTask();486 task = vcdHost.getEntityByReference(VclFinderType.TASK, taskReference);487 if (task != null) {488 System.log("task : " + task.name);489 inputName = workflowInputOfType(wf, System.getObjectType(task));490 if (inputName.length >0) inputProperties.put(inputName, task);491 } 492 }493 else {494 System.warn("Could not get the blocking task " + blockingTaskLink.id + " : " + blockingTaskLink.name);495 Server.warn("Could not get the blocking task " , blockingTaskLink.name + " : " + blockingTaskLink.id );496 var availableBlockingTasks = Server.findAllForType("vCloud:BlockingTask");497 var availableBlockingTasksText = "";498 for each (var availableBlockingTask in availableBlockingTasks) {499 availableBlockingTasksText += availableBlockingTask.id + ":" + availableBlockingTask.name + " : " + availableBlockingTask.status + "\n";500 var taskOwnerRef = availableBlockingTask.taskOwner;501 System.warn("Task owner for waiting blocking task " + vcdHost.getEntityByReference(VclFinderType.VAPP, taskOwnerRef).name);502 }503 System.warn("Available blocking tasks on " + new Date() + " are : " + availableBlockingTasksText);504 Server.warn("Available blocking tasks on " + new Date() + " are : ", availableBlockingTasksText);505 506 507 } 508}509for each (var p in inputProperties.keys) {510 try {511 System.log("Setting " + p + log(inputProperties.get(p))); //" with parameter " + inputProperties.get(p));512 } catch(e) {System.log("Setting " + p + " with parameter " + inputProperties.get(p));}513}514System.log("Running workflow " + wf.name);515Server.log("Running workflow", wf.name);516token = wf.execute(inputProperties);517function workflowInputOfType(wf, type) {518 var wfInParameters = wf.inParameters;519 for each (var wfInParameter in wfInParameters) {520 if (wfInParameter.type == type) return wfInParameter.name;521 }522 return ""; 523}524function getWorkflowInputName(wf, inputName, inputType) {525 System.log("getWorkflowInputName(wf, " + inputName +", " + inputType+ ");");526 var wfInParameters = wf.inParameters;527 for each (var wfInParameter in wfInParameters) {528 if (wfInParameter.name == inputName && wfInParameter.type == inputType) {529 System.log("Found input parameter with matching name and type : " + wfInParameter.name);530 return wfInParameter.name;531 } 532 } 533 //In case the input parameter name is not matching get it based on type534 for each (var wfInParameter in wfInParameters) {535 if (wfInParameter.type == inputType) {536 System.log("Found input parameter with matching type : " + wfInParameter.name);537 return wfInParameter.name;538 }539 }540 System.log("Did not find input parameter");541 return ""; 542}543function workflowHasInput(wf, inputName) {544 var wfInParameters = wf.inParameters;545 for each (var wfInParameter in wfInParameters) {546 if (wfInParameter.name == inputName) return true;547 }548 return false; 549}550function log(object) {551 var log = "";552 var type = System.getObjectType(object);553 log += " (type = " + type;554 if (type.split(":")[1] == "EventType") {555 log += ", value : " + object.value;556 }557 else {558 if (type.split(":")[0] == "vCloud") {559 try {560 var objectName = object.name;561 if (objectName != null) log += ", name = " + objectName;562 var objectUrl = object.href;563 if (objectName != null) log += ", URL = " + objectUrl;564 }565 catch(e) {566 log += "object = " + object;...

Full Screen

Full Screen

testobjects.js

Source:testobjects.js Github

copy

Full Screen

...22 return "Corner[4] + ("+x+"*(x(Corner[3])-x(Corner[4])),"+y+"*(x(Corner[2])-x(Corner[1])))"23 }24 var count = 'Text["Count = 0",'+abspos("0.85","-0.032915")+']'25function newObjectListener(obj) {26if (ggbApplet.getObjectType(obj) === "boolean" || ggbApplet.getObjectType(obj) === "text" || ggbApplet.getObjectType(obj) === "numeric"|| obj == "W")27{return;28}29 if (ggbApplet.getObjectType(obj) == "segment" || ggbApplet.getObjectType(obj) == "circle" || ggbApplet.getObjectType(obj) == "ray" || ggbApplet.getObjectType(obj) == "line") {30ggbApplet.setColor(obj,255,204,102);31}32 function Command(cmd){ggbApplet.debug(cmd); ggbApplet.evalCommand(cmd);}33 function abspos(x,y){34 return "Corner[4] + ("+x+"*(x(Corner[3])-x(Corner[4])),"+y+"*(x(Corner[2])-x(Corner[1])))"35 }36 37var cmdString = ggbApplet.getCommandString(obj);38console.log(cmdString);39console.log(ggbApplet.getObjectType(obj));40console.log(obj);41if (ggbApplet.getObjectType(obj) == "point" && cmdString == "")42{43 console.log(ggbApplet.getXcoord(obj));44 var x = ggbApplet.getXcoord(obj) + 0.01;45 console.log(x);46 var y = ggbApplet.getYcoord(obj) - 0.01;47 Command( obj +"= ("+x+","+y+")");48}49if (cmdString.substring(0,3) == "Ray" || (cmdString.substring(0,2) == "Eq" && ggbApplet.getObjectType(obj)=="point") || cmdString.substring(0,3) == "Seg" ||cmdString.substring(0,3) == "Cir" || cmdString.substring(0,3) == "Mid" || cmdString.substring(0,13) == "AngleBisector" || cmdString.substring(0,4) == "Perp" || cmdString.substring(0,4) == "Line" || (cmdString.substring(0,5) == "Trans"&& ggbApplet.getObjectType(obj)=="point")){50 Command('countnumber = countnumber + 1');51if (!(cmdString.substring(0,3) == "Ray" || cmdString.substring(0,3) == "Seg" || cmdString.substring(0,3) == "Cir") && primitives) { primitives = false;}52function isLowerCase(myString) { 53 return (myString == myString.toLowerCase()); 54}55var lastcomma = cmdString.indexOf(",");56if(cmdString.substring(0,3) == "Cir" && (isLowerCase(cmdString.substring(lastcomma+2,lastcomma+3)) || cmdString.substring(lastcomma+2,lastcomma+4) =="Se" || cmdString.substring(lastcomma+2,lastcomma+4) =="Ra"))57{58primitives = false;} 59}60if (cmdString.substring(0,13) == "AngleBisector"){61var obj1 = cmdString.substring(14,15);62if (ggbApplet.getObjectType(obj1) === "point"){63var obj2 = cmdString.substring(17,18);64var obj3 = cmdString.substring(20,21);65var a = ggbApplet.getXcoord(obj1);66var b = ggbApplet.getYcoord(obj1);67var m = ggbApplet.getXcoord(obj2);68var n = ggbApplet.getYcoord(obj2);69var x = ggbApplet.getXcoord(obj3);70var y = ggbApplet.getYcoord(obj3);71function round(value) {72 return(Math.round(value * 100000) / 100000);73}74if ( round((n-b)*(x-m)) === round((y-n)*(m-a))){75Command('Delete['+obj+']');76Command('Text["You can\'t use the bisecting tool if the angle is 180 degrees !",'+abspos("0.02","-0.632915")+']');77}78}79}80function getCoord(obj){ 81 if (ggbApplet.getObjectType(obj) === "point" ) {82 var x = ggbApplet.getXcoord(obj);83 var y = ggbApplet.getYcoord(obj);84 return "("+x+","+y+")"}85 else if (ggbApplet.getObjectType(obj)==="segment" || ggbApplet.getObjectType(obj)==="ray" ){86 Command("xx = x(Point["+obj+",0.5])");87 Command("yy = y(Point["+obj+",0.5])");88 var x = ggbApplet.getValue("xx");89 var y = ggbApplet.getValue("yy");90 return "("+x+","+y+")";91 }92 else if (ggbApplet.getObjectType(obj)==="circle"){93 var x = ggbApplet.getXcoord(cmdString.substring(7,8));94 var y = ggbApplet.getYcoord(cmdString.substring(7,8));95 return "("+x+","+y+")";96 }97}98 // this functions can check all general objects99 function checkobject(target,x,y) {100 Command("finished = (" + obj + "== " + target + ")");101 finished = ggbApplet.getValueString("finished");102 if (finished.indexOf("true") > -1) {103 Command('f_'+target+'= Text["", (0,0)]');104 Command("W = "+getCoord(target)+"+("+x+","+y+")");105 ggbApplet.setVisible("welldone",true); 106 } 107 }108 // this functions check line segments109 function checksegment(target,x,y) {110 if (ggbApplet.getObjectType(obj) == "segment") {111 var beginpointobject = "Point["+obj+",0]"112 var endpointobject = "Point["+obj+",1]"113 var beginpointtarget = "Point["+target+",0]"114 var endpointtarget = "Point["+target+",1]"115 //here it checks if endpoints of line segment are equal116 if (obj != "finished") {117 Command("finished =((("+beginpointobject+"=="+beginpointtarget+")||("+beginpointobject+"=="+endpointtarget+"))&&(("+endpointobject+"=="+beginpointtarget+")||("+endpointobject+"=="+endpointtarget+")))");118 finished = ggbApplet.getValueString("finished");119 if (finished.indexOf("true") > -1) {120 Command('f_'+target+'= Text["", (0,0)]');121 if (typeof x !== 'undefined'){122 Command("W = "+getCoord(target)+"+("+x+","+y+")")}; 123 ggbApplet.setVisible("welldone",true); 124 }125 }126 }127 }128 // this functions can check if line segment has right direction129 130 function checkdirection(target,x,y) {131 if (ggbApplet.getObjectType(obj) == "segment" || ggbApplet.getObjectType(obj) == "ray" || ggbApplet.getObjectType(obj) == "line") {132 133 Command("finished = (("+obj+"(1)=="+target+"(1))&&("+obj+"(-1)=="+target+"(-1)))");134 finished = ggbApplet.getValueString("finished");135 if (finished.indexOf("true") > -1) {136 Command('f_'+target+'= Text["", (0,0)]');137 if (typeof x !== 'undefined'){138 Command("W = "+getCoord(target)+"+("+x+","+y+")")}; 139 ggbApplet.setVisible("welldone",true); 140 }141 142 }143 }144 // this functions check if the new point is on the targetline145 function checkpointontarget(target,x,y) {146 if (ggbApplet.getObjectType(obj) == "point") {147 Command("finished = ("+target+"(x("+obj+"))==y("+obj+"))");148 finished = ggbApplet.getValueString("finished");149 if (finished.indexOf("true") > -1) {150 Command('f_p'+target+'= Text["", (0,0)]');151 if (typeof x !== 'undefined'){152 Command("W = "+getCoord(obj)+"+("+x+","+y+")")}; 153 ggbApplet.setVisible("welldone",true); 154 }155 }156 }157function drawn(object){158 return ggbApplet.getVisible('f_'+object) ;159}160var setVisible = ggbApplet.setVisible;...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...109 * @param {any} value110 * @returns {boolean}111 */112function isDate (value /* :mixed */ ) /* :boolean */ {113 return getObjectType(value) === '[object Date]'114}115/**116 * Checks to see if a value is an arguments object117 * @param {any} value118 * @returns {boolean}119 */120function isArguments (value /* :mixed */ ) /* :boolean */ {121 return getObjectType(value) === '[object Arguments]'122}123/**124 * Checks to see if a value is a function125 * @param {any} value126 * @returns {boolean}127 */128function isFunction (value /* :mixed */ ) /* :boolean */ {129 return getObjectType(value) === '[object Function]'130}131/**132 * Checks to see if a value is an regex133 * @param {any} value134 * @returns {boolean}135 */136function isRegExp (value /* :mixed */ ) /* :boolean */ {137 return getObjectType(value) === '[object RegExp]'138}139/**140 * Checks to see if a value is an array141 * @param {any} value142 * @returns {boolean}143 */144function isArray (value /* :mixed */ ) /* :boolean */ {145 return (typeof Array.isArray === 'function' && Array.isArray(value)) || getObjectType(value) === '[object Array]'146}147/**148 * Checks to see if a valule is a number149 * @param {any} value150 * @returns {boolean}151 */152function isNumber (value /* :mixed */ ) /* :boolean */ {153 return typeof value === 'number' || getObjectType(value) === '[object Number]'154}155/**156 * Checks to see if a value is a string157 * @param {any} value158 * @returns {boolean}159 */160function isString (value /* :mixed */ ) /* :boolean */ {161 return typeof value === 'string' || getObjectType(value) === '[object String]'162}163/**164 * Checks to see if a valule is a boolean165 * @param {any} value166 * @returns {boolean}167 */168function isBoolean (value /* :mixed */ ) /* :boolean */ {169 return value === true || value === false || getObjectType(value) === '[object Boolean]'170}171/**172 * Checks to see if a value is null173 * @param {any} value174 * @returns {boolean}175 */176function isNull (value /* :mixed */ ) /* :boolean */ {177 return value === null178}179/**180 * Checks to see if a value is undefined181 * @param {any} value182 * @returns {boolean}183 */184function isUndefined (value /* :mixed */ ) /* :boolean */ {185 return typeof value === 'undefined'186}187/**188 * Checks to see if a value is a Map189 * @param {any} value190 * @returns {boolean}191 */192function isMap (value /* :mixed */ ) /* :boolean */ {193 return getObjectType(value) === '[object Map]'194}195/**196 * Checks to see if a value is a WeakMap197 * @param {any} value198 * @returns {boolean}199 */200function isWeakMap (value /* :mixed */ ) /* :boolean */ {201 return getObjectType(value) === '[object WeakMap]'202}203// -----------------------------------204// General205/**206 * The type mapping (type => method) to use for getType. Frozen.207 */208const typeMap = Object.freeze({209 array: isArray,210 boolean: isBoolean,211 date: isDate,212 error: isError,213 class: isClass,214 function: isFunction,215 null: isNull,...

Full Screen

Full Screen

getObject.bundle.js

Source:getObject.bundle.js Github

copy

Full Screen

...90 !*** ./getObject.js ***!91 \**********************/92/*! no static exports found */93/***/ (function(module, exports, __webpack_require__) {94eval("\nconst getObjectType = __webpack_require__(/*! ./src/util/getObjectType */ \"./src/util/getObjectType.js\");\nconst getDate = __webpack_require__(/*! ./src/util/dateUtility */ \"./src/util/dateUtility.js\")\n\nconst getObject = () => {\n const objectType = getObjectType();\n const date = getDate();\n return {\n getObjectType: objectType,\n startDate: date,\n endDate: date + 100000\n }\n}\n\nconsole.log(getObject());\n\n//# sourceURL=webpack:///./getObject.js?");95/***/ }),96/***/ "./src/util/dateUtility.js":97/*!*********************************!*\98 !*** ./src/util/dateUtility.js ***!99 \*********************************/100/*! no static exports found */101/***/ (function(module, exports) {102eval("\n\nconst getDate = () => {\n return Date.now();\n}\n\n// export default getDate;\nmodule.exports = getDate;\n\n//# sourceURL=webpack:///./src/util/dateUtility.js?");103/***/ }),104/***/ "./src/util/getObjectType.js":105/*!***********************************!*\106 !*** ./src/util/getObjectType.js ***!107 \***********************************/108/*! no static exports found */...

Full Screen

Full Screen

FilterDefinition.js

Source:FilterDefinition.js Github

copy

Full Screen

...30 start: node.loc.start,31 end: node.loc.end } } : {},32 ...isNodeConnectionField(node) ? {33 isNodeConnection: true,34 type: getObjectType(getConnectionType(node)),35 edgeType: getConnectionEdgeType(node) } : {},36 ...isObjectConnectionField(node) ? {37 isObjectConnection: true,38 type: getObjectType(getConnectionType(node)),39 edgeType: getConnectionEdgeType(node) } : {},40 ...isScalarConnectionField(node) ? {41 isScalarConnection: true,42 type: getScalarType(getConnectionType(node)),43 edgeType: getConnectionEdgeType(node) } : {},44 ...isListOfScalarField(node) ? {45 isScalarList: true,46 type: getScalarType(getListType(node)) } : {},47 ...isListOfObjectField(node) &&48 isNode(getObjectType(getListType(node))) ? {49 isNodeList: true,50 type: getObjectType(getListType(node)) } : {},51 ...isListOfObjectField(node) &&52 !isNode(getObjectType(getListType(node))) ? {53 isObjectList: true,54 type: getObjectType(getListType(node)) } : {},55 conditions: node.conditions.map(FilterCondition(context)),56 };57 return undefined; // node remains unchanged58 }59 };...

Full Screen

Full Screen

OrderDefinition.js

Source:OrderDefinition.js Github

copy

Full Screen

...30 start: node.loc.start,31 end: node.loc.end } } : {},32 ...isNodeConnectionField(node) ? {33 isNodeConnection: true,34 type: getObjectType(getConnectionType(node)),35 edgeType: getConnectionEdgeType(node) } : {},36 ...isObjectConnectionField(node) ? {37 isObjectConnection: true,38 type: getObjectType(getConnectionType(node)),39 edgeType: getConnectionEdgeType(node) } : {},40 ...isScalarConnectionField(node) ? {41 isScalarConnection: true,42 type: getScalarType(getConnectionType(node)),43 edgeType: getConnectionEdgeType(node) } : {},44 ...isListOfScalarField(node) ? {45 isScalarList: true,46 type: getScalarType(getListType(node)) } : {},47 ...isListOfObjectField(node) &&48 isNode(getObjectType(getListType(node))) ? {49 isNodeList: true,50 type: getObjectType(getListType(node)) } : {},51 ...isListOfObjectField(node) &&52 !isNode(getObjectType(getListType(node))) ? {53 isObjectList: true,54 type: getObjectType(getListType(node)) } : {},55 expressions: node.expressions.map(OrderExpression(context)),56 };57 return undefined; // node remains unchanged58 }59 };...

Full Screen

Full Screen

getObjectTypeSpec.js

Source:getObjectTypeSpec.js Github

copy

Full Screen

...6 describe('getObjectType', () => {7 it('identifies Immutable OrderedMaps', () => {8 const input = OrderedMap();9 const expected = 'ImmutableOrderedMap';10 const result = getObjectType(input);11 expect(result).to.equal(expected);12 });13 it('identifies Immutable Maps', () => {14 const input = Map();15 const expected = 'ImmutableMap';16 const result = getObjectType(input);17 expect(result).to.equal(expected);18 });19 it('identifies Immutable Lists', () => {20 const input = List();21 const expected = 'ImmutableList';22 const result = getObjectType(input);23 expect(result).to.equal(expected);24 });25 it('identifies JS Objects', () => {26 const input = {};27 const expected = 'JSObject';28 const result = getObjectType(input);29 expect(result).to.equal(expected);30 });31 it('identifies JS Arrays', () => {32 const input = [];33 const expected = 'JSArray';34 const result = getObjectType(input);35 expect(result).to.equal(expected);36 });37 it('throws for an unrecognized type', () => {38 const input = 4;39 expect(() => getObjectType(input)).to.throw('Unrecognized type');40 });41 });42 describe('isJS', () => {43 it('identifies JS correctly', () => {44 const inputs = [[], {}];45 const results = [true, true];46 expect(inputs.map(isJS)).to.eql(results);47 });48 it('identifies Immutables correctly', () => {49 const inputs = [List(), Map(), OrderedMap()];50 const results = [false, false, false];51 expect(inputs.map(isJS)).to.eql(results);52 });53 });...

Full Screen

Full Screen

logistic-unit.js

Source:logistic-unit.js Github

copy

Full Screen

...3const network = require('../libs/fabric-lib/food-supply-chain-network.js');4var LogisticUnit = class {5 constructor(opts) {6 this.id = opts.id,7 this.objectType = opts.objectType || LogisticUnit.getObjectType(),8 this.parent = opts.parent,9 this.name = opts.name,10 this.content = opts.content;11 this.content = (opts.content && opts.content instanceof Object) ? 12 JSON.stringify(opts.content) : opts.content;13 }14 toString()15 { 16 return "[ LogisticUnit-id: " + this.id + " , name: " + this.name + 17 " , objectType: " + this.objectType + " , content: " + this.content + " ]"; 18 }19 create()20 {21 return network.invoke('createTraceable', this);22 }23 update()24 {25 return network.invoke('updateTraceable', this); 26 }27 static getObjectType()28 {29 return constants.ObjectTypes.LogisticUnit;30 }31 static find(id)32 { 33 return network.query('getObject', id, LogisticUnit.getObjectType());34 }35 static getAll()36 { 37 let queryString = {38 "selector": {39 "objectType": LogisticUnit.getObjectType()40 } 41 } 42 return network.query('getQueryResultForQueryString', JSON.stringify(queryString));43 }44}...

Full Screen

Full Screen

Jest Testing Tutorial

LambdaTest’s Jest Testing Tutorial covers step-by-step guides around Jest with code examples to help you be proficient with the Jest framework. The Jest tutorial has chapters to help you learn right from the basics of Jest framework to code-based tutorials around testing react apps with Jest, perform snapshot testing, import ES modules and more.

Chapters

  1. What is Jest Framework
  2. Advantages of Jest - Jest has 3,898,000 GitHub repositories, as mentioned on its official website. Learn what makes Jest special and why Jest has gained popularity among the testing and developer community.
  3. Jest Installation - All the prerequisites and set up steps needed to help you start Jest automation testing.
  4. Using Jest with NodeJS Project - Learn how to leverage Jest framework to automate testing using a NodeJS Project.
  5. Writing First Test for Jest Framework - Get started with code-based tutorial to help you write and execute your first Jest framework testing script.
  6. Jest Vocabulary - Learn the industry renowned and official jargons of the Jest framework by digging deep into the Jest vocabulary.
  7. Unit Testing with Jest - Step-by-step tutorial to help you execute unit testing with Jest framework.
  8. Jest Basics - Learn about the most pivotal and basic features which makes Jest special.
  9. Jest Parameterized Tests - Avoid code duplication and fasten automation testing with Jest using parameterized tests. Parameterization allows you to trigger the same test scenario over different test configurations by incorporating parameters.
  10. Jest Matchers - Enforce assertions better with the help of matchers. Matchers help you compare the actual output with the expected one. Here is an example to see if the object is acquired from the correct class or not. -

|<p>it('check_object_of_Car', () => {</p><p> expect(newCar()).toBeInstanceOf(Car);</p><p> });</p>| | :- |

  1. Jest Hooks: Setup and Teardown - Learn how to set up conditions which needs to be followed by the test execution and incorporate a tear down function to free resources after the execution is complete.
  2. Jest Code Coverage - Unsure there is no code left unchecked in your application. Jest gives a specific flag called --coverage to help you generate code coverage.
  3. HTML Report Generation - Learn how to create a comprehensive HTML report based on your Jest test execution.
  4. Testing React app using Jest Framework - Learn how to test your react web-application with Jest framework in this detailed Jest tutorial.
  5. Test using LambdaTest cloud Selenium Grid - Run your Jest testing script over LambdaTest cloud-based platform and leverage parallel testing to help trim down your test execution time.
  6. Snapshot Testing for React Front Ends - Capture screenshots of your react based web-application and compare them automatically for visual anomalies with the help of Jest tutorial.
  7. Bonus: Import ES modules with Jest - ES modules are also known as ECMAScript modules. Learn how to best use them by importing in your Jest testing scripts.
  8. Jest vs Mocha vs Jasmine - Learn the key differences between the most popular JavaScript-based testing frameworks i.e. Jest, Mocha, and Jasmine.
  9. Jest FAQs(Frequently Asked Questions) - Explore the most commonly asked questions around Jest framework, with their answers.

Run Jest 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