Migrate deprecated assertThat()
[bgpcep.git] / pcep / impl / src / test / java / org / opendaylight / protocol / pcep / impl / UtilTest.java
1 /*
2  * Copyright (c) 2014 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.protocol.pcep.impl;
9
10 import static org.hamcrest.MatcherAssert.assertThat;
11 import static org.hamcrest.Matchers.isA;
12 import static org.junit.Assert.assertEquals;
13 import static org.junit.Assert.assertNull;
14
15 import org.junit.Test;
16 import org.opendaylight.protocol.pcep.impl.spi.Util;
17 import org.opendaylight.protocol.pcep.spi.PCEPErrors;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Pcerr;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.OpenBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcep.error.object.ErrorObject;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.error.type.SessionCase;
23
24 public class UtilTest {
25     private static final Open OPEN = new OpenBuilder().build();
26
27     @Test
28     public void testCreateErrorMessageWithOpen() {
29         final Pcerr errMsg = Util.createErrorMessage(PCEPErrors.BAD_LABEL_VALUE, OPEN);
30         assertThat(errMsg.getPcerrMessage().getErrorType(), isA(SessionCase.class));
31         final SessionCase sessionCase = (SessionCase) errMsg.getPcerrMessage().getErrorType();
32         assertEquals(OPEN, sessionCase.getSession().getOpen());
33         final ErrorObject errorObject = errMsg.getPcerrMessage().getErrors().get(0).getErrorObject();
34         assertEquals(PCEPErrors.BAD_LABEL_VALUE.getErrorType(), errorObject.getType());
35         assertEquals(PCEPErrors.BAD_LABEL_VALUE.getErrorValue(), errorObject.getValue());
36     }
37
38     @Test
39     public void testCreateErrorMessage() {
40         final Pcerr errMsg = Util.createErrorMessage(PCEPErrors.BAD_LABEL_VALUE, null);
41         assertNull(errMsg.getPcerrMessage().getErrorType());
42         final ErrorObject errorObject = errMsg.getPcerrMessage().getErrors().get(0).getErrorObject();
43         assertEquals(PCEPErrors.BAD_LABEL_VALUE.getErrorType(), errorObject.getType());
44         assertEquals(PCEPErrors.BAD_LABEL_VALUE.getErrorValue(), errorObject.getValue());
45     }
46 }