use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project lispflowmapping by opendaylight.
the class SimpleMapCache method addMapping.
@Override
public void addMapping(Eid key, Object value, Set<IpAddressBinary> sourceRlocs) {
Eid eid = MaskUtil.normalize(key);
ILispDAO table = getOrInstantiateVniTable(key);
table.put(eid, new MappingEntry<>(SubKeys.RECORD, value));
if (sourceRlocs != null) {
table.put(eid, new MappingEntry<>(SubKeys.SRC_RLOCS, sourceRlocs));
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project lispflowmapping by opendaylight.
the class SimpleMapCache method addData.
@Override
public void addData(Eid eid, String subKey, Object data) {
ILispDAO table = getOrInstantiateVniTable(eid);
Eid key = MaskUtil.normalize(eid);
table.put(key, new MappingEntry<>(subKey, data));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project lispflowmapping by opendaylight.
the class MultiTableMapCacheTest method getMappingTest_withSourceDestKey.
/**
* Tests {@link MultiTableMapCache#getMapping} with SourceDestKey address type.
*/
@Test
public void getMappingTest_withSourceDestKey() {
when(daoMock.getSpecific(VNI, SubKeys.VNI)).thenReturn(tableDaoMock);
final Eid dstAddr = SourceDestKeyHelper.getDstBinary(EID_SOURCE_DEST_KEY_TYPE);
final Eid normalizedDstAddr = MaskUtil.normalize(dstAddr);
final Eid srcAddr = SourceDestKeyHelper.getSrcBinary(EID_SOURCE_DEST_KEY_TYPE);
final Eid normalizedSrcAddr = MaskUtil.normalize(srcAddr);
final Map<String, Object> entry = getEntry1();
final Map<String, Object> entry2 = getEntry2();
when(tableDaoMock.getBest(normalizedDstAddr)).thenReturn(entry);
when(srcDstDaoMock.getBest(normalizedSrcAddr)).thenReturn(entry2);
assertEquals(DUMMY_OBJECT_2, multiTableMapCache.getMapping(null, EID_SOURCE_DEST_KEY_TYPE));
assertNull(multiTableMapCache.getMapping(null, null));
assertNull(multiTableMapCache.getMapping(EID_TEST, null));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project lispflowmapping by opendaylight.
the class MultiTableMapCacheTest method getMappingTest_withIpv4Prefix.
/**
* Tests {@link MultiTableMapCache#getMapping} with Ipv4Prefix address type.
*/
@Test
public void getMappingTest_withIpv4Prefix() {
final Eid key = MaskUtil.normalize(EID_IPV4_PREFIX_DST, (short) 24);
final Eid key2 = MaskUtil.normalize(MaskUtil.normalize(EID_IPV4_PREFIX_SRC), (short) 24);
final Map<String, Object> entry = getEntry1();
final Map<String, Object> entry2 = getEntry2();
when(daoMock.getSpecific(VNI, SubKeys.VNI)).thenReturn(tableDaoMock);
when(tableDaoMock.getBest(key)).thenReturn(entry);
when(srcDstDaoMock.getBest(LispAddressUtil.asIpPrefixBinaryEid(key2))).thenReturn(entry2);
assertEquals(DUMMY_OBJECT_2, multiTableMapCache.getMapping(EID_IPV4_PREFIX_SRC, EID_IPV4_PREFIX_DST));
assertEquals(DUMMY_OBJECT, multiTableMapCache.getMapping(null, EID_IPV4_PREFIX_DST));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project lispflowmapping by opendaylight.
the class SimpleMapCacheTest method getAllXtrIdMappings_withNonMaskableAddress.
/**
* Tests {@link SimpleMapCache#getAllXtrIdMappings} method with non maskable address.
*/
@Test
@SuppressWarnings("unchecked")
public void getAllXtrIdMappings_withNonMaskableAddress() {
final Map<String, Object> entryMock = Mockito.mock(Map.class);
final ILispDAO xtrIdRecordsMock = Mockito.mock(ILispDAO.class);
Mockito.when(daoMock.getSpecific(VNI_0, SubKeys.VNI)).thenReturn(tableMock);
Mockito.when(tableMock.getBest(NORMALIZED_EID_IPV4)).thenReturn(entryMock);
Mockito.when(entryMock.get(SubKeys.XTRID_RECORDS)).thenReturn(xtrIdRecordsMock);
Mockito.when(xtrIdRecordsMock.getSpecific(EID_IPV4, SubKeys.RECORD)).thenReturn(xtrIdDaoMock);
simpleMapCache.getAllXtrIdMappings(EID_IPV4);
Mockito.verify(tableMock).getBest(Mockito.any(Eid.class));
}
Aggregations