Timeouts { public Timeout getTimeout(String key) { Objects.requireNonNull(key, "The key can't be null."); if (getAllTimeouts().get(key) != null) { return getAllTimeouts().get(key); } else { throw new NoSuchElementException("There is no timeout with this given key."); } } Timeouts(ArrayList<Timeout> timeouts, String nameOfProperties);  Timeouts(String nameOfProperties);  Timeouts(ArrayList<Timeout> timeouts);  Timeouts(); Timeout getTimeout(String key); HashMap<String, Timeout> getAllTimeouts(); void setTimeout(Timeout timeout); void readTimeoutProperties();  }
@Test public void testGetTimeout() throws Exception { StringBuilder key = new StringBuilder().append(engine).append(".").append(step); Timeout timeout = new Timeout(engine, step, value); ArrayList<Timeout> timeoutList = new ArrayList<>(); timeoutList.add(timeout); Timeouts timeouts = new Timeouts(timeoutList); Timeout timeoutTest = timeouts.getTimeout(key.toString()); assertEquals("The keys should be equal.", key.toString(), timeoutTest.getKey()); }
@Test(expected = NoSuchElementException.class) public void testGetTimeoutNotExists() throws Exception { Timeout timeout = new Timeout(engine, step, value); ArrayList<Timeout> timeoutList = new ArrayList<>(); timeoutList.add(timeout); Timeouts timeouts = new Timeouts(timeoutList); timeouts.getTimeout("glassfish.deploy"); }