RoutingProcedureResponse { public List<Record> records() { if ( !isSuccess() ) { throw new IllegalStateException( "Can't access records of a failed result", error ); } return records; } RoutingProcedureResponse(Query procedure, List<Record> records );  RoutingProcedureResponse(Query procedure, Throwable error ); private  RoutingProcedureResponse(Query procedure, List<Record> records, Throwable error ); boolean isSuccess(); Query procedure(); List<Record> records(); Throwable error();  }
@Test void shouldHaveRecordsWhenSuccessful() { RoutingProcedureResponse response = new RoutingProcedureResponse( PROCEDURE, asList( RECORD_1, RECORD_2 ) ); assertEquals( asList( RECORD_1, RECORD_2 ), response.records() ); }