+
+ test('Verify that vm.searchVNFs return only generic-vnfs with relation to vserver', () => {
+ // given
+ $controller.changeManagement.serviceType = [];
+ let getVnfsByCustomerIdAndServiceType = Promise.resolve({"data":
+ { "results" : [
+ { "id": "1",
+ "node-type": "generic-vnf",
+ "properties": {
+ "nf-role": "vLB"
+ },
+ "related-to": [
+ { "id": "11",
+ "node-type": "vf-module"
+ },
+ { "id": "12",
+ "node-type": "tenant"
+ }
+ ]
+ },
+ { "id": "2",
+ "node-type": "generic-vnf",
+ "properties": {
+ "nf-role": "vLB"
+ },
+ "related-to": [
+ { "id": "21",
+ "node-type": "tenant"
+ }
+ ]
+ },
+ { "id": "3",
+ "node-type": "generic-vnf",
+ "properties": {
+ "nf-role": "vLB"
+ },
+ "related-to": [
+ { "id": "31",
+ "node-type": "vf-module"
+ },
+ { "id": "32",
+ "node-type": "tenant"
+ },
+ { "id": "33",
+ "node-type": "vserver"
+ }
+ ]
+ },
+ { "id": "11",
+ "node-type": "vf-module",
+ "related-to": [
+ { "id": "111",
+ "node-type": "vserver"
+ }
+ ]
+ },
+ { "id": "31",
+ "node-type": "vf-module",
+ "related-to": [
+ { "id": "311",
+ "node-type": "vserver"
+ }
+ ]
+ }
+ ]
+ }
+ });
+ let expectedVnfs = [
+ {
+ "id": "1",
+ "node-type": "generic-vnf",
+ "properties": {"nf-role": "vLB"},
+ "related-to": [
+ {"id": "11", "node-type": "vf-module"},
+ {"id": "12", "node-type": "tenant"}]},
+ {
+ "id": "3",
+ "node-type": "generic-vnf",
+ "properties": {"nf-role": "vLB"},
+ "related-to": [
+ {"id": "31", "node-type": "vf-module"},
+ {"id": "32", "node-type": "tenant"},
+ {"id": "33", "node-type": "vserver"}
+ ]}];
+ $aaiService.getVnfsByCustomerIdAndServiceType = () => getVnfsByCustomerIdAndServiceType;
+
+ // when
+ $controller.searchVNFs().then(() => {
+ expect($controller.vnfs).toHaveLength(2);
+ expect($controller.vnfs).toEqual(expectedVnfs);
+ });
+ });