use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeyInput 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.GetKeyInput in project lispflowmapping by opendaylight.
the class MappingServiceTest method getKeyTest_withNullMappingAuthkey.
/**
* Tests {@link MappingService#getKey} method with null MappingAuthkey.
*/
@Test
public void getKeyTest_withNullMappingAuthkey() throws ExecutionException, InterruptedException {
// input
final GetKeyInput getKeyInput = new GetKeyInputBuilder().setEid(IPV4_EID).build();
Mockito.when(mappingSystem.getAuthenticationKey(getKeyInput.getEid())).thenReturn(null);
final RpcResult<Object> rpc = RpcResultBuilder.failed().withError(RpcError.ErrorType.APPLICATION, "data-missing", "Key was not found in the mapping database").build();
final RpcError error = rpc.getErrors().iterator().next();
// result
final Future<RpcResult<GetKeyOutput>> result = mappingService.getKey(getKeyInput);
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());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeyInput 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