Modify test to use reflection for expected values

Signed-off-by: Taylor Smock <taylor.smock@kaart.com>
pull/1/head
Taylor Smock 2020-01-15 13:26:42 -07:00
rodzic 1867c78162
commit b396b7c1a2
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 625F6A74A3E4311A
1 zmienionych plików z 12 dodań i 2 usunięć

Wyświetl plik

@ -7,8 +7,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Map;
import javax.swing.JMenu;
@ -73,10 +75,18 @@ public class MapWithAIPluginTest {
/**
* Test method for {@link MapWithAIPlugin#MapWithAIPlugin(PluginInformation)}.
*
* @throws SecurityException see {@link java.lang.Class#getDeclaredField}
* @throws NoSuchFieldException see {@link java.lang.Class#getDeclaredField}
* @throws IllegalAccessException see {@link java.lang.reflect.Field#get}
* @throws IllegalArgumentException see {@link java.lang.reflect.Field#get}
*/
@Test
public void testMapWithAIPlugin() {
final int addedMenuItems = 3;
public void testMapWithAIPlugin()
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
Field menuEntries = MapWithAIPlugin.class.getDeclaredField("MENU_ENTRIES");
menuEntries.setAccessible(true);
final int addedMenuItems = ((Map<?, ?>) menuEntries.get(plugin)).size();
final JMenu dataMenu = MainApplication.getMenu().dataMenu;
final int dataMenuSize = dataMenu.getMenuComponentCount();
plugin = new MapWithAIPlugin(info);