e47e53ec855e92bbc356f99b5f14fb327fa73324
[yangtools.git] / common / yang-common / src / test / java / org / opendaylight / yangtools / yang / common / OperationFailedExceptionTest.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.common;
9
10 import static org.hamcrest.CoreMatchers.containsString;
11 import static org.hamcrest.MatcherAssert.assertThat;
12 import static org.junit.Assert.assertEquals;
13
14 import org.junit.Test;
15
16 public class OperationFailedExceptionTest {
17     @Test
18     public void testOperationFailedException() {
19         final Throwable cause = new Throwable("mock cause");
20         final RpcError rpcErrorShort = RpcResultBuilder.newError(ErrorType.RPC, new ErrorTag("tag"), "msg");
21         final OperationFailedException operationFailedException1 = new OperationFailedException("error msg", cause,
22                 rpcErrorShort);
23         final OperationFailedException operationFailedException2 = new OperationFailedException("error msg",
24                 rpcErrorShort);
25         assertEquals(operationFailedException1.getErrorList(), operationFailedException2.getErrorList());
26         assertThat(operationFailedException1.toString(), containsString("error msg"));
27     }
28 }