Search in sources :

Example 1 with GetMappingOutputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingOutputBuilder 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)

Example 2 with GetMappingOutputBuilder

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

the class MappingService method getMapping.

@Override
public Future<RpcResult<GetMappingOutput>> getMapping(GetMappingInput input) {
    Preconditions.checkNotNull(input, "get-mapping RPC input must be not null!");
    LOG.trace("RPC received to get the following mapping: " + input.toString());
    RpcResultBuilder<GetMappingOutput> rpcResultBuilder;
    MappingData reply = mappingSystem.getMapping(convertToBinaryIfNecessary(input.getEid()));
    if (reply == null) {
        String message = "No mapping was found in the mapping database";
        rpcResultBuilder = RpcResultBuilder.<GetMappingOutput>failed().withError(RpcError.ErrorType.APPLICATION, NOT_FOUND_TAG, message);
    } else {
        final MappingRecord convertedReply = convertFromBinaryIfNecessary(reply.getRecord());
        rpcResultBuilder = RpcResultBuilder.success(new GetMappingOutputBuilder().setMappingRecord(convertedReply));
    }
    return Futures.immediateFuture(rpcResultBuilder.build());
}
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) GetMappingOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingOutputBuilder) GetMappingOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingOutput)

Aggregations

MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)2 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)2 GetMappingOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingOutput)2 GetMappingOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingOutputBuilder)2 Test (org.junit.Test)1 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)1 GetMappingInput (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingInput)1 GetMappingInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetMappingInputBuilder)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1