### Question:
BSHAction implements ActionListener, UIAware { public void actionPerformed (ActionEvent ev) { String bshSource = ev.getActionCommand(); try { Interpreter bsh = new Interpreter (); bsh.source (bshSource); } catch (Exception e) { e.printStackTrace(); } } BSHAction(); void setUI(UI ui, Element e); void actionPerformed(ActionEvent ev); public UI ui; }### Answer:
@Disabled("test fails - needs a real action file") @Test public void testActionPerformed() throws Throwable { new BSHAction().actionPerformed(new ActionEvent("testString", 100, "testBSHActionParam3", 100L, 1000)); assertTrue(true, "Test completed without Exception"); }
@Test public void testActionPerformedThrowsNullPointerException() throws Throwable { try { new BSHAction().actionPerformed(null); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"java.awt.event.ActionEvent.getActionCommand()\" because \"ev\" is null", ex.getMessage(), "ex.getMessage()"); } } }