Remove useless code
[clamp.git] / src / test / java / org / onap / clamp / clds / it / sdc / controller / SdcSingleControllerItCase.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP CLAMP
4  * ================================================================================
5  * Copyright (C) 2018 AT&T Intellectual Property. All rights
6  *                             reserved.
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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  * ===================================================================
21  *
22  */
23
24 package org.onap.clamp.clds.it.sdc.controller;
25
26 import java.io.IOException;
27 import java.util.ArrayList;
28 import java.util.List;
29
30 import org.assertj.core.api.Assertions;
31 import org.junit.Before;
32 import org.junit.Test;
33 import org.junit.runner.RunWith;
34 import org.mockito.Mockito;
35 import org.onap.clamp.clds.config.ClampProperties;
36 import org.onap.clamp.clds.config.sdc.SdcSingleControllerConfigurationTest;
37 import org.onap.clamp.clds.sdc.controller.SdcSingleController;
38 import org.onap.clamp.clds.sdc.controller.installer.CsarHandler;
39 import org.onap.clamp.clds.sdc.controller.installer.CsarInstaller;
40 import org.onap.sdc.api.notification.IArtifactInfo;
41 import org.onap.sdc.api.notification.INotificationData;
42 import org.onap.sdc.api.notification.IResourceInstance;
43 import org.springframework.beans.factory.annotation.Autowired;
44 import org.springframework.boot.test.context.SpringBootTest;
45 import org.springframework.test.context.junit4.SpringRunner;
46
47 @RunWith(SpringRunner.class)
48 @SpringBootTest
49 public class SdcSingleControllerItCase {
50
51     private static final String SDC_FOLDER = "/tmp/csar-handler-tests";
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";
56     private static final String RESOURCE1_INSTANCE_NAME_IN_CSAR = "sim18020";
57     private static final String BLUEPRINT1_NAME = "FOI.Simfoimap223S0112.event_proc_bp.yaml";
58
59     @Autowired
60     private ClampProperties clampProp;
61
62     private SdcSingleController sdcSingleController;
63
64     private INotificationData buildFakeSdcNotification() {
65         // BUild what is needed for CSAR
66         IArtifactInfo serviceArtifact = Mockito.mock(IArtifactInfo.class);
67         Mockito.when(serviceArtifact.getArtifactType()).thenReturn(CsarHandler.CSAR_TYPE);
68         Mockito.when(serviceArtifact.getArtifactName()).thenReturn(CSAR_ARTIFACT_NAME);
69         List<IArtifactInfo> servicesList = new ArrayList<>();
70         servicesList.add(serviceArtifact);
71         INotificationData notifData = Mockito.mock(INotificationData.class);
72         Mockito.when(notifData.getServiceArtifacts()).thenReturn(servicesList);
73         // Build what is needed for UUID
74         Mockito.when(notifData.getServiceInvariantUUID()).thenReturn(SERVICE_UUID);
75         // Build fake resource with one artifact BLUEPRINT
76         IResourceInstance resource1 = Mockito.mock(IResourceInstance.class);
77         Mockito.when(resource1.getResourceType()).thenReturn("VF");
78         Mockito.when(resource1.getResourceInvariantUUID()).thenReturn(RESOURCE1_UUID);
79         Mockito.when(resource1.getResourceInstanceName()).thenReturn(RESOURCE1_INSTANCE_NAME);
80         // Create a fake artifact for resource
81         IArtifactInfo blueprintArtifact = Mockito.mock(IArtifactInfo.class);
82         Mockito.when(blueprintArtifact.getArtifactType()).thenReturn(CsarHandler.BLUEPRINT_TYPE);
83         List<IArtifactInfo> artifactsListForResource = new ArrayList<>();
84         artifactsListForResource.add(blueprintArtifact);
85         Mockito.when(resource1.getArtifacts()).thenReturn(artifactsListForResource);
86         List<IResourceInstance> resourcesList = new ArrayList<>();
87         resourcesList.add(resource1);
88         Mockito.when(notifData.getResources()).thenReturn(resourcesList);
89         return notifData;
90     }
91
92     @Before
93     public void init() throws IOException {
94         sdcSingleController = new SdcSingleController(clampProp, Mockito.mock(CsarInstaller.class),
95             SdcSingleControllerConfigurationTest.loadControllerConfiguration("clds/sdc-controller-config-TLS.json",
96                 "sdc-controller1"),
97             null) {
98         };
99     }
100
101     @Test
102     public void testTreatNotification() {
103         sdcSingleController.treatNotification(buildFakeSdcNotification());
104         Assertions.assertThat(sdcSingleController.getNbOfNotificationsOngoing()).isEqualTo(0);
105
106     }
107
108 }