Search in sources :

Example 46 with Mapping

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping in project lispflowmapping by opendaylight.

the class MappingServiceTest method getMappingTest_withNullMapRecord.

/**
 * Tests {@link MappingService#getMapping} method with null MappingRecord.
 */
@Test
public void getMappingTest_withNullMapRecord() throws ExecutionException, InterruptedException {
    // input
    final GetMappingInput getMappingInput = new GetMappingInputBuilder().setEid(IPV4_EID).build();
    Mockito.when(mappingSystem.getMapping(getMappingInput.getEid())).thenReturn(null);
    final RpcResult<Object> rpc = RpcResultBuilder.failed().withError(RpcError.ErrorType.APPLICATION, "data-missing", "No mapping was found in the mapping database").build();
    final RpcError error = rpc.getErrors().iterator().next();
    // result
    final Future<RpcResult<GetMappingOutput>> result = (mappingService.getMapping(getMappingInput));
    final RpcError errorResult = result.get().getErrors().iterator().next();
    assertEquals(1, result.get().getErrors().size());
    assertEquals(error.getMessage(), errorResult.getMessage());
    assertEquals(error.getApplicationTag(), errorResult.getApplicationTag());
    assertEquals(error.getCause(), errorResult.getCause());
    assertEquals(error.getErrorType(), errorResult.getErrorType());
    assertEquals(error.getInfo(), errorResult.getInfo());
    assertEquals(error.getTag(), errorResult.getTag());
    assertEquals(error.getSeverity(), errorResult.getSeverity());
    assertEquals(rpc.getResult(), result.get().getResult());
    assertEquals(rpc.isSuccessful(), result.get().isSuccessful());
}
Also used : GetMappingInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingInputBuilder) GetMappingInput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingInput) RpcError(org.opendaylight.yangtools.yang.common.RpcError) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Test(org.junit.Test)

Example 47 with Mapping

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping in project lispflowmapping by opendaylight.

the class MappingServiceTest method getKeyTest_withNullMappingAuthkey.

/**
 * Tests {@link MappingService#getKey} method with null MappingAuthkey.
 */
@Test
public void getKeyTest_withNullMappingAuthkey() throws ExecutionException, InterruptedException {
    // input
    final GetKeyInput getKeyInput = new GetKeyInputBuilder().setEid(IPV4_EID).build();
    Mockito.when(mappingSystem.getAuthenticationKey(getKeyInput.getEid())).thenReturn(null);
    final RpcResult<Object> rpc = RpcResultBuilder.failed().withError(RpcError.ErrorType.APPLICATION, "data-missing", "Key was not found in the mapping database").build();
    final RpcError error = rpc.getErrors().iterator().next();
    // result
    final Future<RpcResult<GetKeyOutput>> result = mappingService.getKey(getKeyInput);
    final RpcError errorResult = result.get().getErrors().iterator().next();
    assertEquals(1, result.get().getErrors().size());
    assertEquals(error.getMessage(), errorResult.getMessage());
    assertEquals(error.getApplicationTag(), errorResult.getApplicationTag());
    assertEquals(error.getCause(), errorResult.getCause());
    assertEquals(error.getErrorType(), errorResult.getErrorType());
    assertEquals(error.getInfo(), errorResult.getInfo());
    assertEquals(error.getTag(), errorResult.getTag());
    assertEquals(error.getSeverity(), errorResult.getSeverity());
    assertEquals(rpc.getResult(), result.get().getResult());
    assertEquals(rpc.isSuccessful(), result.get().isSuccessful());
}
Also used : GetKeyInput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeyInput) RpcError(org.opendaylight.yangtools.yang.common.RpcError) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetKeyInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeyInputBuilder) Test(org.junit.Test)

Example 48 with Mapping

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping in project lispflowmapping by opendaylight.

the class MappingDataListenerTest method init.

