+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.mdsal.binding.dom.adapter.invoke;
-
-import static org.hamcrest.CoreMatchers.endsWith;
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThrows;
-import static org.mockito.Mockito.mock;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.util.concurrent.UncheckedExecutionException;
-import java.lang.invoke.MethodHandles;
-import java.lang.invoke.WrongMethodTypeException;
-import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.notification.rev150205.OpendaylightTestNotificationListener;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.Notification;
-import org.opendaylight.yangtools.yang.binding.NotificationListener;
-import org.opendaylight.yangtools.yang.common.QName;
-
-public class NotificationListenerInvokerTest {
- @Test
- public void fromTest() throws Exception {
- assertNotNull(NotificationListenerInvoker.from(OpendaylightTestNotificationListener.class));
- }
-
- @Test
- public void fromWithExceptionTest() {
- final var cause = assertThrows(UncheckedExecutionException.class,
- () -> NotificationListenerInvoker.from(TestPrivateInterface.class))
- .getCause();
- assertThat(cause, instanceOf(IllegalStateException.class));
- assertThat(cause.getCause(), instanceOf(IllegalAccessException.class));
- }
-
- @Test
- public void invokeNotification() throws Exception {
- final var notificationListener = mock(NotificationListener.class);
- final var methodHandle = MethodHandles.publicLookup().unreflect(String.class.getDeclaredMethod("toString"));
-
- final var notificationListenerInvoker = new NotificationListenerInvoker(
- ImmutableMap.of(QName.create("test", "test"), methodHandle));
-
- final var ex = assertThrows(WrongMethodTypeException.class,
- () -> notificationListenerInvoker.invokeNotification(notificationListener, QName.create("test", "test"),
- null));
- assertThat(ex.getMessage(), endsWith(" (String)String but found (NotificationListener,DataContainer)void"));
- }
-
- private interface TestPrivateInterface extends NotificationListener, Augmentation {
- QName QNAME = QName.create("test", "test");
-
- void onTestNotificationInterface(TestNotificationInterface notif);
- }
-
- public interface TestNotificationInterface extends DataObject, Notification<TestNotificationInterface> {
- QName QNAME = QName.create("test", "test");
- }
-}
\ No newline at end of file