use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyBuilder 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.AuthenticationKeyBuilder in project lispflowmapping by opendaylight.
the class DataStoreBackEndTest method getDefaultMappingDatabase.
private static MappingDatabaseBuilder getDefaultMappingDatabase() {
final Mapping mapping_1 = new MappingBuilder().setMappingRecord(getDefaultMappingRecordBuilder().build()).build();
final Mapping mapping_2 = new MappingBuilder().setMappingRecord(getDefaultMappingRecordBuilder().setEid(EID_IPV4_2).build()).build();
final Mapping mapping_3 = new MappingBuilder().setMappingRecord(getDefaultMappingRecordBuilder().setEid(EID_IPV4_3).build()).build();
final Mapping mapping_4 = new MappingBuilder().setMappingRecord(getDefaultMappingRecordBuilder().setEid(EID_IPV4_4).build()).build();
final AuthenticationKey authenticationKey_1 = new AuthenticationKeyBuilder().setKey(new AuthenticationKeyKey(new EidUri("uri-1"))).build();
final AuthenticationKey authenticationKey_2 = new AuthenticationKeyBuilder().setKey(new AuthenticationKeyKey(new EidUri("uri-2"))).build();
final AuthenticationKey authenticationKey_3 = new AuthenticationKeyBuilder().setKey(new AuthenticationKeyKey(new EidUri("uri-3"))).build();
final AuthenticationKey authenticationKey_4 = new AuthenticationKeyBuilder().setKey(new AuthenticationKeyKey(new EidUri("uri-4"))).build();
final VirtualNetworkIdentifier vni_1 = new VirtualNetworkIdentifierBuilder().setVni(new VniUri("vni/uri/1")).setMapping(Lists.newArrayList(mapping_1, mapping_2)).setAuthenticationKey(Lists.newArrayList(authenticationKey_1, authenticationKey_2)).build();
final VirtualNetworkIdentifier vni_2 = new VirtualNetworkIdentifierBuilder().setVni(new VniUri("vni/uri/2")).setMapping(Lists.newArrayList(mapping_3, mapping_4)).setAuthenticationKey(Lists.newArrayList(authenticationKey_3, authenticationKey_4)).build();
return new MappingDatabaseBuilder().setVirtualNetworkIdentifier(Lists.newArrayList(vni_1, vni_2));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyBuilder in project lispflowmapping by opendaylight.
the class AuthenticationKeyDataListener method convertToBinaryIfNecessary.
private static AuthenticationKey convertToBinaryIfNecessary(AuthenticationKey authKey) {
Eid originalEid = authKey.getEid();
if (LispAddressUtil.addressNeedsConversionToBinary(originalEid.getAddress())) {
AuthenticationKeyBuilder akb = new AuthenticationKeyBuilder(authKey);
akb.setEid(LispAddressUtil.convertToBinary(originalEid));
return akb.build();
}
return authKey;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyBuilder in project lispflowmapping by opendaylight.
the class AuthenticationKeyDataListener method convertToBinaryIfNecessary.
private static AuthenticationKey convertToBinaryIfNecessary(AuthenticationKey authKey) {
Eid originalEid = authKey.getEid();
if (LispAddressUtil.addressNeedsConversionToBinary(originalEid.getAddress())) {
AuthenticationKeyBuilder akb = new AuthenticationKeyBuilder(authKey);
akb.setEid(LispAddressUtil.convertToBinary(originalEid));
return akb.build();
}
return authKey;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyBuilder in project lispflowmapping by opendaylight.
the class DSBEInputUtil method toAuthenticationKey.
public static AuthenticationKey toAuthenticationKey(Eid key, MappingAuthkey authKey) {
AuthenticationKeyBuilder akb = new AuthenticationKeyBuilder();
akb.setEidUri(new EidUri(LispAddressStringifier.getURIString(key)));
akb.setEid(key);
akb.setMappingAuthkey(authKey);
return akb.build();
}
Aggregations