BaseCustomComponent extends DefaultVerticalLayout implements Buildable { protected void handleSaveException(RuntimeException ex) { if (ex instanceof OCSValidationException) { LOG.warn(ex.getMessage(), ex); showErrorNotification(((OCSValidationException) ex).getErrors().get(0)); } else if (ex instanceof OCSRuntimeException) { LOG.error(ex.getMessage(), ex); showErrorNotification(ex.getMessage()); } else if (ex instanceof OptimisticLockException | ex instanceof ObjectOptimisticLockingFailureException) { LOG.error(ex.getMessage(), ex); showErrorNotification(message("ocs.optimistic.lock")); } else { LOG.error(ex.getMessage(), ex); showErrorNotification(message("ocs.error.occurred")); } }    }
@Test public void testHandleSaveException() { component.handleSaveException(new OCSValidationException("Some error")); component.handleSaveException(new OCSRuntimeException("Some error")); component.handleSaveException(new OptimisticLockException()); component.handleSaveException(new RuntimeException()); }