packages/root-pack-extras/config-resources/mariadb/db-sql-scripts/main-schemas/MySQL-Requests-schema.sql
**/bin/
/tattletale/
+/.metadata/
def responseData = ""
try {
String vnfId = execution.getVariable("DAAIVfMod_vnfId")
- String vfModuleId = execution.setVariable("DAAIVfMod_vfModuleId")
+ String vfModuleId = execution.getVariable("DAAIVfMod_vfModuleId")
String resourceVersion = execution.getVariable("DAAIVfMod_vfModRsrcVer")
AaiUtil aaiUriUtil = new AaiUtil(this)
package org.onap.so.bpmn.common.baseclient;
+import java.util.ArrayList;
+import java.util.List;
+
import org.onap.so.logging.jaxrs.filter.SpringClientFilter;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
+import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.BufferingClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
public HttpHeaders getHttpHeader() {
return httpHeader;
}
+
+ public HttpHeaders setDefaultHttpHeaders(String auth) {
+ httpHeader = new HttpHeaders();
+ httpHeader.set("Authorization", auth);
+ httpHeader.setContentType(MediaType.APPLICATION_JSON);
+ List<MediaType> acceptMediaTypes = new ArrayList<MediaType>();
+ acceptMediaTypes.add(MediaType.APPLICATION_JSON);
+ acceptMediaTypes.add(MediaType.TEXT_PLAIN);
+ httpHeader.setAccept(acceptMediaTypes);
+ return httpHeader;
+ }
public void setHttpHeader(HttpHeaders httpHeader) {
this.httpHeader = httpHeader;
<?xml version="1.0" encoding="UTF-8"?>
-<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_MagIIMOUEeW8asg-vCEgWQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
+<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_MagIIMOUEeW8asg-vCEgWQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.2" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn2:process id="CreateNetworkCollectionBB" name="CreateNetworkCollectionBB" isExecutable="true">
<bpmn2:startEvent id="createNetworkCollection_startEvent">
<bpmn2:outgoing>SequenceFlow_1maepy7</bpmn2:outgoing>
</bpmn2:serviceTask>
<bpmn2:serviceTask id="ServiceTask_Connect_Collection_to_InstanceGroup" name=" AAI Connect (net collection) " camunda:expression="${CreateNetworkCollection.connectCollectionToInstanceGroup(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))} ">
<bpmn2:incoming>SequenceFlow_0z4c30j</bpmn2:incoming>
- <bpmn2:outgoing>SequenceFlow_1hij1px</bpmn2:outgoing>
+ <bpmn2:outgoing>SequenceFlow_0904jyg</bpmn2:outgoing>
</bpmn2:serviceTask>
<bpmn2:sequenceFlow id="SequenceFlow_05yxpu5" sourceRef="ServiceTask_create_NetworkCollection" targetRef="ServiceTask_create_NetworkCollectionInstanceGroup" />
<bpmn2:sequenceFlow id="SequenceFlow_0z4c30j" sourceRef="ServiceTask_create_NetworkCollectionInstanceGroup" targetRef="ServiceTask_Connect_Collection_to_InstanceGroup" />
<bpmn2:serviceTask id="ServiceTask_Connect_Collection_to_ServiceInstance" name=" AAI Connect (svc instance) " camunda:expression="${CreateNetworkCollection.connectCollectionToServiceInstance(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))} ">
- <bpmn2:incoming>SequenceFlow_1hij1px</bpmn2:incoming>
+ <bpmn2:incoming>SequenceFlow_0gkrvg6</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_0hhklb4</bpmn2:outgoing>
</bpmn2:serviceTask>
- <bpmn2:sequenceFlow id="SequenceFlow_1hij1px" sourceRef="ServiceTask_Connect_Collection_to_InstanceGroup" targetRef="ServiceTask_Connect_Collection_to_ServiceInstance" />
<bpmn2:sequenceFlow id="SequenceFlow_0hhklb4" sourceRef="ServiceTask_Connect_Collection_to_ServiceInstance" targetRef="createNetworkCollection_EndEvent" />
+ <bpmn2:serviceTask id="ServiceTask_Connect_InstanceGroup_to_CloudRegion" name=" AAI Connect (group to cloud) " camunda:expression="${CreateNetworkCollection.connectInstanceGroupToCloudRegion(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))} ">
+ <bpmn2:incoming>SequenceFlow_0904jyg</bpmn2:incoming>
+ <bpmn2:outgoing>SequenceFlow_0gkrvg6</bpmn2:outgoing>
+ </bpmn2:serviceTask>
+ <bpmn2:sequenceFlow id="SequenceFlow_0904jyg" sourceRef="ServiceTask_Connect_Collection_to_InstanceGroup" targetRef="ServiceTask_Connect_InstanceGroup_to_CloudRegion" />
+ <bpmn2:sequenceFlow id="SequenceFlow_0gkrvg6" sourceRef="ServiceTask_Connect_InstanceGroup_to_CloudRegion" targetRef="ServiceTask_Connect_Collection_to_ServiceInstance" />
</bpmn2:process>
<bpmn2:error id="Error_2" name="MSOWorkflowException" errorCode="MSOWorkflowException" />
<bpmn2:error id="Error_1" name="java.lang.Exception" errorCode="java.lang.Exception" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CreateNetworkCollectionBB">
<bpmndi:BPMNShape id="StartEvent_0lbwmd1_di" bpmnElement="createNetworkCollection_startEvent">
- <dc:Bounds x="236" y="-55" width="36" height="36" />
+ <dc:Bounds x="255" y="-55" width="36" height="36" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="229" y="-14" width="50" height="12" />
+ <dc:Bounds x="228" y="-14" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_10l9a3s_di" bpmnElement="createNetworkCollection_EndEvent">
- <dc:Bounds x="1132" y="-55" width="36" height="36" />
+ <dc:Bounds x="1280" y="-55" width="36" height="36" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="1128" y="-19" width="46" height="12" />
+ <dc:Bounds x="1254" y="-19" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ServiceTask_08q9eo4_di" bpmnElement="BuildName_ServiceTask">
<dc:Bounds x="346" y="-77" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1maepy7_di" bpmnElement="SequenceFlow_1maepy7">
- <di:waypoint xsi:type="dc:Point" x="272" y="-37" />
+ <di:waypoint xsi:type="dc:Point" x="291" y="-37" />
<di:waypoint xsi:type="dc:Point" x="346" y="-37" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="309" y="-52" width="0" height="0" />
+ <dc:Bounds x="273.5" y="-52" width="90" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="ServiceTask_02qnccl_di" bpmnElement="ServiceTask_create_NetworkCollection">
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="ServiceTask_15u6tzt_di" bpmnElement="ServiceTask_Connect_Collection_to_ServiceInstance">
- <dc:Bounds x="982" y="-77" width="100" height="80" />
+ <dc:Bounds x="1124" y="-77" width="100" height="80" />
</bpmndi:BPMNShape>
- <bpmndi:BPMNEdge id="SequenceFlow_1hij1px_di" bpmnElement="SequenceFlow_1hij1px">
+ <bpmndi:BPMNEdge id="SequenceFlow_0hhklb4_di" bpmnElement="SequenceFlow_0hhklb4">
+ <di:waypoint xsi:type="dc:Point" x="1224" y="-37" />
+ <di:waypoint xsi:type="dc:Point" x="1280" y="-37" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="1207" y="-52" width="90" height="0" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ServiceTask_0kpj3lv_di" bpmnElement="ServiceTask_Connect_InstanceGroup_to_CloudRegion">
+ <dc:Bounds x="971" y="-77" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_0904jyg_di" bpmnElement="SequenceFlow_0904jyg">
<di:waypoint xsi:type="dc:Point" x="917" y="-37" />
- <di:waypoint xsi:type="dc:Point" x="982" y="-37" />
+ <di:waypoint xsi:type="dc:Point" x="971" y="-37" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="950" y="-62" width="0" height="0" />
+ <dc:Bounds x="944" y="-58" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="SequenceFlow_0hhklb4_di" bpmnElement="SequenceFlow_0hhklb4">
- <di:waypoint xsi:type="dc:Point" x="1082" y="-37" />
- <di:waypoint xsi:type="dc:Point" x="1132" y="-37" />
+ <bpmndi:BPMNEdge id="SequenceFlow_0gkrvg6_di" bpmnElement="SequenceFlow_0gkrvg6">
+ <di:waypoint xsi:type="dc:Point" x="1071" y="-37" />
+ <di:waypoint xsi:type="dc:Point" x="1124" y="-37" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="1107" y="-62" width="0" height="0" />
+ <dc:Bounds x="1097.5" y="-58" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
public void sunnyDayCreateNetworkCollection_Test() throws InterruptedException {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("CreateNetworkCollectionBB",variables);
assertThat(pi).isNotNull();
- assertThat(pi).isStarted().hasPassedInOrder("createNetworkCollection_startEvent", "BuildName_ServiceTask", "ServiceTask_create_NetworkCollection", "ServiceTask_create_NetworkCollectionInstanceGroup", "ServiceTask_Connect_Collection_to_InstanceGroup", "ServiceTask_Connect_Collection_to_ServiceInstance", "createNetworkCollection_EndEvent");
+ assertThat(pi).isStarted().hasPassedInOrder("createNetworkCollection_startEvent", "BuildName_ServiceTask", "ServiceTask_create_NetworkCollection", "ServiceTask_create_NetworkCollectionInstanceGroup", "ServiceTask_Connect_Collection_to_InstanceGroup", "ServiceTask_Connect_InstanceGroup_to_CloudRegion", "ServiceTask_Connect_Collection_to_ServiceInstance", "createNetworkCollection_EndEvent");
assertThat(pi).isEnded();
}
// Get vfModuleName from AAI response if it was not specified on the request
if (vfModuleName == null || vfModuleName.isEmpty()) {
if (execution.getVariable("vfModuleFromAAI") != null) {
- VfModule vfModuleFromAAI = execution.getVariable("vfModuleFromAAI")
- vfModuleName = vfModuleFromAAI.getElementText("vf-module-name")
+ org.onap.aai.domain.yang.VfModule vfModuleFromAAI = execution.getVariable("vfModuleFromAAI")
+ vfModuleName = vfModuleFromAAI.getVfModuleName()
}
}
String vfModuleModelName = execution.getVariable("vfModuleModelName")
}
Optional<GenericVnf> vnf = wrapper.asBean(GenericVnf.class)
- if(!vnf.get().getVfModules().getVfModule().isEmpty()){
- execution.setVariable("DoDVNF_vnfInUse", true)
+ if (vnf.get() != null) {
+ if (vnf.get().getVfModules() != null) {
+ if((vnf.get().getVfModules().getVfModule() != null) && !vnf.get().getVfModules().getVfModule().isEmpty()){
+ execution.setVariable("DoDVNF_vnfInUse", true)
+ }
+ }
}
}else{
execution.setVariable("GENGV_FoundIndicator", false)
def vnfType = execution.getVariable('DOUPVfMod_vnfType')
def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
- def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')
- def vfModuleName = vfModule.getElementText('vf-module-name')
+ def vfModuleName = ""
+ if (execution.getVariable('DOUPVfMod_vfModule') != null) {
+ org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('DOUPVfMod_vfModule')
+ vfModuleName = vfModule.getVfModuleName()
+ }
def tenantId = execution.getVariable('DOUPVfMod_tenantId')
def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
boolean usePreload = execution.getVariable("DOUPVfMod_usePreload")
def tenantId = execution.getVariable('DOUPVfMod_tenantId')
def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')
def volumeGroupStackId = execution.getVariable('DOUPVfMod_volumeGroupStackId')
- def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')
- def heatStackId = vfModule.getElementText('heat-stack-id')
+ def heatStackId = ""
+ if (execution.getVariable('DOUPVfMod_vfModule') != null) {
+ org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('DOUPVfMod_vfModule')
+ heatStackId = vfModule.getHeatStackId()
+ }
def cloudId = execution.getVariable('DOUPVfMod_aicCloudRegion')
def vnfType = execution.getVariable('DOUPVfMod_vnfType')
def vnfName = execution.getVariable('DOUPVfMod_vnfName')
def vnfType = execution.getVariable('DOUPVfMod_vnfType')
def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
- def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')
- def vfModuleName = vfModule.getElementText('vf-module-name')
+ def vfModuleName = ""
+ if (execution.getVariable('DOUPVfMod_vfModule') != null) {
+ org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('DOUPVfMod_vfModule')
+ vfModuleName = vfModule.getVfModuleName()
+ }
def tenantId = execution.getVariable('DOUPVfMod_tenantId')
def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
}
}
+ /**
+ * BPMN access method to connect Instance Group to Cloud Region
+ * @param execution
+ * @throws Exception
+ */
+ public void connectInstanceGroupToCloudRegion(BuildingBlockExecution execution) throws Exception {
+ execution.setVariable("connectInstanceGroupToCloudRegionRollback", false);
+ try{
+ ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
+ Collection networkCollection = serviceInstance.getCollection();
+ aaiNetworkResources.connectInstanceGroupToCloudRegion(networkCollection.getInstanceGroup(), execution.getGeneralBuildingBlock().getCloudRegion());
+ execution.setVariable("connectInstanceGroupToCloudRegionRollback", true);
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
/**
* BPMN access method to connect Network Collection
* @param execution
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet;
import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.entities.AAIEdgeLabel;
import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
injectionHelper.getAaiClient().connect(networkCollectionUri, netwrokCollectionInstanceGroupURI);
}
+ public void connectInstanceGroupToCloudRegion(InstanceGroup instanceGroup, CloudRegion cloudRegion) {
+ AAIResourceUri cloudRegionURI = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION,
+ cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId());
+ AAIResourceUri instanceGroupURI = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId());
+ injectionHelper.getAaiClient().connect(instanceGroupURI, cloudRegionURI, AAIEdgeLabel.USES);
+ }
+
public void connectNetworkCollectionToServiceInstance(Collection networkCollection, ServiceInstance networkCollectionServiceInstance) {
AAIResourceUri networkCollectionUri = AAIUriFactory.createResourceUri(AAIObjectType.COLLECTION, networkCollection.getId());
AAIResourceUri networkCollectionServiceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, networkCollectionServiceInstance.getServiceInstanceId());
import org.junit.Before;
import org.junit.Test;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
private L3Network network;
private ServiceInstance serviceInstance;
private OrchestrationContext orchestrationContext;
+ private CloudRegion cloudRegion;
@Before
public void before() {
serviceInstance = setServiceInstance();
network = setL3Network();
+ cloudRegion = setCloudRegion();
List<L3Network> l3NetworkList = new ArrayList<L3Network>();
l3NetworkList.add(network);
createNetworkCollection.connectCollectionToServiceInstance(execution);
verify(aaiNetworkResources, times(1)).connectNetworkCollectionToServiceInstance(serviceInstance.getCollection(), serviceInstance);
}
+
+ @Test
+ public void connectInstanceGroupToCloudRegionTest() throws Exception {
+ doNothing().when(aaiNetworkResources).connectInstanceGroupToCloudRegion(serviceInstance.getCollection().getInstanceGroup(), cloudRegion);
+ createNetworkCollection.connectInstanceGroupToCloudRegion(execution);
+ verify(aaiNetworkResources, times(1)).connectInstanceGroupToCloudRegion(serviceInstance.getCollection().getInstanceGroup(), cloudRegion);
+ }
}
instanceGroup.setInstanceGroupName("test-instanceGroupName");
instanceGroup.setResourceVersion("test-resourceVersion");
-
ModelInfoInstanceGroup model = new ModelInfoInstanceGroup();
model.setFunction("test-function");
model.setInstanceGroupRole("SUB-INTERFACE");
model.setModelInvariantUUID("modelInvariantUUID-000");
model.setModelUUID("modelUUID-000");
model.setDescription("test-description");
+ model.setInstanceGroupRole("SUB-INTERFACE");
instanceGroup.setModelInfoInstanceGroup(model);
assertEquals(aaiInstanceGroup.getModelVersionId(), instanceGroup.getModelInfoInstanceGroup().getModelUUID());
assertEquals(aaiInstanceGroup.getResourceVersion(), instanceGroup.getResourceVersion());
assertEquals(aaiInstanceGroup.getInstanceGroupType(), instanceGroup.getModelInfoInstanceGroup().getType());
+ assertEquals(aaiInstanceGroup.getInstanceGroupRole(), instanceGroup.getModelInfoInstanceGroup().getInstanceGroupRole());
}
@Test
import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.AAIResourcesClient;
+import org.onap.so.client.aai.entities.AAIEdgeLabel;
import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.aai.entities.Relationships;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), isA(org.onap.aai.domain.yang.Subnet.class));
}
+
+ @Test
+ public void connectInstanceGroupToCloudRegionTest() throws Exception {
+ aaiNetworkResources.connectInstanceGroupToCloudRegion(instanceGroup, cloudRegion);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroup.getId())),
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId())),
+ eq(AAIEdgeLabel.USES));
+ }
}
return e;
}
- private Relationship buildRelationship(AAIResourceUri uri) {
+ protected Relationship buildRelationship(AAIResourceUri uri) {
return buildRelationship(uri, Optional.empty());
}
- private Relationship buildRelationship(AAIResourceUri uri, AAIEdgeLabel label) {
+ protected Relationship buildRelationship(AAIResourceUri uri, AAIEdgeLabel label) {
return buildRelationship(uri, Optional.of(label));
}
- private Relationship buildRelationship(AAIResourceUri uri, Optional<AAIEdgeLabel> label) {
+ protected Relationship buildRelationship(AAIResourceUri uri, Optional<AAIEdgeLabel> label) {
final Relationship result = new Relationship();
result.setRelatedLink(uri.build().toString());
if (label.isPresent()) {
- result.setRelationshipLabel(label.toString());
+ result.setRelationshipLabel(label.get().toString());
}
return result;
}
import static com.github.tomakehurst.wiremock.client.WireMock.put;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
-import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.onap.aai.domain.yang.Relationship;
+import org.onap.so.client.aai.entities.AAIEdgeLabel;
import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
AAIResultWrapper result = client.get(path, NotFoundException.class);
}
+ @Test
+ public void buildRelationshipTest() {
+ AAIResourcesClient client = createClient();
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test");
+ Relationship relationship = new Relationship();
+ relationship.setRelatedLink(uri.build().toString());
+ Relationship actual = client.buildRelationship(uri);
+ assertThat("expect equal no label", actual, sameBeanAs(relationship));
+
+ relationship.setRelationshipLabel(AAIEdgeLabel.USES.toString());
+ actual = client.buildRelationship(uri, AAIEdgeLabel.USES);
+ assertThat("expect equal has label", actual, sameBeanAs(relationship));
+
+ }
+
private AAIResourcesClient createClient() {
AAIResourcesClient client = spy(new AAIResourcesClient());
doReturn(new DefaultAAIPropertiesImpl()).when(client).getRestProperties();
package org.onap.so.db.catalog.beans;
public enum SubType {
- SUB_INTERFACE
+ SUB_INTERFACE("SUB-INTERFACE");
+
+ private final String value;
+ SubType(String value){
+ this.value = value;
+ }
+ @Override
+ public String toString() {
+ return this.value;
+ }
}
import { TestBed, async } from '@angular/core/testing';\r
import { RouterTestingModule } from '@angular/router/testing';\r
import { AppComponent } from './app.component';\r
+import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';\r
+\r
describe('AppComponent', () => {\r
beforeEach(async(() => {\r
TestBed.configureTestingModule({\r
declarations: [\r
AppComponent\r
],\r
+ schemas: [\r
+ CUSTOM_ELEMENTS_SCHEMA\r
+ ],\r
}).compileComponents();\r
}));\r
- it('should create the app', async(() => {\r
+\r
+ // Ensure creation of SO Monitoring application\r
+ it('application should be created', async(() => {\r
const fixture = TestBed.createComponent(AppComponent);\r
const app = fixture.debugElement.componentInstance;\r
expect(app).toBeTruthy();\r
}));\r
- it(`should have as title 'app'`, async(() => {\r
+\r
+\r
+ // Ensure application title is "SO Monitor"\r
+ it(`should have title 'SO Monitor'`, async(() => {\r
const fixture = TestBed.createComponent(AppComponent);\r
const app = fixture.debugElement.componentInstance;\r
- expect(app.title).toEqual('app');\r
- }));\r
- it('should render title in a h1 tag', async(() => {\r
- const fixture = TestBed.createComponent(AppComponent);\r
- fixture.detectChanges();\r
- const compiled = fixture.debugElement.nativeElement;\r
- expect(compiled.querySelector('h1').textContent).toContain('Welcome to ONAP-SO-Monitor!');\r
+ expect(app.title).toEqual('SO Monitor');\r
}));\r
});\r
})\r
\r
export class AppComponent {\r
- title = 'app';\r
+ title = 'SO Monitor';\r
}\r
*/\r
\r
import { BrowserModule } from '@angular/platform-browser';\r
-import { NgModule } from '@angular/core';\r
+import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';\r
\r
import { AppRoutingModule } from './app-routing.module';\r
import { AppComponent } from './app.component';\r
import { MatNativeDateModule } from '@angular/material';\r
import { MatCardModule } from '@angular/material/card';\r
import { NgxSpinnerModule } from 'ngx-spinner';\r
+import { RouterModule, Routes } from '@angular/router';\r
+import { APP_BASE_HREF } from '@angular/common';\r
\r
@NgModule({\r
declarations: [\r
MatDatepickerModule,\r
MatNativeDateModule,\r
MatCardModule,\r
- NgxSpinnerModule\r
+ NgxSpinnerModule,\r
+ RouterModule,\r
+ RouterModule.forRoot([])\r
+ ],\r
+ schemas: [\r
+ CUSTOM_ELEMENTS_SCHEMA\r
],\r
providers: [ToastrNotificationService],\r
bootstrap: [AppComponent]\r
import { TestBed, inject } from '@angular/core/testing';\r
\r
import { DataService } from './data.service';\r
+import { HttpClient } from '@angular/common/http';\r
+import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';\r
+import { async } from '@angular/core/testing';\r
+import { HttpClientModule } from '@angular/common/http';\r
+import { ToastrNotificationService } from './toastr-notification-service.service';\r
+import { environment } from '../environments/environment';\r
+\r
+class StubbedToastrNotificationService extends ToastrNotificationService {\r
+ toastrSettings() {\r
+ }\r
+}\r
\r
describe('DataService', () => {\r
beforeEach(() => {\r
TestBed.configureTestingModule({\r
- providers: [DataService]\r
+ providers: [DataService, { provide: ToastrNotificationService, useClass: StubbedToastrNotificationService }],\r
+ imports: [HttpClientTestingModule]\r
});\r
});\r
\r
- it('should be created', inject([DataService], (service: DataService) => {\r
- expect(service).toBeTruthy();\r
- }));\r
+ // Ensure creation of DataService component\r
+ it('component should be created', async(inject([HttpTestingController, DataService, ToastrNotificationService],\r
+ (httpClient: HttpTestingController, service: DataService, toastr: ToastrNotificationService) => {\r
+ expect(service).toBeTruthy();\r
+ })));\r
+\r
+ // Test retrieveInstance function making POST call\r
+ it('test retrieveInstance POST request', async(inject([HttpTestingController, DataService, ToastrNotificationService],\r
+ (httpClient: HttpTestingController, service: DataService, toastr: ToastrNotificationService) => {\r
+ service.retrieveInstance({}, 1, 2).subscribe(data => { });\r
+ var url = environment.soMonitoringBackendURL + 'v1/search?from=1&to=2';\r
+ const mockReq = httpClient.expectOne(url);\r
+ expect(mockReq.request.method).toEqual('POST');\r
+ mockReq.flush({});\r
+ })));\r
+\r
+ // Test getProcessInstanceId function making GET request to retrieve processInstanceID\r
+ it('test getProcessInstanceId GET request', async(inject([HttpTestingController, DataService, ToastrNotificationService],\r
+ (httpClient: HttpTestingController, service: DataService, toastr: ToastrNotificationService) => {\r
+ service.getProcessInstanceId("").subscribe(data => { });\r
+ var url = environment.soMonitoringBackendURL + 'process-instance-id/' + "";\r
+ const mockReq = httpClient.expectOne(url);\r
+ expect(mockReq.request.method).toEqual('GET');\r
+ mockReq.flush({});\r
+ })));\r
+\r
+ // Test getActivityInstance function making GET request to retrieve activityInstance\r
+ it('test getActivityInstance GET request', async(inject([HttpTestingController, DataService, ToastrNotificationService],\r
+ (httpClient: HttpTestingController, service: DataService, toastr: ToastrNotificationService) => {\r
+ service.getActivityInstance("").subscribe(data => { });\r
+ var url = environment.soMonitoringBackendURL + 'activity-instance/' + "";\r
+ const mockReq = httpClient.expectOne(url);\r
+ expect(mockReq.request.method).toEqual('GET');\r
+ mockReq.flush({});\r
+ })));\r
+\r
+ // Test getProcessInstance function making GET request to retrieve processInstance\r
+ it('test getProcessInstance GET request', async(inject([HttpTestingController, DataService, ToastrNotificationService],\r
+ (httpClient: HttpTestingController, service: DataService, toastr: ToastrNotificationService) => {\r
+ service.getProcessInstance("");\r
+ var url = environment.soMonitoringBackendURL + 'process-instance/' + "";\r
+ const mockReq = httpClient.expectOne(url);\r
+ expect(mockReq.request.method).toEqual('GET');\r
+ })));\r
+\r
+ // Test getProcessDefinition function making GET request to retrieve processDefinition\r
+ it('test getProcessDefinition GET request', async(inject([HttpTestingController, DataService, ToastrNotificationService],\r
+ (httpClient: HttpTestingController, service: DataService, toastr: ToastrNotificationService) => {\r
+ service.getProcessDefinition("").subscribe(data => { });\r
+ var url = environment.soMonitoringBackendURL + 'process-definition/' + "";\r
+ const mockReq = httpClient.expectOne(url);\r
+ expect(mockReq.request.method).toEqual('GET');\r
+ mockReq.flush({});\r
+ })));\r
+\r
+ // Test getVariableInstance function making GET request to retrieve variableInstance\r
+ it('test getVariableInstance GET request', async(inject([HttpTestingController, DataService, ToastrNotificationService],\r
+ (httpClient: HttpTestingController, service: DataService, toastr: ToastrNotificationService) => {\r
+ service.getVariableInstance("").subscribe(data => { });\r
+ var url = environment.soMonitoringBackendURL + 'variable-instance/' + "";\r
+ const mockReq = httpClient.expectOne(url);\r
+ expect(mockReq.request.method).toEqual('GET');\r
+ mockReq.flush({});\r
+ })));\r
});\r
getProcessInstanceId(requestId): Observable<HttpResponse<ProcessInstanceId>> {\r
var url = environment.soMonitoringBackendURL + 'process-instance-id/' + requestId;\r
console.log(requestId);\r
- console.log(url);\r
return this.http.get<ProcessInstanceId>(url, { observe: 'response' })\r
.pipe(\r
catchError(this.httpErrorHandlerService.handleError("GET", url))\r
catchError(this.httpErrorHandlerService.handleError("GET", url))\r
);\r
}\r
-\r
}\r
import { async, ComponentFixture, TestBed } from '@angular/core/testing';\r
\r
import { DetailsComponent } from './details.component';\r
+import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';\r
+import { RouterTestingModule } from '@angular/router/testing';\r
+import { MatTableModule } from '@angular/material';\r
+import { inject } from '@angular/core/testing';\r
+import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';\r
+import { HttpClientModule } from '@angular/common/http';\r
+import { HttpClient } from '@angular/common/http';\r
+import { RouterModule } from '@angular/router';\r
+import { APP_BASE_HREF } from '@angular/common';\r
+import { ToastrNotificationService } from '../toastr-notification-service.service';\r
+import { DataService } from '../data.service';\r
+import { Observable, of } from 'rxjs';\r
+import { ACTINST } from '../model/activityInstance.model';\r
+import { PDI } from '../model/processDefinition.model';\r
+import { PII } from '../model/processInstance.model';\r
+import { VarInstance } from '../model/variableInstance.model';\r
\r
-describe('DetailsComponent', () => {\r
- let component: DetailsComponent;\r
- let fixture: ComponentFixture<DetailsComponent>;\r
+// Generate stub for toastr popup notifications\r
+class StubbedToastrNotificationService extends ToastrNotificationService {\r
+ toastrSettings() {\r
+ }\r
+}\r
+\r
+// Create SPY Object for Jasmine tests to mock DataService\r
+let spyDataService: jasmine.SpyObj<DataService>;\r
\r
+describe('DetailsComponent', () => {\r
beforeEach(async(() => {\r
+ spyDataService = jasmine.createSpyObj('DataService', ['getActivityInstance', 'getVariableInstance']);\r
+\r
TestBed.configureTestingModule({\r
- declarations: [DetailsComponent]\r
+ providers: [DetailsComponent, HttpClient, HttpTestingController,\r
+ { provide: APP_BASE_HREF, useValue: '/' },\r
+ { provide: ToastrNotificationService, useClass: StubbedToastrNotificationService },\r
+ { provide: DataService, useValue: spyDataService }],\r
+ imports: [RouterTestingModule, MatTableModule, HttpClientModule, RouterModule.forRoot([])],\r
+ schemas: [\r
+ CUSTOM_ELEMENTS_SCHEMA\r
+ ]\r
})\r
.compileComponents();\r
}));\r
\r
- beforeEach(() => {\r
- fixture = TestBed.createComponent(DetailsComponent);\r
- component = fixture.componentInstance;\r
- fixture.detectChanges();\r
- });\r
+ // Ensure creation of DetailsComponent component\r
+ it('component should be created', inject([DetailsComponent],\r
+ (detailsComponent: DetailsComponent) => {\r
+ expect(detailsComponent).toBeTruthy();\r
+ }));\r
+\r
+\r
+ // Mock an activityInstance and ensure array is populated\r
+ it('activityInstance should be defined if data service returns activities', inject([DetailsComponent],\r
+ (detailsComponent: DetailsComponent) => {\r
+ const activity: ACTINST = {\r
+ activityId: "",\r
+ processInstanceId: "",\r
+ calledProcessInstanceId: "",\r
+ activityName: "",\r
+ activityType: "",\r
+ durationInMillis: "1",\r
+ endTime: "",\r
+ startTime: ""\r
+ };\r
+ spyDataService.getActivityInstance.and.returnValue(of([activity]));\r
+ detailsComponent.getActInst("");\r
+ expect(detailsComponent.activityInstance.length).toEqual(1);\r
+ }));\r
+\r
+\r
+ // Create a processDefinition and ensure it is defined\r
+ it('processDefinition should be defined if PDI populated', inject([DetailsComponent],\r
+ (detailsComponent: DetailsComponent) => {\r
+ const activity: PDI = {\r
+ processDefinitionId: "1",\r
+ processDefinitionXml: ""\r
+ };\r
+ detailsComponent.getProcessDefinition("");\r
+ detailsComponent.processDefinition = activity;\r
+ expect(detailsComponent.processDefinition).toBeDefined();\r
+ }));\r
+\r
+\r
+ // Create a processInstance and ensure it is defined\r
+ it('processInstance should be defined if PII populated', inject([DetailsComponent],\r
+ (detailsComponent: DetailsComponent) => {\r
+ const testVals: PII = {\r
+ processInstancId: "1",\r
+ processDefinitionId: "1",\r
+ processDefinitionName: "test",\r
+ superProcessInstanceId: "1"\r
+ };\r
+ detailsComponent.getProcInstance("");\r
+ detailsComponent.processInstance = testVals;\r
+ expect(detailsComponent.processInstance).toBeDefined();\r
+ }));\r
+\r
+\r
+ // displayCamundaflow test\r
+ // TODO\r
\r
- it('should create', () => {\r
- expect(component).toBeTruthy();\r
- });\r
+ // Mock an variableInstance and ensure array is populated\r
+ it('variableInstance should be defined if data service returns activities', inject([DetailsComponent],\r
+ (detailsComponent: DetailsComponent) => {\r
+ const activity2: VarInstance = {\r
+ name: "a",\r
+ type: "a",\r
+ value: "1"\r
+ };\r
+ spyDataService.getVariableInstance.and.returnValue(of([activity2]));\r
+ detailsComponent.getVarInst("");\r
+ expect(detailsComponent.variableInstance.length).toEqual(1);\r
+ }));\r
});\r
import { async, ComponentFixture, TestBed } from '@angular/core/testing';\r
\r
import { HomeComponent } from './home.component';\r
+import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';\r
+import { MatTableModule } from '@angular/material';\r
+import { FormsModule } from '@angular/forms';\r
+import { MatDatepickerModule } from '@angular/material/datepicker';\r
+import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';\r
+import { HttpClientModule } from '@angular/common/http';\r
+import { HttpClient } from '@angular/common/http';\r
+import { inject } from '@angular/core/testing';\r
+import { RouterModule } from '@angular/router';\r
+import { APP_BASE_HREF } from '@angular/common';\r
+import { ToastrNotificationService } from '../toastr-notification-service.service';\r
+import { environment } from '../../environments/environment.prod';\r
+\r
+class StubbedToastrNotificationService extends ToastrNotificationService {\r
+ toastrSettings() {\r
+ }\r
+}\r
\r
describe('HomeComponent', () => {\r
let component: HomeComponent;\r
\r
beforeEach(async(() => {\r
TestBed.configureTestingModule({\r
- declarations: [HomeComponent]\r
+ providers: [HomeComponent, HttpClient, HttpTestingController,\r
+ { provide: APP_BASE_HREF, useValue: '/' },\r
+ { provide: ToastrNotificationService, useClass: StubbedToastrNotificationService }],\r
+ imports: [MatTableModule, FormsModule, MatDatepickerModule, HttpClientModule, RouterModule.forRoot([])],\r
+ declarations: [HomeComponent],\r
+ schemas: [\r
+ CUSTOM_ELEMENTS_SCHEMA\r
+ ]\r
})\r
.compileComponents();\r
}));\r
\r
- beforeEach(() => {\r
- fixture = TestBed.createComponent(HomeComponent);\r
- component = fixture.componentInstance;\r
- fixture.detectChanges();\r
- });\r
+ // Ensure creation of HomeComponent component\r
+ it('component should be created', inject([HttpTestingController, HomeComponent],\r
+ (httpClient: HttpTestingController, service: HomeComponent) => {\r
+ expect(service).toBeTruthy();\r
+ }));\r
\r
- it('should create', () => {\r
- expect(component).toBeTruthy();\r
- });\r
+ // Ensure all statistic variables are initialised to zero\r
+ it('ensure statistic variables are defaulted at zero', async(inject([HttpTestingController, HomeComponent],\r
+ (httpClient: HttpTestingController, service: HomeComponent) => {\r
+ expect(service.totalVal === 0 && service.completeVal === 0 &&\r
+ service.inProgressVal === 0 && service.failedVal === 0 &&\r
+ service.pendingVal === 0 && service.unlockedVal === 0 &&\r
+ service.percentageComplete === 0 && service.percentageFailed === 0 &&\r
+ service.percentageInProg === 0 && service.percentagePending === 0 &&\r
+ service.percentageUnlocked === 0).toBeTruthy();\r
+ })));\r
});\r
import { TestBed, inject } from '@angular/core/testing';\r
\r
import { HttpErrorHandlerService } from './http-error-handler.service';\r
+import { ToastrNotificationService } from './toastr-notification-service.service';\r
+\r
+class StubbedToastrNotificationService extends ToastrNotificationService {\r
+ toastrSettings() {\r
+ }\r
+}\r
\r
describe('HttpErrorHandlerService', () => {\r
beforeEach(() => {\r
TestBed.configureTestingModule({\r
- providers: [HttpErrorHandlerService]\r
+ providers: [HttpErrorHandlerService,\r
+ { provide: ToastrNotificationService, useClass: StubbedToastrNotificationService }],\r
});\r
});\r
\r
- it('should be created', inject([HttpErrorHandlerService], (service: HttpErrorHandlerService) => {\r
+ it('ErrorHandler should be created', inject([HttpErrorHandlerService], (service: HttpErrorHandlerService) => {\r
expect(service).toBeTruthy();\r
}));\r
});\r
import { async, ComponentFixture, TestBed } from '@angular/core/testing';\r
\r
import { SidebarComponent } from './sidebar.component';\r
+import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';\r
+import { HttpClientModule } from '@angular/common/http';\r
+import { HttpTestingController } from '@angular/common/http/testing';\r
+import { HttpClient } from '@angular/common/http';\r
+import { inject } from '@angular/core/testing';\r
+import { RouterModule } from '@angular/router';\r
+import { APP_BASE_HREF } from '@angular/common';\r
\r
describe('SidebarComponent', () => {\r
let component: SidebarComponent;\r
\r
beforeEach(async(() => {\r
TestBed.configureTestingModule({\r
- declarations: [SidebarComponent]\r
+ providers: [SidebarComponent, HttpClient, HttpTestingController, { provide: APP_BASE_HREF, useValue: '/' }],\r
+ imports: [HttpClientModule, RouterModule.forRoot([])],\r
+ declarations: [SidebarComponent],\r
+ schemas: [\r
+ CUSTOM_ELEMENTS_SCHEMA\r
+ ]\r
})\r
.compileComponents();\r
}));\r
fixture.detectChanges();\r
});\r
\r
- it('should create', () => {\r
- expect(component).toBeTruthy();\r
- });\r
+ it('component should be created', async(inject([HttpTestingController, SidebarComponent],\r
+ (httpClient: HttpTestingController, sideComponent: SidebarComponent) => {\r
+ expect(sideComponent).toBeTruthy();\r
+ })));\r
+\r
});\r
\r
import { ToastrNotificationService } from './toastr-notification-service.service';\r
\r
+class StubbedToastrNotificationService extends ToastrNotificationService {\r
+ toastrSettings() {\r
+ }\r
+}\r
+\r
describe('ToasterNotificationService', () => {\r
beforeEach(() => {\r
TestBed.configureTestingModule({\r
- providers: [ToastrNotificationService]\r
+ providers: [ToastrNotificationService,\r
+ { provide: ToastrNotificationService, useClass: StubbedToastrNotificationService }]\r
});\r
});\r
\r
- it('should be created', inject([ToastrNotificationService], (service: ToastrNotificationService) => {\r
+ it('component should be created', inject([ToastrNotificationService], (service: ToastrNotificationService) => {\r
expect(service).toBeTruthy();\r
}));\r
});\r
import { async, ComponentFixture, TestBed } from '@angular/core/testing';\r
\r
import { TopbarComponent } from './topbar.component';\r
+import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';\r
\r
describe('TopbarComponent', () => {\r
let component: TopbarComponent;\r
\r
beforeEach(async(() => {\r
TestBed.configureTestingModule({\r
- declarations: [TopbarComponent]\r
+ declarations: [TopbarComponent],\r
+ schemas: [\r
+ CUSTOM_ELEMENTS_SCHEMA\r
+ ]\r
})\r
.compileComponents();\r
}));\r
fixture.detectChanges();\r
});\r
\r
- it('should create', () => {\r
+ it('component should be created', () => {\r
expect(component).toBeTruthy();\r
});\r
});\r