@Before
@SuppressWarnings("unchecked")
public void init() {
    final DataBroker dataBrokerMock = Mockito.mock(DataBroker.class);
    iMappingSystemMock = Mockito.mock(IMappingSystem.class);
    notificationPublishServiceMock = Mockito.mock(NotificationPublishService.class);
    mappingDataListener = new MappingDataListener(dataBrokerMock, iMappingSystemMock, notificationPublishServiceMock);
    final InstanceIdentifier<Mapping> instanceIdentifierMock = Mockito.mock(InstanceIdentifier.class);
    final DataTreeIdentifier<Mapping> dataTreeIdentifier = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, instanceIdentifierMock);
    change_del = Mockito.mock(DataTreeModification.class);
    change_subtreeModified = Mockito.mock(DataTreeModification.class);
    change_write = Mockito.mock(DataTreeModification.class);
    mod_del = Mockito.mock(DataObjectModification.class);
    mod_subtreeModified = Mockito.mock(DataObjectModification.class);
    mod_write = Mockito.mock(DataObjectModification.class);
    Mockito.when(change_del.getRootPath()).thenReturn(dataTreeIdentifier);
    Mockito.when(change_del.getRootNode()).thenReturn(mod_del);
    Mockito.when(change_subtreeModified.getRootPath()).thenReturn(dataTreeIdentifier);
    Mockito.when(change_subtreeModified.getRootNode()).thenReturn(mod_subtreeModified);
    Mockito.when(change_write.getRootPath()).thenReturn(dataTreeIdentifier);
    Mockito.when(change_write.getRootNode()).thenReturn(mod_write);
    Mockito.when(mod_del.getModificationType()).thenReturn(ModificationType.DELETE);
    Mockito.when(mod_subtreeModified.getModificationType()).thenReturn(ModificationType.SUBTREE_MODIFIED);
    Mockito.when(mod_write.getModificationType()).thenReturn(ModificationType.WRITE);
    Mockito.when(iMappingSystemMock.isMaster()).thenReturn(true);
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) DataTreeIdentifier(org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier) DataObjectModification(org.opendaylight.controller.md.sal.binding.api.DataObjectModification) IMappingSystem(org.opendaylight.lispflowmapping.interfaces.mapcache.IMappingSystem) Mapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) NotificationPublishService(org.opendaylight.controller.md.sal.binding.api.NotificationPublishService) Before(org.junit.Before)

Example 49 with Mapping

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping in project lispflowmapping by opendaylight.

the class MappingDataListenerTest method onDataTreeChangedTest_subtreeModified_NB.

/**
 * Tests {@link MappingDataListener#onDataTreeChanged} method with SUBTREE_MODIFIED modification type from
 * northbound.
 */
@Test
@Ignore
@SuppressWarnings("unchecked")
public void onDataTreeChangedTest_subtreeModified_NB() throws InterruptedException {
    final List<DataTreeModification<Mapping>> changes = Lists.newArrayList(change_subtreeModified);
    final MappingChanged mapChanged = MSNotificationInputUtil.toMappingChanged(MAPPING_EID_2_NB.getMappingRecord(), null, null, null, MappingChange.Updated);
    Mockito.when(mod_subtreeModified.getDataAfter()).thenReturn(MAPPING_EID_2_NB);
    mappingDataListener.onDataTreeChanged(changes);
    final ArgumentCaptor<MappingData> captor = ArgumentCaptor.forClass(MappingData.class);
    Mockito.verify(iMappingSystemMock).addMapping(Mockito.eq(MappingOrigin.Northbound), Mockito.eq(IPV4_EID_2), captor.capture());
    assertEquals(captor.getValue().getRecord(), MAPPING_EID_2_NB.getMappingRecord());
    Mockito.verify(notificationPublishServiceMock).putNotification(mapChanged);
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) MappingChanged(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingChanged) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 50 with Mapping

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping in project lispflowmapping by opendaylight.

the class MappingDataListenerTest method onDataTreeChangedTest_write_NB.

/**
 * Tests {@link MappingDataListener#onDataTreeChanged} method with WRITE modification type from northbound.
 */
@Test
@Ignore
@SuppressWarnings("unchecked")
public void onDataTreeChangedTest_write_NB() throws InterruptedException {
    final List<DataTreeModification<Mapping>> changes = Lists.newArrayList(change_write);
    final MappingChanged mapChanged = MSNotificationInputUtil.toMappingChanged(MAPPING_EID_3_NB.getMappingRecord(), null, null, null, MappingChange.Created);
    Mockito.when(mod_write.getDataAfter()).thenReturn(MAPPING_EID_3_NB);
    mappingDataListener.onDataTreeChanged(changes);
    final ArgumentCaptor<MappingData> captor = ArgumentCaptor.forClass(MappingData.class);
    Mockito.verify(iMappingSystemMock).addMapping(Mockito.eq(MappingOrigin.Northbound), Mockito.eq(IPV4_EID_3), captor.capture());
    assertEquals(captor.getValue().getRecord(), MAPPING_EID_3_NB.getMappingRecord());
    Mockito.verify(notificationPublishServiceMock).putNotification(mapChanged);
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) MappingChanged(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingChanged) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)34 Test (org.junit.Test)32 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)32 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)26 ArrayList (java.util.ArrayList)21 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)17 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)16 MappingBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder)14 BigInteger (java.math.BigInteger)13 Mapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping)13 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)12 LocatorRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder)11 EidUri (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.EidUri)11 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)10 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)9 Subscriber (org.opendaylight.lispflowmapping.interfaces.dao.Subscriber)8 GotMapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)8 MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)8 MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)8 XtrIdMapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.mapping.XtrIdMapping)8