TPSReportStatusUsage { public String message(TPSReportStatus status) { return status.match(new TPSReportStatus.MatchBlock<String>() { @Override public String _case(Pending x) { return "Pending"; } @Override public String _case(Approved x) { return "Approved by " + x.approver; } @Override public String _case(Denied x) { return "Denied by " + x.rejector; } }); }  boolean isApproved(TPSReportStatus status); String message(TPSReportStatus status); void notify(TPSReportStatus status, final StatusNotifier notifier); void notifyDenied(TPSReportStatus status, final StatusNotifier notifier); boolean isApprovedV2(TPSReportStatus status);  }
@Test public void testMessage() { assertEquals("Approved by Manager(name = Fred)", usage.message(_Approved(_Manager("Fred")))); assertEquals("Denied by Manager(name = Bob)", usage.message(_Denied(_Manager("Bob")))); assertEquals("Pending", usage.message(_Pending())); }