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());
}
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());
}
Aggregations