Search in sources :

Example 1 with GetKeyOutput

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

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeyOutput 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());
}
Also used : GetKeyInput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeyInput) RpcError(org.opendaylight.yangtools.yang.common.RpcError) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetKeyInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeyInputBuilder) Test(org.junit.Test)

Example 3 with GetKeyOutput

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

Test (org.junit.Test)2 GetKeyInput (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeyInput)2 GetKeyInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.GetKeyInputBuilder)2 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 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)2 MappingAuthkey (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey)1 RpcError (org.opendaylight.yangtools.yang.common.RpcError)1