TPSReportStatusUsage { public void notify(TPSReportStatus status, final StatusNotifier notifier) { status._switch(new TPSReportStatus.SwitchBlock() { @Override public void _case(Denied x) { notifier.notifyDenied(); } @Override public void _case(Approved x) { notifier.notifyApproved(); } @Override public void _case(Pending x) { notifier.notifyPending(); } }); }  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 testNotify() { final Ref<String> result = new Ref<String>(); final StatusNotifier notifier = new StatusNotifier() { @Override public void notifyPending() { result.value = "pending"; } @Override public void notifyDenied() { result.value = "denied"; } @Override public void notifyApproved() { result.value = "approved"; } }; usage.notify(_Approved(_Manager("Fred")), notifier); assertEquals("approved", result.value); usage.notify(_Denied(_Manager("Fred")), notifier); assertEquals("denied", result.value); usage.notify(_Pending(), notifier); assertEquals("pending", result.value); }