import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
-import com.google.common.base.Optional;
import com.google.common.collect.Lists;
import java.lang.reflect.Field;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState;
import org.opendaylight.lispflowmapping.interfaces.lisp.IMapResolverAsync;
import org.opendaylight.lispflowmapping.interfaces.lisp.IMapServerAsync;
import org.opendaylight.lispflowmapping.interfaces.mappingservice.IMappingService;
private final NotificationService notificationService = Mockito.mock(NotificationService.class);
private final IMappingService mappingService = Mockito.mock(IMappingService.class);
private final OdlLispSbService odlLispSbService = Mockito.mock(OdlLispSbService.class);
- private final EntityOwnershipService entityOwnershipSrvice = Mockito.mock(EntityOwnershipService.class);
@InjectMocks
private LispMappingService lispMappingService = new LispMappingService(
notificationService,
mappingService,
- odlLispSbService, entityOwnershipSrvice);
+ odlLispSbService);
private static final byte[] IPV4_BYTES_1 = new byte[] {1, 2, 3, 0};
private static final byte[] IPV4_BYTES_2 = new byte[] {1, 2, 4, 0};
Mockito.when(mapRegister.getMappingRecordItem())
.thenReturn(Lists.newArrayList(MAPPING_RECORD_ITEM_BUILDER.build()));
Mockito.when(tlsMapNotifyMock.get()).thenReturn(getDefaultMapNotifyPair());
- Mockito.when(entityOwnershipSrvice.getOwnershipState(Mockito.any(Entity.class))).thenReturn(Optional.of
- (new EntityOwnershipState(true, true)));
lispMappingService.onAddMapping(addMapping);
Mockito.verify(odlLispSbService, Mockito.times(2)).sendMapNotify(Mockito.argThat(new TransportAddressMatch()));
.setMapNotify(new org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105
.mapnotifymessage.MapNotifyBuilder().setKeyId((short) 1).build())
.setTransportAddress(TRANSPORT_ADDRESS);
- Mockito.when(entityOwnershipSrvice.getOwnershipState(Mockito.any(Entity.class))).thenReturn(Optional.of
- (new EntityOwnershipState(true, true)));
lispMappingService.onAddMapping(addMapping);
Mockito.verify(odlLispSbService).sendMapNotify(smnib.build());
Mockito.when(requestMapping.getTransportAddress()).thenReturn(TRANSPORT_ADDRESS_1);
Mockito.when(mapRequest.getEidItem()).thenReturn(Lists.newArrayList(EID_ITEM_BUILDER.build()));
Mockito.when(tlsMapReplyMock.get()).thenReturn(mapReply);
- Mockito.when(entityOwnershipSrvice.getOwnershipState(Mockito.any(Entity.class))).thenReturn(Optional.of
- (new EntityOwnershipState(true, true)));
// result
final SendMapReplyInputBuilder smrib = new SendMapReplyInputBuilder()
Mockito.when(mapRequest.getEidItem()).thenReturn(Lists.newArrayList(EID_ITEM_BUILDER.build()));
Mockito.when(tlsMapReplyMock.get()).thenReturn(null);
- Mockito.when(entityOwnershipSrvice.getOwnershipState(Mockito.any(Entity.class))).thenReturn(Optional.of
- (new EntityOwnershipState(true, true)));
lispMappingService.onRequestMapping(requestMapping);
Mockito.verifyZeroInteractions(odlLispSbService);
}