use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project lispflowmapping by opendaylight.
the class MappingServiceTest method getMappingTest_withNullMapRecord.
/**
* Tests {@link MappingService#getMapping} method with null MappingRecord.
*/
@Test
public void getMappingTest_withNullMapRecord() throws ExecutionException, InterruptedException {
// input
final GetMappingInput getMappingInput = new GetMappingInputBuilder().setEid(IPV4_EID).build();
Mockito.when(mappingSystem.getMapping(getMappingInput.getEid())).thenReturn(null);
final RpcResult<Object> rpc = RpcResultBuilder.failed().withError(RpcError.ErrorType.APPLICATION, "data-missing", "No mapping was found in the mapping database").build();
final RpcError error = rpc.getErrors().iterator().next();
// result
final Future<RpcResult<GetMappingOutput>> result = (mappingService.getMapping(getMappingInput));
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.params.xml.ns.yang.pcep.types.rev181109.Object in project lispflowmapping by opendaylight.
the class MappingServiceTest method updateKeyTest_withNullMapAuthkey.
/**
* Tests {@link MappingService#updateKey} method with null MappingAuthkey.
*/
@Test
public void updateKeyTest_withNullMapAuthkey() throws ExecutionException, InterruptedException {
final UpdateKeyInput updateKeyInput = new UpdateKeyInputBuilder().setEid(IPV4_EID).build();
Mockito.when(mappingSystem.getAuthenticationKey(IPV4_EID)).thenReturn(null);
// input
final RpcResult<Object> rpc = RpcResultBuilder.failed().withError(RpcError.ErrorType.PROTOCOL, "data-missing", "Key doesn't exist! Please use add-key if you want to create a new authentication key.").build();
final RpcError error = rpc.getErrors().iterator().next();
// result
final Future<RpcResult<Void>> result = mappingService.updateKey(updateKeyInput);
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.params.xml.ns.yang.pcep.types.rev181109.Object 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.params.xml.ns.yang.pcep.types.rev181109.Object in project lispflowmapping by opendaylight.
the class HashMapDb method getBest.
@Override
public Map<String, Object> getBest(Object key) {
if (key instanceof Eid) {
Eid eid = (Eid) key;
RadixTrie<Object>.TrieNode node = lookupBestNode(eid);
if (node == null) {
return get(key);
}
return get(node.data());
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project lispflowmapping by opendaylight.
the class HashMapDb method tryRemoveFromTrie.
private void tryRemoveFromTrie(Object key) {
if (key instanceof Eid) {
Eid eid = (Eid) key;
if (eid.getAddress() instanceof Ipv4PrefixBinary) {
Ipv4PrefixBinary prefix = (Ipv4PrefixBinary) eid.getAddress();
ip4Trie.remove(prefix.getIpv4AddressBinary().getValue(), prefix.getIpv4MaskLength());
} else if (eid.getAddress() instanceof Ipv6PrefixBinary) {
Ipv6PrefixBinary prefix = (Ipv6PrefixBinary) eid.getAddress();
ip6Trie.remove(prefix.getIpv6AddressBinary().getValue(), prefix.getIpv6MaskLength());
}
}
}
Aggregations