2 * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.remote.rpc;
10 import static org.junit.Assert.assertEquals;
12 import java.util.ArrayList;
13 import java.util.List;
14 import org.junit.Before;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.common.RpcError;
17 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
19 public class RpcErrorsExceptionTest {
20 private static final String ERROR_MESSAGE = "Test error message.";
22 private List<RpcError> rpcErrors;
23 private RpcErrorsException exception;
27 final RpcError rpcError = RpcResultBuilder.newError(
28 RpcError.ErrorType.RPC, "error", "error message");
29 final RpcError rpcWarning = RpcResultBuilder.newWarning(
30 RpcError.ErrorType.RPC, "warning", "warning message");
32 rpcErrors = new ArrayList<>();
33 rpcErrors.add(rpcError);
34 rpcErrors.add(rpcWarning);
36 exception = new RpcErrorsException(ERROR_MESSAGE, rpcErrors);
40 public void testGetMessage() {
41 assertEquals(ERROR_MESSAGE, exception.getMessage());
45 public void testGetRpcErrors() {
46 final List<RpcError> actualErrors = (List<RpcError>) exception.getRpcErrors();
47 assertEquals(rpcErrors.size(), actualErrors.size());
49 for (int i = 0; i < actualErrors.size(); i++) {
50 final RpcError expected = rpcErrors.get(i);
51 final RpcError actual = actualErrors.get(i);
53 assertEquals(expected.getApplicationTag(), actual.getApplicationTag());
54 assertEquals(expected.getSeverity(), actual.getSeverity());
55 assertEquals(expected.getMessage(), actual.getMessage());
56 assertEquals(expected.getErrorType(), actual.getErrorType());
57 assertEquals(expected.getCause(), actual.getCause());
58 assertEquals(expected.getInfo(), actual.getInfo());
59 assertEquals(expected.getTag(), actual.getTag());