import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.GrantlessGrantManager;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcExternalSystemInfoProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcGrantManager;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManagerForVfc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
public class LifecycleManagerForVfc extends LifecycleManager {
@Autowired
- LifecycleManagerForVfc(CatalogManagerForVfc catalogManager, GrantlessGrantManager grantManager, CbamRestApiProviderForVfc restApiProvider, VfcExternalSystemInfoProvider vimInfoProvider, JobManagerForVfc jobManager, LifecycleChangeNotificationManagerForVfc notificationManager) {
+ LifecycleManagerForVfc(CatalogManagerForVfc catalogManager, VfcGrantManager grantManager, CbamRestApiProviderForVfc restApiProvider, VfcExternalSystemInfoProvider vimInfoProvider, JobManagerForVfc jobManager, LifecycleChangeNotificationManagerForVfc notificationManager) {
super(catalogManager, grantManager, restApiProvider, vimInfoProvider, jobManager, notificationManager);
}
--- /dev/null
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcNotificationSender;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManagerForVfc;
+
+import static junit.framework.TestCase.assertNotNull;
+import static org.junit.Assert.*;
+
+public class TestSelfRegistrationManagerForSo extends TestBase {
+ @Test
+ public void testBean() {
+ VfcNotificationSender vfcNotificationSender = Mockito.mock(VfcNotificationSender.class);
+ AAIExternalSystemInfoProvider aaiExternalSystemInfoProvider = Mockito.mock(AAIExternalSystemInfoProvider.class);
+ SelfRegistrationManagerForSo selfRegistrationManagerForSo = new SelfRegistrationManagerForSo(aaiExternalSystemInfoProvider, msbApiProvider, cbamRestApiProviderForSo);
+ assertNotNull(selfRegistrationManagerForSo);
+ assertBean(SelfRegistrationManagerForSo.class);
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcExternalSystemInfoProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcNotificationSender;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
+
+import static junit.framework.TestCase.assertNotNull;
+
+public class TestSelfRegistrationManagerForVfc extends TestBase {
+ @Test
+ public void testBean() {
+ VfcExternalSystemInfoProvider vfcExternalSystemInfoProvider = Mockito.mock(VfcExternalSystemInfoProvider.class);
+ SelfRegistrationManagerForVfc selfRegistrationManagerForVfc = new SelfRegistrationManagerForVfc(vfcExternalSystemInfoProvider, msbApiProvider, cbamRestApiProviderForVfc);
+ assertNotNull(selfRegistrationManagerForVfc);
+ assertBean(SelfRegistrationManagerForVfc.class);
+ }
+}
\ No newline at end of file
package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc;
+import com.google.common.collect.Sets;
import org.junit.Before;
import org.junit.Test;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
verify(logger).error("Unable to query VNFM from VF-C with myVnfmId identifier", expectedException);
}
}
+
+ /**
+ * The VNFM identifier is loaded from property files
+ */
+ @Test
+ public void testGetVnfms(){
+ setFieldWithPropertyAnnotation(vfcExternalSystemInfoProvider, "${vnfmId}", "myVnfmId");
+ assertEquals(Sets.newHashSet("myVnfmId"), vfcExternalSystemInfoProvider.getVnfms());
+ }
}
package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
-import static org.junit.Assert.*;
+import junit.framework.TestCase;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
-public class TestCbamRestApiProviderForSo {
+public class TestCbamRestApiProviderForSo extends TestBase{
+ @Test
+ public void testBean(){
+ CbamTokenProviderForSo cbamTokenProvider = Mockito.mock(CbamTokenProviderForSo.class);
+ AAIExternalSystemInfoProvider aaiExternalSystemInfoProvider = Mockito.mock(AAIExternalSystemInfoProvider.class);
+ CbamSecurityProvider cbamSecurityProvider = Mockito.mock(CbamSecurityProvider.class);
+ CbamRestApiProviderForSo cbamRestApiProviderForSo = new CbamRestApiProviderForSo(cbamTokenProvider, aaiExternalSystemInfoProvider, cbamSecurityProvider);
+ TestCase.assertNotNull(cbamRestApiProviderForSo);
+ assertBean(CbamRestApiProviderForSo.class);
+ }
}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
+
+import junit.framework.TestCase;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcExternalSystemInfoProvider;
+
+
+public class TestCbamRestApiProviderForVfc extends TestBase{
+ @Test
+ public void testBean(){
+ CbamTokenProviderForVfc cbamTokenProvider = Mockito.mock(CbamTokenProviderForVfc.class);
+ VfcExternalSystemInfoProvider c = Mockito.mock(VfcExternalSystemInfoProvider.class);
+ CbamSecurityProvider cbamSecurityProvider = Mockito.mock(CbamSecurityProvider.class);
+ CbamRestApiProviderForVfc cbamRestApiProviderForVfc = new CbamRestApiProviderForVfc(cbamTokenProvider, c, cbamSecurityProvider);
+ TestCase.assertNotNull(cbamRestApiProviderForVfc);
+ assertBean(CbamRestApiProviderForVfc.class);
+ }
+}
\ No newline at end of file
import org.mockito.Mock;
import org.mockito.Mockito;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcExternalSystemInfoProvider;
public class TestCbamTokenProviderForSo extends TestBase {
@Test
public void testBean(){
- CbamTokenProviderForSo cbamTokenProvider = Mockito.mock(CbamTokenProviderForSo.class);
AAIExternalSystemInfoProvider aaiExternalSystemInfoProvider = Mockito.mock(AAIExternalSystemInfoProvider.class);
- CbamSecurityProvider cbamSecurityProvider = Mockito.mock(CbamSecurityProvider.class);
- CbamRestApiProviderForSo cbamRestApiProviderForSo = new CbamRestApiProviderForSo(cbamTokenProvider, aaiExternalSystemInfoProvider, cbamSecurityProvider);
- TestCase.assertNotNull(cbamRestApiProviderForSo);
- assertBean(CbamRestApiProviderForSo.class);
+ CbamTokenProviderForSo cbamTokenProviderForSo = new CbamTokenProviderForSo(aaiExternalSystemInfoProvider);
+ TestCase.assertNotNull(cbamTokenProviderForSo);
+ assertBean(CbamTokenProviderForSo.class);
}
}
\ No newline at end of file
public class TestCbamTokenProviderForVfc extends TestBase {
@Test
public void testBean(){
- CbamTokenProviderForVfc cbamTokenProvider = Mockito.mock(CbamTokenProviderForVfc.class);
VfcExternalSystemInfoProvider vfcExternalSystemInfoProvider = Mockito.mock(VfcExternalSystemInfoProvider.class);
- CbamSecurityProvider cbamSecurityProvider = Mockito.mock(CbamSecurityProvider.class);
- CbamRestApiProviderForVfc cbamRestApiProviderForVfc = new CbamRestApiProviderForVfc(cbamTokenProvider, vfcExternalSystemInfoProvider, cbamSecurityProvider);
- TestCase.assertNotNull(cbamRestApiProviderForSo);
- assertBean(CbamRestApiProviderForSo.class);
+ CbamTokenProviderForVfc cbamTokenProviderForVfc = new CbamTokenProviderForVfc(vfcExternalSystemInfoProvider);
+ TestCase.assertNotNull(cbamTokenProviderForVfc);
+ assertBean(CbamTokenProviderForVfc.class);
}
}
\ No newline at end of file
/**
* test instantiation with backward compatibility test with Amsterdam release
* - the vim identifier is supplied as vimid with not camel case
+ * - the access info is supplied as accessinfo with not camel case
*/
@Test
public void testInstantiationNoVimId() throws Exception {
assertEquals(0, actualInstantiationRequest.getAllValues().size());
//verify
verify(logger).error("VF-C did not send VIM identifier in grant response");
+ }
+
+ /**
+ * instantiation fails if VF-C does not send access info in grant response
+ */
+ @Test
+ public void testVfcFailsToSendAccessInfo() throws Exception {
+ VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO);
+ when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(vnfInfo));
+ additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL);
+ when(vfcGrantManager.requestGrantForInstantiate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, INSTANTIATION_LEVEL, cbamVnfdContent, JOB_ID)).thenReturn(grantResponse);
+ grantResponse.setVimId(VIM_ID);
+ GrantVNFResponseVimAccessInfo accessInfo = new GrantVNFResponseVimAccessInfo();
+ accessInfo.setTenant(TENANT);
+ String caCert = new String(readAllBytes(Paths.get(TestVfcGrantManager.class.getResource("/unittests/localhost.cert.pem").toURI())));
+ vimInfo.setSslInsecure("false");
+ vimInfo.setSslCacert(caCert);
+ //grantResponse.setAccessInfo(accessInfo);
+ ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
+ when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(buildObservable(instantiationOperationExecution));
+ //when
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
+ waitForJobToFinishInJobManager(finished);
+ assertEquals(0, actualInstantiationRequest.getAllValues().size());
+ //verify
+ verify(logger).error("VF-C did not send access info in grant response");
}
/**
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.GrantlessGrantManager;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcExternalSystemInfoProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcGrantManager;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManagerForSo;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManagerForVfc;
@Test
public void testBean(){
CatalogManagerForVfc catalogManager = mock(CatalogManagerForVfc.class);
- GrantlessGrantManager grantManager = mock(GrantlessGrantManager.class);
- VfcExternalSystemInfoProvider aaiExternalSystemInfoProvider = mock(VfcExternalSystemInfoProvider.class);
- JobManagerForVfc jobManagerForSo = mock(JobManagerForVfc.class);
- LifecycleChangeNotificationManagerForVfc lifecycleChangeNotificationManagerForSo = mock(LifecycleChangeNotificationManagerForVfc.class);
- LifecycleManagerForVfc lifecycleManagerForSo = new LifecycleManagerForVfc(catalogManager, grantManager, cbamRestApiProviderForVfc, aaiExternalSystemInfoProvider, jobManagerForSo, lifecycleChangeNotificationManagerForSo);
+ VfcGrantManager vfcGrantManager = mock(VfcGrantManager.class);
+ VfcExternalSystemInfoProvider vfcExternalSystemInfoProvider = mock(VfcExternalSystemInfoProvider.class);
+ JobManagerForVfc lifecycleManagerForVfc = mock(JobManagerForVfc.class);
+ LifecycleChangeNotificationManagerForVfc lifecycleChangeNotificationManagerForVfc = mock(LifecycleChangeNotificationManagerForVfc.class);
+ LifecycleManagerForVfc lifecycleManagerForSo = new LifecycleManagerForVfc(catalogManager, vfcGrantManager, cbamRestApiProviderForVfc, vfcExternalSystemInfoProvider, lifecycleManagerForVfc, lifecycleChangeNotificationManagerForVfc);
assertNotNull(lifecycleManagerForSo);
assertBean(LifecycleChangeNotificationManagerForVfc.class);
}
--- /dev/null
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification.AAINotificationProcessor;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
+
+import static junit.framework.TestCase.assertNotNull;
+
+public class TestLifecycleChangeNotificationManagerForSo extends TestBase {
+ @Test
+ public void testBean() {
+ AAINotificationProcessor aaiNotificationProcessor = Mockito.mock(AAINotificationProcessor.class);
+ LifecycleChangeNotificationManagerForSo lifecycleChangeNotificationManagerForSo = new LifecycleChangeNotificationManagerForSo(cbamRestApiProviderForSo, selfRegistrationManagerForSo, aaiNotificationProcessor);
+ assertNotNull(lifecycleChangeNotificationManagerForSo);
+ assertBean(LifecycleChangeNotificationManagerForSo.class);
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification.AAINotificationProcessor;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcNotificationSender;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
+
+import static junit.framework.TestCase.assertNotNull;
+
+public class TestLifecycleChangeNotificationManagerForVfc extends TestBase {
+ @Test
+ public void testBean() {
+ VfcNotificationSender vfcNotificationSender = Mockito.mock(VfcNotificationSender.class);
+ LifecycleChangeNotificationManagerForVfc lifecycleChangeNotificationManagerForVfc = new LifecycleChangeNotificationManagerForVfc(cbamRestApiProviderForVfc, selfRegistrationManagerForVfc, vfcNotificationSender);
+ assertNotNull(lifecycleChangeNotificationManagerForVfc);
+ assertBean(LifecycleChangeNotificationManagerForVfc.class);
+ }
+}
\ No newline at end of file