### Question:
DailyTaskAdaptor extends QBeanSupport implements Runnable { protected void initService () throws Exception { QFactory factory = getServer().getFactory(); Element e = getPersist (); task = (Runnable) factory.newInstance (e.getChildTextTrim ("class")); factory.setLogger (task, e); } DailyTaskAdaptor(); void run(); Date getWhen();  }### Answer:
@Test public void testInitServiceThrowsNullPointerException() throws Throwable { DailyTaskAdaptor dailyTaskAdaptor = new DailyTaskAdaptor(); try { dailyTaskAdaptor.initService(); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"org.jpos.q2.Q2.getFactory()\" because the return value of \"org.jpos.q2.iso.DailyTaskAdaptor.getServer()\" is null", ex.getMessage(), "ex.getMessage()"); } assertTrue(dailyTaskAdaptor.isModified(), "dailyTaskAdaptor.isModified()"); assertNull(dailyTaskAdaptor.task, "dailyTaskAdaptor.task"); } }
@Test public void testInitServiceThrowsNullPointerException1() throws Throwable { DailyTaskAdaptor dailyTaskAdaptor = new DailyTaskAdaptor(); String[] args = new String[3]; args[0] = "vI"; args[1] = "e."; args[2] = "testString"; dailyTaskAdaptor.setServer(q2); try { dailyTaskAdaptor.initService(); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"org.jdom2.Element.getChildTextTrim(String)\" because \"e\" is null", ex.getMessage(), "ex.getMessage()"); } assertFalse(dailyTaskAdaptor.isModified(), "dailyTaskAdaptor.isModified()"); assertNull(dailyTaskAdaptor.task, "dailyTaskAdaptor.task"); } }