BrokersResult { public void setResult(List<ChePlugin> toolingFromBroker) throws InfrastructureException { if (!started.get()) { throw new IllegalStateException( "Submitting a broker result is not allowed before calling BrokerResult#get"); } if (future.isDone()) { throw new InfrastructureException( "Plugins brokering result is unexpectedly submitted more than one time. This indicates unexpected behavior of the system"); } future.complete(new ArrayList<>(toolingFromBroker)); } BrokersResult(); void error(Exception e); void setResult(List<ChePlugin> toolingFromBroker); List<ChePlugin> get(long waitTime, TimeUnit tu);  }
@Test( expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "Submitting a broker result is not allowed before calling BrokerResult#get") public void shouldThrowExceptionOnCallingAddResultBeforeCallGet() throws Exception { brokersResult.setResult(emptyList()); }
@Test( expectedExceptions = InfrastructureException.class, expectedExceptionsMessageRegExp = "Plugins brokering result is unexpectedly submitted more than one time. This indicates unexpected behavior of the system") public void shouldThrowExceptionIfResultIsSubmittedSecondTime() throws Exception { executeBrokerGet(); waitBrokerGetCalled(); brokersResult.setResult(singletonList(new ChePlugin())); brokersResult.setResult(singletonList(new ChePlugin())); }