Search in sources :

Example 1 with AuthenticationKeyBuilder

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);
}
Also used : AuthenticationKeyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyBuilder) MappingBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder) AuthenticationKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey) MappingAuthkey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) Mapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with AuthenticationKeyBuilder

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));
}
Also used : AuthenticationKeyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyBuilder) VirtualNetworkIdentifierBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.database.VirtualNetworkIdentifierBuilder) AuthenticationKeyKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyKey) XtrIdMappingBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.mapping.XtrIdMappingBuilder) MappingBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder) VniUri(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.VniUri) AuthenticationKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey) VirtualNetworkIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.database.VirtualNetworkIdentifier) EidUri(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.EidUri) MappingDatabaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingDatabaseBuilder) Mapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping) XtrIdMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.mapping.XtrIdMapping)

Example 3 with AuthenticationKeyBuilder

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;
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) AuthenticationKeyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyBuilder)

Example 4 with AuthenticationKeyBuilder

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;
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) AuthenticationKeyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyBuilder)

Example 5 with AuthenticationKeyBuilder

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();
}
Also used : AuthenticationKeyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyBuilder) EidUri(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.EidUri)

Aggregations

AuthenticationKeyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyBuilder)6 EidUri (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.EidUri)3 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)2 AuthenticationKey (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey)2 Mapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping)2 MappingBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder)2 Test (org.junit.Test)1 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)1 MappingAuthkey (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey)1 MappingDatabaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingDatabaseBuilder)1 VniUri (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.VniUri)1 AuthenticationKeyKey (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyKey)1 XtrIdMapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.mapping.XtrIdMapping)1 XtrIdMappingBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.mapping.XtrIdMappingBuilder)1 VirtualNetworkIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.database.VirtualNetworkIdentifier)1 VirtualNetworkIdentifierBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.database.VirtualNetworkIdentifierBuilder)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1