StellarResult { public static StellarResult error(Throwable exception) { return new StellarResult(Status.ERROR, exception); } private  StellarResult(Status status, Object value); private  StellarResult(Status status, Throwable exception); static StellarResult success(Object value); static StellarResult error(Throwable exception); static StellarResult error(String errorMessage); static StellarResult noop(); static StellarResult terminate(); boolean isSuccess(); boolean isError(); boolean isTerminate(); boolean isValueNull(); Status getStatus(); Optional<Object> getValue(); Optional<Throwable> getException(); @Override String toString();  }
@Test public void testError() { final String expected = "my error message"; StellarResult result = StellarResult.error(expected); assertNotNull(result); assertFalse(result.getValue().isPresent()); assertTrue(result.getException().isPresent()); assertEquals(expected, result.getException().get().getMessage()); assertEquals(StellarResult.Status.ERROR, result.getStatus()); assertFalse(result.isSuccess()); assertTrue(result.isError()); assertFalse(result.isTerminate()); }