AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 1 | /*! |
| 2 | * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
| 13 | * or implied. See the License for the specific language governing |
| 14 | * permissions and limitations under the License. |
| 15 | */ |
| 16 | import {Factory} from 'rosie'; |
| 17 | import SequenceDiagramFactory from './SequenceDiagramFactory.js'; |
| 18 | import ParticipantFactory from './ParticipantFactory.js'; |
| 19 | import UUID from 'uuid-js'; |
| 20 | |
| 21 | const serviceIDByArtifactType = { |
| 22 | NETWORK_CALL_FLOW: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b', |
| 23 | WORKFLOW: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b', |
| 24 | PUPPET: '0280b577-2c7b-426e-b7a2-f0dc16508c37' |
| 25 | }; |
| 26 | |
| 27 | const defaultServiceId = '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b'; |
| 28 | |
| 29 | Factory.define('FlowBaseFactory') |
| 30 | .attrs({ |
| 31 | artifactName: 'zizizi', |
| 32 | artifactType: 'WORKFLOW', |
| 33 | description: 'aslkjdfl asfdasdf', |
| 34 | }); |
| 35 | |
| 36 | Factory.define('FlowBaseWithServiceIdFactory') |
| 37 | .extend('FlowBaseFactory') |
| 38 | .attr( |
| 39 | 'serviceID', ['artifactType'], artifactType => serviceIDByArtifactType[artifactType] || defaultServiceId |
| 40 | ); |
| 41 | |
| 42 | Factory.define('FlowBaseWithUniqueIdFactory') |
| 43 | .extend('FlowBaseFactory') |
| 44 | .attr('uniqueId', ['artifactType', 'artifactName'], (artifactType, artifactName) => `${serviceIDByArtifactType[artifactType] || defaultServiceId}.${artifactName}`); |
| 45 | |
| 46 | Factory.define('FlowBaseFetchAndDeleteFactory') |
| 47 | .extend('FlowBaseWithServiceIdFactory') |
| 48 | .extend('FlowBaseWithUniqueIdFactory') |
| 49 | .attrs({ |
| 50 | participants: [] |
| 51 | }); |
| 52 | |
| 53 | Factory.define('FlowBaseWithEsIdFactory') |
| 54 | .extend('FlowBaseWithUniqueIdFactory') |
| 55 | .attr('esId', ['uniqueId'], uniqueId => uniqueId); |
| 56 | |
| 57 | export const FlowBasicFactory = new Factory() |
| 58 | .extend('FlowBaseFactory').attrs({uniqueId: () => UUID.create(4)}); |
| 59 | |
| 60 | export const FlowCreateFactory = new Factory() |
| 61 | .extend('FlowBaseWithServiceIdFactory'); |
| 62 | |
| 63 | export const FlowPostRequestFactory = new Factory() |
| 64 | .extend('FlowBaseFactory') |
| 65 | .attrs({ |
| 66 | artifactGroupType: 'INFORMATIONAL', |
| 67 | payloadData: 'eyJWRVJTSU9OIjp7Im1ham9yIjoxLCJtaW5vciI6MH0sImRlc2NyaXB0aW9uIjoiYXNsa2pkZmwgYXNmZGFzZGYifQ==' |
| 68 | }) |
| 69 | .attr('artifactLabel', ['artifactName'], name => name); |
| 70 | |
| 71 | Factory.define('FlowPostResponeAndUpdateBaseFactory') |
| 72 | .extend('FlowBaseFactory') |
| 73 | .extend('FlowBaseWithUniqueIdFactory') |
| 74 | .extend('FlowBaseWithEsIdFactory') |
| 75 | .attrs({ |
| 76 | artifactGroupType: 'INFORMATIONAL', |
| 77 | artifactUUID: () => UUID.create(4), |
| 78 | artifactVersion: '1', |
| 79 | creationDate: 1470144601623, |
| 80 | lastUpdateDate: 1470144601623, |
| 81 | mandatory: false, |
| 82 | timeout: 0, |
| 83 | artifactChecksum: 'NjBmYjc4NGM5MWIwNmNkMDhmMThhMDAwYmQxYjBiZTU=' |
| 84 | }) |
| 85 | .attr('artifactLabel', ['artifactName'], name => name) |
| 86 | .attr('artifactDisplayName', ['artifactName'], name => name); |
| 87 | |
| 88 | export const FlowPostResponseFactory = new Factory() |
| 89 | .extend('FlowPostResponeAndUpdateBaseFactory') |
| 90 | .attrs({ |
| 91 | attUidLastUpdater: 'cs0008', |
| 92 | payloadUpdateDate: 1470144602131, |
| 93 | serviceApi: false, |
| 94 | updaterFullName: 'Carlos Santana', |
| 95 | artifactCreator: 'cs0008' |
| 96 | }); |
| 97 | |
| 98 | export const FlowUpdateRequestFactory = new Factory() |
| 99 | .extend('FlowPostResponeAndUpdateBaseFactory') |
| 100 | .extend('FlowBaseFetchAndDeleteFactory') |
| 101 | .extend('FlowBaseWithEsIdFactory') |
| 102 | .attrs({ |
| 103 | heatParameters: [], |
| 104 | participants: ParticipantFactory.buildList(10) |
| 105 | }) |
| 106 | .attr('sequenceDiagramModel', ['participants'], participants => SequenceDiagramFactory.build({}, {participants})); |
| 107 | |
| 108 | export const FlowFetchRequestFactory = new Factory() |
| 109 | .extend('FlowBaseFetchAndDeleteFactory'); |
| 110 | |
| 111 | export const FlowDeleteRequestFactory = new Factory() |
| 112 | .extend('FlowBaseFetchAndDeleteFactory'); |
| 113 | |
| 114 | export const FlowFetchResponseFactory = new Factory() |
| 115 | .extend('FlowBaseFactory') |
| 116 | .attrs({ |
| 117 | base64Contents: 'eyJWRVJTSU9OIjp7Im1ham9yIjoxLCJtaW5vciI6MH0sImRlc2NyaXB0aW9uIjoiYXNsa2pkZmwgYXNmZGFzZGYifQ==' |
| 118 | }); |