BrokersResult { public List<ChePlugin> get(long waitTime, TimeUnit tu) throws ExecutionException, InterruptedException, TimeoutException { if (started.compareAndSet(false, true)) { return future.get(waitTime, tu); } else { throw new IllegalStateException("BrokerResult#get doesn't support multiple calls"); } } BrokersResult(); void error(Exception e); void setResult(List<ChePlugin> toolingFromBroker); List<ChePlugin> get(long waitTime, TimeUnit tu);  }
@Test( expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "BrokerResult#get doesn't support multiple calls") public void shouldThrowExceptionIfGetCalledTwice() throws Exception { executeBrokerGet(); waitBrokerGetCalled(); brokersResult.get(100, TimeUnit.MILLISECONDS); }
@Test(expectedExceptions = TimeoutException.class) public void shouldThrowTimeoutExceptionIfResultIsNotSubmitted() throws Exception { brokersResult.get(1, TimeUnit.MILLISECONDS); }