diff options
author | Decebal Suiu <decebal.suiu@gmail.com> | 2019-04-20 22:00:17 +0300 |
---|---|---|
committer | Decebal Suiu <decebal.suiu@gmail.com> | 2019-04-20 22:00:17 +0300 |
commit | fd916791822fe3dcd83ed7a197d17f8903668049 (patch) | |
tree | 9e9cf53cb85d4b786a41317f144f51d16d00c835 | |
parent | 65e8fe76c8da4049f58c263b651e77c80b375067 (diff) | |
download | pf4j-fd916791822fe3dcd83ed7a197d17f8903668049.tar.gz pf4j-fd916791822fe3dcd83ed7a197d17f8903668049.zip |
Add AbstractPluginManagerTest
-rw-r--r-- | pf4j/src/test/java/org/pf4j/AbstractPluginManagerTest.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/pf4j/src/test/java/org/pf4j/AbstractPluginManagerTest.java b/pf4j/src/test/java/org/pf4j/AbstractPluginManagerTest.java new file mode 100644 index 0000000..784d1f9 --- /dev/null +++ b/pf4j/src/test/java/org/pf4j/AbstractPluginManagerTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2012-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.pf4j; + +import org.junit.jupiter.api.Test; +import org.pf4j.plugin.TestExtension; +import org.pf4j.plugin.TestExtensionPoint; + +import java.util.ArrayList; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.CALLS_REAL_METHODS; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +/** + * @author Decebal Suiu + */ +public class AbstractPluginManagerTest { + + @Test + public void getExtensionsByType() { + AbstractPluginManager pluginManager = mock(AbstractPluginManager.class, CALLS_REAL_METHODS); + + ExtensionFinder extensionFinder = mock(ExtensionFinder.class); + List<ExtensionWrapper<TestExtensionPoint>> extensionList = new ArrayList<>(1); + extensionList.add(new ExtensionWrapper<>(new ExtensionDescriptor(0, TestExtension.class), new DefaultExtensionFactory())); + when(extensionFinder.find(TestExtensionPoint.class)).thenReturn(extensionList); + + pluginManager.extensionFinder = extensionFinder; + List<TestExtensionPoint> extensions = pluginManager.getExtensions(TestExtensionPoint.class); + assertEquals(1, extensions.size()); + } + +} |