use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder in project lispflowmapping by opendaylight.
the class DSBEInputUtil method toMapping.
public static Mapping toMapping(MappingOrigin origin, Eid key) {
MappingBuilder mb = new MappingBuilder();
mb.setEidUri(new EidUri(LispAddressStringifier.getURIString(key)));
mb.setOrigin(origin);
mb.setMappingRecord(new MappingRecordBuilder().setEid(key).build());
return mb.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder in project lispflowmapping by opendaylight.
the class RPCInputConvertorUtil method toMapping.
private static Mapping toMapping(Eid eid) {
MappingBuilder mb = new MappingBuilder();
mb.setEidUri(new EidUri(LispAddressStringifier.getURIString(eid)));
mb.setOrigin(MappingOrigin.Northbound);
mb.setMappingRecord(new MappingRecordBuilder().setEid(eid).build());
return mb.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder in project lispflowmapping by opendaylight.
the class MappingSystemTest method getMappingTest_NbFirst_withNullExpiredNbMapping.
/**
* Tests {@link MappingSystem#getMapping} method with NB mapping == null, expired mapping.
*/
@Test
public void getMappingTest_NbFirst_withNullExpiredNbMapping() {
final MappingData mappingData = getDefaultMappingData();
mappingData.setTimestamp(EXPIRED_DATE);
Mockito.when(pmcMock.getMapping(EID_IPV4_SRC, EID_IPV4_DST)).thenReturn(null);
Mockito.when(smcMock.getMapping(EID_IPV4_DST, (XtrId) null)).thenReturn(mappingData, null);
final Mapping mapping = new MappingBuilder().setEidUri(new EidUri("ipv4:" + IPV4_DST)).setOrigin(MappingOrigin.Southbound).setSiteId(Lists.newArrayList(SITE_ID)).setMappingRecord(mappingData.getRecord()).build();
assertNull(mappingSystem.getMapping(EID_IPV4_SRC, EID_IPV4_DST));
Mockito.verify(dsbeMock).removeMapping(mapping);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder in project lispflowmapping by opendaylight.
the class MappingSystemTest method restoreDaoFromDatastoreTest.
/**
* Tests {@link MappingSystem#restoreDaoFromDatastore} method.
*/
@Test
public void restoreDaoFromDatastoreTest() {
final Mapping mapping_1 = new MappingBuilder().setOrigin(MappingOrigin.Northbound).setMappingRecord(getDefaultMappingRecordBuilder().setEid(EID_IPV4_1).build()).build();
final Mapping mapping_2 = new MappingBuilder().setOrigin(MappingOrigin.Northbound).setMappingRecord(getDefaultMappingRecordBuilder().setEid(EID_IPV4_2).build()).build();
final MappingAuthkey mappingAuthkey_1 = MAPPING_AUTHKEY_BUILDER.build();
final AuthenticationKey authenticationKey_1 = new AuthenticationKeyBuilder().setMappingAuthkey(mappingAuthkey_1).setEid(EID_IPV4_1).build();
final MappingAuthkey mappingAuthkey_2 = MAPPING_AUTHKEY_BUILDER.setKeyString("pass-2").build();
final AuthenticationKey authenticationKey_2 = new AuthenticationKeyBuilder().setMappingAuthkey(mappingAuthkey_2).setEid(EID_IPV4_2).build();
final List<Mapping> mappings = Lists.newArrayList(mapping_1, mapping_2);
final List<AuthenticationKey> authenticationKeys = Lists.newArrayList(authenticationKey_1, authenticationKey_2);
Mockito.when(dsbeMock.getLastUpdateTimestamp()).thenReturn(System.currentTimeMillis());
Mockito.when(dsbeMock.getAllMappings(LogicalDatastoreType.CONFIGURATION)).thenReturn(mappings);
Mockito.when(dsbeMock.getAllAuthenticationKeys()).thenReturn(authenticationKeys);
Mockito.when(tableMapMock.get(MappingOrigin.Northbound)).thenReturn(pmcMock);
mappingSystem.initialize();
ArgumentCaptor<MappingData> captor = ArgumentCaptor.forClass(MappingData.class);
Mockito.verify(pmcMock).addMapping(Mockito.eq(EID_IPV4_1), captor.capture());
assertEquals(captor.getValue().getRecord(), mapping_1.getMappingRecord());
Mockito.verify(pmcMock).addMapping(Mockito.eq(EID_IPV4_2), captor.capture());
assertEquals(captor.getValue().getRecord(), mapping_2.getMappingRecord());
Mockito.verify(akdbMock).addAuthenticationKey(EID_IPV4_1, mappingAuthkey_1);
Mockito.verify(akdbMock).addAuthenticationKey(EID_IPV4_2, mappingAuthkey_2);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder in project lispflowmapping by opendaylight.
the class MappingSystemTest method getMappingTest_NbSbIntersection_withSbNull.
/**
* Tests {@link MappingSystem#getMapping} method, northbound and southbound intersection with single Ipv4 type
* locator, southbound null. Returns the original mapping.
*/
@Test
public void getMappingTest_NbSbIntersection_withSbNull() throws NoSuchFieldException, IllegalAccessException {
setLookupPolicy(IMappingService.LookupPolicy.NB_AND_SB);
final MappingRecord mappingRecord = getDefaultMappingRecordBuilder().setLocatorRecord(Lists.newArrayList(// Ipv4 type Rloc
getDefaultLocatorRecordBuilder().build())).build();
MappingData nbMappingData = getDefaultMappingData(mappingRecord);
MappingData sbMappingData = getDefaultMappingData(mappingRecord);
sbMappingData.setTimestamp(EXPIRED_DATE);
Mockito.when(pmcMock.getMapping(EID_IPV4_SRC, EID_IPV4_DST)).thenReturn(nbMappingData);
Mockito.when(smcMock.getMapping(EID_IPV4_DST, (XtrId) null)).thenReturn(sbMappingData, null);
final Mapping mapping = new MappingBuilder().setEidUri(new EidUri("ipv4:" + IPV4_DST)).setOrigin(MappingOrigin.Southbound).setSiteId(Lists.newArrayList(SITE_ID)).setMappingRecord(mappingRecord).build();
assertEquals(nbMappingData, mappingSystem.getMapping(EID_IPV4_SRC, EID_IPV4_DST));
Mockito.verify(dsbeMock).removeMapping(mapping);
}
Aggregations