Search in sources :

Example 21 with MappingRecord

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.

the class MappingSystemTest method getMappingTest_NbFirst.

/**
 * Tests {@link MappingSystem#getMapping} method with Ipv4 type dst address.
 */
@Test
public void getMappingTest_NbFirst() {
    final MappingRecord mappingRecord = getDefaultMappingRecordBuilder().setLocatorRecord(Lists.newArrayList(getDefaultLocatorRecordBuilder().build())).build();
    final MappingData mappingData = getDefaultMappingData(mappingRecord);
    Mockito.when(pmcMock.getMapping(EID_IPV4_SRC, EID_IPV4_DST)).thenReturn(mappingData);
    assertEquals(mappingData, mappingSystem.getMapping(EID_IPV4_SRC, EID_IPV4_DST));
}
Also used : MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 22 with MappingRecord

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord 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);
}
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) EidUri(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.EidUri) 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 23 with MappingRecord

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.

the class MappingServiceTest method addMappingTest_fromNorthbound.

/**
 * Tests {@link MappingService#addMapping} method from northbound.
 */
@Test
public void addMappingTest_fromNorthbound() throws ExecutionException, InterruptedException {
    // input
    final MappingOrigin origin = MappingOrigin.Northbound;
    final MappingRecord record = getDefaultMappingRecordBuilder().setXtrId(XTR_ID).build();
    final MappingData data = getDefaultMappingData(record);
    mappingService.addMapping(origin, IPV4_EID, SITE_ID, data);
    Mockito.verify(dsbe).addMapping(DSBEInputUtil.toMapping(origin, IPV4_EID, SITE_ID, data));
    Mockito.verifyZeroInteractions(mappingSystem);
    Mockito.verifyNoMoreInteractions(dsbe);
}
Also used : MappingOrigin(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingOrigin) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) Test(org.junit.Test)

Example 24 with MappingRecord

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.

the class MappingServiceTest method getMappingTest_withNullMapRecord.

/**
 * Tests {@link MappingService#getMapping} method with null MappingRecord.
 */
@Test
public void getMappingTest_withNullMapRecord() throws ExecutionException, InterruptedException {
    // input
    final GetMappingInput getMappingInput = new GetMappingInputBuilder().setEid(IPV4_EID).build();
    Mockito.when(mappingSystem.getMapping(getMappingInput.getEid())).thenReturn(null);
    final RpcResult<Object> rpc = RpcResultBuilder.failed().withError(RpcError.ErrorType.APPLICATION, "data-missing", "No mapping was found in the mapping database").build();
    final RpcError error = rpc.getErrors().iterator().next();
    // result
    final Future<RpcResult<GetMappingOutput>> result = (mappingService.getMapping(getMappingInput));
    final RpcError errorResult = result.get().getErrors().iterator().next();
    assertEquals(1, result.get().getErrors().size());
    assertEquals(error.getMessage(), errorResult.getMessage());
    assertEquals(error.getApplicationTag(), errorResult.getApplicationTag());
    assertEquals(error.getCause(), errorResult.getCause());
    assertEquals(error.getErrorType(), errorResult.getErrorType());
    assertEquals(error.getInfo(), errorResult.getInfo());
    assertEquals(error.getTag(), errorResult.getTag());
    assertEquals(error.getSeverity(), errorResult.getSeverity());
    assertEquals(rpc.getResult(), result.get().getResult());
    assertEquals(rpc.isSuccessful(), result.get().isSuccessful());
}
Also used : GetMappingInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingInputBuilder) GetMappingInput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingInput) RpcError(org.opendaylight.yangtools.yang.common.RpcError) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Test(org.junit.Test)

Example 25 with MappingRecord

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.

the class MappingServiceTest method getMappingTest.

/**
 * Tests {@link MappingService#getMapping} method.
 */
@Test
public void getMappingTest() throws ExecutionException, InterruptedException {
    // input
    final GetMappingInput getMappingInput = new GetMappingInputBuilder().setEid(IPV4_EID).build();
    final MappingData mappingData = getDefaultMappingData();
    final MappingRecord nonBinaryMappingRecord = getDefaultMappingRecordBuilder().setEid(LispAddressUtil.toEid(new Ipv4Address(IPV4_STRING), null)).build();
    Mockito.when(mappingSystem.getMapping(getMappingInput.getEid())).thenReturn(mappingData);
    final RpcResult<GetMappingOutput> rpc = RpcResultBuilder.success(new GetMappingOutputBuilder().setMappingRecord(nonBinaryMappingRecord)).build();
    // result
    final Future<RpcResult<GetMappingOutput>> result = mappingService.getMapping(getMappingInput);
    final RpcResult<GetMappingOutput> rpcResult = result.get();
    assertEquals(rpc.getResult(), rpcResult.getResult());
    assertEquals(rpc.getErrors(), rpcResult.getErrors());
    assertEquals(rpc.isSuccessful(), rpcResult.isSuccessful());
}
Also used : GetMappingInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingInputBuilder) GetMappingInput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingInput) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) GetMappingOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingOutputBuilder) GetMappingOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingOutput) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Aggregations

MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)56 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)31 Test (org.junit.Test)28 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)22 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)11 GotMapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)10 MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)10 LocatorRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)9 MappingRecordItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem)6 MappingBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder)6 ArrayList (java.util.ArrayList)5 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)5 EidUri (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.EidUri)5 Subscriber (org.opendaylight.lispflowmapping.interfaces.dao.Subscriber)4 InstanceIdType (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType)4 AddMapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.AddMapping)4 XtrId (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId)4 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)3 SourceDestKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey)3