Search in sources :

Example 1 with GetKeyOutputBuilder

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

the class MappingServiceTest method getKeyTest.

/**
 * Tests {@link MappingService#getKey} method.
 */
@Test
public void getKeyTest() throws ExecutionException, InterruptedException {
    final GetKeyInput getKeyInput = new GetKeyInputBuilder().setEid(IPV4_EID).build();
    final RpcResult<GetKeyOutput> rpcResult = RpcResultBuilder.success(new GetKeyOutputBuilder().setMappingAuthkey(MAPPING_AUTHKEY).build()).build();
    Mockito.when(mappingSystem.getAuthenticationKey(getKeyInput.getEid())).thenReturn(MAPPING_AUTHKEY);
    final Future<RpcResult<GetKeyOutput>> result = mappingService.getKey(getKeyInput);
    assertEquals(rpcResult.getErrors(), result.get().getErrors());
    assertEquals(rpcResult.getResult(), result.get().getResult());
    assertEquals(rpcResult.isSuccessful(), result.get().isSuccessful());
}
Also used : GetKeyOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeyOutputBuilder) GetKeyInput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeyInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetKeyInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeyInputBuilder) GetKeyOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeyOutput) Test(org.junit.Test)

Example 2 with GetKeyOutputBuilder

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

the class MappingService method getKey.

@Override
public Future<RpcResult<GetKeyOutput>> getKey(GetKeyInput input) {
    Preconditions.checkNotNull(input, "get-key RPC input must be not null!");
    LOG.trace("RPC received to get the following key: " + input.toString());
    RpcResultBuilder<GetKeyOutput> rpcResultBuilder;
    MappingAuthkey key = mappingSystem.getAuthenticationKey(convertToBinaryIfNecessary(input.getEid()));
    if (key == null) {
        String message = "Key was not found in the mapping database";
        rpcResultBuilder = RpcResultBuilder.<GetKeyOutput>failed().withError(RpcError.ErrorType.APPLICATION, NOT_FOUND_TAG, message);
    } else {
        rpcResultBuilder = RpcResultBuilder.success(new GetKeyOutputBuilder().setMappingAuthkey(key));
    }
    return Futures.immediateFuture(rpcResultBuilder.build());
}
Also used : GetKeyOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeyOutputBuilder) MappingAuthkey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey) GetKeyOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeyOutput)

Aggregations

GetKeyOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeyOutput)2 GetKeyOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeyOutputBuilder)2 Test (org.junit.Test)1 MappingAuthkey (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey)1 GetKeyInput (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeyInput)1 GetKeyInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeyInputBuilder)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1