2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
24 package org.onap.clamp.clds.it.sdc.controller;
26 import java.util.ArrayList;
27 import java.util.List;
29 import org.assertj.core.api.Assertions;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.junit.runner.RunWith;
33 import org.mockito.Mockito;
34 import org.onap.clamp.clds.config.ClampProperties;
35 import org.onap.clamp.clds.config.sdc.SdcSingleControllerConfigurationTest;
36 import org.onap.clamp.clds.sdc.controller.SdcSingleController;
37 import org.onap.clamp.clds.sdc.controller.installer.CsarHandler;
38 import org.onap.clamp.clds.sdc.controller.installer.CsarInstaller;
39 import org.onap.sdc.api.notification.IArtifactInfo;
40 import org.onap.sdc.api.notification.INotificationData;
41 import org.onap.sdc.api.notification.IResourceInstance;
42 import org.springframework.beans.factory.annotation.Autowired;
43 import org.springframework.boot.test.context.SpringBootTest;
44 import org.springframework.test.context.ActiveProfiles;
45 import org.springframework.test.context.junit4.SpringRunner;
47 @RunWith(SpringRunner.class)
49 @ActiveProfiles(profiles = "clamp-default,clamp-default-user,clamp-sdc-controller")
50 public class SdcSingleControllerItCase {
52 private static final String CSAR_ARTIFACT_NAME = "testArtifact.csar";
53 private static final String SERVICE_UUID = "serviceUUID";
54 private static final String RESOURCE1_UUID = "resource1UUID";
55 private static final String RESOURCE1_INSTANCE_NAME = "sim-1802 0";
58 private ClampProperties clampProp;
60 private SdcSingleController sdcSingleController;
62 private INotificationData buildFakeSdcNotification() {
63 // BUild what is needed for CSAR
64 IArtifactInfo serviceArtifact = Mockito.mock(IArtifactInfo.class);
65 Mockito.when(serviceArtifact.getArtifactType()).thenReturn(CsarHandler.CSAR_TYPE);
66 Mockito.when(serviceArtifact.getArtifactName()).thenReturn(CSAR_ARTIFACT_NAME);
67 List<IArtifactInfo> servicesList = new ArrayList<>();
68 servicesList.add(serviceArtifact);
69 INotificationData notifData = Mockito.mock(INotificationData.class);
70 Mockito.when(notifData.getServiceArtifacts()).thenReturn(servicesList);
71 // Build what is needed for UUID
72 Mockito.when(notifData.getServiceInvariantUUID()).thenReturn(SERVICE_UUID);
73 // Build fake resource with one artifact BLUEPRINT
74 IResourceInstance resource1 = Mockito.mock(IResourceInstance.class);
75 Mockito.when(resource1.getResourceType()).thenReturn("VF");
76 Mockito.when(resource1.getResourceInvariantUUID()).thenReturn(RESOURCE1_UUID);
77 Mockito.when(resource1.getResourceInstanceName()).thenReturn(RESOURCE1_INSTANCE_NAME);
78 // Create a fake artifact for resource
79 IArtifactInfo blueprintArtifact = Mockito.mock(IArtifactInfo.class);
80 Mockito.when(blueprintArtifact.getArtifactType()).thenReturn(CsarHandler.BLUEPRINT_TYPE);
81 List<IArtifactInfo> artifactsListForResource = new ArrayList<>();
82 artifactsListForResource.add(blueprintArtifact);
83 Mockito.when(resource1.getArtifacts()).thenReturn(artifactsListForResource);
84 List<IResourceInstance> resourcesList = new ArrayList<>();
85 resourcesList.add(resource1);
86 Mockito.when(notifData.getResources()).thenReturn(resourcesList);
91 * Initialization method.
95 sdcSingleController = new SdcSingleController(clampProp, Mockito.mock(CsarInstaller.class),
96 SdcSingleControllerConfigurationTest.loadControllerConfiguration("clds/sdc-controller-config-TLS.json",
103 public void testTreatNotification() {
104 sdcSingleController.treatNotification(buildFakeSdcNotification());
105 Assertions.assertThat(sdcSingleController.getNbOfNotificationsOngoing()).isEqualTo(0);