Search in sources :

Example 6 with MappingBuilder

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

the class LispNotificationHelperTest method getMappingTest_SiteIdNotPresent.

/**
 * Tests {@link LispNotificationHelper#getMapping} method with invalid address, isXtrSiteIdPresent == false.
 */
@Test
public void getMappingTest_SiteIdNotPresent() {
    final MappingBuilder mappingBuilder_1 = new MappingBuilder().setMappingRecord(new MappingRecordBuilder().setEid(EID_IPV4).build()).setEidUri(new EidUri("ipv4:" + IPV4_STRING)).setOrigin(MappingOrigin.Southbound);
    final MappingBuilder mappingBuilder_2 = new MappingBuilder().setMappingRecord(new MappingRecordBuilder().setEid(EID_IPV6).build()).setEidUri(new EidUri("ipv6:" + IPV6_STRING)).setOrigin(MappingOrigin.Southbound);
    assertEquals(Lists.newArrayList(mappingBuilder_1.build(), mappingBuilder_2.build()), LispNotificationHelper.getMapping(getDefaultAddMapping(false)));
}
Also used : MappingBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder) AddMappingBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMappingBuilder) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) EidUri(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.EidUri) Test(org.junit.Test)

Example 7 with MappingBuilder

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

the class DataStoreBackEndTest method removeMapping.

/**
 * Tests {@link DataStoreBackEnd#removeMapping} method.
 */
@Test
public void removeMapping() {
    final Mapping mapping = new MappingBuilder().setMappingRecord(getDefaultMappingRecordBuilder().build()).setOrigin(MappingOrigin.Northbound).build();
    dataStoreBackEnd.removeMapping(mapping);
    Mockito.verify(wTxMock).delete(Mockito.eq(LogicalDatastoreType.CONFIGURATION), iidCaptorMapping.capture());
    // result
    MappingKey result = iidCaptorMapping.getValue().firstKeyOf(Mapping.class);
    assertEquals("ipv4:" + IPV4_STRING_1, result.getEidUri().getValue());
    assertEquals(MappingOrigin.Northbound, result.getOrigin());
}
Also used : 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) 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) MappingKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingKey) XtrIdMappingKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.mapping.XtrIdMappingKey) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 8 with MappingBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder 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 9 with MappingBuilder

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

the class DataStoreBackEndTest method addMappingTest.

/**
 * Tests {@link DataStoreBackEnd#addMapping} method.
 */
@Test
public void addMappingTest() {
    final Mapping mapping = new MappingBuilder().setMappingRecord(getDefaultMappingRecordBuilder().build()).setOrigin(MappingOrigin.Northbound).build();
    dataStoreBackEnd.addMapping(mapping);
    Mockito.verify(wTxMock).put(Mockito.eq(LogicalDatastoreType.CONFIGURATION), iidCaptorMapping.capture(), Mockito.eq(mapping), Mockito.eq(true));
    // result
    MappingKey result = iidCaptorMapping.getValue().firstKeyOf(Mapping.class);
    assertEquals("ipv4:" + IPV4_STRING_1, result.getEidUri().getValue());
    assertEquals(MappingOrigin.Northbound, result.getOrigin());
}
Also used : 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) 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) MappingKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingKey) XtrIdMappingKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.mapping.XtrIdMappingKey) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 10 with MappingBuilder

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

the class MappingDataListener method convertToBinaryIfNecessary.

private static Mapping convertToBinaryIfNecessary(Mapping mapping) {
    MappingRecord originalRecord = mapping.getMappingRecord();
    List<LocatorRecord> originalLocators = originalRecord.getLocatorRecord();
    List<LocatorRecord> convertedLocators = null;
    if (originalLocators != null) {
        // If convertedLocators is non-null, while originalLocators is also non-null, conversion has been made
        convertedLocators = convertToBinaryIfNecessary(originalLocators);
    }
    if (LispAddressUtil.addressNeedsConversionToBinary(originalRecord.getEid().getAddress()) || (originalLocators != null && convertedLocators != null)) {
        MappingRecordBuilder mrb = new MappingRecordBuilder(originalRecord);
        mrb.setEid(LispAddressUtil.convertToBinary(originalRecord.getEid()));
        if (convertedLocators != null) {
            mrb.setLocatorRecord(convertedLocators);
        }
        return new MappingBuilder(mapping).setMappingRecord(mrb.build()).build();
    }
    return mapping;
}
Also used : MappingBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)

Aggregations

MappingBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder)16 EidUri (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.EidUri)11 Test (org.junit.Test)8 Mapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping)8 XtrIdMappingBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.mapping.XtrIdMappingBuilder)7 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)5 XtrIdMapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.mapping.XtrIdMapping)4 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)3 MappingKey (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingKey)3 XtrIdMappingKey (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.mapping.XtrIdMappingKey)3 AddMappingBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMappingBuilder)2 SiteId (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.SiteId)2 AuthenticationKey (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey)2 AuthenticationKeyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyBuilder)2 ArrayList (java.util.ArrayList)1 AddMapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping)1 LocatorRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)1 MappingAuthkey (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey)1