Bump MRI upstreams
[bgpcep.git] / pcep / impl / src / test / java / org / opendaylight / protocol / pcep / impl / UtilTest.java
index 8475f45d896c10aee5409f3bacf1cb68f43a8bef..772b752e517a2b56b62343ca4c0bcb77f634c8cb 100644 (file)
@@ -7,56 +7,40 @@
  */
 package org.opendaylight.protocol.pcep.impl;
 
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import org.junit.Assert;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
 import org.junit.Test;
 import org.opendaylight.protocol.pcep.impl.spi.Util;
 import org.opendaylight.protocol.pcep.spi.PCEPErrors;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Pcerr;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.OpenBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcep.error.object.ErrorObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.error.type.SessionCase;
 
 public class UtilTest {
-
     private static final Open OPEN = new OpenBuilder().build();
 
     @Test
     public void testCreateErrorMessageWithOpen() {
-        final Message msg = Util.createErrorMessage(PCEPErrors.BAD_LABEL_VALUE, OPEN);
-        Assert.assertTrue(msg instanceof Pcerr);
-        final Pcerr errMsg = (Pcerr) msg;
-        Assert.assertTrue(errMsg.getPcerrMessage().getErrorType() instanceof SessionCase);
+        final Pcerr errMsg = Util.createErrorMessage(PCEPErrors.BAD_LABEL_VALUE, OPEN);
+        assertThat(errMsg.getPcerrMessage().getErrorType(), isA(SessionCase.class));
         final SessionCase sessionCase = (SessionCase) errMsg.getPcerrMessage().getErrorType();
-        Assert.assertEquals(OPEN, sessionCase.getSession().getOpen());
+        assertEquals(OPEN, sessionCase.getSession().getOpen());
         final ErrorObject errorObject = errMsg.getPcerrMessage().getErrors().get(0).getErrorObject();
-        Assert.assertEquals(PCEPErrors.BAD_LABEL_VALUE.getErrorType(), errorObject.getType());
-        Assert.assertEquals(PCEPErrors.BAD_LABEL_VALUE.getErrorValue(), errorObject.getValue());
+        assertEquals(PCEPErrors.BAD_LABEL_VALUE.getErrorType(), errorObject.getType());
+        assertEquals(PCEPErrors.BAD_LABEL_VALUE.getErrorValue(), errorObject.getValue());
     }
 
     @Test
     public void testCreateErrorMessage() {
-        final Message msg = Util.createErrorMessage(PCEPErrors.BAD_LABEL_VALUE, null);
-        Assert.assertTrue(msg instanceof Pcerr);
-        final Pcerr errMsg = (Pcerr) msg;
-        Assert.assertNull(errMsg.getPcerrMessage().getErrorType());
+        final Pcerr errMsg = Util.createErrorMessage(PCEPErrors.BAD_LABEL_VALUE, null);
+        assertNull(errMsg.getPcerrMessage().getErrorType());
         final ErrorObject errorObject = errMsg.getPcerrMessage().getErrors().get(0).getErrorObject();
-        Assert.assertEquals(PCEPErrors.BAD_LABEL_VALUE.getErrorType(), errorObject.getType());
-        Assert.assertEquals(PCEPErrors.BAD_LABEL_VALUE.getErrorValue(), errorObject.getValue());
+        assertEquals(PCEPErrors.BAD_LABEL_VALUE.getErrorType(), errorObject.getType());
+        assertEquals(PCEPErrors.BAD_LABEL_VALUE.getErrorValue(), errorObject.getValue());
     }
-
-    @Test(expected = UnsupportedOperationException.class)
-    public void testPrivateConstructor() throws Throwable {
-        final Constructor<Util> c = Util.class.getDeclaredConstructor();
-        c.setAccessible(true);
-        try {
-            c.newInstance();
-        } catch (InvocationTargetException e) {
-            throw e.getCause();
-        }
-    }
-
 }