package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
import com.google.common.collect.Lists;
-import com.nokia.cbam.lcn.v32.ApiException;
import com.nokia.cbam.lcn.v32.model.CreateSubscriptionRequest;
import com.nokia.cbam.lcn.v32.model.Subscription;
import com.nokia.cbam.lcn.v32.model.SubscriptionAuthentication;
@Before
public void initMocks() throws Exception {
setField(SelfRegistrationManager.class, "logger", logger);
- when(lcnApi.subscriptionsGet(NOKIA_LCN_API_VERSION)).thenReturn(subscriptions);
+ when(lcnApi.subscriptionsGet(NOKIA_LCN_API_VERSION)).thenReturn(buildObservable(subscriptions));
when(driverProperties.getVnfmId()).thenReturn(VNFM_ID);
setField(selfRegistrationManager, "driverMsbExternalIp", "1.2.3.4");
setField(selfRegistrationManager, "driverVnfmExternalIp", "5.6.7.8");
public void testRegistration() throws Exception {
//given
Subscription subscription = new Subscription();
- when(lcnApi.subscriptionsPost(subscriptionToCreate.capture(), Mockito.eq(NOKIA_LCN_API_VERSION))).thenReturn(subscription);
+ when(lcnApi.subscriptionsPost(subscriptionToCreate.capture(), Mockito.eq(NOKIA_LCN_API_VERSION))).thenReturn(buildObservable(subscription));
MicroServiceFullInfo returnedMicroService = new MicroServiceFullInfo();
when(msbClient.registerMicroServiceInfo(registeredMicroservice.capture())).thenReturn(returnedMicroService);
//when
@Test
public void testFailedLcnSubscription() throws Exception {
//given
- ApiException expectedException = new ApiException();
+ RuntimeException expectedException = new RuntimeException();
when(lcnApi.subscriptionsPost(any(), any())).thenThrow(expectedException);
//when
try {
public void testFailedMsbPublish() throws Exception {
//given
Subscription subscription = new Subscription();
- when(lcnApi.subscriptionsPost(subscriptionToCreate.capture(), Mockito.eq(NOKIA_LCN_API_VERSION))).thenAnswer(new Answer<Subscription>() {
- @Override
- public Subscription answer(InvocationOnMock invocationOnMock) throws Throwable {
- subscription.setCallbackUrl("http://5.6.7.8:12345/api/NokiaSVNFM/v1/lcn");
- subscription.setId(UUID.randomUUID().toString());
- subscriptions.add(subscription);
- return subscription;
- }
+ when(lcnApi.subscriptionsPost(subscriptionToCreate.capture(), Mockito.eq(NOKIA_LCN_API_VERSION))).thenAnswer(invocationOnMock -> {
+ subscription.setCallbackUrl("http://5.6.7.8:12345/api/NokiaSVNFM/v1/lcn");
+ subscription.setId(UUID.randomUUID().toString());
+ subscriptions.add(subscription);
+ return buildObservable(subscription);
});
MicroServiceFullInfo returnedMicroService = new MicroServiceFullInfo();
RouteException expectedException = new RouteException();
subscription.setId(UUID.randomUUID().toString());
subscriptions.add(subscription);
when(jobManager.hasOngoingJobs()).thenReturn(false);
- ApiException expectedException = new ApiException();
+ RuntimeException expectedException = new RuntimeException();
doThrow(expectedException).when(lcnApi).subscriptionsSubscriptionIdDelete(subscription.getId(), NOKIA_LCN_API_VERSION);
//when
try {