package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.nokia.cbam.lcn.v32.api.SubscriptionsApi;
*
* @param vnfmId the identifier of the VNFM
*/
+ @VisibleForTesting
public void assureSubscription(String vnfmId) {
if (!vnfmIdToSubscriptionId.containsKey(vnfmId)) {
subscribeToLcn(vnfmId);
if (nsId.isPresent()) {
addSingletonRelation(vnf.getRelationshipList(), linkToNs(nsId.get()));
}
+ else{
+ logger.warn("Not linking VNF with {} identifier to any NS", vnfId);
+ }
aaiRestApiProvider.getNetworkApi().createOrUpdateNetworkGenericVnfsGenericVnf(vnf.getVnfId(), vnf).blockingFirst();
}
package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
-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 java.util.Set;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.INotificationSender;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.OperationMustBeAborted;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider;
return buildObservable(subscription);
});
selfRegistrationManager.assureSubscription(VNFM_ID);
+ selfRegistrationManager.assureSubscription(VNFM_ID);
when(jobManager.hasOngoingJobs()).thenReturn(false);
when(lcnApi.subscriptionsSubscriptionIdDelete(subscription.getId(), NOKIA_LCN_API_VERSION)).thenReturn(VOID_OBSERVABLE.value());
VoidObservable MSB_DELETE = new VoidObservable();
package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct;
import java.util.ArrayList;
+import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.onap.aai.model.CloudRegion;
import org.onap.aai.model.EsrSystemInfo;
import org.onap.aai.model.EsrVnfm;
+import org.onap.aai.model.EsrVnfmList;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
import org.onap.vnfmdriver.model.VimInfo;
import org.onap.vnfmdriver.model.VnfmInfo;
assertEquals(expectedException, e.getCause());
}
}
+
+ /**
+ * the list of VNFMs is retrieved from AAI
+ */
+ @Test
+ public void testQueryAAIExternaSystemProvider() throws Exception{
+ EsrVnfmList e = new EsrVnfmList();
+ EsrVnfm esrVnfmItem = new EsrVnfm();
+ esrVnfmItem.setVnfmId(VNFM_ID);
+ e.addEsrVnfmItem(esrVnfmItem);
+ when(externalSystemApi.getExternalSystemEsrVnfmList()).thenReturn(buildObservable(e));
+ //when
+ Set<String> vnfms = aaiExternalSystemInfoProvider.getVnfms();
+ //verify
+ assertEquals(1, vnfms.size());
+ assertEquals(VNFM_ID, vnfms.iterator().next());
+ }
}
\ No newline at end of file
import com.nokia.cbam.lcm.v32.model.VnfInfo;
import io.reactivex.Observable;
-import java.util.HashSet;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Set;
+import java.util.*;
import java.util.concurrent.atomic.AtomicLong;
import org.junit.Before;
import org.junit.Test;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
import static java.lang.Boolean.TRUE;
+import static java.util.Optional.empty;
import static java.util.Optional.of;
import static junit.framework.TestCase.assertEquals;
when(cbamRestApiProviderForSo.getCbamLcmApi(VNFM_ID).vnfsVnfInstanceIdGet(VNF_ID, CbamRestApiProvider.NOKIA_LCM_API_VERSION)).thenReturn(buildObservable(vnfInfo));
when(networkApi.createOrUpdateNetworkGenericVnfsGenericVnf(eq(VNF_ID), payload.capture())).thenReturn(VOID_OBSERVABLE.value());
vnfInfo.setName("vnfName");
+ vnfInAaai.setRelationshipList(new ArrayList<>());
+ vnfInAaai.getRelationshipList().add(new Relationship());
//when
- genericVnfManager.createOrUpdate(VNF_ID, true, VNFM_ID, of("nsId"));
+ genericVnfManager.createOrUpdate(VNF_ID, true, VNFM_ID, empty());
//verify
GenericVnf vnfSentToAai = payload.getValue();
assertEquals(VNF_ID, vnfSentToAai.getVnfId());
assertEquals("vnfName", vnfSentToAai.getVnfName());
verify(systemFunctions, never()).sleep(anyLong());
VOID_OBSERVABLE.assertCalled();
+ assertEquals(1, vnfInAaai.getRelationshipList().size());
verify(networkApi, times(1)).getNetworkGenericVnfsGenericVnf(VNF_ID, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
}
--- /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 org.junit.Test;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.TestUtil;
+
+public class TestConstants {
+
+ @Test
+ public void useInStaticWay(){
+ TestUtil.coveragePrivateConstructorForClassesWithStaticMethodsOnly(Constants.class);
+ }
+}
\ No newline at end of file