Search in sources :

Example 21 with MappingAuthkey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey in project lispflowmapping by opendaylight.

the class MappingServiceTest method addKeyTest.

/**
 * Tests {@link MappingService#addKey} method.
 */
@Test
public void addKeyTest() throws ExecutionException, InterruptedException {
    final MappingAuthkey mappingAuthkey = new MappingAuthkeyBuilder().setKeyString("dummy-password").setKeyType(2).build();
    final AddKeyInput addKeyInput = new AddKeyInputBuilder().setMappingAuthkey(mappingAuthkey).setEid(IPV4_EID).build();
    Mockito.when(mappingSystem.getAuthenticationKey(IPV4_EID)).thenReturn(MAPPING_AUTHKEY);
    // input
    final RpcResult<Object> rpc = RpcResultBuilder.failed().withError(RpcError.ErrorType.PROTOCOL, "data-exists", "Key already exists! Please use update-key if you want to change it.").build();
    // equals() not implemented int RpcError
    final RpcError error = rpc.getErrors().iterator().next();
    // result
    final Future<RpcResult<Void>> result = mappingService.addKey(addKeyInput);
    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 : AddKeyInput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeyInput) MappingAuthkey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey) RpcError(org.opendaylight.yangtools.yang.common.RpcError) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) MappingAuthkeyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkeyBuilder) AddKeyInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeyInputBuilder) Test(org.junit.Test)

Example 22 with MappingAuthkey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey in project lispflowmapping by opendaylight.

the class MappingServiceTest method addKeyTest_withNullMapAuthkey.

/**
 * Tests {@link MappingService#addKey} method with null MappingAuthkey.
 */
@Test
public void addKeyTest_withNullMapAuthkey() throws ExecutionException, InterruptedException {
    final AddKeyInput addKeyInput = new AddKeyInputBuilder().setEid(IPV4_EID).build();
    Mockito.when(mappingSystem.getAuthenticationKey(IPV4_EID)).thenReturn(null);
    final Future<RpcResult<Void>> result = mappingService.addKey(addKeyInput);
    Mockito.verify(dsbe).addAuthenticationKey(Mockito.any());
    assertEquals(RPC_RESULT_SUCCESS.getErrors(), result.get().getErrors());
    assertEquals(RPC_RESULT_SUCCESS.getResult(), result.get().getResult());
    assertEquals(RPC_RESULT_SUCCESS.isSuccessful(), result.get().isSuccessful());
}
Also used : AddKeyInput(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeyInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) AddKeyInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeyInputBuilder) Test(org.junit.Test)

Aggregations

MappingAuthkey (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey)16 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)9 Test (org.junit.Test)6 MappingAuthkeyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkeyBuilder)4 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)4 AddKeyInput (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeyInput)3 AddKeyInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.AddKeyInputBuilder)3 AuthenticationKeyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyBuilder)3 RpcError (org.opendaylight.yangtools.yang.common.RpcError)3 ILispDAO (org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO)2 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)2 MapRegisterCacheMetadataBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.metadata.container.MapRegisterCacheMetadataBuilder)2 MapRegisterCacheValueBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.value.grouping.MapRegisterCacheValueBuilder)2 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)2 MappingRecordItem (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem)2 EidUri (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.EidUri)2 AuthenticationKey (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1